70016 Parallax Inc, 70016 Datasheet

TEXT INFRARED REMOTE FOR BOE-BOT

70016

Manufacturer Part Number
70016
Description
TEXT INFRARED REMOTE FOR BOE-BOT
Manufacturer
Parallax Inc
Datasheet

Specifications of 70016

Accessory Type
Manual
Product
Microcontroller Accessories
Lead Free Status / RoHS Status
Contains lead / RoHS non-compliant
For Use With/related Products
Boe-Bot®
For Use With
29122 - KIT PARTS IR REMOTE FOR BOE-BOT
Lead Free Status / RoHS Status
Lead free / RoHS Compliant, Contains lead / RoHS non-compliant

Available stocks

Company
Part Number
Manufacturer
Quantity
Price
Part Number:
70016SE
Manufacturer:
ST
0
IR Remote for the Boe-Bot
By Andy Lindsay
VERSION 1.1

Related parts for 70016

70016 Summary of contents

Page 1

IR Remote for the Boe-Bot By Andy Lindsay VERSION 1.1 ...

Page 2

... HomeWork Board, Parallax, and the Parallax logo are trademarks of Parallax Inc. If you decide to use trademarks of Parallax Inc. on your web page or in printed material, you must state that "(trademark trademark of Parallax Inc.”, “upon the first appearance of the trademark name in each printed document or web page ...

Page 3

... Parallax products. Parallax Inc. is also not responsible for any personal damage, including that to life and health, resulting from use of any of our products. You take full responsibility for your BASIC Stamp application, no matter how life-threatening it may be ...

Page 4

...

Page 5

Preface.......................................................................................................................vii An Autonomous Robot and a Handheld Remote.......................................................... vii Audience ....................................................................................................................... vii Educator Resources .................................................................................................... viii The Stamps in Class Educational Series..................................................................... viii Foreign Translations ...................................................................................................... ix Special Contributors .......................................................................................................x Chapter 1: Infrared Remote Communication...........................................................1 Getting Started................................................................................................................1 Kit Contents ....................................................................................................................1 ...

Page 6

...

Page 7

Preface AN AUTONOMOUS ROBOT AND A HANDHELD REMOTE The handheld remote may be the tool of choice for channel surfing couch potatoes worldwide, but this device can also be used to send messages to your Boe-Bot The press of a ...

Page 8

... Microcontroller?”, Student Guide, Version 2.2, Parallax Inc., 2004 “Robotics with the Boe-Bot”, Student Guide, Version 2.2, Parallax Inc., 2004 You may continue on with other Educational Project topics, or you may wish to explore our other Robotics Kits. ...

Page 9

... To gain experience with robotics, consider continuing with the following Stamps in Class student guides, each of which has a corresponding robot kit: “IR Remote for the Boe-Bot”, Student Guide, Version 1.0, Parallax Inc., 2004 “Applied Robotics with the SumoBot”, Student Guide, Version 1.0, Parallax Inc., 2005 “ ...

Page 10

SPECIAL CONTRIBUTORS The Parallax team assembled to produce this text includes: application design and technical writing by Andy Lindsay, illustration by Rich Allred, cover design by Larissa Crittenden and Jen Jacobs, technical review by Kris Magri, and technical editing by ...

Page 11

Chapter 1: Infrared Remote Communication GETTING STARTED The IR Remote AppKit has two documents you can use to get started: This book – takes you from beginner to advanced in a step-by-step format. • IR Remote AppKit Documentation – a ...

Page 12

Infrared Remote Parts List:* (1) 020-00001 Universal Remote and Universal Remote Manual** (1) 350-00014 IR detector (1) 150-02210 Resistor – 220 Ω (1) 800-00016 Jumper wires – bag Batteries sold separately ** The remote and instruction sheet/booklet ...

Page 13

Figure 1-2 Parts from Boe-Bot Parts Kit Parts List: (2) Infrared detectors (2) IR LEDs – (clear case) (2) IR LED shield assemblies (2) Resistors – 220 Ω (2) Resistors – 1 kΩ (1) Piezospeaker (2) LEDs – red Chapter ...

Page 14

HOW THE REMOTE SENDS MESSAGES Figure 1-3 shows how the handheld remote can be used to send messages to a Boe-Bot. When a button on the remote is pressed, it flashes its IR LED on/off at 38.5 kHz to broadcast ...

Page 15

The IR receiver the Boe-Bot used for infrared object detection in Robotics with the Boe- Bot is the same detector found in many TVs and VCRs. This detector sends a low signal whenever it detects IR flashing on/off at 38.5 ...

Page 16

Figure 1-4: IR Message Timing Diagram Resting state Resting states between message between data pulses packets = 20- 0.6 ms Start Bit-0 Bit-2 Bit-1 Start pulse Binary-0 duration = 2.4 ms data pulse durations = ...

Page 17

Infrared Remote Parts (1) Universal remote (1) Instruction sheet/booklet for the universal remote Compatible batteries How to Configure the Universal Remote to Send SONY TV Protocol Signals These instructions are for the remote included in the IR Remote AppKit. √ ...

Page 18

Your Turn – Testing the Remote on Other Devices √ If you'd like to test it out on your brand of TV/VCR, etc., try following the instructions in the remote manual to see if you can get it to work. ...

Page 19

The IR Detection Circuit It only takes one IR detector to capture messages from the IR remote (see Figure 1-6). √ Build this circuit on your Boe-Bot's prototyping area. The numbers ( the IR detector are also ...

Page 20

High pulse vs. low pulse: If the voltage a BASIC Stamp I/O pin senses starts low, then goes high for a while before returning to low, that's a high pulse. The term positive pulse is also commonly used. The high ...

Page 21

CountStartPulses.bs2 counts the number of low pulses that it receives with durations that fall in the 1.95 to 2.85 ms range. Figure 1-8 shows what your Debug Terminal should display after you have pressed a numeric key for a couple ...

Page 22

Do not press CBL, VCR, or TV/VCR. Your remote may or may not have these buttons does and you press one of those keys, it tells the remote to send messages to a different device, either a VCR ...

Page 23

VAR counter VAR DEBUG "START PULSES", CR, "Repetitions Current Duration", CR, " (microseconds) "----------- ----------------" Inside the , the program executes the command DO…LOOP measures pulses. Whenever a pulse duration is between 975 (1.95 ms) and 1425 (2.85 ms), ...

Page 24

Change DEBUG "START PULSES", CR, to DEBUG "BINARY-1 PULSES", CR, √ Change IF (time > 975) AND (time < 1425) THEN to IF (time > 450) AND (time < 750) THEN √ Save your modified program. √ Run the ...

Page 25

