Engineering H192 - Computer Programming The Ohio State University Gateway Engineering Education Coalition Lect 26P. 1Winter Quarter Handy Board Lecture.

Slides:



Advertisements
Similar presentations
Overview of programming in C C is a fast, efficient, flexible programming language Paradigm: C is procedural (like Fortran, Pascal), not object oriented.
Advertisements

Engineering H192 - Computer Programming Gateway Engineering Education Coalition Lect FXP. 1Winter Quarter Course Wrap Up and Final Review Topics Lecture.
Engineering H192 - Computer Programming The Ohio State University Gateway Engineering Education Coalition Lect 16P. 1Winter Quarter Strings Lecture 16.
Engineering H192 - Computer Programming The Ohio State University Gateway Engineering Education Coalition Lect 12P. 1Winter Quarter User-Written Functions.
Programming Languages and Paradigms The C Programming Language.
Making Choices in C if/else statement logical operators break and continue statements switch statement the conditional operator.
Engineering EG167C - Computer Programming The Ohio State University Gateway Engineering Education Coalition Lect M1 P. 1Winter Quarter Midterm I Review.
CS1010 Programming Methodology
Handy Board. Why the Handy Board Designed to be the controller of small, mobil robots Has many features that make it ideal for robotics projects –Integrated.
Engineering H192 - Computer Programming The Ohio State University Gateway Engineering Education Coalition Lect FXP. 1Winter Quarter Course Wrap Up and.
Chapter 10.
Engineering H192 - Computer Programming The Ohio State University Gateway Engineering Education Coalition Lect 29P. 1Winter Quarter Software Design Project.
Engineering H193 - Team Project Gateway Engineering Education Coalition P. 1 Spring Quarter 2008 Robot Programming Tips Week 4 Day 2 By Matt Gates and.
C Programming Basics Lecture 5 Engineering H192 Winter 2005 Lecture 05
Handy Board. Why the Handy Board Designed to be the controller of small, mobil robots Has many features that make it ideal for robotics projects –Integrated.
Engineering H192 - Computer Programming The Ohio State University Gateway Engineering Education Coalition Lect 13P. 1Winter Quarter Scope of Variables.
1 Key Concepts:  Why C?  Life Cycle Of a C program,  What is a computer program?  A program statement?  Basic parts of a C program,  Printf() function?
Software Design Project
Engineering H192 - Computer Programming The Ohio State University Gateway Engineering Education Coalition Lect 11P. 1Winter Quarter Arrays Lecture 11.
Engineering H192 - Computer Programming The Ohio State University Gateway Engineering Education Coalition Lect M1 P. 1Winter Quarter Midterm I Review Topics.
Engineering H192 - Computer Programming The Ohio State University Gateway Engineering Education Coalition Lect 6P. 1Winter Quarter I/O in C Lecture 6.
Guide To UNIX Using Linux Third Edition
Engineering H192 - Computer Programming The Ohio State University Gateway Engineering Education Coalition Lect M2P. 1Winter Quarter Midterm 2 Review Topics.
Engineering H192 - Computer Programming The Ohio State University Gateway Engineering Education Coalition Lect 14P. 1Winter Quarter Pointers Lecture 14.
Engineering H192 - Computer Programming The Ohio State University Gateway Engineering Education Coalition Lect FXP. 1Winter Quarter Course Wrap Up and.
Engineering H192 - Computer Programming The Ohio State University Gateway Engineering Education Coalition Lect 9P. 1Winter Quarter Switch Case Structures.
Engineering H192 - Computer Programming The Ohio State University Gateway Engineering Education Coalition Lect 15P. 1Winter Quarter Arrays and Pointers.
Engineering H192 - Computer Programming Gateway Engineering Education Coalition Lab 7P. 1Winter Quarter Stop Light Lab 7.
Engineering H192 - Computer Programming The Ohio State University Gateway Engineering Education Coalition Lect 21P. 1Winter Quarter MATLAB: Structures.
1 COMP 2130 Introduction to Computer Systems Computing Science Thompson Rivers University.
Engineering H192 - Computer Programming Gateway Engineering Education Coalition Lect 14P. 1Winter Quarter Pointers Lecture 14.
18-2 Understand “Scope” of an Identifier Know the Storage Classes of variables and functions Related Chapter: ABC 5.10, 5.11.
By Sidhant Garg.  C was developed between by Dennis Ritchie at Bell Laboratories for use with the Unix Operating System.  Unlike previously.
C Programming Tutorial – Part I CS Introduction to Operating Systems.
Introduction to Computer Programming Using C Session 23 - Review.
Robot Building Lab: Introduction Lab 1 The Handy Board and Interactive-C (IC) es/robotlab/labs/lab1.ps.
Engineering H192 - Computer Programming The Ohio State University Gateway Engineering Education Coalition Lect 24P. 1Winter Quarter C++ Lecture 24.
The George Washington University Department of ECE ECE Intro: Electrical & Computer Engineering –Intro to the Robotics –Introducing the IC –Discuss.
Engineering H192 - Computer Programming The Ohio State University Gateway Engineering Education Coalition Lect 7P. 1Winter Quarter File I/O in C Lecture.
C Programming language Basic Concepts Prepared By The Smartpath Information systems
Engineering H192 - Computer Programming Gateway Engineering Education Coalition Lect 25P. 1Winter Quarter C++: I/O and Classes Lecture 25.
Lecture 2: Introduction to C Programming. OBJECTIVES In this lecture you will learn:  To use simple input and output statements.  The fundamental data.
The Handy Board Bryan Valentini General Robotics 2003.
Engineering H192 - Computer Programming The Ohio State University Gateway Engineering Education Coalition Lect 5P. 1Winter Quarter C Programming Basics.
19&20-2 Know how to declare pointer variables. Understand the & (address) and *(indirection) operators. Dynamic Memory Allocation Related Chapter: ABC.
Engineering H192 - Computer Programming Gateway Engineering Education Coalition Lect 5P. 1Winter Quarter C Programming Basics Lecture 5.
Engineering H192 - Computer Programming Gateway Engineering Education Coalition Lect 26P. 1Winter Quarter Handy Board Lecture 26.
Engineering H193 - Team Project Gateway Engineering Education Coalition Lab 1P. 1Spring Quarter Introduction to Sensors Lab 1.
Engineering H192 - Computer Programming Gateway Engineering Education Coalition Lect 12P. 1Winter Quarter User-Written Functions Lecture 12.
Slides created by: Professor Ian G. Harris Hello World #include main() { printf(“Hello, world.\n”); }  #include is a compiler directive to include (concatenate)
Engineering H192 - Computer Programming Gateway Engineering Education Coalition Lect 29P. 1Winter Quarter Software Design Project Lecture 29.
C++ / G4MICE Course Session 1 - Introduction Edit text files in a UNIX environment. Use the g++ compiler to compile a single C++ file. Understand the C++
Microcontrollers, Microcomputers, and Microprocessors
Functions Structured Programming. Topics to be covered Introduction to Functions Defining a function Calling a function Arguments, local variables and.
EEL 3801 C++ as an Enhancement of C. EEL 3801 – Lotzi Bölöni Comments  Can be done with // at the start of the commented line.  The end-of-line terminates.
Lecture 15: Course Review BJ Furman ME 30 16MAY2011.
Engineering H192 - Computer Programming The Ohio State University Gateway Engineering Education Coalition Lect 11P. 1Winter Quarter Arrays Lecture 11.
CPS120 Introduction to Computer Science Exam Review Lecture 18.
CMSC 104, Section 301, Fall Lecture 18, 11/11/02 Functions, Part 1 of 3 Topics Using Predefined Functions Programmer-Defined Functions Using Input.
1 Introduction to Haptics Introduction to the Hapkit board Allison M. Okamura Stanford University.
ME 120: Arduino Programming Arduino Programming Part II ME 120 Mechanical and Materials Engineering Portland State University
CCSA 221 Programming in C CHAPTER 3 COMPILING AND RUNNING YOUR FIRST PROGRAM 1 ALHANOUF ALAMR.
DYNAMIC MEMORY ALLOCATION. Disadvantages of ARRAYS MEMORY ALLOCATION OF ARRAY IS STATIC: Less resource utilization. For example: If the maximum elements.
Prof: Dr. Shu-Ching Chen TA: Samira Pouyanfar Spring 2017
A bit of C programming Lecture 3 Uli Raich.
C Programming Tutorial – Part I
Stop Light Lab 7 Winter Quarter.
Introduction C is a general-purpose, high-level language that was originally developed by Dennis M. Ritchie to develop the UNIX operating system at Bell.
Programming Languages and Paradigms
C Programming Lecture-17 Storage Classes
Presentation transcript:

