MICROCONTROLLERS MODULE 2 Programming, Controlling and Monitoring.

Slides:



Advertisements
Similar presentations
IR Communication Materials taken from a variety of sources including IR Remote for the Boe-Bot by Andy Lindsay.
Advertisements

1 Chapter 2: Light on- Lights off Presentation based on: "What's a Microcontroller ?" By Andy Lindsay Parallax, Inc Presentation developed by: Martin A.
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.
Pulse Detector Ramiro Duarte, Clayton Greenbaum Prof. Betty Lise Anderson.
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.
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.
Digital Outputs 7-Segment Display
Input and Output Developed by: Electronic Systems Technologies College of Applied Sciences and Arts Southern Illinois University Carbondale
George Washington University DC Circuits Lab Professor Ahmadi ECE 002.
Using Your Arduino, Breadboard and Multimeter Work in teams of two! living with the lab 1 © 2012 David Hall.
Presented by Tim Surtell in association with
Electronic Components
McGraw-Hill © 2008 The McGraw-Hill Companies Inc. All rights reserved. Electricity Principles & Applications Seventh Edition Chapter 4 Circuit Components.
Institute Of Applied Technology ATE 1012 Grade 10 Eng. Rose Hasan.
Sheila Porter Intel Ireland
Working with Arduino: Lesson #1: Getting Acquainted with the Kit EGN1007.
RM2C Understanding Connections on the Robot Control Board (RCB).
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.
Agenda Introduction to circuits Building a simple circuit
Instrumental Analysis Electrical Components and Circuits.
Boe-Bot Review.
Daily Sprint START In your own words describe the functions of the following: variable resistor photoresistor fixed resistor.
MICRO CONTROLLER MODULE 1. Learning Objectives Name some gadgets that use microcontrollers. Define a microcontroller. Differentiate between a computer.
Experiments Day 1 & 2 Resistors, Potentiometers and Photocells.
Experiments Day 1 Resistors.. Electronic Technology Definition: The technology of using small amounts of electricity for controlling, detecting, collecting,
Software and documentation Download and install: “Setup-Stamp-Editor-Lrg-v2.2.6.exe”  Downloads  BASIC Stamp software BASIC Stamp Syntax.
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 Chapters 2 And 3 Presentation based on: "What's a Microcontroller ?" By Andy Lindsay Parallax, Inc Presentation developed by: Martin A. Hebel Southern.
Digital Electronics Board-of-Education : Input. Board of Education - Input This presentation will explain, both from a hardware and software perspective,
Physics 2225: Working With Electronic Equipment Purpose  Learn how to use basic electronic equipment: Digital multi meter Oscilloscope Function generator.
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.
Microcontrollers Module 3: Digital Display. 7 – Segment Display A seven-segment display (SSD), or seven- segment indicator, is a form of electronic display.
CSC522 Embedded Systems Introduction to Circuit Design.
IR Communication Materials taken from a variety of sources including IR Remote for the Boe-Bot by Andy Lindsay.
Computer Hardware Technology
How an NPN Transistor Works
Two basic types Ceramic disk Electrolytic Has positive and negative sides Farads – unit of measure (F) Microfarads(uF) and picofarads (pF) Cans have value.
Slide Menlo Drive Suite 100 Rocklin, CA
Resistor Colour Code Why the Colour Code? The Colour code was developed to overcome two basic problems; Difficult to print and see numbers on a.
PHY 235 Robotics Workshop Day 4 Robotic Behaviors, Light Sensing, Voltage Dividers, LCD-MOD.
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. 
Digital Electronics Board-of-Education : Output. Board of Education - Output This presentation will explain, both from a hardware and software perspective,
1 ELEKTRONIKA DASAR Jurusan Teknik Elektro Fakultas Teknik UGM 2007 Bahan Kuliah Minggu I.
Resistors Foundations of Technology Resistors © 2013 International Technology and Engineering Educators Association, STEM  Center for Teaching and Learning™
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. 
CONDUCTION, INSULATION AND PROTECTION. CONDUCTION Energy (eg. Electrical) transfer from one material to another by direct contact. Conductors are materials.
An introduction to PIC’s for KS3 and KS4. Mr Rooks Hetton School.
PLC programming Part 3: Problems with solutions. Topics  Every problem is devided into three parts:  Technology description contains the general properties.
Controlling an LED with a switch. 2 breadboard place where you can build electric circuits really quickly the magical breadboard.
Diode Foundations of Technology Diode © 2013 International Technology and Engineering Educators Association, STEM  Center for Teaching and Learning™ Foundations.
Building Circuits.
Resistance A resistor is a component in a circuit that transforms electrical energy into other types of energy. Some resistors like the heating element.
Prototyping with Microcontrollers and Sensors
Arduino Development for Beginners
Introduction to Handshaking Communication with SSC-32U
Introduction to Handshaking Communication with SSC-32
Unit 3 – Fundamentals of Electronics Examination Specifications
Unit 3 – Fundamentals of Electronics Examination Specifications
Lighting LEDs with a RASPBERRY PI
Programming Boe-Bots (Part 1)
Working with Arduino: Lesson #1: Getting Acquainted with the Kit
Basic circuits Electrical circuits Electrical properties Ohm’s law
Arduino Part 4 Let there be more light.
Prepared by: Engr. Qurban Ali Memon Incharge of Final project Lab.
CTY SAR FCPS Shawn Lupoli, Elliot Tan
2019 Investing Now Summer Program
Presentation transcript:

MICROCONTROLLERS MODULE 2 Programming, Controlling and Monitoring

Module Objectives Define the purpose of indicator lights. Assemble and test an LED circuit manually. Connect an LED circuit to the BASIC Stamp and control it. Write programs using DO…LOOP and FOR… NEXT loop commands. Declare and use variables in a program. Demonstrate the operation of a bi-color LED by assembling a simple ON/OFF circuit. Control a bi-color LED with the BASIC Stamp. Connect and test a pushbutton circuit manually. Connect a pushbutton circuit to the BASIC Stamp and monitor its status.

Introduction In this module, you will learn how to write simple programs to control indicator lights connected to the output pins of the BASIC stamp, And also how to monitor the status of the pins configured as inputs to the BASIC Stamp.

Indicator Lights

Uses Of Indicator lights Indicator lights tells us that what process is going on in a particular machine and we also note that the device is running properly or needs some attention! A few examples of devices with indicator lights include car stereos, televisions, VCRs, disk drives, and alarm system control panels. Turning an indicator light ON or OFF is a simple matter of connecting and disconnecting it from a power source.

Building an LED Circuit What is LED? It is a diode which will conduct in one direction. LIGHT EMITTING DIODE ( LED ) It is available in red, green, yellow, blue and bi color.

LED Function LEDs emit light when an electric current passes through them. Circuit symbol :

LED CONNECTION

Different colours of LED

Circuit Components An LED must be connected with a resistor in series with it to limit current flowing through its terminals. Resistor: A resistor is a component that ‘resists’ the flow of electricity or current. Each resistor has a value that informs how strongly it resists current flow. The resistance value is given in ohms. The colored stripes help you determine the value of the resistor.

Resistor

Resistor bands and circuit symbol

Resistor color codes Digit Color 0 Black 1 Brown 2 Red 3 Orange 4 Yellow 5 Green 6 Blue 7 Violet 8 Grey 9 White

Resistor color codes. Remember this: BBROY OF GREAT BRITAIN HAD A VERY GOOD WIFE !

In the resistor, the first and second color stripes represent the first and second digits. The third color stripe represents the number of following zeros. There may be a fourth color stripe that indicates the resistor’s tolerance. The tolerance tells you how far off the part’s true resistance might be from the labeled resistance. Tolerance is measured in percent, and it could be gold (5%), silver (10%) or no stripe (20%).

Can you find out the value of resistor shown in figure? The color of the 1st bar is yellow, which corresponds to the 1st digit, the digit is _________ The color of the 2nd bar is violet, which corresponds to the second digit, the digit is ____ The color of the 3rd bar is brown, which corresponds to the number of zeros to follow the 2nd digit. The number of zeros is _____ Therefore the resistance value calculated Is _____________- ohms.

Resistance color codes