Measuring the Resting State between Messages When you press and hold a given key on the remote, the remote sends the code for that key, then waits a while and sends it again. CountStartPulses.bs2 also can be modified to search ...

Page 26

IR Remote for the Boe-Bot - CountRestingStates.bs2 ' Capture and count the number of 20 ms+ (high) resting states. '{$STAMP BS2} '{$PBASIC 2.5} time VAR Word counter VAR Word DEBUG "RESTING STATE", CR, "Repetitions Current Duration", CR, " (microseconds) ...

Page 27

Your Turn – Measuring the Time between Data Pulses You can modify the condition for the the very brief high resting states between data pulses. √ Save CountRestingStates.bs2 as CountRestingStatesYourTurn.bs2. √ Change the condition for the IF (time > 1000) ...

Page 28

Your Turn – Counting the Number of Messages Per Second By pressing and holding a key on the remote for ten seconds, you can determine how many messages per second the IR remote sends. √ Run CountStartPulses.bs2 again; it was ...

Page 29

Compare this IR message time to the one you calculated by adding up all the IR message's components. ACTIVITY #3: CAPTURING THE IR MESSAGES In this activity, you will write programs to measure and ...

Page 30

Five variables named characters, each of which can store a different byte value. Example Program: ArrayExample.bs2 This example program uses the Debug Terminal for setting array elements and then displaying their contents. Figure 1-12 shows an example of what the ...

Page 31

Enter and run ArrayExample.bs2. √ Click the Debug Terminal's Transmit Windowpane. √ Type five letters. √ When the Debug Terminal displays "You typed: …", verify that the BASIC Stamp has sent back the same characters you entered ...

Page 32

A second loop reads and displays the values of each FOR…NEXT element. FOR index = DEBUG characters(index) NEXT The first time through the FOR…NEXT displayed. The second time through, on. Your Turn – Storing Values Instead of ...

Page 33

Keep executing the • PULSIN detected. Use twelve more • PULSIN an array of word variables. Optional – use a • FOR…NEXT Figure 1-13 shows the array variable declaration creates twelve different word variables, each of which can store its ...

Page 34

The next example program will not use a loop to set each of the values. Because the time between the pulses sent by the remote is very small, the extra code overhead involved in a FOR…NEXT each array element value ...

Page 35

Enter and run RecordAndDisplayPwm.bs2. √ Resize the Debug Terminal so that it's as tall as your monitor, because otherwise the data might not all fit. √ Try pressing and holding the following keys and verify that each binary pattern ...

Page 36

MEASUREMENTS", CR, "Element Duration, 2-us", CR, "------- --------------" PULSIN 9, 1, time(0) LOOP UNTIL time(0) > 1000 PULSIN 9, 0, time(0) PULSIN 9, 0, time(1) PULSIN 9, 0, time(2) PULSIN 9, 0, time(3) PULSIN 9, 0, time(4) ...

Page 37

The code block in the this DO…LOOP larger than 2 ms, which means it must be the resting state between IR messages. DO PULSIN 9, 1, time(0) LOOP UNTIL time(0) > 1000 When the command finishes measuring the resting pulse ...

Page 38

The last command sends the program back to the first LOOP block within this outer repeats over and over again, processing the messages as DO…LOOP the remote sends them. Your Turn – Recording Pulse Patterns for Each Key The next ...

Page 39

Table 1-1: Time Measurements for Each Key Array Remote Key Element time(0) time(1) time(2) time(3) time(4) time(5) time(6) Array Remote Key Element VOL- VOL+ time(0) time(1) time(2) time(3) time(4) time(5) time(6) ACTIVITY #4: BASIC IR REMOTE BOE-BOT ...

Page 40

Build/rebuild and test the Boe-Bot servo, IR detector, and piezospeaker circuits shown in Figure 1-15 as needed. Vin White P13 Red Black Vss Vin White P12 Red Black Vss P4 Vss Back to IF…THEN Statements for Navigation The next ...

Page 41

Add FREQOUT 4, 2000, 3000 √ Remove all the commands. DEBUG √ Remove all the commands except the ones that store time measurements PULSIN into and time(0) time(1) √ Remove the loop that displays the pulse durations. FOR…NEXT √ ...

Page 42

These programs are written for Boe-Bots with Parallax Continuous Rotation servos. If your Boe-Bot is labeled with the letters "PM" highlighted in blue, you will need to use different PULSOUT Duration servos, use 500 in place of 650 and 1000 ...

Page 43

ELSEIF (time(1) < 500) AND (time(0) > 500) THEN PULSOUT 13, 650 PULSOUT 12, 850 ELSEIF (time(1) > 500) AND (time(0) < 500) THEN PULSOUT 13, 850 PULSOUT 12, 850 ELSEIF (time(1) > 500) AND (time(0) > 500) THEN PULSOUT ...

Page 44

One Timing Change and Lots More IF…THEN There are two changes you will have to make to 2BitRemoteBoeBot.bs2 to get it to accommodate this specification. You may have already guessed the first change; the program will have to make its ...

Page 45