Engineering H192 - Computer Programming The Ohio State University Gateway Engineering Education Coalition Lect 26P. 1Winter Quarter Handy Board Lecture 26

Engineering H192 - Computer Programming The Ohio State University Gateway Engineering Education Coalition Lect 26P. 2Winter Quarter Hands-on Lab #7 – The Traffic Light Hands-On Lab #7 will use the MIT Handy Board controller. First part of exercise is to write a C (not C++) program which performs functions to simulate the operation of a traffic light. Second part of exercise will be to convert program to run on Interactive C, the compiler for the Handy Board. Hand-outs will be provided for Handy Board basics, description of required C program, and laboratory exercise.

Engineering H192 - Computer Programming The Ohio State University Gateway Engineering Education Coalition Lect 26P. 3Winter Quarter Programming in Real Time – Time of Day Programs which run in real time make frequent use of system timing functions and system clock. On the Unix system there are some useful timing routines in and We will need to use at least: –time defined in –sleepdefined in

Engineering H192 - Computer Programming The Ohio State University Gateway Engineering Education Coalition Lect 26P. 4Winter Quarter Programming in Real Time – Time of Day From the time routine in we can look up the current time of day: NAME time - get time SYNOPSIS #include /* Not usually required */ #include time_t time (time_t *tloc) ; DESCRIPTION time returns the value of time in seconds since 00:00:00 UTC, January 1,1970. If tloc is non-zero, the return value is also stored in the location to which tloc points.

