Real-Time Programming Good Practices N. Delson. Objective of Good Programming  Programs that can be easily updated and modified.  Programs that can.

Slides:



Advertisements
Similar presentations
Etter/Ingber Engineering Problem Solving with C Fundamental Concepts Chapter 4 Modular Programming with Functions.
Advertisements

Software Testing. Quality is Hard to Pin Down Concise, clear definition is elusive Not easily quantifiable Many things to many people You'll know it when.
Advanced Programming 15 Feb The “OI” Programming Process Reading the problem statement Thinking Coding + Compiling Testing + Debugging Finalizing.
Procedural programming in Java
1 C++ Syntax and Semantics The Development Process.
1. 2 LabVIEW for FRC Doug Norman National Instruments January 6, 2012.
ECE 353 Introduction to Microprocessor Systems Michael G. Morrow, P.E. Week 6.
MotoHawk Training Model-Based Design of Embedded Systems.
ITEC113 Algorithms and Programming Techniques
Software Engineering and Design Principles Chapter 1.
Software engineering, program management. The problem  Software is expensive to design! – Industry estimates put software development labor costs at.
Group 4 Rotationally Refreshed Display Patrick Boyd Daniel Hill.
Program Design and Development
ME 224 Experimental Engineering: Professor Espinosa 2005 TEAM : Jamie Charles Carlo Niko Javier.
DRY. 11: DRY—Don’t Repeat Yourself Every piece of knowledge should have a single, unambiguous, authoritative representation within a system Duplication.
Understanding the Mainline Logical Flow Through a Program (continued)
Chapter 1 Program Design
Problem Solving Chapter 2. What is an algorithm? n A solution to a problem that is: –Precise –Effective –Terminating.
Chapter 3 Planning Your Solution
Fibonacci Problem Solving and Thinking in Engineering Programming H. James de St. Germain.
Jordan Wagner Justin Spencer Mark Sears John Jachna.
What is RobotC?!?! Team 2425 Hydra. Overview What is RobotC What is RobotC used for What you need to program a robot How a robot program works Framework.
Chapter 7 Software Engineering Objectives Understand the software life cycle. Describe the development process models.. Understand the concept of modularity.
Guidelines for the CMM coding project 5 October 2006 (or, “How to make your life easier in the long run”)
Peripherals and their Control An overview of industrially available “peripheral devices” that use “pulse-width modulation” for information passing. Review.
Digital Communications Math class.
LAB 1 MATLAB, dSPACE and Simulink
1 Computing Software. Programming Style Programs that are not documented internally, while they may do what is requested, can be difficult to understand.
Copyright © 2012 Pearson Education, Inc. Publishing as Pearson Addison-Wesley C H A P T E R 6 Value- Returning Functions and Modules.
Magnetic Field Measurement System as Part of a Software Family Jerzy M. Nogiec Joe DiMarco Fermilab.
Modular Programming. Modular Programming (1/6) Modular programming  Goes hand-in-hand with stepwise refinement and incremental development  Makes the.
Objectives Implement pointers using indexed addressing modes Use pointers to access arrays, strings, structures, tables, and matrices Present finite-state.
Procedures and Functions Computing Module 1. What is modular programming? Most programs written for companies will have thousands of lines of code. Most.
1 CSC 222: Computer Programming II Spring 2004 See online syllabus at: Course goals:
Testing. 2 Overview Testing and debugging are important activities in software development. Techniques and tools are introduced. Material borrowed here.
Improving the Quality of Existing Code Svetlin Nakov Telerik Corporation
C++ Programming Language Lecture 2 Problem Analysis and Solution Representation By Ghada Al-Mashaqbeh The Hashemite University Computer Engineering Department.
Programming Logic and Design Using Methods. 2 Objectives Review how to use a simple method with local variables and constants Create a method that requires.
Designing classes How to write classes in a way that they are easily understandable, maintainable and reusable 5.0.
Chapter 10 Software Engineering. Understand the software life cycle. Describe the development process models. Understand the concept of modularity in.