IF (time(2) < 500) AND (time(1) < 500) AND (time(0) < 500) THEN PULSOUT 13, 750 PULSOUT 12, 650 ELSEIF (time(2) < 500) AND (time(1) < 500) AND (time(0) > 500) THEN PULSOUT 13, 850 PULSOUT 12, 650 ELSEIF (time(2) ...

Page 46

ENDIF ENDIF The next change that has to be made is much more subtle, and the reason for the change isn't necessarily all that obvious either. First, here is the change that has to be made: √ Change the command ...

Page 47

If the command does not detect the rising edge of the resting state, the loop that PULSIN searches for a high pulse will keep testing for pulses and waiting for one that's longer than 1000. Eventually, maybe ...

Page 48

Explain the problem with the 9 key using Table 1 reference Remote for the Boe-Bot - 3BitRemoteBoeBot.bs2 ' Control your Boe-Bot with keys 1 remote set to control a SONY TV. '{$STAMP BS2} ...

Page 49

ENDIF LOOP Your Turn – Fixing the 9 Key If you refer back to Table 1-1 on page 29, you'll notice that the 9 key has than 500 while the rest of the time Bot pivoted forward and to the ...

Page 50

SUMMARY This chapter demonstrated how the BASIC Stamp can detect and store messages sent by universal handheld remote controls. The particular signal used to control SONY TV sets was introduced and explained, then measured in detail using an infrared detector ...

Page 51

Projects 1. Write a program that adds up all the IR pulses and displays the duration message in microseconds. Record and add up all the data pulses first. Then filter for, capture, and add: the resting state ...

Page 52

Solutions Q1. PWM stands for pulse width modulation, and it can be used for digital to analog conversion, motor control, and communication. Q2. A high signal. Q3. On page 6, it states: "the term 'programming' means a sequence of key-presses ...

Page 53

VAR Nib DO DO PULSIN 9, 1, time(0) LOOP UNTIL time(0) > 1000 PULSIN 9, 0, time(0) PULSIN 9, 0, time(1) PULSIN 9, 0, time(2) PULSIN 9, 0, time(3) PULSIN 9, 0, time(4) PULSIN 9, 0, time(5) PULSIN 9, ...

Page 54

DEBUG "time(0) = ", DEC time( " us", CR LOOP P2. Start with 4BitRemoteBoeBot.bs2. √ Add this variable declaration: counter VAR Byte √ Delete these two PULSOUT PULSOUT 13, 750 PULSOUT 12, 750 √ Replace them with this ...

Page 55

Chapter 2: Create and Use Remote Applications REUSABLE PROGRAMS In this chapter, you will develop and test two different multi-purpose IR remote application programs. You will test them on their own, and also with new Boe-Bot applications. They will make ...

Page 56

Counting in Binary vs. Counting in Decimal Here is how to count to 20 with binary numbers: Binary 100 101 110 111 1000 1001 1010 1011 Decimal Binary 1100 1101 1110 1111 10000 ...

Page 57

First, enter the binary number into the upper row of boxes. Make sure to put the rightmost bit into the rightmost box, then continue to the left as you copy numbers. • Second, multiply each bit by its power ...

Page 58

Example Program – BinaryToDecimal.bs2 Although you can write a PBASIC program that follows each of the steps just discussed, the and modifiers make the job easy. BIN DEC √ Enter and run BinaryToDecimal.bs2. √ Click the Debug Terminal's Transmit Windowpane. ...

Page 59

That means that each pulse has to be translated and then the corresponding bit position in a variable has to be set or cleared. The variable modifier can be used to set and clear bits ...

Page 60

Example Program – SetAndClearWithDotBit.bs2 Figure 2-4 shows an example of what you can do with SetAndClearWithDotBit.bs2. By typing a digit into the Transmit Windowpane when prompted for the "bit index" you can select the bit in the variable that you ...

Page 61

DO DEBUG CLS, BIN8 value, " <- Binary value", CR, "76543210 <- Bit index", CR, CR, "Type bit index (0 to 7): " DEBUGIN DEC1 index DEBUG CR, "Type 1 to set clear: " DEBUGIN BIN1 setClear ...

Page 62

A command clears the Receive Windowpane, displays the 8-bit binary DEBUG CLS representation of the variable, then displays the index values for each bit, followed value by the first prompt for the user (you) to enter a digit. DEBUG CLS, ...

Page 63

Modify the command so that it looks like this: DEBUG DEBUG CLS, BIN8 value, " <- Binary value", CR, "76543210 <- Bit index", CR, "Decimal value: ", DEC3 value, CR, CR, "Type bit index (0 to 7): ", CR ...

Page 64

Figure 2-5 shows a timing diagram of the signal the IR receiver sends to the BASIC Stamp I/O pin as it indicates when it does and does not detect 38 kHz infrared transmitted by IR remote. Figure 2-5: Command Execution ...

Page 65

The first repeats an DO...LOOP RCTIME ms high time between messages. remains of the start pulse. An IF...THEN sure the measurement is within a range that confirms a start pulse. If it's not in RCTIME that range, the statement sends ...

Page 66

IR Remote for the Boe-Bot - PulsesToByteValue.bs2 ' Display the binary and decimal values of the lower seven bits message. '{$STAMP BS2} '{$PBASIC 2.5} time VAR Word remoteCode VAR Byte DEBUG "Binary Value Decimal Value", CR, ...

Page 67

Advanced Topic – How PulsesToByteValue.bs2 Works A label named is added at the very beginning of the main Get_Pulses next example program. The routine in the main decodes the data bit pulses from the IR remote. command coupled with an ...

Page 68

The command has a RCTIME 9, 1, time time from when it is executed until the signal on P9 transitions from high to low. In contrast, has a RCTIME 9, 0, time when it is executed until it detects a ...

Page 69

RCTIME 9, 0, time IF time > 300 THEN remoteCode.BIT1 = 1 RCTIME 9, 0, time IF time > 300 THEN remoteCode.BIT2 = 1 RCTIME 9, 0, time IF time > 300 THEN remoteCode.BIT3 = 1 RCTIME 9, 0, time ...

Page 70

Table 2-1: Remote Key Codes Key POWER ACTIVITY #2: DESIGNING A REUSABLE REMOTE PROGRAM Up to this point, you have completed a program that performs IR remote message capture and decoding for SONY TV signals. Before doing more Boe-Bot applications, ...

Page 71

Example Program: IrRemoteButtons.bs2 √ Enter, save, and run IrRemoteButtons.bs2. √ Make sure to save this program under the name IrRemoteButtons.bs2. √ Press and release each digit key on the remote and verify that the correct digit is displayed. √ Try ...

Page 72

LOOP ' -----[ Subroutine - Get_Ir_Remote_Code ]--------------------------------- ' SONY TV IR remote subroutine loads the remote code into the ' remoteCode variable. Get_Ir_Remote_Code: remoteCode = 0 ' Wait for resting state between messages to end. DO RCTIME IrDet, 1, irPulse ...

Page 73

You will be saving many copies of this file, and then modifying these copies to perform a variety of Boe-Bot functions. Let’s modify a copy of IrRemoteButtons.bs2 to print out descriptions of keys that aren’t numeric. To test the remote, ...

Page 74

Run TestIrRemoteButtons.bs2 and test the remote's keypad keys as well as the other buttons listed in the constant declarations section. √ Try the MUTE , and LAST/PREV CH keys, what happened? The Your Turn portion of this activity will ...

Page 75

These are the variables you will need for your subroutines. The PulsesToByteValue.bs2 was renamed to ' -----[ Variables ]--------------------------------------------------- ' SONY TV IR remote variables irPulse VAR remoteCode VAR Many published PBASIC application examples you will encounter just have a ...

Page 76

Subroutine - Get_Ir_Remote_Code ]--------------------------------- ' SONY TV IR remote subroutine loads the remote code into the ' remoteCode variable. Get_Ir_Remote_Code: remoteCode = 0 ' Wait for resting state between messages to end. DO RCTIME IrDet, 1, irPulse LOOP ...

Page 77

Save the program as TestIrRemoteButtonsYourTurn.bs2. √ Modify the Constants section so that these values are accounted for. √ Modify the SELECT…CASE key is pressed and "LAST" or "PREV CH" when the LAST (or sometimes PREV CH) key is pressed. ...

Page 78

A Simple Boe-Bot Main Routine In the previous activity, you replaced the main routine in IrRemoteButtons.bs2 with a code block that contained a SELECT…CASE works is that you use it to SELECT…CASE evaluate basis. CASE CASE ...

Page 79

DO ' Call subroutine that loads the IR message value into the ' remoteCode variable. GOSUB Get_Ir_Remote_Code ' Send PULSOUT durations for the various maneuvers based on ' the value of the remoteCode variable. SELECT remoteCode CASE 2, ChUp PULSOUT ...

Page 80

Title ]----------------------------------------------------------- ' IR Remote for the Boe-Bot - 7BitRemoteBoeBot.bs2 ' With an IR remote configured to control a SONY TV, point the remote at ' the Boe-Bot and press and hold the 1-9 keys for different maneuvers. ...

