Software and documentation Download and install: “Setup-Stamp-Editor-Lrg-v2.2.6.exe” www.parallax.com  Downloads  BASIC Stamp software BASIC Stamp Syntax.

Slides:



Advertisements
Similar presentations
EMS1EP Lecture 4 Intro to Programming Dr. Robert Ross.
Advertisements

JED Microprocessors Pty Ltd Presenting the JED T430 low-cost Projector Controllers Nov 22nd, 2009.
Lab7: Introduction to Arduino
Introduction 2 BASIC Stamp®. Microcontrollers Microcontrollers can be thought of as very small computers which may be programmed to control systems such.
CSC 405 Lab 1 - Building a Simple Combinatorial Circuit In this laboratory exercise you will learn about the layout of some small-scale integrated circuits.
MICROCONTROLLERS MODULE 2 Programming, Controlling and Monitoring.
Using the Board of Education Breadboard and Your Multimeter ENGR 120 Work in teams of two!
1 Boe-Bot Parts BOE-BOT Lecture #1b DE - Digital Electronics.
Hardware Meets Software CPSC 120 Principles of Computer Science February 15, 2012.
Living with the Lab Using Your Arduino, Breadboard and Multimeter EAS 199A Fall 2011 Work in teams of two!
Basic Stamp II is kinda cool Bytes of EEPROM(non-volatile) - Clock speed of 20 MHz. - Holds 600 lines of code in EEPROM - executes an average of.
ENGR 101: Robotics Lecture 2 – Text Programming Outline  Introduction to PBASIC  Variables, I/O, Arithmetic  Controlling the LEDs References 
Input and Output Developed by: Electronic Systems Technologies College of Applied Sciences and Arts Southern Illinois University Carbondale
Introduction.
Embedded Programming and Robotics
LSU 06/04/2007BASIC Stamp Editor1 The BASIC Stamp Editor Programming Unit, Lecture 3.
Slide Menlo Drive Suite 100 Rocklin, CA Presentation based on: “What’s a Microcontroller?" by Andy Lindsay Presented by Andy.
Basic Stamp Quick Start. Basic Stamp II Self contained computer –“Micro-controller” Specialized for “embedded” computing (sensing and controlling things)
ARDUINO PROGRAMMING Working with the Arduino microcontroller.
MICROCONTROLLERS MODULE 2 Programming, Controlling and Monitoring.
Dean Brock, Rebecca Bruce and Susan Reiser, CCSC SE 2009 Using Arduino Material taken from Todbot blog Bionic Arduino Todbot blog Bionic ArduinoTodbot.
Parallax BASIC Stamp® Tutorial
BASIC Stamp Editor Once installed, the Stamp Editor will be available on your desktop, and as a menu option under Start  Program Files  Parallax Inc.
1 Applied Control Systems Technology. 2 Pin configuration Applied Control Systems.
Slide Menlo Drive Suite 100 Rocklin, CA Presentation based on: “What’s a Microcontroller?" by Andy Lindsay Presented by Jessica.
The Basic Stamp Instruction Set Architecture. The Microprocessor A microprocessor is a computer that typically has an architecture that is well suited.
1 Basic Electronics Voltage (V or E): Potential difference between 2 points. Volts. (+) - A lack of electrons (-) – A surplus of electrons When a circuit.
MICRO CONTROLLER MODULE 1. Learning Objectives Name some gadgets that use microcontrollers. Define a microcontroller. Differentiate between a computer.
Basic Stamp OEM module By Wilmer Arellano. OEM BASIC Stamp 2sx Wiring diagram Note: - is connection to negative pole of the battery 220 Ohm Push button.
Controlling the Outside World
Programming the CheapBot-14. Start the Editor Set the Mode.
First, let’s review the structure and use of a breadboard.
Basic Stamp OEM module By Wilmer Arellano. 2  The BASIC Stamp 2 OEM is a discreet component version of the BS2 which may be purchased in kit form. 
1 Chapter 1: Getting Started Presentation based on: "What's a Microcontroller ?" By Andy Lindsay Parallax, Inc Presentation developed by: Martin A. Hebel.
1 Parallax BASIC Stamp ® Tutorial Developed by: Electronic Systems Technologies College of Applied Sciences and Arts Southern Illinois University Carbondale.
Microcontroller I Seth Price Department of Chemical Engineering New Mexico Tech Rev. 9/22/14.
Digital Electronics Board-of-Education : Input. Board of Education - Input This presentation will explain, both from a hardware and software perspective,
IR Communication Materials taken from a variety of sources including IR Remote for the Boe-Bot by Andy Lindsay.
ME456: Mechatronics Systems Design Lecture 3 Chapter 2: Lights On –Lights Off Prof. Clark J. Radcliffe Mechanical Engineering Michigan State University.
1 Chapter 1: Getting Started Presentation based on: "What's a Microcontroller ?" By Andy Lindsay Parallax, Inc Presentation developed by: Martin A. Hebel.
IR Communication October 27, Sources  Lindsay, Andy. IR Remote for the Boe- Bot. v
CSC522 Embedded Systems Introduction to Circuit Design.
Slide Menlo Drive Suite 100 Rocklin, CA Presentation based on: “What’s a Microcontroller?" by Andy Lindsay Presented by Andy.
ENGR 101: Robotics Lecture 3 – Robot Motion Outline  Robot Motion  FOR Loops  Making Music References 
ENGR 101: Robotics Lecture 4 – Making Decisions Outline  The Stall Sensor  Making Decisions  Random Number Generation References 
July 7, 2003 Slide 1 of 6 Automation, Robotics and Mechatronics Lab, SUNY at Buffalo Introduction To Programming Chetan Jadhav Talib Bhabharawala Seung-Kook.
Slide Menlo Drive Suite 100 Rocklin, CA
Slide 1 Chapter #7: Measuring Light Light Sensor Circuit Parts (1) (1)Resistor – 220 Ω (red-red-brown) (1) Capacitor – 0.1  F (1) Capacitor – 0.01  F.
Basic Stamp OEM module By Wilmer Arellano. 2  The BASIC Stamp 2 OEM is a discreet component version of the BS2 which may be purchased in kit form. 
Welcome to Week 4 at the Summer Computer Club Raspberry Pi (contd)
Digital Electronics Board-of-Education : Output. Board of Education - Output This presentation will explain, both from a hardware and software perspective,
INTERNET OF EVERYTHING SDU 2016 Week 4. Simple Digital and Analog Inputs  The Arduino’s ability to sense digital and analog inputs allows it to respond.
Basic Stamp OEM module By Wilmer Arellano. 2  The BASIC Stamp 2 OEM is a discreet component version of the BS2 which may be purchased in kit form. 
Microcontroller basics Embedded systems for mortals.
Basic Stamp OEM module By Wilmer Arellano. 2  The BASIC Stamp 2 OEM is a discreet component version of the BS2 which may be purchased in kit form. 
Arduino “Getting Started” Instructor : Dr Matthew Miss Khin Yi Kyaw
Controlling an LED with a switch. 2 breadboard place where you can build electric circuits really quickly the magical breadboard.
Slide Menlo Drive Suite 100 Rocklin, CA
Assist. Prof. Rassim Suliyev - SDU 2017
Microcontroller basics
OEM BASIC Stamp 2sx 220 Ohm.
Diagram of the Board of Education
Chapter 1: Getting Started
Programming Boe-Bots (Part 1)
Internet-of-Things (IoT)
Arduino Part 4 Let there be more light.
Fevzi Ozaydin & Violet Mwaffo
CTY SAR FCPS Shawn Lupoli, Elliot Tan
Programming the BASIC Stamp
Intro to Arduino Part 2 The Breadboard
Presentation transcript:

Software and documentation Download and install: “Setup-Stamp-Editor-Lrg-v2.2.6.exe”  Downloads  BASIC Stamp software BASIC Stamp Syntax and Reference Manual Version 2.2 (5.3 MB) Software for Windows: BASIC Stamp Windows Editor version (~6.0 MB). Windows NT4/2K/XP. With BS1 Support!  Downloads  Documentation

OEM module  The BASIC Stamp 2 OEM is a discreet component version of the BS2 which may be purchased in kit form.  The male header provides the means to ‘plug-it’ into your own board, or connect to other boards. Regulated 5V output (Vdd) Ground- 0V (Vss) 5.5 – 15V input (Vin) Reset Input (RES) P0-P15 I/O Power the board with EITHER: A) VDC on Vin. This will also provide 5 VDC regulated output on Vdd. B) Regulated 5V Input on Vdd.

Using the breadboard (Socket board) The bread board has many strips of metal (copper usually) which run underneath the board. The metal strips are laid out as shown in orange. The long top and bottom row of holes are usually used for power supply connections. To use the bread board, the legs of components are placed in the holes (the sockets). The holes are made so that they will hold the component in place. The circuit is built by placing components and connecting them together with jumper wires.

Connection 220 Ohm resistor should be connected to pin P4 of the OEM Basic Stamp 2sx. “+” (long) lead of LED should be connected to opposite side of the resistor. The other (short) lead of the LED goes to “-” 220 Ohm LED 9 V battery