Introduction to ArcGIS for Environmental Scientists Module 3 – GIS Analysis Model Builder.
read and learn from example loop programs develop modular program
Functions & Libraries. Introduction Functions – Modules of code Uses – Abstraction Build complex tasks with simpler ones Don't worry about details at.
July 7, 2003 Slide 1 of 6 Automation, Robotics and Mechatronics Lab, SUNY at Buffalo Introduction To Programming Chetan Jadhav Talib Bhabharawala Seung-Kook.
FPD PROGRAM / FPD MOTION DIAGRAM / FPD MOTION - NEW DIAGRAM / FPD RANDOM PROGRAM / FPD PROGRAM Lionel PEYRICHOUX 03/22/2001.
Program Style Chapter 22 IB103 Week 12 (part 2). Modularity: the ability to reuse code Encapsulation: hide data access directly but may use methods (the.
Introduction to Testing CSIS 1595: Fundamentals of Programming and Problem Solving 1.
FUNCTIONS. Topics Introduction to Functions Defining and Calling a Void Function Designing a Program to Use Functions Local Variables Passing Arguments.
Testing Chapter 23 IB103 Week 12 (part 3). Verify that a complex (any) program works correctly, that the program meets specifications The chapter reviews.
July 18, UCSD - R.A. de Callafon Short Intro to Micro Processors and I/O functions of our Kinetic Sculpture Control Box Raymond de Callafon.
SAP DEVELOPMENT BASICS Bohuslav Tesar. TRAINING OVERVIEW Amazing life of ABAP developer ;) SAP introduction ABAP basics ABAP Reporting.
CHAPTER 2 PROBLEM SOLVING USING C++ 1 C++ Programming PEG200/Saidatul Rahah.
1 The Software Development Process ► Systems analysis ► Systems design ► Implementation ► Testing ► Documentation ► Evaluation ► Maintenance.
ENEE150 – 0102 ANDREW GOFFIN More With Pointers. Importance of Pointers Dynamic Memory (relevant with malloc) Passing By Reference Pointer Arithmetic.
M1G Introduction to Programming 2 2. Creating Classes: Game and Player.
CSCI 161 Lecture 3 Martin van Bommel. Operating System Program that acts as interface to other software and the underlying hardware Operating System Utilities.
Program Design. Simple Program Design, Fourth Edition Chapter 1 2 Objectives In this chapter you will be able to: Describe the steps in the program development.
Circular motion About angular motion. Which angle is bigger? 1.5 degrees 2.5 radians 3.5 revolutions
Introduction to Algorithmic Processes CMPSC 201C Fall 2000.
ME 120: User-defined functions: average analog input reading Arduino Programming – Part 5: User-defined functions ME 120 Mechanical and Materials Engineering.
1 Structured Programming Arab Academy for Science and Technology CC112 Dr. Sherif Mohamed Tawfik The Course.
Presentation By :- Nikhil R. Anande ( ) Electronic & Communication Engineering. 3 nd Year / 5 th Semester FACULTY GUIDE : RAHIUL PATEL SIR MICROCONTROLLER.
Chapter 3 Using Variables, Constants, Formatting Mrs. UlshaferSept
Structured Programming The Basics
Unit 1 Introduction Number Systems and Conversion.
MODULAR PROGRAMMING Many programs are too large to be developed by one person. programs are routinely developed by teams of programmers The linker program.
Lecture 2 Introduction to Programming
Topics Introduction to Value-returning Functions: Generating Random Numbers Writing Your Own Value-Returning Functions The math Module Storing Functions.
2 Making Blocks with INPUTS.
Presentation transcript:

Real-Time Programming Good Practices N. Delson

Objective of Good Programming  Programs that can be easily updated and modified.  Programs that can be easily verified and debugged.  Programs that can be easily understood by others (including author three months after writing). Additional Objectives for Real-Time Programming  High speed  Low memory use  Meet accuracy recruitments often with integer math Objective of Good Programming  Programs that can be easily updated and modified.  Programs that can be easily verified and debugged.  Programs that can be easily understood by others (including author three months after writing). Additional Objectives for Real-Time Programming  High speed  Low memory use  Meet accuracy recruitments often with integer math

Good Programming Methods  Modularity Modularity  Generalization Generalization  Documentation and Notation Documentation and Notation Good Programming Methods  Modularity Modularity  Generalization Generalization  Documentation and Notation Documentation and Notation

 Use meaningful variable names  Document as you write code  Use meaningful variable names  Document as you write code Good ExampleBad Example % GOOD DOCUMENTATION % Define system parameters arm_length = 0.5; % arm length in meters alpha = 25*pi/180; % angle of motion in radians dalpha = 0.1; % angular velocity in radians / second time_step = 0.01; % seconds % Calc new angle using Euler method alpha_new = alpha + dalpha*time_step; % BAD DOCUMENTATION % (bad: no short overview of code) length = 0.5; % (bad: no units!) a = 25; % (bad: variable name too short and use of angles instead of radians) da = 0.1; % (bad: no units) time = 0.01; %(bad: ambiguous variable name) % (bad: no short overview of code) a = a + da*time; % (bad: reuse of variable name is confusing)

Modularity  In a well-written modular program, one module can be updated without requiring changes in the other parts of the program. When should one use a subroutines or functions?  When there are logical separate functional needs  Whenever one finds repeated code Printer dialog box example

Generalization  Never hardcode values into program; use variable or constants instead.  Use arrays instead of sequentially numbered variables.  Never hardcode values into program; use variable or constants instead.  Use arrays instead of sequentially numbered variables. Good ExampleBad Example % GOOD CODE % Define number of links as variable % and use arrays when possible nlink = 4; % number of links % use loop to easily display link lengths for ilink=1:nlink disp(link_length(ilink)); end % No code changes are required if the value of nlink is changed. % More importantly code corrections need to be done in one location only % BAD CODE % The following code may be easy to start writing, % but does not allow easy changes to number of links or use of loops disp(link_length_1); disp(link_length_2); disp(link_length_3); disp(link_length_4);

Real-Time Examples  Analog to Digital Input (A/D)  Digital Input  Positive and Negative Numbers  Integer Math  Serial Communication  Motor Driver  Analog to Digital Input (A/D)  Digital Input  Positive and Negative Numbers  Integer Math  Serial Communication  Motor Driver