Page 81

SELECT remoteCode CASE 2, ChUp PULSOUT 13, 850 PULSOUT 12, 650 CASE 4, VolDn PULSOUT 13, 650 PULSOUT 12, 650 CASE 6, VolUp PULSOUT 13, 850 PULSOUT 12, 850 CASE 8, ChDn PULSOUT ...

Page 82

RCTIME 9, 0, irPulse IF irPulse > 1125 OR irPulse < 675 THEN GOTO Get_Ir_Remote_Code ' Get data bit pulses. RCTIME IrDet, 0, irPulse IF irPulse > 300 THEN remoteCode.BIT0 = 1 RCTIME IrDet, 0, irPulse IF irPulse > 300 ...

Page 83

Notice that the statements are using constants such as CASE IrRemoteButtons.bs2 template's constant declarations section: ' -----[ Constants ]--------------------------------------------------- ' SONY TV IR remote constants for non-keypad buttons. Enter CON ChUp CON ChDn CON VolUp CON VolDn CON Power CON ...

Page 84

The Speaker Circuit Whether it's a keypad on an alarm system, microwave oven Boe-Bot, a speaker really helps let you know that the device understood when you pressed that digit key. The speaker shown in Figure 2-6 was ...

Page 85

Example Program: EnterLargeValues.bs2 This example program behaves similarly to a microwave oven with a digital keypad. You can build larger numbers, such as 635 by pressing and releasing the and 5 keys followed by the ENTER ...

Page 86

Replace the in the main routine with this one: DO…LOOP DO DEBUG "Type a value (up to 65535)", CR, "Then press ENTER", CR, CR value = 0 remoteCode = 0 DEBUG "Digits entered: " DO value = value * ...

Page 87

SONY TV IR remote variables irPulse VAR remoteCode VAR ' Main Routine variables value VAR The first thing the code in the main routine does is clear the variables. Then, a command displays the "Digits entered: " message. DEBUG ...

Page 88

Your Turn – Processing Only Digits and Enter If you were to design a product with a BASIC Stamp and a universal remote, you might get some complaints from customers if you use EnterLargeValues.bs2 without some extra work. The program ...

Page 89

Add these two subroutines to the end of your program: ' -----[ Subroutine - Beep_Valid ]------------------------------------ ' Call this subroutine to acknowledge a key press. Beep_Valid: FREQOUT Speaker, 100, 3500 PAUSE 200 RETURN ' -----[ Subroutine - Beep_Error ]------------------------------------ ...

Page 90

Use Edit → Copy and Edit → Paste to move everything shown below from EnterLargeValuesYourTurn.bs2 into your new subroutine in IrRemoteKeypad.bs2. value = 0 remoteCode = 0 DO value = value * 10 + remoteCode DO GOSUB Get_Ir_Remote_Code IF ...

Page 91

Save the program after you have fully tested it. ' -----[ Title ]----------------------------------------------------------- ' IR Remote for the Boe-Bot - IrRemoteKeypad.bs2 ' Capture and store button codes sent by a universal remote configured to ' control a SONY TV. ...

Page 92

SONY TV IR remote subroutine loads the remote code into the ' remoteCode variable. Get_Ir_Remote_Code: remoteCode = 0 ' Wait for resting state between messages to end. DO RCTIME IrDet, 1, irPulse LOOP UNTIL irPulse > 1000 ' Measure ...

Page 93

DO value = value * 10 + remoteCode DO GOSUB Get_Ir_Remote_Code IF (remoteCode < 10) THEN DEBUG "You pressed: ", DEC1 remoteCode, CR GOSUB Beep_Valid EXIT ELSEIF (remoteCode = Enter) THEN DEBUG "You pressed: ...

Page 94

Your Turn – Making Application Backup Copies You will use and re-use the application programs you have developed in Activity #2 through Activity #4. √ Create a separate folder for your application programs. √ Make backup copies of IrRemoteButtons.bs2, 7BitRemoteBoeBot.bs2, ...

Page 95

Add the initialization routine for the Boe-Bot's start/reset indicator along with some operation instructions for the Debug Terminal. This section should be placed just before the Main Routine section. ' -----[ Initialization ]--------------------------------------------- DEBUG "Program Starting...", CR, CR FREQOUT ...

Page 96

PULSOUT ServoRight, 850 CASE VolUp PULSOUT ServoLeft, 850 PULSOUT ServoRight, 850 CASE VolDn PULSOUT ServoLeft, 650 PULSOUT ServoRight, 650 ENDSELECT PAUSE 20 NEXT LOOP A complete program listing is included after these checklist instructions. √ Save then run your modified ...

Page 97

BS2} ' {$PBASIC 2.5} ' -----[ I/O Definitions ]------------------------------------------------- ' SONY TV IR remote declaration - input receives from IR detector IrDet PIN 9 Speaker PIN 4 ' Boe-Bot Servo Pins ServoLeft PIN 13 ServoRight PIN 12 ' ...

Page 98

DO DEBUG "Select direction (CH/VOL):" GOSUB Get_Ir_Remote_Code IF (remoteCode < ChUp) OR (remoteCode > VolDn) THEN DEBUG "Select direction (CH/VOL):", CR GOSUB Beep_Error ENDIF LOOP UNTIL (remoteCode >= ChUp) AND (remoteCode <= VolDn) direction = remoteCode GOSUB Beep_Valid ...

Page 99

SONY TV IR remote subroutine loads the remote code into the ' remoteCode variable. Get_Ir_Remote_Code: remoteCode = 0 ' Wait for resting state between messages to end. DO RCTIME IrDet, 1, irPulse LOOP UNTIL irPulse > 1000 ' Measure ...

Page 100

DO value = value * 10 + remoteCode DO GOSUB Get_Ir_Remote_Code IF (remoteCode < 10) THEN DEBUG "You pressed: ", DEC1 remoteCode, CR GOSUB Beep_Valid EXIT ELSEIF (remoteCode = Enter) THEN DEBUG "You pressed: ...

Page 101