220 Ohm OEM BASIC Stamp 2sx

Wiring diagram Note: - is connection to negative pole of the battery 220 Ohm Push button Buzzer LED OUT PIR Motion sensor 9 V battery COM port Microcontroller chip 15 KOhm

BASIC Stamp software Stamp Mode: BS2sx “Run” Your saved program files “Identify” Finds COM port with BASIC Stamp connected

' My first program ' {$STAMP BS2sx} ' {$PBASIC 2.5} DEBUG "Hello, is anybody home?" END Example 0 Your first program: Run this program when your BS2sx microcontroller is powered and connected to the computer via COM port. What do you see on the screen? File: “Example-00.bsx”

' Example 01a ' {$STAMP BS2sx} ' {$PBASIC 2.5} Red:'Lable LOW 4'Makes pin 4 to have low voltage PAUSE 1000'Pause 1 second HIGH 4'Makes pin 4 to have high voltage PAUSE 50'Pause 0.05 sec GOTO Red'Makes program to go back to “Red” lable END Example 01a File: “ Example-01a.bsx” Red LED

' Example 01b ' {$STAMP BS2sx} ' {$PBASIC 2.5} DO LOW 4 'Makes pin 4 to have low voltage PAUSE 1000 'Pause 1 second HIGH 4 'Makes pin 4 to have high voltage PAUSE 50 'Pause 0.05 sec LOOP END Example 01b File: “ Example-01b.bsx” Red LED

' Example 01c ' {$STAMP BS2sx} ' {$PBASIC 2.5} RedLED PIN 4' red LED is connected to pin 4 IsOn CON 1' IsOn = 1(constant) LED is active high IsOff CON 0' IsOff = 0(constant) LED is active low Setup: OUTPUT RedLED' sets OUTPUT to be pin 4 Main: DO RedLED = IsOn' same as HIGH 4 PAUSE 1000' pause 1 s = 1000 ms RedLED = IsOff' same as LOW 4 PAUSE 1000' pause 1 s = 1000 ms LOOP END Example 01c File: “ Example-01c.bsx” Red LED

' Example 02a ' {$STAMP BS2sx} ' {$PBASIC 2.5} Green:' label “green” DEBUG ? IN0, CR' sends information to the PC ' about the status of input pin 0 PAUSE 1000' pause 1 s = 1000 ms GOTO Green' return to label “green” END Example 02a File: “ Example-02a.bsx” Run program. Press the pushbutton. What do you see on the screen? Release the pushbutton. What do you see on the screen? Red LED and pushbutton

' Example 02b ' {$STAMP BS2sx} ' {$PBASIC 2.5} DO DEBUG ? IN0' sends information to the PC ' about the status of input pin 0 IF (IN0 = 1) THEN HIGH 4 PAUSE 50 LOW 4 PAUSE 50 ELSE PAUSE 100 ENDIF LOOP Example 02b File: “ Example-02b.bsx” Red LED and pushbutton

' Example 03 ' {$STAMP BS2sx} ' {$PBASIC 2.5} myNumber VAR Nib DO DEBUG CR, "Enter a number (from 1 to 5)? --> " DEBUGIN DEC1 myNumber IF ((myNumber >= 1) AND (myNumber <= 5)) THEN DEBUG CR, " -- You entered: ", DEC1 myNumber ELSE DEBUG CR, " -- Sorry, your number is out of range" ENDIF LOOP END Example 03 File: “ Example-03.bsx” Input from the PC

' Example 04 ' {$STAMP BS2sx} ' {$PBASIC 2.5} RedLED PIN 4 ' red LED is connected to pin 4 YellowLED PIN 13 ' Yellow LED is connected to pin 13 GreenLED PIN 15 ' Green LED is connected to pin 15 IsOn CON 1 ' IsOn = 1(constant) LED is active high IsOff CON 0 ' IsOff = 0(constant) LED is active low Setup: OUTPUT RedLED ' sets OUTPUT to be pin 4 OUTPUT YellowLED OUTPUT GreenLED Main: DO RedLED = IsOn PAUSE 100 RedLED = IsOff PAUSE 10 YellowLED = IsOn PAUSE 100 YellowLED = IsOff PAUSE 10 GreenLED = IsOn PAUSE 100 GreenLED = IsOff PAUSE 500 LOOP END Example 04 File: “ Example-04.bsx” 3 LEDs

