A Tilt Radio Controller for Your Boe-Bot
Andy Lindsay (Parallax)
Posts: 1,919
A Tilt Radio Controller for Your Boe-Bot
·
When an accelerometer is mounted on the Boe-Bot® Robot, it can be programmed to seek out hilltops or valleys.· It can also be programmed to detect when the hill it's trying to climb is too ambitious and seek out another route.· Instead of an autonomous roaming aid for the Boe-Bot, an accelerometer can be a useful tool in a tilt radio controller.· The great thing about the Boe-Bot is that it can also be directed by a remote controller, but use intelligence you program into it to decide whether or not to follow the instructions it's receiving.·
·
Figure 1 shows a tilt radio controlled Boe-Bot example.· It's easy to use; the Boe-Bot travels in the direction you tilt the controller.· The programs the Boe-Bot and radio frequency (RF) tilt controller are running make it possible to exert fine control over the Boe-Bot's motions, including forward, backward, turning in a narrow or wide curves, rotating in place, and pivoting.·
·
+ Download zipped video clip (951 KB) - TiltRfControlledBoeBot.wmv·
+ Download Source Code (3 KB)·- TiltControlledBoeBot_SourceCode.zip
·
Figure 1 - Tilt Controlled RF Boe-Bot (s-curves not shown)
·
Getting Started
This project contains advanced topics, not intended for Boe-Bot beginners. ·Before continuing, it is highly recommended you complete the following tasks in order to gain a better understanding on how this application works:
√······· Complete at minimum Chapters 1-4 in Robotics with the Boe-Bot
√······· Download the Memsic 2125 Demo Kit Documentation and learn the accelerometer’s basics.
√······· Go through Chapter 3: The Memsic Dual Axis Accelerometer in Smart Sensors and Applications (.pdf 4.5 MB). This will give you a better·· understanding on how the Memsic Dual Axis Accelerometer works.
√······· Optionally try Chapters 5 & 6 in Smart Sensors and Applications.· These chapters contain cool projects such as programming video games, determining height using line-of-sight, and measuring acceleration while executing an Ollie on a skateboard. These activities are fun, and they will also help you better familiarize yourself with the Memsic Dual Axis Accelerometer.
Figure 2 – Sample video game activity from Chapter 5: Accelerometer Gaming Basics in Smart Sensors and Applications.· Game maze (left), win screen (middle), and lose screen (right).
√······· Try the activity in·Boe-Bot® Robot Navigation·with Accelerometer Incline Sensing. ·The codes for these two activities are very similar, and it is a good idea to familiarize yourself with the coding techniques.
√······· Download the 433 MHz Parallax RF Receiver Manual and the 433 MHz Parallax RF Transmitter Manual and review their principles of operation.
Hardware for Sending, Receiving, and Interpreting Serial Tilt Measurements
In addition to the BASIC Stamp® 2 module and Board of Education included in the Boe-Bot Robot Kit, this activity makes use of a second BASIC Stamp 2 and Board of Education.· The BASIC Stamp HomeWork Board can also be used in place of the second BASIC Stamp 2 and board of education.·
Parts and Equipment
(1) Boe-Bot® Robot, assembled and tested
The parts below are included in the Boe-Bot Robot kit:
····· (1) Piezospeaker
····· (4) Resistors - 220 Ω (Red-Red-Brown)
····· (misc)· Jumper wires
(1) Wireless Control for Robotics kit
The parts below are included in the Wireless Control for Robotics kit:
····· (1)·HomeWork Board with BASIC Stamp 2
···········The BASIC Stamp 2 Board of Education or the Radio Shack What's a Microcontroller BASIC Stamp Kit is also suitable for ·this activity
····· (1)·Memsic 2125 Dual-axis Accelerometer
····· (1)·Parallax 433 MHz RF Transmitter
····· (1)·Parallax 433 MHz RF Receiver
·
How it Works
This activity uses a single serial RF channel to transmit the x and y-axis tilt information from your handheld RF tilt controller to the Boe-Bot.· The BASIC Stamp module in the RF tilt controller captures the tilt pulses from the MX2125, and stores them in its RAM.· It then sends the serial version of these values to the RF transmitter it's connected to, which in turn modulates and broadcasts the serial messages.· If the RF receiver on the Boe-Bot is in range, it receives and demodulates the message, and sends the reproduced serial message to the Boe-Bot's BASIC Stamp.· When the BASIC Stamp gets the x and y axis tilt measurements, it can then use them to make navigation decisions and send control pulses to its servos.
Figure·3 - Block Diagram
·
Building the Circuits
Figure 3 shows a schematic and wiring diagram for the RF tilt controller, and Figure 4 shows the schematic and wiring diagram for the radio controlled Boe-Bot.
·
√······· Build the circuit shown in Figure 3 on a separate Board of Education (or on a BASIC Stamp HomeWork Board).
√······· Build the circuit shown· in Figure 4 on your Boe-Bot.
Figure·4 - Schematic and Wiring Diagram - RF Tilt Controller
Figure·5 - Schematic and Wring Diagram - Radio Controlled Boe-Bot
·
BASIC Stamps Exchanging Serial Messages with SEROUT and SERIN
The same kind of serial communication the BASIC Stamp uses to send messages to the computer with the DEBUG command can be used to exchange messages between BASIC Stamps.· The DEBUG command is actually a special case of a more general command called SEROUT.· For example, you can use the command SEROUT 16, 16468, [noparse][[/noparse]"Hello"] in place of the command DEBUG "Hello".· The DEBUGIN command is also a special case of the SERIN command.· For example, the command DEBUGIN DEC3 value can be replaced by the command SERIN 16, 16468, [noparse][[/noparse]DEC3 value].·
·
When SEROUT or SERIN use 16 as a Pin argument, it makes the BASIC Stamp send or receive the serial message on its SOUT or SIN pins.· Those pins are connected to the serial cable by the Board of Education.· To send or receive the same serial message on P10, use 10 as your Pin argument, like this: SEROUT 10, 16468, [noparse][[/noparse]Hello].· If you want to receive a serial message with a 3-digit number on P11, the command SERIN, 11, 16468, [noparse][[/noparse]DEC3 value] will do the trick.·
·
The second number used in the example SEROUT and SERIN commands has been 16468, which is called the BaudMode argument.· In this case, the BaudMode argument tells the BASIC Stamp to transmit and receive messages at 9600 bits per second (bps).· You can change the BaudMode argument to 16780, and then the SERIN and SEROUT commands will send and receive data at 2400 bps instead.· The example programs in this activity use a BaudeMode of 16780 because 2400 bps is the maximum baud rate recommended by the RF Digital Transmitter and Receiver module documentation.
·
Testing the Accelerometer, Transmitter, and Receiver
You can test the system with the RF tilt controller disconnected from the serial cable while it's running TestTiltTransmitter.bs2.· The radio controlled Boe-Bot has to be connected to the serial cable during this test, and it has to be running TestTiltReceiver.bs2.· The test involves tilting the RF tilt controller and checking to make sure radio controlled Boe-Bot receives and displays the correct tilt information in the Debug Terminal.
·
TestTiltTransmiter.bs2 is a test program for testing the tilt radio controller.· It displays the accelerometer measurements with a DEBUG command, and then sends those same measurements to the RF transmitter with a SEROUT command.· The DEBUG command will allow you to make sure the accelerometer is working properly before disconnecting it from the serial cable.· The SEROUT command sends the x and y-axis values to the RF transmitter, which in turn broadcasts these values at 433.92 MHz for any 433.92 MHz receiver to receive.· Both the x and y-axis values are stored in word variables.· Since a word is really two bytes, the.HIGHBYTE and .LOWBYTE modifiers are used to send the upper byte of the word variable, followed by the lower byte.
·
· SEROUT 10, 16780, [noparse][[/noparse] "!",··················
····················· x.HIGHBYTE, x.LOWBYTE,
····················· y.HIGHBYTE, y.LOWBYTE ]
·
TestTiltReceiver.bs2 is a test program for the Radio Controlled Boe-Bot, and it receives messages from the 433.92 MHz receiver with a SERIN command.· It then displays the values it receives with the DEBUG command.· Since the SEROUT command in TestTiltTransmitter.bs2 sends an exclamation point to indicate that the next four bytes will contain the x and y-axis measurements, the SERIN command in TestTiltReceiver.bs2 uses the WAIT() formatter to wait for the exclamation point before storing any data.· It also uses the .HIGHBYTE and .LOWBYTE operators to store the values it receives into the x and y word variables in the same order that they were transmitted by the RF tilt controller.
·
· SERIN 11, 16780, [noparse][[/noparse] WAIT("!"),··············
··················· ·x.HIGHBYTE, x.LOWBYTE,··
··················· ·y.HIGHBYTE, y.LOWBYTE ]··
Example Program – TestTiltTransmitter.bs2
√······· Connect your programming cable to your tilt controller.
√······· Enter, save, and run TestTiltTransmitter.bs2.
√······· Test and verify that the accelerometer is reporting correct measurements for its x and y-axes in the Debug Terminal.
√······· Make sure it's working right; trouble-shoot the circuit and/or code if necessary.
√······· Disconnect your programming cable from your tilt controller, but leave the battery (or DC supply) connected so that the program keeps running.
√······· Move on to the instructions in Example Program - TestTiltReceiver.bs2.
Example Program – TestTiltReceiver.bs2
√······· Connect your programming cable to your Radio Controlled Boe-Bot.
√······· Enter, save, and run TestTiltReceiver.bs2.
√······· This is the cool part - try tilting your RF tilt controller and observe the Debug Terminal, which is now receiving messages from your radio controlled Boe-Bot.· The Debug Terminal should still report the correct measurements for its x and y-axes that are wirelessly transmitted by your RF tilt controller.
√······· Make sure it's working right; trouble-shoot the circuit and/or code if necessary.
·
Your Turn - SEROUT Vs. DEBUG
The .HIGHBYTE and .LOWBYTE operators are not often used in DEBUG commands because they really don't cause the Debug Terminal to display meaningful data.· With DEBUG and DEBUGIN commands, formatters such as SDEC and DEC4 are the more common choices for displaying the x and y-axis measurements.· Let's take a closer look at the DEC4 operator.· It takes four characters to send the x-axis measurement, and four more to send the y-axis measurement.· That's a total of eight bytes, nine if you add the exclamation point.· In contrast, the .HIGHBYTE and .LOWBYTE modifiers get the job done with only two bytes each, so that's five bytes including the "!".·
·
Why does this matter?· Because we really don't want to exceed 40 ms between servo pulses, and guess what, two accelerometer axis measurements and five bytes at 2400 bps takes a total of 40 ms.· In the serial messages we are using, each byte has a start bit, stop bit, and eight data bits.· So, how much longer would it take if the programs were to use the DEC4 formatter?· Since the transmit rate is 2400 bits per second, each bit takes 1/2400 of a second, or 0.417 ms.· Multiply this by 40 more bits, and that's 16.7 more ms for a total of almost 57 ms.· So, adding four more bites causes too much time to elapse between servo pulses, which will cause the servos to perform very poorly.
·
All that said, it's still a good idea to see how it can work while there are no servos running.·
·
√······· Modify the SEROUT command in TestTiltTransmitter.bs2 so that it looks like this:
·
······ SEROUT 10, 16780, [noparse][[/noparse] "!", DEC4 x, DEC4 y]··················
·
√······· Modify the SERIN command in TestTiltReceiver.bs2 so that it looks like this:
·
·······SERIN 11, 16780, [noparse][[/noparse]WAIT("!"), DEC4 x, DEC4 y]
·
√······· Repeat the tests for the modified versions of TestTiltTransmitter.bs2 and TestTiltReceiver.bs2.
Radio Controlled Boe-Bot Application
To keep the message rate in the 40 ms range, all the pauses and DEBUG commands in TestTiltTransmitter.bs2 have been removed, and the modified program was saved as RfTiltTransmitter.bs2.· This program sends x and y coordinates every 40.6 ms, which will keep the Boe-Bot's servos going at a reasonable rate.· Boe-BotReceiver.bs2 receives and stores the x and y-axis values sent by the transmitter.· Then, it uses these values to decide what pulses to send to the servos.
Example Program – RfTiltTransmitter.bs2.
√······· Connect the RF tilt controller to your serial cable.
√······· Enter, save, and run RfTiltTransmitter.bs2
√······· Disconnect the serial cable from the tilt controller.
·
Example Program – BoeBotReceiver.bs2
√······· Connect your radio controlled Boe-Bot to the programming cable.
√······· Enter, save, and run RfTiltControlledBoeBot.bs2.
√······· Disconnect the radio controlled Boe-Bot from the programming cable.
√······· Take your Boe-Bot for a test drive using your RF tilt controller to guide it.
How RfTiltControlledBoeBot.bs2 Works
This example program is a modified version of UphillBoeBot.bs2 from Boe-Bot® Robot Navigation·with Accelerometer Incline Sensing.··If you have not already done so, it would be a good idea to try out this activity and familiarize yourself with the coding techniques.
·
Instead of two PULSIN commands to get the x and y-axis tilt values, this program uses a SERIN command to get the x and y-axis tilt values that are relayed by the RF receiver.· The SERIN command waits to receive the "!" character, then stores the next four bytes to reconstruct the x and y-axis word variable values.· After this SERIN command, the x and y variables store the raw accelerometer measurements.· This makes the rest of the program easier because it can be written as though the accelerometer is on-board.· ·
·
· SERIN 11, 16780, [noparse][[/noparse]WAIT("!"), x.HIGHBYTE, x.LOWBYTE, y.HIGHBYTE, y.LOWBYTE]
·
These scaling and offset commands differ from UphillBoeBot.bs2.· The narrower range of values makes the RF tilt controller more friendly in terms of fine motor control with a range of -62 to + 62 instead of -625 to + 625. ·The statements now convert the highest measurement into the lowest result, and visa versa.· They do so by subtracting the scaled accelerometer measurements from 62 instead of subtracting 62 from the scaled accelerometer measurements.· This change converts a hill climbing Boe-Bot into a hill descending Boe-Bot.·
·
· x = 62 - ((x MIN 1875 MAX 3125) - 1875 / 10)
· y = 62 - ((y MIN 1875 MAX 3125) - 1875 / 10)
·
The navigation decisions are also slightly different from UphillBoeBot.bs2.· They have been modified to make driving your Boe-Bot with a tilt controller easier and more intuitive.· The statement IF (ABS(x) > 12) OR (ABS(y) > 12) THEN creates a deadband so that the Boe-Bot doesn't immediately react as soon as you just barely tilt the RF tilt controller.· When both x and y are in this range, the ELSE statement at the bottom of the code block makes the Boe-Bot hold still.· Once you tilt the controller far enough to make x or y greater than 12 or less than -12, y is subtracted from pulseLeft and added to pulseRight.· When y is negative, it makes the Boe-Bot go backwards, if it's positive, the Boe-Bot goes forwards.· After the forward pulse values have been determined, the turn can be mixed in.· For forward motion, the x tilt values have to be subtracted from both pulseLeft and pulsRight to get that natural forward turning control.· When the Boe-Bot is backing up, the turn directions have to be reversed to keep the control intuitive, so instead of subtracting x from pulseLeft and pulseRight, x is added to these variables.·
·
· ' Navigation decisions
· IF (ABS(x) > 12) OR (ABS(y) > 12) THEN····
··· pulseLeft· = 750 - y····················
··· pulseRight = 750 + y
··· IF (ySign = Negative) OR (ABS(y) < 12) THEN·
····· pulseLeft =· pulseLeft· - x
····· pulseRight = pulseRight - x
··· ELSE···························· ········
····· pulseLeft· = pulseLeft· + x
····· pulseRight = pulseRight + x
··· ENDIF
· ELSE······································
··· pulseLeft· = 750
··· pulseRight = 750
· ENDIF
·
The remainder of the program, especially the ramping routine, is introduced and explained in more detail in·Boe-Bot® Robot Navigation·with Accelerometer Incline Sensing.·
Your Turn - Making Time for Sensors
There are many ways to make time for other sensors.· The easiest check for RF messages and read the sensors between alternate servo pulses.· ····
·
√······· Add the declaration operation VAR Bit to the variables section.
√······· Add this command operation = ~ operation at the beginning of the main routine, on the line just below DO.·
√······· Use a SELECT...CASE statement evaluates the operation variable that executes the existing main routine for CASE is 0, and a new routine (add PAUSE 40 for now) when case is 1.· That's enough time to check a lot of sensors.
√······· Try your modified code out and decide whether or not the change in performance is acceptable.
Summary
The contents of two word variables can be sent from one BASIC Stamp to another via serial communication, with the SEROUT and SERIN commands.· The information can be transmitted with a pair of wires, one for signal and one for ground.· A radio transmitter and receiver can replace the pair of wires, for "wireless" serial communication.· This means of communicating values was used to transmit the x and y-axis tilt values from an RF tilt controller to the Boe-Bot.· When the Boe-Bot receives the values, the rest of the programming can be done many of the accelerometer programming techniques covered in earlier chapters.
·
The SERIN and SEROUT commands offer the same user-friendly formatters and control characters that DEBUG and DEBUGIN feature, and much more.· These arguments that make the display of values more meaningful also take longer to transmit.· The .HIGHBYTE and .LOWBYTE modifiers can be used parse word variables into two byte values.· This technique is more efficient than using formatters such as DEC4, SDEC, BIN, etc.·
Questions
1.······ How many wires does it take to replace the link between RF transmitter and receiver?
2.······ When replacing the RF transmitter/receiver with wires, what role does each wire play?
3.······ What are the Pin, BaudMode, and DataItem arguments in this command: SEROUT 16, 16468, [noparse][[/noparse]"Hello"]?
4.······ How would you modify this command (SEROUT 16, 16468, [noparse][[/noparse]"Hello"]) so that transmits the "Hello" message to P5?
5.······ How would you modify this command so that it sends the data at
6.······ What does the WAIT formatter do in a SERIN command?
7.······ Why does the SERIN command need variables between the square brackets?
8.······ If x = "ab", what will DEBUG x.HIGHBYTE display?
9.······ If x = "ab", what will DEBUG x.LOWBYTE display?
10.·· What's the most time you want to elapse between servo pulses on the Boe-Bot?
11.·· What does the command IF (ABS(x) > 12) OR (ABS(y) > 12) THEN do for your RC tilt controller's behavior?
12.·· If y is negative, what direction do pulseLeft· = 750 - y and pulseRight = 750 + y make the Boe-Bot go?
13.·· What do the commands pulseLeft =· pulseLeft· - x and pulseRight = pulseRight - x
·
When an accelerometer is mounted on the Boe-Bot® Robot, it can be programmed to seek out hilltops or valleys.· It can also be programmed to detect when the hill it's trying to climb is too ambitious and seek out another route.· Instead of an autonomous roaming aid for the Boe-Bot, an accelerometer can be a useful tool in a tilt radio controller.· The great thing about the Boe-Bot is that it can also be directed by a remote controller, but use intelligence you program into it to decide whether or not to follow the instructions it's receiving.·
·
Figure 1 shows a tilt radio controlled Boe-Bot example.· It's easy to use; the Boe-Bot travels in the direction you tilt the controller.· The programs the Boe-Bot and radio frequency (RF) tilt controller are running make it possible to exert fine control over the Boe-Bot's motions, including forward, backward, turning in a narrow or wide curves, rotating in place, and pivoting.·
·
+ Download zipped video clip (951 KB) - TiltRfControlledBoeBot.wmv·
+ Download Source Code (3 KB)·- TiltControlledBoeBot_SourceCode.zip
·
Figure 1 - Tilt Controlled RF Boe-Bot (s-curves not shown)
·
Getting Started
This project contains advanced topics, not intended for Boe-Bot beginners. ·Before continuing, it is highly recommended you complete the following tasks in order to gain a better understanding on how this application works:
√······· Complete at minimum Chapters 1-4 in Robotics with the Boe-Bot
√······· Download the Memsic 2125 Demo Kit Documentation and learn the accelerometer’s basics.
√······· Go through Chapter 3: The Memsic Dual Axis Accelerometer in Smart Sensors and Applications (.pdf 4.5 MB). This will give you a better·· understanding on how the Memsic Dual Axis Accelerometer works.
√······· Optionally try Chapters 5 & 6 in Smart Sensors and Applications.· These chapters contain cool projects such as programming video games, determining height using line-of-sight, and measuring acceleration while executing an Ollie on a skateboard. These activities are fun, and they will also help you better familiarize yourself with the Memsic Dual Axis Accelerometer.
Figure 2 – Sample video game activity from Chapter 5: Accelerometer Gaming Basics in Smart Sensors and Applications.· Game maze (left), win screen (middle), and lose screen (right).
√······· Try the activity in·Boe-Bot® Robot Navigation·with Accelerometer Incline Sensing. ·The codes for these two activities are very similar, and it is a good idea to familiarize yourself with the coding techniques.
√······· Download the 433 MHz Parallax RF Receiver Manual and the 433 MHz Parallax RF Transmitter Manual and review their principles of operation.
Hardware for Sending, Receiving, and Interpreting Serial Tilt Measurements
In addition to the BASIC Stamp® 2 module and Board of Education included in the Boe-Bot Robot Kit, this activity makes use of a second BASIC Stamp 2 and Board of Education.· The BASIC Stamp HomeWork Board can also be used in place of the second BASIC Stamp 2 and board of education.·
Parts and Equipment
(1) Boe-Bot® Robot, assembled and tested
The parts below are included in the Boe-Bot Robot kit:
····· (1) Piezospeaker
····· (4) Resistors - 220 Ω (Red-Red-Brown)
····· (misc)· Jumper wires
(1) Wireless Control for Robotics kit
The parts below are included in the Wireless Control for Robotics kit:
····· (1)·HomeWork Board with BASIC Stamp 2
···········The BASIC Stamp 2 Board of Education or the Radio Shack What's a Microcontroller BASIC Stamp Kit is also suitable for ·this activity
····· (1)·Memsic 2125 Dual-axis Accelerometer
····· (1)·Parallax 433 MHz RF Transmitter
····· (1)·Parallax 433 MHz RF Receiver
·
How it Works
This activity uses a single serial RF channel to transmit the x and y-axis tilt information from your handheld RF tilt controller to the Boe-Bot.· The BASIC Stamp module in the RF tilt controller captures the tilt pulses from the MX2125, and stores them in its RAM.· It then sends the serial version of these values to the RF transmitter it's connected to, which in turn modulates and broadcasts the serial messages.· If the RF receiver on the Boe-Bot is in range, it receives and demodulates the message, and sends the reproduced serial message to the Boe-Bot's BASIC Stamp.· When the BASIC Stamp gets the x and y axis tilt measurements, it can then use them to make navigation decisions and send control pulses to its servos.
Figure·3 - Block Diagram
·
Building the Circuits
Figure 3 shows a schematic and wiring diagram for the RF tilt controller, and Figure 4 shows the schematic and wiring diagram for the radio controlled Boe-Bot.
·
√······· Build the circuit shown in Figure 3 on a separate Board of Education (or on a BASIC Stamp HomeWork Board).
√······· Build the circuit shown· in Figure 4 on your Boe-Bot.
Figure·4 - Schematic and Wiring Diagram - RF Tilt Controller
Figure·5 - Schematic and Wring Diagram - Radio Controlled Boe-Bot
·
BASIC Stamps Exchanging Serial Messages with SEROUT and SERIN
The same kind of serial communication the BASIC Stamp uses to send messages to the computer with the DEBUG command can be used to exchange messages between BASIC Stamps.· The DEBUG command is actually a special case of a more general command called SEROUT.· For example, you can use the command SEROUT 16, 16468, [noparse][[/noparse]"Hello"] in place of the command DEBUG "Hello".· The DEBUGIN command is also a special case of the SERIN command.· For example, the command DEBUGIN DEC3 value can be replaced by the command SERIN 16, 16468, [noparse][[/noparse]DEC3 value].·
·
When SEROUT or SERIN use 16 as a Pin argument, it makes the BASIC Stamp send or receive the serial message on its SOUT or SIN pins.· Those pins are connected to the serial cable by the Board of Education.· To send or receive the same serial message on P10, use 10 as your Pin argument, like this: SEROUT 10, 16468, [noparse][[/noparse]Hello].· If you want to receive a serial message with a 3-digit number on P11, the command SERIN, 11, 16468, [noparse][[/noparse]DEC3 value] will do the trick.·
·
The second number used in the example SEROUT and SERIN commands has been 16468, which is called the BaudMode argument.· In this case, the BaudMode argument tells the BASIC Stamp to transmit and receive messages at 9600 bits per second (bps).· You can change the BaudMode argument to 16780, and then the SERIN and SEROUT commands will send and receive data at 2400 bps instead.· The example programs in this activity use a BaudeMode of 16780 because 2400 bps is the maximum baud rate recommended by the RF Digital Transmitter and Receiver module documentation.
·
Testing the Accelerometer, Transmitter, and Receiver
You can test the system with the RF tilt controller disconnected from the serial cable while it's running TestTiltTransmitter.bs2.· The radio controlled Boe-Bot has to be connected to the serial cable during this test, and it has to be running TestTiltReceiver.bs2.· The test involves tilting the RF tilt controller and checking to make sure radio controlled Boe-Bot receives and displays the correct tilt information in the Debug Terminal.
·
TestTiltTransmiter.bs2 is a test program for testing the tilt radio controller.· It displays the accelerometer measurements with a DEBUG command, and then sends those same measurements to the RF transmitter with a SEROUT command.· The DEBUG command will allow you to make sure the accelerometer is working properly before disconnecting it from the serial cable.· The SEROUT command sends the x and y-axis values to the RF transmitter, which in turn broadcasts these values at 433.92 MHz for any 433.92 MHz receiver to receive.· Both the x and y-axis values are stored in word variables.· Since a word is really two bytes, the.HIGHBYTE and .LOWBYTE modifiers are used to send the upper byte of the word variable, followed by the lower byte.
·
· SEROUT 10, 16780, [noparse][[/noparse] "!",··················
····················· x.HIGHBYTE, x.LOWBYTE,
····················· y.HIGHBYTE, y.LOWBYTE ]
·
TestTiltReceiver.bs2 is a test program for the Radio Controlled Boe-Bot, and it receives messages from the 433.92 MHz receiver with a SERIN command.· It then displays the values it receives with the DEBUG command.· Since the SEROUT command in TestTiltTransmitter.bs2 sends an exclamation point to indicate that the next four bytes will contain the x and y-axis measurements, the SERIN command in TestTiltReceiver.bs2 uses the WAIT() formatter to wait for the exclamation point before storing any data.· It also uses the .HIGHBYTE and .LOWBYTE operators to store the values it receives into the x and y word variables in the same order that they were transmitted by the RF tilt controller.
·
· SERIN 11, 16780, [noparse][[/noparse] WAIT("!"),··············
··················· ·x.HIGHBYTE, x.LOWBYTE,··
··················· ·y.HIGHBYTE, y.LOWBYTE ]··
Example Program – TestTiltTransmitter.bs2
√······· Connect your programming cable to your tilt controller.
√······· Enter, save, and run TestTiltTransmitter.bs2.
√······· Test and verify that the accelerometer is reporting correct measurements for its x and y-axes in the Debug Terminal.
√······· Make sure it's working right; trouble-shoot the circuit and/or code if necessary.
√······· Disconnect your programming cable from your tilt controller, but leave the battery (or DC supply) connected so that the program keeps running.
√······· Move on to the instructions in Example Program - TestTiltReceiver.bs2.
[color=#008000]' TestTiltTransmitter.bs2[/color] [color=#008000]' Test accelerometer readings.[/color] [color=#008000]'{$STAMP BS2}[/color] [color=#008000]'{$PBASIC 2.5}[/color] [color=#008000][color=#0]x VAR Word[/color] ' Left/right tilt[/color] [color=#008000][color=#0]y VAR Word[/color] ' Forward/backward tilt[/color] [color=#0000ff]DEBUG[/color] [color=#ff0000]"Beep!!!"[/color][color=#008000] ' Test piezospeaker[/color] [color=#0000ff]FREQOUT[/color] 4, 2000, 3000 [color=#0000ff]DEBUG[/color] [color=#800080]CLS[/color][color=#008000][color=#0],[/color] [/color][color=#ff0000]" x y"[/color][color=#008000][color=#0],[/color] [/color][color=#800080]CR[/color][color=#008000] ' Axis headings[/color] [color=#0000ff]DO[/color][color=#008000] ' Begin main routine[/color] [color=#0000ff]PULSIN[/color][color=#008000] [color=#0]6, 1, x[/color] ' Get X-axis tilt[/color] [color=#0000ff]PULSIN[/color][color=#008000] [color=#0]7, 1, y[/color] ' Get Y-axis tilt[/color] [color=#008000] ' Send tilt at 2400 bps, non-inverted.[/color] [color=#0000ff]SEROUT[/color] 10, 16780, [noparse][[/noparse] [color=#ff0000]"!"[/color][color=#008000][color=#0],[/color] ' Start character[/color] [color=#008000] [color=#0]x.HIGHBYTE, x.LOWBYTE,[/color] ' X-axis word[/color] [color=#008000] [color=#0]y.HIGHBYTE, y.LOWBYTE[/color] [color=#0]][/color]' Y-axis word[/color] [color=#008000] ' Display x AND y tilt measurements.[/color] [color=#0000ff]DEBUG[/color] [color=#800080]CRSRX[/color][color=#008000][color=#0], 0,[/color] [/color][color=#ff0000]"("[/color][color=#008000], [/color][color=#000080]SDEC3[/color][color=#008000][color=#0] x,[/color] [/color][color=#ff0000]", "[/color][color=#008000][color=#0],[/color] [/color][color=#000080]SDEC3[/color][color=#008000][color=#0] y,[/color] [/color][color=#ff0000]")"[/color][color=#008000][color=#0],[/color] [/color][color=#800080]CLREOL[/color] [color=#0000ff]PAUSE[/color][color=#008000] [color=#0]100[/color] ' Pause 1/10 s[/color] [color=#0000ff]LOOP[/color][color=#008000] ' Repeat main routine[/color]
Example Program – TestTiltReceiver.bs2
√······· Connect your programming cable to your Radio Controlled Boe-Bot.
√······· Enter, save, and run TestTiltReceiver.bs2.
√······· This is the cool part - try tilting your RF tilt controller and observe the Debug Terminal, which is now receiving messages from your radio controlled Boe-Bot.· The Debug Terminal should still report the correct measurements for its x and y-axes that are wirelessly transmitted by your RF tilt controller.
√······· Make sure it's working right; trouble-shoot the circuit and/or code if necessary.
[color=#008000]' TestTiltReceiver.bs2[/color] [color=#008000]' Test accelerometer readings.[/color] [color=#008000]'{$STAMP BS2}[/color] [color=#008000]'{$PBASIC 2.5}[/color] [color=#008000][color=#0]x VAR Word[/color] ' Left/right tilt[/color] [color=#008000][color=#0]y VAR Word[/color] ' Forward/backward tilt[/color] [color=#0000ff]DEBUG[/color] [color=#ff0000]"Beep!!!"[/color][color=#008000] ' Test piezospeaker[/color] [color=#0000ff]FREQOUT[/color] 4, 2000, 3000 [color=#0000ff]DEBUG[/color] [color=#800080]CLS[/color][color=#008000][color=#0],[/color] [/color][color=#ff0000]" x y"[/color][color=#008000][color=#0],[/color] [/color][color=#800080]CR[/color][color=#008000] ' Axis headings[/color] [color=#0000ff]DO[/color][color=#008000] ' Begin main routine[/color] [color=#008000] ' Get serial measurements from RF receiver.[/color] [color=#0000ff]SERIN[/color][color=#008000] [color=#0]11, 16780, [noparse][[/noparse][/color] [/color][color=blue]WAIT[/color]([color=#ff0000]"!"[/color][color=#008000][color=#0]),[/color] ' Wait for start character[/color] [color=#008000] [color=#0]x.HIGHBYTE, x.LOWBYTE,[/color] ' Get x-axis word[/color] [color=#008000] [color=#0]y.HIGHBYTE, y.LOWBYTE ][/color] ' Get y-axis word[/color] [color=#008000] ' Convert raw tilt measurements to a convenient scale.[/color] x = (x MIN 1875 MAX 3125) - 1875 / 5 - 125 y = (y MIN 1875 MAX 3125) - 1875 / 5 - 125 [color=#008000] ' Display x AND y tilt measurements.[/color] [color=#0000ff]DEBUG[/color] [color=#800080]CRSRX[/color][color=#008000][color=#0], 0,[/color] [/color][color=#ff0000]"("[/color], [color=#000080]SDEC3[/color][color=#008000][color=#0] x,[/color] [/color][color=#ff0000]", "[/color], [color=#000080]SDEC3[/color][color=#008000][color=#0] y,[/color] [/color][color=#ff0000]")"[/color][color=#008000][color=#0],[/color] [/color][color=#800080]CLREOL[/color] [color=#0000ff]PAUSE[/color][color=#008000] [color=#0]100 [/color]' Pause 1/10 s[/color] [color=#0000ff]LOOP[/color][color=#008000] ' Repeat main routine[/color]
·
Your Turn - SEROUT Vs. DEBUG
The .HIGHBYTE and .LOWBYTE operators are not often used in DEBUG commands because they really don't cause the Debug Terminal to display meaningful data.· With DEBUG and DEBUGIN commands, formatters such as SDEC and DEC4 are the more common choices for displaying the x and y-axis measurements.· Let's take a closer look at the DEC4 operator.· It takes four characters to send the x-axis measurement, and four more to send the y-axis measurement.· That's a total of eight bytes, nine if you add the exclamation point.· In contrast, the .HIGHBYTE and .LOWBYTE modifiers get the job done with only two bytes each, so that's five bytes including the "!".·
·
Why does this matter?· Because we really don't want to exceed 40 ms between servo pulses, and guess what, two accelerometer axis measurements and five bytes at 2400 bps takes a total of 40 ms.· In the serial messages we are using, each byte has a start bit, stop bit, and eight data bits.· So, how much longer would it take if the programs were to use the DEC4 formatter?· Since the transmit rate is 2400 bits per second, each bit takes 1/2400 of a second, or 0.417 ms.· Multiply this by 40 more bits, and that's 16.7 more ms for a total of almost 57 ms.· So, adding four more bites causes too much time to elapse between servo pulses, which will cause the servos to perform very poorly.
·
All that said, it's still a good idea to see how it can work while there are no servos running.·
·
√······· Modify the SEROUT command in TestTiltTransmitter.bs2 so that it looks like this:
·
······ SEROUT 10, 16780, [noparse][[/noparse] "!", DEC4 x, DEC4 y]··················
·
√······· Modify the SERIN command in TestTiltReceiver.bs2 so that it looks like this:
·
·······SERIN 11, 16780, [noparse][[/noparse]WAIT("!"), DEC4 x, DEC4 y]
·
√······· Repeat the tests for the modified versions of TestTiltTransmitter.bs2 and TestTiltReceiver.bs2.
Radio Controlled Boe-Bot Application
To keep the message rate in the 40 ms range, all the pauses and DEBUG commands in TestTiltTransmitter.bs2 have been removed, and the modified program was saved as RfTiltTransmitter.bs2.· This program sends x and y coordinates every 40.6 ms, which will keep the Boe-Bot's servos going at a reasonable rate.· Boe-BotReceiver.bs2 receives and stores the x and y-axis values sent by the transmitter.· Then, it uses these values to decide what pulses to send to the servos.
Example Program – RfTiltTransmitter.bs2.
√······· Connect the RF tilt controller to your serial cable.
√······· Enter, save, and run RfTiltTransmitter.bs2
√······· Disconnect the serial cable from the tilt controller.
[color=#008000]' RfTiltTransmitter.bs2[/color] [color=#008000]' Transmit tilt data every 41 ms.[/color] [color=#008000]'{$STAMP BS2}[/color] [color=#008000]'{$PBASIC 2.5}[/color] [color=#008000][color=#0]x VAR Word[/color] ' Left/right tilt[/color] [color=#008000]y VAR Word ' Forward/backward tilt[/color] [color=#0000ff]DEBUG[/color] [color=#ff0000]"Program running..."[/color][color=#008000] ' Test piezospeaker[/color] [color=#0000ff]FREQOUT[/color] 4, 2000, 3000 [color=#0000ff]DO[/color][color=#008000] ' Begin main routine[/color] [color=#0000ff]PULSIN[/color][color=#008000] [color=#0]6, 1, x[/color] ' Get X-axis tilt[/color] [color=#0000ff]PULSIN[/color][color=#008000] [color=#0]7, 1, y[/color] ' Get Y-axis tilt[/color] [color=#008000] ' Send tilt at 2400 bps, non-inverted.[/color] [color=#0000ff]SEROUT[/color] 10, 16780, [noparse][[/noparse] [color=#ff0000]"!"[/color][color=#008000], ' Start character[/color] [color=#008000] [color=#0]x.HIGHBYTE, x.LOWBYTE,[/color] ' X-axis word[/color] [color=#008000] [color=#0]y.HIGHBYTE, y.LOWBYTE][/color] ' Y-axis word[/color] [color=#008000] ' DO NOT Display x AND y tilt measurements; DO NOT pause.[/color] [color=#0000ff]LOOP[/color][color=#008000] ' Repeat main routine[/color]
·
Example Program – BoeBotReceiver.bs2
√······· Connect your radio controlled Boe-Bot to the programming cable.
√······· Enter, save, and run RfTiltControlledBoeBot.bs2.
√······· Disconnect the radio controlled Boe-Bot from the programming cable.
√······· Take your Boe-Bot for a test drive using your RF tilt controller to guide it.
[color=#008000]' -----[noparse][[/noparse] Title ]--------------------------------------------------------------[/color] [color=#008000]' RfTiltControlledBoeBot.bs2[/color] [color=#008000]' Boe-Bot navigates based on signals from an RF tilt controller. The[/color] [color=#008000]' tilt controller should be running RfTiltTransmitter.bs2[/color] [color=#008000]'{$STAMP BS2}[/color] [color=#008000]'{$PBASIC 2.5}[/color] [color=#008000]' -----[noparse][[/noparse] Constants ]----------------------------------------------------------[/color] Negative CON 1 [color=#008000]' Left/right tilt[/color] [color=#008000]' -----[noparse][[/noparse] Variables ]----------------------------------------------------------[/color] x VAR Word [color=#008000]' Left/right tilt[/color] y VAR Word [color=#008000]' Uphill/downhill tilt[/color] ySign VAR y.BIT15 [color=#008000]' Sign bit for y[/color] pulseLeft VAR Word [color=#008000]' Current left pulse value[/color] pulseLeftOld VAR Word [color=#008000]' Previous left pulse value[/color] pulseRight VAR Word [color=#008000]' Current right pulse value[/color] pulseRightOld VAR Word [color=#008000]' Previous right pulse value[/color] [color=#008000]' -----[noparse][[/noparse] Initialization ]-----------------------------------------------------[/color] [color=#0000ff]FREQOUT[/color] 4, 2000, 3000 [color=#008000]' Beep to signify program start[/color] pulseLeft = 750 [color=#008000]' Start with all pulses centered[/color] pulseRight = 750 pulseLeftOld = 750 pulseRightOld = 750 [color=#008000]' -----[noparse][[/noparse] Main Routine ]-------------------------------------------------------[/color] [color=#0000ff]DO[/color] [color=#008000]' Begin main routine.[/color] [color=#008000] ' This SERIN command gets the x and y-axis values from the[/color] [color=#0000ff]SERIN[/color] 11, 16780, [noparse][[/noparse][color=#000080]WAIT[/color]([color=#ff0000]"!"[/color]), x.HIGHBYTE, x.LOWBYTE, y.HIGHBYTE, y.LOWBYTE] [color=#008000] ' Scale to -62 to 62 with 0 -> level.[/color] x = 62 - ((x MIN 1875 MAX 3125) - 1875 / 10) y = 62 - ((y MIN 1875 MAX 3125) - 1875 / 10) [color=#008000] ' Navigation decisions[/color] [color=#0000ff]IF[/color] (ABS(x) > 12) [color=#0000ff]OR[/color] (ABS(y) > 12) [color=#0000ff]THEN[/color] [color=#008000]' Is it tilted enough?[/color] pulseLeft = 750 - y [color=#008000]' Forward/backward pulses[/color] pulseRight = 750 + y [color=#0000ff]IF[/color] (ySign = Negative) [color=#0000ff]OR[/color] (ABS(y) < 12) [color=#0000ff]THEN[/color][color=#008000] ' Turning for forward.[/color] pulseLeft = pulseLeft - x pulseRight = pulseRight - x [color=#0000ff]ELSE[/color] [color=#008000]' Turning for backward.[/color] pulseLeft = pulseLeft + x pulseRight = pulseRight + x [color=#0000ff]ENDIF[/color] [color=#0000ff]ELSE[/color] [color=#008000]' Stay still[/color] pulseLeft = 750 pulseRight = 750 [color=#0000ff]ENDIF[/color] [color=#008000] ' Increment/decrement routine only adjusts pulse durations by 8 at a time.[/color] [color=#0000ff]IF[/color] pulseLeft > (pulseLeftOld + 6) [color=#0000ff]THEN[/color] pulseleft = pulseLeftOld + 6 [color=#0000ff]IF[/color] pulseLeft < (pulseLeftOld - 6) [color=#0000ff]THEN[/color] pulseLeft = pulseLeftOld - 6 [color=#0000ff]IF[/color] pulseRight > (pulseRightOld + 6) [color=#0000ff]THEN[/color] pulseRight = pulseRightOld + 6 [color=#0000ff]IF[/color] pulseRight < (pulseRightOld - 6) [color=#0000ff]THEN[/color] pulseRight = pulseRightOld - 6 pulseLeft = pulseLeft MIN 650 MAX 850 [color=#008000]' Keep 650 <= durations <= 850[/color] pulseRight = pulseRight MIN 650 MAX 850 pulseLeftOld = pulseLeft [color=#008000]' Remember old values[/color] pulseRightOld = pulseRight [color=#0000ff]PULSOUT[/color] 13, pulseLeft [color=#008000]' Send control pulses to servos[/color] [color=#0000ff]PULSOUT[/color] 12, pulseRight [color=#0000ff]LOOP[/color] [color=#008000]' Repeat main routine.[/color]
How RfTiltControlledBoeBot.bs2 Works
This example program is a modified version of UphillBoeBot.bs2 from Boe-Bot® Robot Navigation·with Accelerometer Incline Sensing.··If you have not already done so, it would be a good idea to try out this activity and familiarize yourself with the coding techniques.
·
Instead of two PULSIN commands to get the x and y-axis tilt values, this program uses a SERIN command to get the x and y-axis tilt values that are relayed by the RF receiver.· The SERIN command waits to receive the "!" character, then stores the next four bytes to reconstruct the x and y-axis word variable values.· After this SERIN command, the x and y variables store the raw accelerometer measurements.· This makes the rest of the program easier because it can be written as though the accelerometer is on-board.· ·
·
· SERIN 11, 16780, [noparse][[/noparse]WAIT("!"), x.HIGHBYTE, x.LOWBYTE, y.HIGHBYTE, y.LOWBYTE]
·
These scaling and offset commands differ from UphillBoeBot.bs2.· The narrower range of values makes the RF tilt controller more friendly in terms of fine motor control with a range of -62 to + 62 instead of -625 to + 625. ·The statements now convert the highest measurement into the lowest result, and visa versa.· They do so by subtracting the scaled accelerometer measurements from 62 instead of subtracting 62 from the scaled accelerometer measurements.· This change converts a hill climbing Boe-Bot into a hill descending Boe-Bot.·
·
· x = 62 - ((x MIN 1875 MAX 3125) - 1875 / 10)
· y = 62 - ((y MIN 1875 MAX 3125) - 1875 / 10)
·
The navigation decisions are also slightly different from UphillBoeBot.bs2.· They have been modified to make driving your Boe-Bot with a tilt controller easier and more intuitive.· The statement IF (ABS(x) > 12) OR (ABS(y) > 12) THEN creates a deadband so that the Boe-Bot doesn't immediately react as soon as you just barely tilt the RF tilt controller.· When both x and y are in this range, the ELSE statement at the bottom of the code block makes the Boe-Bot hold still.· Once you tilt the controller far enough to make x or y greater than 12 or less than -12, y is subtracted from pulseLeft and added to pulseRight.· When y is negative, it makes the Boe-Bot go backwards, if it's positive, the Boe-Bot goes forwards.· After the forward pulse values have been determined, the turn can be mixed in.· For forward motion, the x tilt values have to be subtracted from both pulseLeft and pulsRight to get that natural forward turning control.· When the Boe-Bot is backing up, the turn directions have to be reversed to keep the control intuitive, so instead of subtracting x from pulseLeft and pulseRight, x is added to these variables.·
·
· ' Navigation decisions
· IF (ABS(x) > 12) OR (ABS(y) > 12) THEN····
··· pulseLeft· = 750 - y····················
··· pulseRight = 750 + y
··· IF (ySign = Negative) OR (ABS(y) < 12) THEN·
····· pulseLeft =· pulseLeft· - x
····· pulseRight = pulseRight - x
··· ELSE···························· ········
····· pulseLeft· = pulseLeft· + x
····· pulseRight = pulseRight + x
··· ENDIF
· ELSE······································
··· pulseLeft· = 750
··· pulseRight = 750
· ENDIF
·
The remainder of the program, especially the ramping routine, is introduced and explained in more detail in·Boe-Bot® Robot Navigation·with Accelerometer Incline Sensing.·
Your Turn - Making Time for Sensors
There are many ways to make time for other sensors.· The easiest check for RF messages and read the sensors between alternate servo pulses.· ····
·
√······· Add the declaration operation VAR Bit to the variables section.
√······· Add this command operation = ~ operation at the beginning of the main routine, on the line just below DO.·
√······· Use a SELECT...CASE statement evaluates the operation variable that executes the existing main routine for CASE is 0, and a new routine (add PAUSE 40 for now) when case is 1.· That's enough time to check a lot of sensors.
√······· Try your modified code out and decide whether or not the change in performance is acceptable.
Summary
The contents of two word variables can be sent from one BASIC Stamp to another via serial communication, with the SEROUT and SERIN commands.· The information can be transmitted with a pair of wires, one for signal and one for ground.· A radio transmitter and receiver can replace the pair of wires, for "wireless" serial communication.· This means of communicating values was used to transmit the x and y-axis tilt values from an RF tilt controller to the Boe-Bot.· When the Boe-Bot receives the values, the rest of the programming can be done many of the accelerometer programming techniques covered in earlier chapters.
·
The SERIN and SEROUT commands offer the same user-friendly formatters and control characters that DEBUG and DEBUGIN feature, and much more.· These arguments that make the display of values more meaningful also take longer to transmit.· The .HIGHBYTE and .LOWBYTE modifiers can be used parse word variables into two byte values.· This technique is more efficient than using formatters such as DEC4, SDEC, BIN, etc.·
Questions
1.······ How many wires does it take to replace the link between RF transmitter and receiver?
2.······ When replacing the RF transmitter/receiver with wires, what role does each wire play?
3.······ What are the Pin, BaudMode, and DataItem arguments in this command: SEROUT 16, 16468, [noparse][[/noparse]"Hello"]?
4.······ How would you modify this command (SEROUT 16, 16468, [noparse][[/noparse]"Hello"]) so that transmits the "Hello" message to P5?
5.······ How would you modify this command so that it sends the data at
6.······ What does the WAIT formatter do in a SERIN command?
7.······ Why does the SERIN command need variables between the square brackets?
8.······ If x = "ab", what will DEBUG x.HIGHBYTE display?
9.······ If x = "ab", what will DEBUG x.LOWBYTE display?
10.·· What's the most time you want to elapse between servo pulses on the Boe-Bot?
11.·· What does the command IF (ABS(x) > 12) OR (ABS(y) > 12) THEN do for your RC tilt controller's behavior?
12.·· If y is negative, what direction do pulseLeft· = 750 - y and pulseRight = 750 + y make the Boe-Bot go?
13.·· What do the commands pulseLeft =· pulseLeft· - x and pulseRight = pulseRight - x
Comments
bugg
Oh, by the way, that sounds like a really cool project.
The next step would be to have two Boe-Bots communicating, telling each other were not
to go.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
So many projects, so little time.
I have BS2 on Tx side connected with a 27988 transceiver(serial mode +5V) and BS2p on Rx side connected with 27988 transceiver(serial mode +5V) also. I want to know what baudmode should I set on both side. It is becasue I had tried different setting (9600bps) on both side, still no message on Rx. It only display (125, -125).
Thanks,
Yet why are their hopes shattered? As a student, when I have a problem I go directly to my teachers. They provide me with the guidance that I need, and point me in the right direction. What's different about your students, I wonder? Perhaps they've just traded one "fool" for another.
(post edited by kgracey to remove offensive suggestions that are not appropriate for any sixth graders who may visit the Parallax forums). - Ken
Post Edited By Moderator (Ken Gracey (Parallax)) : 10/21/2008 2:48:23 AM GMT
This forum post is fairly advanced, and is recommended after completing the material in Robotics with the Boe-Bot and the accelerometer introduction. There’s a For more information box at the beginning of this post, which states:
·When you get to the Hill Climbing Boe-Bot post there’s a similar information box that states:
The Robotics with the Boe-Bot textbook (~350 pages) and kit get used by a variety of grade levels and course subjects. Grade levels typically range from 10th grade to university, with students going through the book from cover to cover. (The more advanced the course, the more quickly the material gets covered.) Courses the book and kit typically get incorporated into include: computer programming, robotics, electronics, and pre-engineering. Some teachers do use this text/kit for younger groups like 8th & 9th grades, but they go through the material with a fine tooth comb first, and then develop custom handouts that simplify and encapsulate the concepts and techniques presented by the text.
To ensure success with Parallax educational products, we have a several resources available. This forum is an important resource, and the best way to get answers to solve a technical problem is to post as much information as you can, including the parts you are using, digital pictures of your setup, and the .bs2 files. And, the better your netiquette, the more help you’ll get. Additional teacher resources are documented in the fine print in our Stamps in Class textbooks. In many cases, our Technical Support Department can provide quick and effective trouble shooting for Parallax products. To find out email, web, and telephone contact information for Tech Support, go to www.parallax.com and click the Support tab.
Post Edited By Moderator (Jessica Uelmen (Parallax)) : 6/8/2009 10:36:24 PM GMT
If you have any more questions, you should start a new thread.
Happy Developing!
Jessica
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Jessica Uelmen
Education Department
Parallax, Inc.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
WWW.HAPB.NET
"Don't ask yourself what the world needs - ask yourself what makes you come alive, and then go do it." - H.T.Whitman
Yes, the 220 Ω resistor is used for current limiting purposes only. Basically it's a habit we like to get people into in order to prevent the I/O pin from getting damaged. The resistor acts as a buffer in case one accidentally sends a HIGH signal to the BASIC Stamp's I/O pin while the pin is receiving a LOW signal, preventing a short circuit.
Jessica
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Jessica Uelmen
Education Department
Parallax, Inc.
Dan Toborowski
The results you're describing could be caused by low batteries. Have you tried using brand new batteries and then running the program again?
If not, could you please post your code?· I know you mentioned that you've copied it directly, but perhaps something didn't copy correctly.
Jessica
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Jessica Uelmen
Education Department
Parallax, Inc.
Post Edited (Jessica Uelmen (Parallax)) : 4/29/2009 4:31:49 PM GMT
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Dan Taylor
Dan Toborowski
President
Central Illinois Robotics Club
www.circ.mtco.com
You should be able to cut and paste the code that's in the article.
There's a file download link at the very bottom of that loooong first post!
-Stephanie Lindsay
Editor, Parallax Inc.
As it turns out, the source code was not included in the original·zip file.· I have now attached it and it can be downloaded at the top of the original forum post.· Or as a shortcut, here.
Happy Developing!
Jessica
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Jessica Uelmen
Education Department
Parallax, Inc.
I understand·how to move a servo to a desired position using PULSEOUT commands imbedded in a FOR loop like so:
FOR counter X to Y
· PULSEOUT, 12, Duration
· PAUSE 20
But this method will not work for my application as I need to control the servos position relative to the accelerometer readings in real-time. I understand how to read the accelerometer and use the data to produce an adjusted output just·like the tilt controlled BOE bot but I'm not sure which variable to adjust for controlling servo position·instead·of speed then how to send these instructions to the servo in real-time.
Any advice would be appreciated. Thanks!
For examples of getting pushbutton state data from the transmitting board to the receiving board, you might be able to integrate some of the concepts from Jessica's Wireless Musical Keyboard Stamps in Class mini-project. There,·pushbuttons on one board play different tones on a piezospeaker on anthother board.
-Steph Lindsay
If I might make a suggestion - next time you have a question that's not directly related to a forum post, try posting a new thread. Since this post already has 2 pages, sometimes your question will get lost if people aren't monitoring the forum directly. You can always link to old threads if you want to reference them in new posts!
Now, to answer your question - you can use the same approach! The only difference between the Parallax Standard Servo and the Parallax Continuous Rotation Servo is that the Standard Servo has mechanical stoppers to confine the servo to a 180-degree range. When you send PULSOUT durations to the Standard Servo it controls the position, whereas with the Continuous Rotation servo it controls the speed and direction.
Take the command PULSOUT 12, 850. When this command is sent to the Standard Servo, it rotates to roughly (and I mean roughly) the 11 o'clock position. When this same command is sent to the Continuous Rotation Servo rotates full speed counter-clockwise. Why? The simplest answer is because the mechanical stoppers in the Continuous Rotation Servo have been removed, so the servo is always trying to get to that 11 o'clock position but can't because there's no stopping point for reference. The only reference is that a PULSOUT duration of 750 is stop - because you calibrated it to do that.
Now for your application you will have to adjust the MIN and MAX values for the pulseLeft and pulseRight values since the PULSOUT durations will be larger than those for moving the BOE-Bot. Other than that you can pretty much use the same code. You are right in saying that the standard servos won't have a need to "turn", but if you're still planning to use 2, you can have one move if the board is tilted forward and back and the other if it's tilted left and right.
I hope this helps. Have fun playing around with the code, and let me know if you have any questions!
Jessica
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Jessica Uelmen
Education Department
Parallax, Inc.
I am doing a tilt controlled boe-bot with others for a school project and we are having troubles similar with Dans. The bot moves in jerky movements, but only when moving forward. And it suffers from little spastic twitches, even when the RF transmitter is totally off. We tried replacing the batteries several times, and thats definitely not it. If it matters, we are using then 433Mhz transceiver instead of transmitter. We double-triple-quadruple checked the code and it is all identical, the only difference being on the transmitter side we floated a high on p11 to enable the transmit on the transceiver. Any suggestions? thanks!
EDIT: nevermind, problem was resolved. For anyone elses' future reference, the Ping accessory for the boe bot will interfere with the transceiver if it is connected to the board and in close proximity.
Post Edited (sovereign) : 1/20/2010 8:15:41 PM GMT