How KeypadDirectionDistance.bs2 Works Two variables have to be added to IrRemoteKeypad.bs2, one for storing the Boe-Bot's direction, and the other for counting the number of pulses Boe-Bot navigation variables direction VAR counter VAR The first command inside ...

Page 102

GOSUB Beep_Valid Another command prompts you to enter the number of pulses (using the remote's DEBUG numeric keypad). DEBUG "Enter number of pulses: ", CR The subroutine call is the part where you use the numeric Get_Multi_Digit_Value keypad to enter ...

Page 103

PULSOUT ServoRight, 650 ENDSELECT PAUSE 20 NEXT Your Turn – Repeating The "LAST" Action For TV control, the LAST button (sometimes labeled PREV CH ) switches you back to the channel you viewed just before the channel you are currently ...

Page 104

Add this Servo_Pulses: DEBUG "The value is: ", DEC value, CR Servo_Pulses: DEBUG "Running...", CR, CR Spaghetti Code Alert! Using the command to jump to a label elsewhere in a program is frowned upon by GOTO many instructors, computer ...

Page 105

FOR counter = 1 TO value SELECT direction CASE ChUp PULSOUT ServoLeft, 850 PULSOUT ServoRight, 650 CASE ChDn PULSOUT ServoLeft, 650 PULSOUT ServoRight, 850 CASE VolUp PULSOUT ServoLeft, 850 PULSOUT ServoRight, 850 CASE VolDn PULSOUT ServoLeft, 650 PULSOUT ServoRight, 650 ...

Page 106

SUMMARY Decoding is the process of converting an electronic signal into something understandable and useable. In the case of the IR remote message, decoding involved converting pulse duration measurements into binary 1s and byte variable. Each time ...

Page 107

Why would you use a speaker with a pushbutton or keypad? Exercises 1. Count from binary. 2. What must binary? 3. Calculate the multiplier you would use for bit- binary ...

Page 108

Solutions Q1. "To recognize and interpret an electronic signal." Q2. A bit. Q3. By raising 2 to the power of the bit position. Q4. A bit is set when it is "set" to one. A bit is cleared if it ...

Page 109

Add this declaration to the Constants section: MuteCode CON 20 √ Add a bit variable to the Variables section. Name it ' Boe-Bot control bit mute VAR Bit √ Add this command to the Initialization that sets ' -----[ ...

Page 110

...

Page 111

Chapter 3: More IR Remote Applications EXPANDING APPLICATION PROGRAMS The whole point of reusable code is that it allows you to more easily build on previous work to make better and more powerful applications. The previous work might be code ...

Page 112

One of the most common mistakes in robotics projects is trying to make all the parts work together in one fell swoop. The end result is usually a programming bug that's too difficult to find. It's best to make sure ...

Page 113

Vdd P9 220 Ω Vss Ω IR LED Vss Left IR Pair P10 Ω 220 Red LED Vss LED Indicator for Left IR Pair Ω IR LED Vss Vdd P0 Ω 220 Vss Right ...

Page 114

To Servos Vdd Longer Red (anode) Black leads X4 X5 Vdd Vin Vss X3 P15 P14 P13 P12 P11 P10 Board of Education Rev ...

Page 115

Sensor inputs • Messages from the Debug Terminal • Messages from an IR remote • In the next example program, a variable named servos can be set with a DEBUGIN you can make the Boe-Bot roam at anywhere between 0 ...

Page 116

Example Program: IrRoamingWithSpeedControl.bs2 This example program is a modified version of FastIrRoaming.bs2 from Robotics with the Boe-Bot, Chapter 7, Activity #5. The comments in the program listing will show ...

Page 117

DEBUG "Main routine running..." DO FREQOUT 8, 1, 38500 irDetectLeft = IN9 FREQOUT 2, 1, 38500 irDetectRight = IN0 IF (irDetectLeft = 0) AND (irDetectRight = 0) THEN pulseLeft = 750 - speed pulseRight = 750 + speed ELSEIF (irDetectLeft ...

Page 118

The percent value you enter determines the percent of the full speed pulse width. This is not the same as the actual speed. For help predicting the actual speed, consult the transfer curves introduced in Robotics with the Boe-Bot, Chapter ...

Page 119

Check the RAM Map to see how much RAM you are using. The color coding should show that REG 0 and 1 are word storage variables. It should also show that REG 2 has a byte and two bit ...

Page 120

Here's how it will work: By pressing the any button, you will interrupt the Boe-Bot's roaming. • Then, you will use the numeric keypad to type in the new percent-speed. • To make the Boe-Bot resume roaming at the new ...

Page 121

Add an Initialization section with this startup code for the Boe-Bot just before the main routine section. ' -----[ Initialization ]---------------------------------------------- ' Boe-Bot initialization. DEBUG "Starting...", CR, CR FREQOUT 4, 2000, 3000 speed = 0 √ Replace the in ...

Page 122

IF (irDetectLeft = 0) AND (irDetectRight = 0) THEN PULSOUT 13, 750 - speed PULSOUT 12, 750 + speed ELSEIF (irDetectLeft = 0) THEN PULSOUT 13, 750 + speed PULSOUT 12, 750 + speed ELSEIF (irDetectRight = 0) THEN PULSOUT ...

Page 123

The first time the program is run, the value of zero. The statement detects this and the code block within prompts you to enter IF…THEN a speed. The statement also detects when the remote is sending a ...

Page 124

Replace this statement: IF…THEN IF (IN9 = 0) OR (speed = 0) THEN FREQOUT Speaker, 100, 3500 PAUSE 100 • • • GOSUB Get_Multi_Digit_Value speed = value • • • PAUSE 250 ENDIF with this one: IF (IN9 = ...

Page 125

ACTIVITY #2: MULTI-FUNCTION BOE-BOT WITH REMOTE SELECT With the press of a remote button, you can select between three different Boe-Bot functions: Remote controlled Boe-Bot • Autonomous roaming Boe-Bot • Following Boe-Bot • Selecting Among Main Routines The next example ...

Page 126

DO SELECT operation ' If operation = 1, execute a modified version of ' 7BitRemoteBoeBot.bs2 that also allows ' you to change the operation variable with the POWER key. CASE 1 ' Modified main routine from 7BitRemoteBoeBot.bs2 ' goes here. ...

Page 127

Boe-Bot. FastIrRoaming.bs2 was featured in Chapter 7, Activity #5, and FollowingBoeBot.bs2 was featured in Chapter 8, Activity #2. √ Load, run, and test 7BitRemoteBoeBot.bs2. √ Load, run, and test FastIrRoaming.bs2. √ Load, run, and test FollowingBoeBot.bs2. When you ...

Page 128

Add these constant declarations to the Constants section of the program: ' Boe-Bot proportional control constants (from FollowingBoeBot.bs2). Kpl CON -35 Kpr CON 35 SetPoint CON 2 CenterPulse CON 750 √ Copy these variable declarations from FollowingBoeBot.bs2, and paste ...

Page 129

Subroutine - Send_Pulse ]------------------------------------- Send_Pulse: PULSOUT 13,pulseLeft PULSOUT 12,pulseRight PAUSE 5 RETURN √ Replace the initialization routine with the one shown here: ' -----[ Initialiazation ]-------------------------------------------- DEBUG "Press POWER to select", CR, "mode of operation:", CR, CR, "1 ...

Page 130

SELECT remoteCode CASE Power FREQOUT Speaker, 100, 3500 PAUSE 100 FREQOUT Speaker, 100, 3500 PAUSE 200 DEBUG "Select operation mode...", CR GOSUB Get_Ir_Remote_Code operation = remoteCode DEBUG ? operation, CR, "Running...", CR FREQOUT Speaker, 100, 3500 PAUSE 100 FREQOUT Speaker, ...

Page 131

IF IN9 = 0 THEN operation = 1 FREQOUT 8, 1, 38500 irDetectLeft = IN9 FREQOUT 2, 1, 38500 irDetectRight = IN0 IF (irDetectLeft = 0) AND (irDetectRight = 0) THEN pulseLeft = 650 pulseRight = 850 ELSEIF (irDetectLeft = ...

Page 132

The Boe-Bot should beep twice, then start autonomously roaming and avoiding objects. √ Press/release the POWER button. The Boe-Bot should beep twice. √ Press/release the 3 key. √ The Boe-Bot should now roam in object following mode. Test to ...

Page 133

Kpl CON -35 Kpr CON 35 SetPoint CON 2 CenterPulse CON 750 ' -----[ Variables ]------------------------------------------------------- ' SONY TV IR remote variables irPulse VAR Word remoteCode VAR Byte ' Boe-Bot navigation variables (from FollowingBoeBot.bs2). freqSelect VAR Nib irFrequency VAR Word ...

Page 134

Modified main routine from 7BitRemoteBoeBot.bs2 ' goes here. GOSUB Get_Ir_Remote_Code ' Check for POWER button. If yes, get remote code; otherwise, ' send PULSOUT durations for the various maneuvers based on ' the value of the remoteCode variable. SELECT ...

Page 135

PULSOUT 12, 750 ENDSELECT ' If operation = 2, execute modified FastIrRoaming.bs2. CASE 2 ' Modified main routine from FastIrRoaming.bs2 goes here. IF IN9 = 0 THEN operation = 1 FREQOUT 8, 1, 38500 irDetectLeft = IN9 FREQOUT 2, 1, ...

Page 136

SONY TV IR remote subroutine loads the remote code into the ' remoteCode variable. Get_Ir_Remote_Code: remoteCode = 0 ' Wait for resting state between messages to end. DO RCTIME IrDet, 1, irPulse LOOP UNTIL irPulse > 1000 ' Measure ...

Page 137

FREQOUT 8,1,irFrequency irDetectLeft = IN9 distanceLeft = distanceLeft + irDetectLeft FREQOUT 2,1,irFrequency irDetectRight = IN0 distanceRight = distanceRight + irDetectRight NEXT RETURN ' -----[ Subroutine - Send_pulse ]----------------------------------------- Send_Pulse: PULSOUT 13,pulseLeft PULSOUT 12,pulseRight PAUSE 5 RETURN How IrMultiBot.bs2 Works As ...

Page 138

When the program starts, the value of would be a problem because none of the a command setting to 1 was added to the Initialization section. operation ' -----[ Initialization ]--------------------------------------------- • • • operation = 1 The main routine ...

Page 139

This statement contains commands that make it possible for you to select CASE a different routine. Your Turn – Fixing Bugs and Adding Comments This program gets lost if you press the POWER key, then a number key other ...

Page 140

ACTIVITY #3: REMOTE PROGRAMMED BOE-BOT You can write a PBASIC program for your Boe-Bot that will allow you to program it with motion patterns using your remote. By pressing a sequence of buttons on the remote, you can load a ...

Page 141

This is another design that should be broken into a step-by-step process. The majority of the development work will be done with the Debug Terminal. After the program's functionality has been proven with the Debug Terminal, adapting it to the ...

Page 142

Figure 3-4 shows examples of the two DebugPlayback.bs2, and how they relate to the command syntax. Most of this syntax was introduced in Robotics with the Boe-Bot v2.0 in Chapter 4, Activity #6. One element that may be new to ...

Page 143

Here is the syntax for the command: READ READ Location, {Word} Variable {, {Word} Variable, ...} is the EEPROM address that stores the value you want to retrieve, and Location is the name of the variable that receives the value ...

Page 144

The second time through, eeIndex will be 1 while Maneuver_List is still 15. The READ command fetches the "L" stored at address 16 and stores it in the direction variable. The third time through the loop, eeIndex ...

Page 145

PAUSE 200 eeIndex = eeIndex + 1 LOOP END Your Turn – Step 2 – Exit the Routine without Displaying The can be modified so that it skips displaying the "Q" and the 0 at the end ...

Page 146

While the command retrieves a READ command stores a WRITE DataItem syntax from the PBASIC Syntax guide: WRITE Location, {Word} DataItem {, {Word} DataItem ...} Here is the that stores instructions with DO…LOOP DebugPlaybackYourTurn.bs2, you can build your own list ...

Page 147

Since directives won't be needed, why do the DATA and and Maneuver_List Distance_List because the directives are still at the beginning of the program to hold those DATA locations for memory space. The only difference is that no EEPROM during ...

Page 148

Title ]----------------------------------------------------------- ' IR Remote for the Boe-Bot - DebugRecordPlayback.bs2 ' Use Debug Terminal to Store a list of values to EEPROM, then retrieve ' and display them. ' {$STAMP BS2} ' {$PBASIC 2.5} ' -----[ EEPROM Data ...

Page 149

READ Distance_List + eeIndex, distance IF direction = "Q" THEN EXIT DEBUG direction, " ", DEC distance, CR PAUSE 200 eeIndex = eeIndex + 1 LOOP END Your Turn – Step 4 – Wait until the Right Character is Entered ...

Page 150

DO DEBUG CR, " Q", CR, "Enter Direction: " DEBUGIN direction SELECT direction CASE "F", "B", "R", "L", "Q" EXIT CASE ELSE DEBUG CR, "Invalid character", CR ENDSELECT LOOP √ Re-run the program ...

Page 151

You will need to declare another byte variable named routine. Aside from that, the next example program is how your code should look after the modifications. Example Program – DebugRecordPlaybackWithMenu.bs2 √ Save DebugRecordPlaybackFiltered.bs2 as DebugRecordPlaybackWithMenu.bs2. √ Modify it so that ...

Page 152

Routine - Record Instructions eeIndex = 0 direction = 0 DO UNTIL (eeIndex = 19) DO DEBUG CR, " Q", CR, "Enter Direction: " DEBUGIN direction SELECT direction CASE "F", "B", "R", "L", "Q" EXIT CASE ...

Page 153

PAUSE 200 eeIndex = eeIndex + 1 LOOP ELSE DEBUG "Invalid character", CR, "try again." ENDIF DEBUG CR, "Press any key..." DEBUGIN operation LOOP Your Turn – Step 6 – Adapting maneuvers to the Boe-Bot You can replace the PAUSE ...

Page 154

Run the program and verify that you can program and reprogram the Boe-Bot's motion sequences with the Debug Terminal. √ Save your modified program. Step 7 – Adapting the Program to the Infrared Remote At this point, you are ...

Page 155

EEPROM Data ]------------------------------------------------ ' Set aside data for lists of Maneuver_List and Distance_List. Maneuver_List DATA @ 15 Distance_List DATA @ 35 √ Copy these declarations into the Pin Definitions section: ' Boe-Bot Servo Pins ServoLeft PIN 13 ServoRight ...

Page 156

DO GOSUB Get_Ir_Remote_Code SELECT remoteCode CASE ChUp TO VolDn, Enter GOSUB Beep_Valid EXIT CASE ELSE DEBUG "Press CH+/-, VOL+/-, or ENTER", CR GOSUB Beep_Error ENDSELECT LOOP direction = remoteCode WRITE eeIndex + Maneuver_List, direction IF (direction = Enter) THEN EXIT ...

Page 157

CASE ChDn PULSOUT ServoLeft, 650 PULSOUT ServoRight, 850 CASE VolUp PULSOUT ServoLeft, 850 PULSOUT ServoRight, 850 CASE VolDn PULSOUT ServoLeft, 650 PULSOUT ServoRight, 650 ENDSELECT PAUSE 20 NEXT eeIndex = eeIndex + 1 LOOP ELSE GOSUB Beep_Error ENDIF LOOP Example ...

Page 158

Boe-Bot's EEPROM and replay them. ' Press POWER key to program or ENTER key to play program programming mode, press a CH/VOL key to choose a maneuver. ' Use the keypad to enter the number of pulses, ...

Page 159

Boe-Bot navigation variables direction VAR Byte counter VAR Word eeIndex VAR Byte ' -----[ Main Routine ]---------------------------------------------------- DO DEBUG "Press POWER to record", CR, "or ENTER to playback", CR, CR GOSUB Get_Ir_Remote_Code IF remoteCode = Power THEN ' Routine ...

Page 160

DEBUG "Enter number of pulses: ", CR GOSUB Get_Multi_Digit_Value DEBUG DEC value, " pulses", CR, CR WRITE eeIndex + Distance_List, value eeIndex = eeIndex + 1 LOOP ELSEIF remoteCode = Enter THEN ' Routine - playback data GOSUB Beep_Valid DEBUG ...

Page 161

ENDIF LOOP ' -----[ Subroutine - Get_Ir_Remote_Code ]--------------------------------- ' SONY TV IR remote subroutine loads the remote code into the ' remoteCode variable. Get_Ir_Remote_Code: remoteCode = 0 ' Wait for resting state between messages to end. DO RCTIME IrDet, 1, ...

Page 162

Acquire multi-digit value (up to 65535) and store the value variable. Speaker beeps each time a key is ' pressed. Get_Multi_Digit_Value: value = 0 remoteCode = 0 DO value = value * 10 + remoteCode DO ...

Page 163

FREQOUT Speaker, 100, 3000 PAUSE 200 RETURN Your Turn – LED Prompts and Program Organization To make this program complete, a pair of LEDs can make it easier to program the Boe- Bot without the Debug Terminal. This could come ...

Page 164

SUMMARY This chapter introduced some more applications you can create with the IR remote application. Application programs have to be well organized, with each task accomplished in subroutines. The I/O pins, variables, and constants also have to be defined and ...

Page 165

Elements of user interface (UI) design have been introduced throughout this text. In earlier chapters, button debouncing and speaker and LED feedback have already been introduced and applied. In the third activity of this chapter, programming techniques were introduced for ...

Page 166

Modify this code block so that it only accepts values between 16 and 19. DO DEBUG CR, " Q", CR, "Enter Direction: " DEBUGIN direction SELECT direction CASE "F", "B", "R", "L", "Q" EXIT CASE ELSE ...

Page 167

CASE Q4. The operator allows you to specify the starting address in EEPROM @Address for the directive's first DATA ...

Page 168

E2. Near the main routine's DO…LOOP just above the . ENDSELECT ' If operation is 4, execute the YourProgram.bs2. CASE 4 ' Modified main routine from YourProgram.bs2 goes here. • • • operation is not 1-4, execute this ...

Page 169

ENTER a second time exits programming mode. √ ENTER a third time makes the Boe-Bot execute the maneuvers. P1. Add these bit declarations to the Variables section of the program. irDetectLeft VAR irDetectRight VAR √ Grab the IR detection ...

Page 170

P2. Add case statements to the outer for each function. Remember to update the menu list in the Initialization routine. DO SELECT operation CASE 1 • • • CASE 2 • • • CASE 3 • • • ...

Page 171

TOGGLE 1 pulseLeft = 725 pulseRight = 725 ELSE pulseLeft = 775 pulseRight = 725 ENDIF GOSUB Send_Pulse LOW 1 LOW operation is 6, test for ballast interference the ballast interference tester only triggers once. ...

Page 172

...

Page 173

Appendix A: IR Remote AppKit Documentation Version 1.1 INFRARED REMOTE APPKIT (#29122) A Wireless Keypad for Your BASIC Stamp With a universal remote and an infrared receiver, you can add a wireless keypad to your BASIC Stamp Applications. The IR ...

Page 174

Kit Contents* Infrared Remote Parts List: (1) 020-00001 Universal Remote and Universal Remote Manual (1) 350-00014 IR detector (1) 150-02210 Resistor – 220 Ω (1) 800-00016 Jumper wires – bag of 10 *Two alkaline AA batteries sold separately How IR ...

Page 175

Handheld Remote Infrared Messages Excerpt from IR Remote for the Boe-Bot text The examples here will rely on the protocol universal remotes use to control SONY sets. This protocol strobes the IR thirteen times with roughly half a millisecond rest ...

Page 176

Resting state Resting states between message between data pulses packets = 20- 0.6 ms Start Bit-0 Bit-2 Bit-1 Start pulse Binary-0 duration = 2.4 ms data pulse durations = 0 Message Timing Diagram ...

Page 177

Make sure to configure your universal remote to control a SONY documentation that comes with your universal remote. √ Press the TV button on your remote so that you know it is sending TV signals. √ Download or hand ...

Page 178

RCTIME 9, 0, irPulse IF irPulse > 300 THEN remoteCode.BIT5 = 1 RCTIME 9, 0, irPulse IF irPulse > 300 THEN remoteCode.BIT6 = 1 ' Map digit keys to actual values. IF (remoteCode < 10) THEN remoteCode = remoteCode + ...

Page 179

As with the previous example program, make sure your remote is configured to control a SONY TV first. √ Update the Directive for the BASIC Stamp module you are using. $STAMP √ Download or hand enter, then run IrRemoteButtonDisplay.bs2. ...

Page 180

ThresholdStart CON 2400 ThresholdPulse CON 500 * #CASE #ELSE #ERROR This BASIC Stamp NOT supported. #ENDSELECT ' SONY TV IR remote constants for non-keypad buttons Enter CON 11 ChUp CON 16 ChDn CON 17 VolUp CON 18 ...

Page 181

DO GOSUB Get_Ir_Remote_Code DEBUG CLS, "Remote button: " SELECT remoteCode CASE DEBUG DEC remoteCode CASE Enter DEBUG "ENTER" CASE ChUp DEBUG "CH+" CASE ChDn DEBUG "CH-" CASE VolUp DEBUG "VOL+" CASE VolDn DEBUG "VOL-" CASE Mute DEBUG ...

Page 182

RCTIME IrDet, 0, irPulse IF irPulse > ThresholdEdge THEN remoteCode.BIT0 = 1 RCTIME IrDet, 0, irPulse IF irPulse > ThresholdEdge RCTIME IrDet, 0, irPulse IF irPulse > ThresholdEdge RCTIME IrDet, 0, irPulse IF irPulse > ThresholdEdge RCTIME IrDet, 0, irPulse ...

Page 183

Add this declaration to the IrRemoteButtonDisplay.bs2's Variables section: value VAR √ Replace the in IrRemoteButtonDisplay.bs2's main routine with the one DO…LOOP shown below. √ Run the program and follow the Debug Terminal's prompts. ' Replace the DO...LOOP in the ...

Page 184

The routine below is for a Boe-Bot robot with Parallax Continuous Rotation servos. Its left servo should be connected to P13, and its right servo connected to P12. If you have Parallax PM servos, use 500 in place of 650 ...

Page 185

... Column #76: Control from the Couch introduces capturing and decoding SONY TV IR control signals with the BASIC Stamp 2SX (or 2p). BASIC Stamp and Boe-Bot are registered trademarks of Parallax Inc. Parallax and the Parallax logo are trademarks of Parallax Inc. Sony is a registered trademark of Sony Corporation Japan. ...

Page 186

...

Page 187

Appendix B: BS2 to BS2 IR Messages This appendix/activity demonstrates how to send messages from one BASIC Stamp to another with IR and a custom protocol. This technique lends itself to IR communication between BASIC Stamp modules, Boe-Bot robots, etc. ...

Page 188

Figure B-1 IR Transmit and Receive Circuits Developing the IR Communion Protocol All it takes to transmit infrared with the BASIC Stamp LED, a resistor, and the command. The one hitch to the FREQOUT will transmit ...

Page 189

For this activity, we'll go with 8, but the number of data bits can be increased or decreased, simply by changing a couple lines of code. Here is how the protocol will ...

Page 190

Disconnected the board with the transmitting circuit from the programming cable. √ Connect the board with the receiving circuit shown in Figure B-1 to the programming cable. √ Download ReceiveCustomIrMessage.bs2 into it. √ Leave it connected to the programming ...

Page 191

EEPROM Data ]----------------------------------------------------- eeChars DATA "a" ' -----[ I/O Definitions ]------------------------------------------------- IrLedPin CON 8 ' -----[ Constants ]------------------------------------------------------- IrFreq CON 38000 StartBitTime CON 3 Binary0Time CON 2 Binary1Time CON 1 BtwnPulses CON 1 ' -----[ Variables ]------------------------------------------------------- counter ...

Page 192

FOR counter = irMessage.LOWBIT(counter THEN duration = 2 ELSE duration = 1 ENDIF FREQOUT IrLedPin,duration,IrFreq PAUSE BtwnPulses NEXT RETURN How TransmitCustomIrMessage.bs2 Works Here is a hard-coded example of sending the number 9 with the ...

Page 193

For example, to send the value 9, simply set the . Transmit_Ir_Byte irMessage = 9 GOSUB Transmit_Ir_Byte The subroutine examines each bit in the Transmit_Ir_Byte selects the corresponding Duration for the first, the subroutine uses a FOR...NEXT to 7. Transmit_Ir_Byte: ...

Page 194

Also, PAUSE BtwnPulses defined the constant declarations.) This ensures at least delay between data bit pulses. Example Program: ReceiveCustomIrMessage.bs2 ' -----[ Title ]----------------------------------------------------------- ' IR Remote for the Boe-Bot - ReceiveCustomIrMessage.bs2 ' Receives ...

Page 195

Get_Ir_Byte_Message: DO PULSIN IrDetPin, 0, irPulse LOOP UNTIL irPulse < StartMax AND irPulse > StartMin FOR counter = PULSIN IrDetPin, 0, irPulse SELECT irPulse CASE Bin1Min TO Bin1Max irMessage.LOWBIT(counter CASE Bin0Min TO Bin0Max irMessage.LOWBIT(counter) = ...

Page 196

CR GOTO Get_Ir_Byte_Message ENDSELECT NEXT RETURN Like the example programs in Chapters 2 and 3, there's a the subroutine waits for the start pulse. Remember that So start pulse should result in a for this ...

Page 197

Save TransmitCustomIrMessage.bs2 as TransmitCustomIrValues.bs2. √ Modify this line so that the eeChar address other words, change eeChars DATA to eeChars DATA √ Comment this line by placing an apostrophe to the left of it ...

Page 198

FOR...NEXT arguments changed from 7 to 15. The transmitting program will have to use the EndValue Word formatter before the DataItem variable values in the and ...

Page 199

Appendix C: Transmitting IR Remote Signals with the BASIC Stamp 2 The activities in this text focused on programming the BASIC Stamp to receive and decode IR remote signals. If you are also interested in encoding and transmitting the same ...

Page 200

Boe-Bot kits. However, the missing parts are inexpensive, easy to obtain, and they can also be ordered from Parallax. The Parallax part numbers for the extra parts are included in the parts list below. (1) Capacitor - 0.01 µF ...

Related keywords