' Example 05a ' {$STAMP BS2sx} ' {$PBASIC 2.5} FREQOUT 1,3000,1900 PAUSE 1000 FREQOUT 1,3000,1900,2533 PAUSE 1000 FREQOUT 1,3000,1900,1903 END Example 05a File: “ Example-05a.bsx” Buzzer Run the program. What do you hear?

' Example 05b ' {$STAMP BS2sx} ' {$PBASIC 2.5} Dit CON 90 ' Short span of time in milliseconds. Dah CON 3*Dit ' Longer time, 3 times the above. index VAR Nib ' Index. sos VAR Nib FOR sos=1 TO 3 FOR index=1 TO 3 ' Send 5 sounds. FREQOUT 1, Dit, 1900 ' Send a dit. PAUSE Dit ' Short silence. NEXT PAUSE Dah ' Longer silence between digits. FOR index=1 TO 3 ' Send 5 sounds. FREQOUT 1, Dah, 1900 ' Send a Dah. PAUSE Dah ' Short silence. NEXT FOR index=1 TO 3 ' Send 5 sounds. FREQOUT 1, Dit, 1900 ' Send a dit. PAUSE Dit ' Short silence. NEXT PAUSE Dah*3 NEXT END Example 05b File: “ Example-05b.bsx” Buzzer: SOS

' Example 04 ' {$STAMP BS2sx} ' {$PBASIC 2.5} RedLED PIN 4 ' red LED is connected to pin 4 YellowLED PIN 13 ' Yellow LED is connected to pin 13 GreenLED PIN 15 ' Green LED is connected to pin 15 IsOn CON 1 ' IsOn = 1(constant) LED is active high IsOff CON 0 ' IsOff = 0(constant) LED is active low Setup: OUTPUT RedLED ' sets OUTPUT to be pin 4 OUTPUT YellowLED OUTPUT GreenLED Main: DO RedLED = IsOn PAUSE 100 RedLED = IsOff PAUSE 10 YellowLED = IsOn PAUSE 100 YellowLED = IsOff PAUSE 10 GreenLED = IsOn PAUSE 100 GreenLED = IsOff PAUSE 500 LOOP END Example 05c File: “ Example-05c.bsx” 3 LEDs and buzzer

Format of variables 1.Bit 0 or 1 2.Nibble (Nib) Byte Word or to MouseVARBIT' Value can be 0 or 1. CatVARNIB' Value can be 0 to 15. DogVARBYTE' Value can be 0 to 255. RhinoVARWORD' Value can be 0 to Example of variables:

' {$STAMP BS2sx} ' {$PBASIC 2.5} TOTAL VAR Byte X CON 20 TOTAL = 0 TOTAL = TOTAL +100 DEBUG ? TOTAL TOTAL= TOTAL/3 DEBUG ? TOTAL DEBUG ? X END Example 06 Performing calculations File: “ Example-06.bsx” Run the program. What do you see?

Pseudo Code Start of program Measure temperature -Is temperature < 100 F ? Yes, Turn on heat -Is temperature > 102 F ? Yes, Turn on cooling fan Go back to start.

22 Start Measure Temperature Temp. < 100 Energize Heater Temp. > 102 Energize Fan Yes No Yes No Flow Chart

23 Sequential Flow Example Pseudo-Code: Start of program  Turn off LED 1  Turn off LED 2  Pause for 2 seconds  Light LED 1  Pause for 2 seconds  Light LED 2  End of program Flowchart: ' <<<< INSERT COMMON ' CIRCUIT DECLARATIONS >>>>CIRCUIT DECLARATIONS 'Prog 6A: Example of sequential flow ' ****** Main program ******** LED1 = LED_Off'Turn off LED 1 LED2 = LED_Off'Turn off LED 2 PAUSE 2000'Pause for 2 sec. LED1 = LED_On'Light LED 1 PAUSE 2000'Pause for 2 sec. LED2 = LED_On'Light LED 2 END Code: Start Turn OFF LED1 Turn OFF LED2 2 Second Pause Turn ON LED1 Turn ON LED2 2 Second Pause End

Branching Overview “GOTO” Branching is the act of breaking out of a sequence to perform code in another location of the program. The simplest form of branching is to use the GOTO instruction: GOTO label

