Presentation is loading. Please wait.

Presentation is loading. Please wait.

Programming Boe-Bots (Part 1)

Similar presentations


Presentation on theme: "Programming Boe-Bots (Part 1)"— Presentation transcript:

1 Programming Boe-Bots (Part 1)
Slides taken from: WAM tutorial, and course material developed by Dean Brock and Tammy Gammon

2 Module Components Serial Signal Conditioning Conditions voltage signals between PC serial connection (+/- 12V) and BASIC Stamp (5V) for Programming. 5V Regulator Regulates voltage to 5V with a supply of 5.5VDC to 15VDC EEPROM Stores the tokenized PBASIC program. Resonator Sets the speed at which instructions are processed. Interpreter Chip Reads the BASIC program from the EEPROM and executes the instructions.

3 Module Pins Regulated 5V.
Pin 1: SOUT Transmits serial data during programming and using the DEBUG instruction Pin 24: VIN Un-regulated input voltage (5.5-15V) Pin 23: VSS Ground (0V) Pin 2: SIN Receives serial data during programming Pin 22: RES Reset- LOW to reset Pin 3: ATN Uses the serial DTR line to gain the Stamps attention for programming. Pin 21: VDD Regulated 5V. P0 P15 Pins 5-20: Input/Output (I/O) pins P0 through P15 P1 P14 Pin 4: VSS Communications Ground (0V). P2 P13 P3 P12 P4 P11 P5 P10 P6 P9 P7 P8

4 The Board of Education makes it easy to connect devices, power up and program.
5V regulator Battery Servo Connections Wall DC Supply Power Header Power On Light I/O Header Breadboard Serial Programming Port Reset Switch Off/Module Power/Servo Power

5 A Simple Program Enter your first program into the BASIC Stamp Editor.
Notice that different code appears in different colors. This is a great help in writing correct code!

6 'Running' Your Program Download, or Run your program by clicking the Run button. The DEBUG Window should appear showing your message.

7 How a Program is Placed on the Module
A program is written in the BASIC Stamp Editor. The program is tokenized, or converted into symbolic format. Tokenizer The tokenized program is transmitted through the serial cable and stored in EEPROM memory. The Interpreter Chip reads the program from EEPROM and executes the instructions.

8 Directives Directives are special instructions to the Editor ensuring the the code is tokenized for the correct PBASIC version and for the correct BASIC Stamp. When starting a new program, be sure to click the buttons to add these directives to your program.

9 Hello, it's me, your BASIC Stamp!
DEBUG Window When a program contains a DEBUG command, the Editor opens the DEBUG Window. Hello, it's me, your BASIC Stamp! Data is sent back through the serial cable as characters to be viewed. This data is sent very quickly! The RESET button on board will start the program on your Stamp again.

10 Getting Help

11 Program like you are an engineer
Organize and structure your code. Use indentation to clarify organization. Indent loops and code skipped by if’s Use white space wisely. Follow a consistent style and format. Use comments to explain your code. input 14 ‘push button – normal timing Use variable and loop names which clarify purpose.

12 The Program Header Identify the code. Briefly state purpose of code.
Your name Project Title Date Title/file of code Briefly state purpose of code.

13 Good Program Structure
Header Define the constants green con 0 “Declare” the pins input ‘push button for normal timing output green ‘green LED Declare and comment your variables n var byte ‘index for varying blink rate

14 I/O Pin “Language” input 14 ‘normal mode pushbutton if in14 then ……
output ‘green led out0 = 0 pause 500 out0 = 1 You don’t even have to declare output: low green pause high green

15 Declaring & Assigning Variables
A variable & its size must be declared: normal var bit ‘allocates 1 bit (0 or 1) x var nib ‘nibble, 4 bits (0 – 15) y var byte ‘byte, 8 bits (0 – 255) counter var word ‘16 bits (0 – 65,535) Variables contain values which can be changed. Examples: normal = in14 normal = ~normal counter = counter + 1

16 If …. then Function Arithmetic and logical operators may be used in the test condition. A bit of code… if in14 = 0 then normal_mode if in14 = 0 and in7 = 0 then non_resp Why wouldn’t you want to list if…then statements as shown?

17 For….next Iterative loop Example to create varying pause times:
x var nib for x = 1 to 10 pause * x next

18 Of course, we must mention…
goto label ‘creates continuous loop ‘or skips to another part of program And all happily ever-afters finish with a “the end” or just END in PBASIC.

19 Sensors A microcontroller-controlled system changes its outputs according to its input signals A sensor is an input device used to detect or measure. Example: push-button

20 Push-Button Sensor OPEN (Not pressed) CLOSED (Pressed)

21 Push-Button Sensor

22 Sample Code input 2 ‘push button recheck: if in2 = 0 then blink
goto recheck blink: …make some led blink


Download ppt "Programming Boe-Bots (Part 1)"

Similar presentations


Ads by Google