Engineering H192 - Computer Programming The Ohio State University Gateway Engineering Education Coalition Lect 26P. 5Winter Quarter Programming in Real Time – Time of Day To get the elapsed time from some starting point: #include int time_start, time_now, delta_t ; … time_start = time (NULL) ; … time_now = time (NULL) ; delta_t = time_now - time_start ; More rigorously, one would probably use the difftime function: delta_t = difftime ( time_now, time_start) ;

Engineering H192 - Computer Programming The Ohio State University Gateway Engineering Education Coalition Lect 26P. 6Winter Quarter A sleep function void sleep (float nseconds) { long start ; start = time (NULL) ; while (time (NULL) - start < nseconds) ; }

Engineering H192 - Computer Programming The Ohio State University Gateway Engineering Education Coalition Lect 26P. 7Winter Quarter Programming in Real Time – Waiting From the sleep routine in we can wait for time to elapse (i.e., "take a nap"): NAME sleep - suspend execution for interval SYNOPSIS #include unsigned sleep (unsigned seconds); DESCRIPTION The current thread is suspended from execution for the number of seconds specified by the argument. The suspension time may be longer than requested by an arbitrary amount due to the scheduling of other activity in the system. See "man sleep" for more details on SLEEP(3C).

Engineering H192 - Computer Programming The Ohio State University Gateway Engineering Education Coalition Lect 26P. 8Winter Quarter Programming in Real Time – Waiting To wait a specified amount of time between two statements in a program: #include int color1, color2, direction1, direction2;  change_lites (color1, direction1) ; sleep (6) ; change_lites (color2, direction2) ;

Engineering H192 - Computer Programming The Ohio State University Gateway Engineering Education Coalition Lect 26P. 9Winter Quarter The Handy Board

Engineering H192 - Computer Programming The Ohio State University Gateway Engineering Education Coalition Lect 26P. 10Winter Quarter The Handy Board The Handy Board features: 52–pin Motorola 6811 microprocessor with system clock at 2 MHz. 32K of battery-backed CMOS static RAM. Two L293D chips capable of driving four DC motors. 16 x 2 character LCD screen. Two user-programmable buttons, one knob, and piezo beeper. Powered header inputs for 7 analog sensors and 9 digital sensors. Internal 9.6v nicad battery with built-in recharging circuit. Hardware 38 kHz oscillator and drive transistor for IR output and on-board 38 kHz IR receiver. Board size of 4.25 x 3.15 inches, designed for a commercial, high grade plastic enclosure which holds battery pack beneath the board.

Engineering H192 - Computer Programming The Ohio State University Gateway Engineering Education Coalition Lect 26P. 11Winter Quarter Interactive C Loosely based on ANSI C Several versions available: –IC version installed in lab, available for $35 per educational user from Newton Labs. This is the most up-to-date version for non-Expanded Handy Boards with some local (OSU) enhancements. –IC Version 4.2.x – also installed and will be used this quarter. May only be used with Expanded Handy Boards. –IC Version – recently available and may be used next quarter. Available as a free download at

Engineering H192 - Computer Programming The Ohio State University Gateway Engineering Education Coalition Lect 26P. 12Winter Quarter Interactive C Things that are different in IC V3.2 (compared to ANSI C): –No function prototypes –No pointer arithmetic –Limited formats possible in printf –Array bounds checked at run time –Arrays can not be converted to pointers –No #include statements –Smaller set of allowable data types (only int, long, float, char, and struct –Character strings are supported, but simple char variables are not

Engineering H192 - Computer Programming The Ohio State University Gateway Engineering Education Coalition Lect 26P. 13Winter Quarter Interactive C More things that are different in IC V3.2 (compared to ANSI C): –No switch/case construct –Can only do +, -, and * on long int ( No division) –All source files must be compiled together –No extern statement –#define has global scope –User functions come first in source file –No do/while construct

Engineering H192 - Computer Programming The Ohio State University Gateway Engineering Education Coalition Lect 26P. 14Winter Quarter Traffic Light States

Engineering H192 - Computer Programming The Ohio State University Gateway Engineering Education Coalition Lect 26P. 15Winter Quarter Traffic Light States

Engineering H192 - Computer Programming The Ohio State University Gateway Engineering Education Coalition Lect 26P. 16Winter Quarter Skeleton Program for Traffic Light void change ( /*parameters*/ ) { /* motor function calls (or display light status) */ } int main ( ) { /* declarations */ /* set initial light conditions */ /* while loop with timing and function calls */ }