25 Looping Flow Example Pseudo-Code: Start of program  Turn off LED 1  Turn off LED 2  Pause for 2 seconds  Light LED 1  Pause for 2 seconds  Light LED 2  Go back to start ' <<<< INSERT COMMON ' CIRCUIT DECLARATIONS >>>>CIRCUIT DECLARATIONS 'Prog 6B: Example of sequential ' flow with looping ' ****** Main program ********** Main: LED1 = LED_Off 'Turn off LED 1 LED2 = LED_Off 'Turn off LED 2 PAUSE 2000 'Pause for 2 sec. LED1 = LED_On 'Light LED 1 PAUSE 2000 'Pause for 2 sec. LED2 = LED_On 'Light LED 2 GOTO Main'Repeat sequence Code: : Flowchart : Start Turn OFF LED1 Turn OFF LED2 2 Second Pause Turn ON LED1 Turn ON LED2 2 Second Pause

Conditionals Overview The previous example is an unconditional branch; the program will branch back to Main regardless of any code parameters. In a conditional branch a decision is made based on a current condition to branch or not to branch. As humans, we constantly make decisions based on input as to what to perform. Shower too cold? Turn up the hot. Shower too hot? Turn down the hot water. Microcontrollers can be programmed to act based on condition.

“IF…THEN” The “IF-THEN” is the primary means of conditional branching. IF condition THEN addressLabel If the condition is evaluated to be true, execution will branch to the named address label. If the condition is not true, execution will continue to the next step in the program sequence. A condition is typically an equality: value1 = value2 value1 > value2 value1 < value2 IN8 = 1 Note: Compared to many versions of BASIC and other languages, the PBASIC 2.0 implementation of the IF-THEN is fairly limited. See the PBASIC 2.5 appendix for new implementations of IF-THEN.

28 “IF-THEN” Example: Alarm This program will sound the alarm as long as pushbutton 1 is pressed. Start: Is button 1 pressed? Yes, Go sound Alarm No, Go back to start Alarm: Sound speaker Go back to start of program ' <<<< INSERT SECTION 5 COMMON ' CIRCUIT DECLARATIONS >>>> CIRCUIT DECLARATIONS 'Prog 6C: Conditional Branching Alarm Main: ' If pushbutton 1 is pressed, ' then go sound alarm IF PB1 = PB_On THEN Alarm GOTO Main Alarm: 'Sound the alarm FREQOUT Speaker, 1000, 2000 GOTO Main Pseudo-Code Flowchart Program Code Button 1 Pressed Main Speaker 2000Hz for 1 second Main TrueFalse

' Example 07 ' {$STAMP BS2sx} ' {$PBASIC 2.5} RedLED PIN 4 ' red LED is connected to pin 4 YellowLED PIN 13 ' yellow LED is connected to pin 13 PushButton PIN 0 ' push button is connected to pin 0 IsOn CON 1 ' IsOn = 1(constant) LED is active high IsOff CON 0 ' IsOff = 0(constant) LED is active low X VAR Bit Setup: OUTPUT RedLED ' sets OUTPUT to be pin 4 OUTPUT YellowLED ' sets OUTPUT to be pin 4 MainA: ' label “MainA” RedLED = IsOff YellowLED = IsOn X = IN0 IF X = 0 THEN MainA MainB: ' label “MainB” YellowLED = IsOff RedLED = IsOn X = IN0 IF X = 0 THEN GOTO MainA ELSE GOTO MainB END Example 07 IF…THEN…ELSE File: “ Example-07.bsx”

' File: Example-PIR.bsx ' {$STAMP BS2sx} ' {$PBASIC 2.5} ' -----[ I/O Definitions ] PIR PIN 7 ' I/O Pin For PIR Sensor RED PIN 4 ' I/O Pin For RED LED GREEN PIN 15 ' I/O Pin For GREEN LED YELLOW PIN 13 ' I/O Pin For YELLOW LED ' -----[ Variables ] counter VAR Byte ' Trip Counter ' -----[ Initialization ] DEBUG CLS ' Clear DEBUG Screen LOW RED LOW GREEN HIGH YELLOW FOR counter = 20 TO 0 ' Wait 40 Seconds For PIR Warm-Up DEBUG HOME, "WARMING UP:", DEC2 counter PAUSE 1000 ' Display Counter Every Second NEXT LOW YELLOW counter = 0 ' Clear Counter Variable DEBUG HOME, "WAITING... " ' Display Waiting Message ' -----[ Program Code ] Main: HIGH GREEN DO IF PIR = 1 THEN ' Motion Detected? counter = counter + 1 ' Update Trip Counter LOW GREEN HIGH RED ' Light LED DEBUG HOME, "TRIPPED...", DEC3 counter DO : LOOP UNTIL PIR = 0 ' Wait For PIR To Clear DEBUG HOME, "CLEARED...", DEC3 counter LOW RED ' Turn Off LED HIGH GREEN ENDIF LOOP Example PIR PIR - sensor File: “ Example-PIR.bsx”