Prototyping Area White Breadboard: Consists of two group of rows separated by a vertical channel. Each row consists of 5 horizontal interconnected sockets. There is no connection across channel (rows are not interconnected) There is no connection between black of the headers to the white breadboard.

Horizontal black strip is called Power Header and consists of: V dd = +5 Volts. V ss = GND = 0 Volts. V IN = Supply Voltage from battery (9V) or wall DC supply. Side black strip is called I/O Header and consists of: 16 I/O sockets labeled P0-to-P15  I/O connections to the BS2.

Lab Activity 1

Task #1: LED Test Circuit without BASIC Stamp LED Circuit on breadboard Circuit Diagram

Procedure Disconnect power from your BoE by setting the 3- position SW on the BoE to position-0. Refer to Figure and make the following connections: Connect the cathode terminal of the LED to Vss. Connect the anode terminal into a suitable socket. Connect one terminal of R (470Ω) to the anode of the LED. Connect the other terminal of R (470Ω) to VDD. Turn on the Power of the BOE. What do you observe?

Task #2: LED Test Circuit with BASIC Stamp Disconnect power from your BoE. Modify the circuit to match the one in figure Enter the following program on the BASIC Stamp editor and save it as LEDOnOff.bs2

How LEDOnOff.bs2 Works The command DEBUG“The LED connected to Pin14 is blinking”makes this statement appear in the Debug terminal. The command HIGH 14 causes the BASIC Stamp to internally connect I/O pin P14 to Vdd. This turns the LED ON. The command PAUSE 500 causes the BASIC Stamp to pause or stop for 0.5 second while the LED stays ON. The number 500 tells the BASIC Stamp to wait for 500/1000 of a second. The command syntax is PAUSE duration where the duration is in milliseconds.

The command LOW 14 causes the BASIC Stamp to internally connect I/O pin P14 to Vss. This turns the LED OFF. Since LOW 14 is followed by another PAUSE 500, the LED stays OFF for 0.5 second. The reason the code repeats itself, or the LED keeps blinking over and over again is because it is nested between the PBASIC keywords DO and LOOP. The four commands between the DO and LOOP are executed by the BASIC Stamp over and over again. Therefore, the LED will keep flashing until the power is disconnected, or until the battery runs out.

Bi-Color LED Control The bi-color LED is just two LEDs in one package.

Uses of bi colour LED The device shown in figure is a security monitor for electronic keys. When an electronic key with the right code is used, the LED changes color, and a door opens. This is one of the uses of a bi-color LED.

Bi colour LED connection Figure shows how you can apply voltage in one direction and the LED will glow RED. By disconnecting the LED and plugging it back in reversed, the LED will glow green. As with other LEDs, if both terminals of the LED are connected to Vss, the LED will not emit light.

Lab Activity2 Objective: To build and test the Bi-color LED Circuit Background: Initially, you will conduct a manual test for the bi-color LED. The bi- color LED will be connected to the BASIC Stamp in the second test. Controlling a bi-color LED with the BASIC Stamp requires two I/O pins. After you have manually verified that the bi-color LED works using the manual test, you can proceed with the second test. Part #1: Manual Test Disconnect power from your Board of Education. Build the circuit shown on the left side of Figure Reconnect power and verify that the bi-color LED is emitting red light. Disconnect power again. Modify your circuit so that it matches the right side of Figure Reconnect power. Verify that the bi-color LED is now emitting green light. Disconnect power.

Manual Bi-color LED Test

Part #2: Controlling bi-color LED with BASIC Stamp

Circuit diagram Figure shows how you can use P15 and P14 to control the current flow in the bi-color LED circuit.

Enter the TestBiColorLed.bs2 code into the BASIC Stamp editor. Run the program, and verify that the bi-color LED cycles through red, green and off states

Program for bi colour LED

Counting and Repeating In the previous activity, the LED circuit flashed on and off all the time. What if you want the LED to flash on and off ten times?

FOR …. NEXT LOOP There are many ways to make the LED blink on and off ten times. The simplest way is to use a FOR...NEXT loop. The FOR...NEXT loop is similar to the DO...LOOP. This is called a counted or finite loop. The FOR...NEXT loop depends on a variable to track how many times the LED has blinked on and off. A variable is a word of your choosing that is used to store a value.

PBASIC PROGRAMMING Variable TypeNo. of BitsRange of Values Bit10 to 1 Nib40 to 15 Byte80 to 255 Word160 to Variable Declaration: BASIC Stamp has four different types of variables, and each can store a different range of numbers as shown in the table below:

Using Variables in PBASIC Programming  Variable allocation lines generally should go at the beginning of your program.  The syntax for variable declaration is as follows: Name VAR VarType Example counter VAR Byte

Rules for choosing Variable names. PBASIC keywords or labels cannot be used as variable names. ( e.g DEBUG, DO, LOOP, PAUSE, HIGH, LOW – NOT TO BE USED ) can be up to 32 characters long. must start with a letter, and can contain a mixture of letters, numbers, and underscore (_) characters. PBASIC does not distinguish between upper and lower case. Select the smallest size of a VarType which can store the largest expected value of the variable. For example, if you need a VAR to hold the ON/OFF status (1/0) of switch, use a Bit. If you need a counter for a “FOR...NEXT” loop that counts from 1 to 100, use a Byte, and so on. The name cannot contain a space.

LAB ACTIVITY 2 PART 3 TO COUNT NO.OF TIMES Here we use FOR …. NEXT LOOP STEPS:  First introduce a variable named counter to control the number of times the LED blinks.  Modify the previous program, instead of DO – LOOP use FOR ….. NEXT LOOP command.

PBASIC PROGRAMMING

Digital Input - Pushbuttons Name some devices which use input pushbuttons. Calculators Microwave oven Mouse computer

NO (NORMALLY OPEN ) PUSHBUTTON AND SCHEMATIC SYMBOL In each device, there is a microcontroller scanning the pushbuttons and waiting for the circuit to change. When the circuit changes, the microcontroller detects the change and takes action.

Two of the pushbutton’s pins are connected to each terminal. This means that connecting a wire of part lead to pin 1 of the pushbutton is the same as connecting it to pin 4. The same rule applies with pins 2 and 3. The reason the pushbutton does not have just two pins is because it needs stability.

Pushbutton Operation The following Figures illustrate the operation of the PB. When the PB is not pressed, there is no connection between the 1,4 and 2,3 terminals(open circuit state). When the button is pressed, the gap between the 1,4 and 2,3 terminals is bridged by a conductive metal (closed circuit state). NOT PRESSED PRESSED

Lab Activity 3 Objective: To build and test a pushbutton circuit. Background: Initially, you will conduct a manual test for the pushbutton. The pushbutton circuit will be connected to the BASIC Stamp in the second test. BASIC Stamp program will monitor the status of the PB (ON/OFF) and display its value as 1 or 0.

Part #1: Manual Test Build the circuit shown in figure Verify that the LED in your test circuit is OFF. Press the pushbutton, and check the LED status. When the pushbutton is pressed, the LED must turn ON. Press and hold the pushbutton, and verify that the LED emits light while you are holding the pushbutton down

Part #2: Pushbutton Circuit with BASIC Stamp Schematic diagram Circuit connection

Refer to the above figure, When the PB is pressed, P3 will be connected to Vdd via 220Ω resistor. The BS2 will detect the state of P3 as High and set its value to 1. When the PB is not pressed, the I/O P3 is pulled down to Vss via 220Ω and 10kΩ resistors. The BS2 will detect the state of P3 as Low and set its value to 0. The command that could be used to read the status of I/O pin is IN. The command syntax is INpin, for example, the command IN3 will read the status of pin 3.

Procedure: Turn off the power to the BoE. Build the circuit shown in figure Switch ON the power to the BoE. Enter the following program code (ReadPushbuttonState.bs2): ‘What’s a Microcontroller-ReadPushbuttonState.bs2 ‘{$STAMP BS2} ‘{$PBASIC 2.5} DO DEBUG ? IN3 PAUSE 250 LOOP END

Run the program. Verify that the debug terminal displays the value 0 when the pushbutton is not pressed. Verify that the debug terminal displays the value 1 when the pushbutton is pressed and held.

Observations: When the PB is not pressed, the value displayed is When the PB is pressed and held, the value displayed is