How to Boe-Bot Robot with Easy Bluetooth Module
Jessica Uelmen
Posts: 490
How to – Boe-Bot Robot with Easy Bluetooth Module
·
Bluetooth is widely used for various communication devices today including cell phones, headsets, and computer mice and keyboards. In this activity, we will demonstrate how to wirelessly control your Boe-Bot’s movements through a PC using the Easy Bluetooth Module.
View Video Introduction (YouTube)
Download Source Code – BoeBotEasyBluetooth_SourceCode.zip
Getting Started
If you are new to the BASIC Stamp microcontroller or to programming, it would be a good idea to review the following before continuing:
√······· Complete Chapters 1-4 in Robotics with the Boe-Bot
√······· Try the “Mini Project” Wireless Musical Keyboard to learn the basics of RF communication
√······· Review the Easy Bluetooth Documentation v1.1 and follow all set-up instructions
Parts List
(1) Boe-Bot® Robot, assembled and tested
(1) Easy Bluetooth Module
What is Bluetooth?
Bluetooth is a wireless communication protocol that uses radio frequencies in the 2.4GHz range to exchange data over short distances from fixed and mobile devices.· This allows electronic devices that formally had to be connected via cables (such as computers, cell phones, headsets, keyboards, mice, printers and PDAs) to be connected wirelessly on one secure Bluetooth network.·
·
Bluetooth devices communicate through what’s known as a PAN (Personal Area Network), in which only Bluetooth devices that you have enabled can communicate.· This prevents other Bluetooth devices in the area from interfering with your network.· However, say you want to use a lot of Bluetooth devices on one network, how can it differentiate each connection?· Basically, each PAN consists of many different frequencies that each device can communicate on; and in order to avoid interference from multiple devices, each device “hops” to a new frequency many times per second.
·
Even with frequency hopping, two Bluetooth devices will occasionally end up on the same frequency, and they have built-in protection against the resulting garbled data.· They use an error correction technique called a Cyclical Redundancy Check or CRC.· The CRC makes it possible to figure out when data that was received doesn’t match the data that was sent.· The transmitter performs calculations on the packet before it sends it, and it sends the result of its calculations along with the packet.· The receiver performs the same calculations, and if its result doesn’t match it requests a second copy of the packet.
Bluetooth and the Boe-Bot
The two most common wireless BASIC Stamp configurations that involve the Easy Bluetooth Module are:
1)···· A BASIC Stamp communicating with a Bluetooth equipped PC (Figure 1)
2)···· Two BASIC Stamps using two Easy Bluetooth Modules to communicate
Figure 1 – PC ↔ Boe-Bot Robot Bluetooth Communication
We will use Configuration 1 for this activity, a BASIC Stamp using the Easy Bluetooth Module to communicate with a Bluetooth equipped PC.· In this case, the Boe-Bot Robot’s BASIC Stamp is running code that sends user prompts to the PC so that you can enter navigation instructions using the BASIC Stamp Editor’s Debug Terminal.· The PC’s Bluetooth radio and software combined with the Easy Bluetooth Module plugged into the Board of Education platform’s AppMod header makes it possible for the two to use serial communication over the Bluetooth wireless connection.
Initializing a Connection·
Before attempting any code, it’s a good idea to verify that your PC and the Boe-Bot are communicating properly.· Here’s a quick way for you to confirm that a connection has been established:
√······· Follow the instructions in the Easy Bluetooth Documentation v1.1 for connecting the Easy Bluetooth Module to your Board of Education + BASIC Stamp 2.
√······· Follow the instructions in the Easy Bluetooth Documentation v1.1 for setting up a Bluetooth connection between your PC and Easy Bluetooth module with your computer's Bluetooth manager.
√······· Open the BASIC Stamp Editor and select Preferences from the Edit menu.
√······· In the Debug Port tab, select Edit Ports.
√······· As shown in Figure 2, right-click the COM port entry that matches the Outgoing COM Port determined when you set-up the Easy Bluetooth module and select Include Port.
Figure 2 – Including the Bluetooth COM Port
√······· Enter and run TestBluetoothConnection.bs2 and
√······· Unplug the serial cable from your Boe-Bot.
√······· Open a new Debug Terminal by pressing “Ctrl+D”
√······· Select the Outgoing COM port you enabled in the Edit Ports window (See Figure 3)
√······· Click the Debug Terminal’s transmit windowpane, and start typing characters.
√······· Verify that the Debug Terminal displays results similar to Figure 3.
[color=#008000]' TestBluetoothConnection.bs2[/color] [color=#008000]' This program displays a bi-directional communication between the Easy[/color] [color=#008000]' Bluetooth and the Debug Terminal.[/color] [color=#008000]' {$STAMP BS2}[/color] [color=#008000]' {$PBASIC 2.5}[/color] [color=#000000]RX PIN 2 [/color][color=#008000]' RX of the Easy Bluetooth[/color] [color=#000000]TX PIN 0 [/color][color=#008000]' TX of the Easy Bluetooth[/color] [color=#000000]Baud CON 84 [/color][color=#008000]' Baud set at 9600[/color] [color=#000000]myByte VAR Byte [/color][color=#008000]' Byte to establish connection & used for workspace[/color] [color=#020FC0]PAUSE[/color][color=#000000] 250 [/color][color=#008000]' Waits 1/4 second[/color] [color=#020FC0]SERIN[/color][color=#000000] RX, Baud, [noparse][[/noparse]myByte] [/color][color=#008000]' Waiting for byte[/color] [color=#000000]myByte = 0 [/color][color=#008000]' Clear the byte value[/color] [color=#020FC0]SEROUT[/color][color=#000000] TX[/color][color=#000000], Baud, [noparse][[/noparse] [/color][color=#800080]CLS[/color][color=#000000], [/color][color=#008000]' Send instructions to the Debug[/color] [color=#ff0000]"Click the Debug Terminal's"[/color][color=#000000], [/color][color=#800080]CR[/color][color=#000000], [/color][color=#008000]' Terminal[/color] [color=#ff0000]"transmit windowpane"[/color][color=#000000], [/color][color=#800080]CR[/color][color=#000000],[/color] [color=#ff0000]"and then Press any key: "[/color][color=#000000], [/color][color=#800080]CR [/color][color=#000000]][/color] [color=#020FC0]DO[/color] [color=#020FC0]DO[/color] [color=#020FC0]UNTIL[/color][color=#000000] myByte > 0 [/color][color=#008000]' Wait until byte is valid[/color] [color=#020FC0]SERIN[/color] [color=#020FC0]RX[/color][color=#000000], Baud, [noparse][[/noparse]myByte] [/color][color=#008000]' Receive byte[/color] [color=#020FC0]LOOP[/color] [color=#020FC0]SEROUT[/color][color=#000000] TX[/color][color=#000000], Baud, [/color][color=#ff0000][noparse][[/noparse]"You pressed "[/color][color=#000000], myByte, [/color][color=#ff0000]"."[/color][color=#000000], [/color][color=#800080]CR[/color][color=#000000]] [/color][color=#008000]' Display byte received[/color] [color=#000000] myByte = 0 [/color][color=#008000]' Clear the byte value[/color] [color=#020FC0]LOOP[/color]
[/size]Figure 3 – Debug Display when Running TestBluetoothConnection.bs2
How TestBluetoothConnection.bs2 Works
In most PBASIC examples where the BASIC Stamp communicates with the Debug Terminal the DEBUG and DEBUGIN commands are used.· DEBUG and DEBUGIN are actually special cases of the more general SEROUT and SERIN commands.· While the SEROUT and SERIN commands have arguments for setting serial communication pins, baud rate, and other parameters, the DEBUG and DEBUGIN commands communicate only through the BASIC Stamp’s programming connection pins at 9600 bps.· The Debug Terminal always “pops up” whenever you run a program that uses DEBUG because the BASIC Stamp editor detects that the DEBUG command has been used, so it automatically launches the Debug Terminal after downloading the program.
·
In TestBluetoothConnection.bs2, we aren’t communicating from the BASIC Stamp to the computer through a serial cable.· Instead, we’re communicating directly from the Bluetooth connection in the PC to the Easy Bluetooth module to the BASIC Stamp on the Boe-Bot. ·Therefore, we need to set the COM Port in the Debug Terminal to the COM Port that the Easy Bluetooth Module uses to send signals.
·
The first portion of the TestBluetoothConnection.bs2 waits for a byte to be received before continuing with the rest of the program.· This gives the user time to open a Debug Terminal and select the right COM port before receiving instructions on how to continue.· Once the user has pressed a button, instructions are then sent from the Easy Bluetooth Module to the Debug Terminal using the SEROUT command:
·
PAUSE 250······
SERIN RX, Baud, [noparse][[/noparse]myByte]
myByte = 0
·
SEROUT TX, Baud, [noparse][[/noparse] CLS,····························
·················· "Click the Debug Terminal's", CR,
·················· "transmit windowpane", CR,
··············· ···"and then Press any key: ", CR ]
·
Using the SERIN command, the Easy Bluetooth Module then keeps receiving bytes from the PC’s keyboard, and stores them in a variable named myByte.· Using the SEROUT command, the module then sends the string “You pressed”, the received byte (myByte), and then the string “.” back to the PC to display in the Debug Terminal.· If the characters displayed in the Debug Terminal are the same as what was typed, the PC and the Easy Bluetooth Module are communicating properly.
·
DO
· DO UNTIL myByte > 0
··· SERIN RX, Baud, [noparse][[/noparse]myByte]
· LOOP
·
· SEROUT TX, Baud, [noparse]/noparse]"You pressed "[/color][/size][/font], myByte, [font=Times New Roman][size=2][color=#ff0000]"."[/color][/size][/font], [font=Times New Roman][size=2][color=#800080]CR[/color][/size][/font
· myByte = 0
LOOP
Wireless Movement Using the Debug Terminal
The TerminalBoeBotControl.bs2·example program·will prompt you for the number of pulses to send to the servos, and then the pulse width to transmit to each servo.· The program sends about 42 pulses per second, so 42 pulses would give you 1 second of run time, 84 would give you 2 seconds, and so on.· For speed control, 800 is about full speed counterclockwise, 700 is full speed clockwise, and 750 is stop.· If you want a wheel to go half speed counter clockwise, try about 775.· Half speed clockwise would be about 725, and so on.·
[color=#008000]' TerminalBoeBotControl.bs2[/color] [color=#008000]' {$STAMP BS2}[/color] [color=#008000]' {$PBASIC 2.5}[/color] [color=#000000]RX PIN 2 [/color][color=#008000]' RX of the Easy Bluetooth[/color] [color=#000000]TX PIN 0 [/color][color=#008000]' TX of the Easy Bluetooth[/color] [color=#000000]Baud CON 84 [/color][color=#008000]' Baud set at 9600[/color] [color=#000000]myByte VAR Byte [/color][color=#008000]' Byte to establish connection[/color] [color=#000000]pulseCnt VAR Word [/color][color=#008000]' Stores number of pulses[/color] [color=#000000]pulseLeft VAR Word [/color][color=#008000]' Pulse width for left servo[/color] [color=#000000]pulseRight VAR Word [/color][color=#008000]' Pulse width for right servo[/color] [color=#000000]counter VAR Word [/color][color=#008000]' Counter for FOR...NEXT loop[/color] [color=#020FC0]PAUSE[/color][color=#000000] 250 [/color][color=#008000]' Waits 1/4 second[/color] [color=#020FC0]SERIN[/color][color=#000000] RX, Baud, [noparse][[/noparse]myByte] [/color][color=#008000]' Waiting for byte[/color] [color=#000000]myByte = 0 [/color][color=#008000]' Clear the byte value[/color] [color=#020FC0]SEROUT[/color][color=#000000] TX, Baud, [noparse][[/noparse] [/color][color=#800080]CLS[/color][color=#000000],[/color] [color=#ff0000]"Click the Debug Terminal's"[/color][color=#000000],[/color] [color=#800080]CR[/color][color=#000000], [/color][color=#ff0000]"transmit windowpane and..." [/color][color=#000000]][/color] [color=#020FC0]PAUSE[/color][color=#000000] 250[/color] [color=#020FC0]DO[/color] [color=#008000] ' Prompt user for number of pulses[/color] [color=#020FC0]SEROUT[/color][color=#000000] TX[/color][color=#000000], BAUD, [noparse][[/noparse][/color][color=#800080]CR[/color][color=#000000], [/color][color=#800080]CR[/color][color=#000000], [/color][color=#ff0000]"Enter number of pulses: "[/color][color=#000000]][/color] [color=#008000] ' Recieve number of pulses from the PC[/color] [color=#020FC0]SERIN[/color][color=#000000] RX, Baud, [noparse][[/noparse][/color][color=#000080]DEC[/color][color=#000000] pulseCnt][/color] [color=#008000] ' Display number of pulses entered in the Debug Terminal[/color] [color=#020FC0]SEROUT[/color][color=#000000] TX[/color][color=#000000], Baud, [noparse][[/noparse][/color][color=#000080]DEC[/color][color=#000000] pulseCnt][/color] [color=#008000] ' Promput user for left servo pulse width[/color] [color=#020FC0]SEROUT[/color][color=#000000] TX[/color][color=#000000], Baud, [noparse][[/noparse] [/color][color=#800080]CR[/color][color=#000000], [/color][color=#ff0000]"Enter left servo"[/color][color=#000000],[/color] [color=#ff0000]"pulse width: "[/color][color=#000000]][/color] [color=#008000] ' Receive left servo pulse width from PC[/color] [color=#020FC0]SERIN[/color][color=#000000] RX, Baud, [noparse][[/noparse][/color][color=#000080]DEC[/color][color=#000000] pulseLeft][/color] [color=#008000] ' Display left servo pulse entered in the Debug Terminal[/color] [color=#020FC0]SEROUT[/color][color=#000000] TX[/color][color=#000000], Baud, [noparse][[/noparse][/color][color=#000080]DEC[/color][color=#000000] pulseLeft][/color] [color=#008000] ' Prompt user for right servo pulse width[/color] [color=#020FC0]SEROUT[/color][color=#000000] TX[/color][color=#000000], Baud, [noparse][[/noparse] [/color][color=#800080]CR[/color][color=#000000], [/color][color=#ff0000]"Enter right servo"[/color][color=#000000],[/color] [color=#ff0000]"pulse width: "[/color][color=#000000]][/color] [color=#008000] ' Receive right servo pulse width from PC[/color] [color=#020FC0]SERIN[/color][color=#000000] RX, Baud, [noparse][[/noparse][/color][color=#000080]DEC[/color][color=#000000] pulseRight][/color] [color=#008000] ' Display right servo pulse width in the Debug Terminal[/color] [color=#020FC0]SEROUT[/color][color=#000000] TX[/color][color=#000000], Baud, [noparse][[/noparse][/color][color=#000080]DEC[/color][color=#000000] pulseRight][/color] [color=#008000] ' All data necessary has been recieved,[/color] [color=#020FC0]SEROUT[/color][color=#000000] TX, Baud, [noparse][[/noparse][/color][color=#800080]CR[/color][color=#000000], [/color][color=#ff0000]"Executing..."[/color][color=#000000]][/color] [color=#020FC0]FOR[/color][color=#000000] counter = 1 [/color][color=#020FC0]TO[/color][color=#000000] pulseCnt[/color] [color=#020FC0]PULSOUT[/color][color=#000000] 13, pulseLeft[/color] [color=#020FC0]PULSOUT[/color][color=#000000] 12, pulseRight[/color] [color=#020FC0]PAUSE[/color][color=#000000] 20[/color] [color=#020FC0]NEXT[/color] [color=#020FC0]LOOP[/color]
How TerminalBoeBotControl.bs2 Works
Much like TestBluetoothConnection.bs2, this program receives data from the PC and then sends that information to the BASIC Stamp for processing.· First the user is prompted for information by a string sent from the Easy Bluetooth module.
·
SEROUT TX, BAUD, [noparse][[/noparse]CR, CR, "Enter number of pulses: "]
·
The SERIN command is then used to retrieve a decimal value from the user and store it to the proper variable (pulseCnt, pulseLeft, or pulseRight), and the SEROUT command displays what the user entered.
·
SERIN· RX, Baud, [noparse][[/noparse]DEC pulseLeft]
SEROUT TX, Baud, [noparse][[/noparse]DEC pulseLeft]
·
Once all the values have been gathered, the BASIC Stamp on the Boe-Bot uses the values in each variable to move the Boe-Bot according to the user’s input.
·
FOR counter = 1 TO pulseCnt
· PULSOUT 13, pulseLeft
· PULSOUT 12, pulseRight
· PAUSE 20
NEXT
Control the Boe-Bot Using Your Keyboard
Included in the Easy Bluetooth Documentation v1.1 is sample code to control your Boe-Bot using a GUI interface from RoboTech SRL (the manufacturer of the RoboTech RBT-001 Bluetooth serial module, used on the Easy Bluetooth Module). This application allows you to control your Boe-Bot using the arrow keys on your keyboard.· We can also accomplish the same thing using the same ideas introduced in TerminalBoeBotControl.bs2, the Debug Terminal, and the numerical pad or the letters “awdx” on a keyboard.· Figure 4 shows the layout of each set of keys and what movement they control.
·
Figure 4 – Keyboard Movement
Enter and run TerminalBoeBotControl_Keypad.bs2 and:
√······· Verify that your Boe-Bot moves in the correct direction according to Figure 4
√······· An arrow is displayed in the Debug Terminal depicting which direction the Boe-Bot is moving
[color=#008000]' TerminalBoeBotControl_Keypad.bs2[/color] [color=#008000]' Moves the Boe-Bot based on the numbers 2, 4, 6, 8 or the[/color] [color=#008000]' letters A, W, D, X.[/color] [color=#008000]' {$STAMP BS2}[/color] [color=#008000]' {$PBASIC 2.5}[/color] [color=#000000]RX PIN 2 [/color][color=#008000]' RX of the Easy Bluetooth[/color] [color=#000000]TX PIN 0 [/color][color=#008000]' TX of the Easy Bluetooth[/color] [color=#000000]ltServo PIN 13 [/color][color=#008000]' Left Servo Pin[/color] [color=#000000]rtServo PIN 12 [/color][color=#008000]' Right Servo Pin[/color] [color=#000000]FwdLtFast CON 850 [/color][color=#008000]' Left servo forward full speed[/color] [color=#000000]BwdLtFast CON 650 [/color][color=#008000]' Left servo backward full speed[/color] [color=#000000]FwdRtFast CON 650 [/color][color=#008000]' Right servo forward full speed[/color] [color=#000000]BwdRtFast CON 850 [/color][color=#008000]' Right servo backward full speed[/color] [color=#000000]Baud CON 84 [/color][color=#008000]' Baud set at 9600[/color] [color=#000000]myByte VAR Byte [/color][color=#008000]' Byte to establish connection[/color] [color=#000000]index VAR Word [/color][color=#008000]' READ index/character storage[/color] [color=#000000]character VAR Word[/color] [color=#000000]dirChar VAR Word [/color][color=#008000]' Stores directional character[/color] [color=#020FC0]DATA[/color] [color=#800080]CLS[/color][color=#000000],[/color] [color=#ff0000]" "[/color][color=#000000], [/color][color=#800080]CR[/color][color=#000000], [/color][color=#008000] ' 14[/color] [color=#ff0000]" "[/color][color=#000000], [/color][color=#800080]CR[/color][color=#000000], [/color][color=#008000]' 28[/color] [color=#ff0000]" | "[/color][color=#000000], [/color][color=#800080]CR[/color][color=#000000], [/color][color=#008000]' 42[/color] [color=#ff0000]" --o-- "[/color][color=#000000], [/color][color=#800080]CR[/color][color=#000000], [/color][color=#008000]' 56[/color] [color=#ff0000]" | "[/color][color=#000000], [/color][color=#800080]CR[/color][color=#000000], [/color][color=#008000]' 70[/color] [color=#ff0000]" "[/color][color=#000000], [/color][color=#800080]CR[/color][color=#000000], [/color][color=#008000]' 84[/color] [color=#ff0000]" "[/color][color=#000000], [/color][color=#800080]CR[/color] [color=#008000]' 98[/color] [color=#020FC0]PAUSE[/color][color=#000000] 250 [/color][color=#008000] ' Waits 1/4 second[/color] [color=#020FC0]SERIN[/color][color=#000000] RX, Baud, [noparse][[/noparse]myByte] [/color][color=#008000]' Waiting for byte[/color] [color=#000000]myByte = 0 [/color][color=#008000]' Clear the byte value[/color] [color=#008000]' Display background[/color] [color=#020FC0]FOR[/color][color=#000000] index = 0 [/color][color=#020FC0]TO[/color][color=#000000] 99[/color] [color=#020FC0]READ[/color][color=#000000] index, character[/color] [color=#020FC0]SEROUT[/color][color=#000000] TX[/color][color=#000000], Baud, [noparse][[/noparse]character][/color] [color=#020FC0]NEXT[/color] [color=#008000]' Let user know the program is running[/color] [color=#020FC0]SEROUT[/color][color=#000000] TX, BAUD, [noparse][[/noparse][/color][color=#800080]CR[/color][color=#000000], [/color][color=#800080]CR[/color][color=#000000], "Program Running..."][/color] [color=#020FC0]DO[/color] [color=#008000]' Recieve character from the PC[/color] [color=#020FC0]SERIN[/color][color=#000000] RX, Baud, [noparse][[/noparse]dirChar][/color] [color=#020FC0]IF[/color][color=#000000] (dirChar = [/color][color=#ff0000]"8"[/color][color=#000000]) OR (dirChar = [/color][color=#ff0000]"w"[/color][color=#000000]) [/color][color=#020FC0]THEN[/color] [color=#020FC0]GOSUB[/color][color=#000000] Forward[/color] [color=#020FC0]ELSEIF[/color][color=#000000] (dirChar = [/color][color=#ff0000]"2"[/color][color=#000000]) OR (dirChar = [/color][color=#ff0000]"x"[/color][color=#000000]) [/color][color=#020FC0]THEN[/color] [color=#020FC0]GOSUB[/color][color=#000000] Backward[/color] [color=#020FC0]ELSEIF[/color][color=#000000] (dirChar = [/color][color=#ff0000]"4"[/color][color=#000000]) OR (dirChar = [/color][color=#ff0000]"a"[/color][color=#000000]) [/color][color=#020FC0]THEN[/color] [color=#020FC0]GOSUB[/color][color=#000000] Left[/color] [color=#020FC0]ELSEIF[/color][color=#000000] (dirChar = [/color][color=#ff0000]"6"[/color][color=#000000]) OR (dirChar = [/color][color=#ff0000]"d"[/color][color=#000000]) [/color][color=#020FC0]THEN[/color] [color=#020FC0]GOSUB[/color][color=#000000] Right[/color] [color=#020FC0]ENDIF[/color] [color=#020FC0]LOOP[/color] [color=#000000]Forward:[/color] [color=#020FC0]SEROUT[/color][color=#000000] TX, BAUD, [noparse][[/noparse][/color][color=#800080]CRSRXY[/color][color=#000000], 7, 0, [/color][color=#ff0000]"*"[/color][color=#000000], [/color][color=#800080]CRSRXY[/color][color=#000000], 6, 1, [/color][color=#ff0000]"*"[/color][color=#000000], [/color][color=#800080]CRSRXY[/color][color=#000000], 8, 1, [/color][color=#ff0000]"*"[/color][color=#000000]][/color] [color=#020FC0]PULSOUT[/color][color=#000000] ltServo, FwdLtFast[/color] [color=#020FC0]PULSOUT[/color][color=#000000] rtServo, FwdRtFast[/color] [color=#020FC0]PAUSE[/color][color=#000000] 20[/color] [color=#020FC0]SEROUT[/color][color=#000000] TX, BAUD, [noparse][[/noparse][/color][color=#800080]CRSRXY[/color][color=#000000], 7, 0, [/color][color=#ff0000]" "[/color][color=#000000], [/color][color=#800080]CRSRXY[/color][color=#000000], 6, 1, [/color][color=#ff0000]" "[/color][color=#000000], [/color][color=#800080]CRSRXY[/color][color=#000000], 8, 1, [/color][color=#ff0000]" "[/color][color=#000000]][/color] [color=#020FC0]RETURN[/color] [color=#000000]Backward:[/color] [color=#020FC0]SEROUT[/color][color=#000000] TX, BAUD, [noparse][[/noparse][/color][color=#800080]CRSRXY[/color][color=#000000], 7, 6, [/color][color=#ff0000]"*"[/color][color=#000000], [/color][color=#800080]CRSRXY[/color][color=#000000], 6, 5, [/color][color=#ff0000]"*"[/color][color=#000000], [/color][color=#800080]CRSRXY[/color][color=#000000], 8, 5, [/color][color=#ff0000]"*"[/color][color=#000000]][/color] [color=#020FC0]PULSOUT[/color][color=#000000] ltServo, BwdLtFast[/color] [color=#020FC0]PULSOUT[/color][color=#000000] rtServo, BwdRtFast[/color] [color=#020FC0]PAUSE[/color][color=#000000] 20[/color] [color=#020FC0]SEROUT[/color][color=#000000] TX, BAUD, [noparse][[/noparse][/color][color=#800080]CRSRXY[/color][color=#000000], 7, 6, [/color][color=#ff0000]" "[/color][color=#000000], [/color][color=#800080]CRSRXY[/color][color=#000000], 6, 5, [/color][color=#ff0000]" "[/color][color=#000000], [/color][color=#800080]CRSRXY[/color][color=#000000], 8, 5, [/color][color=#ff0000]" "[/color][color=#000000]][/color] [color=#020FC0]RETURN[/color] [color=#000000]Left:[/color] [color=#020FC0]SEROUT[/color][color=#000000] TX, BAUD, [noparse][[/noparse][/color][color=#800080]CRSRXY[/color][color=#000000], 3, 3, [/color][color=#ff0000]"*"[/color][color=#000000], [/color][color=#800080]CRSRXY[/color][color=#000000], 4, 2, [/color][color=#ff0000]"*"[/color][color=#000000], [/color][color=#800080]CRSRXY[/color][color=#000000], 4, 4, [/color][color=#ff0000]"*"[/color][color=#000000]][/color] [color=#020FC0]PULSOUT[/color][color=#000000] ltServo, FwdRtFast[/color] [color=#020FC0]PULSOUT[/color][color=#000000] rtServo, FwdRtFast[/color] [color=#020FC0]PAUSE[/color][color=#000000] 20[/color] [color=#020FC0]SEROUT[/color][color=#000000] TX, BAUD, [noparse][[/noparse][/color][color=#800080]CRSRXY[/color][color=#000000], 3, 3, [/color][color=#ff0000]" "[/color][color=#000000], [/color][color=#800080]CRSRXY[/color][color=#000000], 4, 2, [/color][color=#ff0000]" "[/color][color=#000000], [/color][color=#800080]CRSRXY[/color][color=#000000], 4, 4, [/color][color=#ff0000]" "[/color][color=#000000]][/color] [color=#020FC0]RETURN[/color] [color=#000000]Right:[/color] [color=#020FC0]SEROUT[/color][color=#000000] TX, BAUD, [noparse][[/noparse][/color][color=#800080]CRSRXY[/color][color=#000000], 11, 3, [/color][color=#ff0000]"*"[/color][color=#000000], [/color][color=#800080]CRSRXY[/color][color=#000000], 10, 2, [/color][color=#ff0000]"*"[/color][color=#000000], [/color][color=#800080]CRSRXY[/color][color=#000000], 10, 4, [/color][color=#ff0000]"*"[/color][color=#000000]][/color] [color=#020FC0]PULSOUT[/color][color=#000000] ltServo, FwdLtFast[/color] [color=#020FC0]PULSOUT[/color][color=#000000] rtServo, FwdLtFast[/color] [color=#020FC0]PAUSE[/color][color=#000000] 20[/color] [color=#020FC0]SEROUT[/color][color=#000000] TX, BAUD, [noparse][[/noparse][/color][color=#800080]CRSRXY[/color][color=#000000], 11, 3, [/color][color=#ff0000]" "[/color][color=#000000], [/color][color=#800080]CRSRXY[/color][color=#000000], 10, 2, [/color][color=#ff0000]" "[/color][color=#000000], [/color][color=#800080]CRSRXY[/color][color=#000000], 10, 4, [/color][color=#ff0000]" "[/color][color=#000000]][/color] [color=#020FC0]RETURN[/color]
__________________________________________________ ___________________________
··
(c) 2009·by Parallax Inc - all rights reserved.··
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Jessica Uelmen
Education Department
Parallax Inc.
Post Edited (Jessica Uelmen (Parallax)) : 8/25/2010 6:27:25 PM GMT
Comments
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Jessica Uelmen
Education Department
Parallax, Inc.
Thank you for taking the time to write and test such a popular area of discussion for many parallax users, not just in the stamp in Class but also in the Robotics section.
I have seen many post's in the past just on this area alone with many members not really sure in witch direction to go, or even how to start it.
Thank you again,
Rob7
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Whit+
"We keep moving forward, opening new doors, and doing new things, because we're curious and curiosity keeps leading us down new paths." - Walt Disney
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Jessica Uelmen
Education Department
Parallax, Inc.
Thanks, great project.· Nice to have everything that is needed readily identified -- your article is exceptional.·
I still have two EmbeddedBlue Transceivers #30068.· Would there be a lot of changes in the source code to use these modules, and/or can they communicate with the Easy Bluetooth modules,·of which·I also plan to use?
Thanks,
Robert
There are a few changes to the source code to use it with the eb500, but not many. Andy actually posted an article for that module back in December, and you can see it here.
As for communication, it is possible, since they're both Bluetooth enabled. You will have to set one to be in search mode, which isn't the easiest thing in the world, but it can be done. I'm hoping to do a future Project of the Week demonstrating this, but we'll see what time allows.
Jessica
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Jessica Uelmen
Education Department
Parallax, Inc.
I could implement the "Control the Boe-Bot Using Your Keyboard" TerminalBoeBotControl_Keypad.bs2 code on my Boe-Bot. So I can run Boe-Bot via Easy Bluetooth Module, wirelessly.
Now I am trying to improve the code. I want that Boe Bot begins to move gradually increasing speed. Here is the code. It works fine.
It is easier and more precise to drive Boe-Bot remotely if it is increasing speed gradually while moving forward, backward, and making turns. And I've read in the book "Robotics with the Boe-Bot" by Andy Lindsay that it also saves batteries' energy and prolongs servos' life.
If one wants that Boe-Bot starts to move gradually increasing speed it is necessary to press "space" on the keyboard between "w"-forward, "x"-backward, "a"-left, "d"-right. If one wants that Boe-Bot starts to move at the highest possible speed just do not press "space" in-between.
Post Edited (Alex-VII) : 6/10/2010 3:46:52 PM GMT
So glad to see you're improving on the code, and your code looks great! And good call catching the unnecessary counter variable, I must have added it for some reason and then forgot to remove it, I'll remove it now!
I think the issue might be as simple as needing to reset the FwdLt, FwdRt, BwdLt, and BwdRt within your IF...THEN statements. Currently, it looks like you've got them reversed - the Bwd's are reset to 750 in the Fwd statement and the Fwd's are reset to 750 in the Bwd statement.
This seems like it would be the most simple solution, but I haven't tried it out. If it doesn't work, let me know, I've got some other ideas too. :]
-- Jess
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Jessica Uelmen
Education Department
Parallax Inc.
I think by now that pressing "space" on the keyboard between movements is a useful feature, not a bug.
Because, now there is a choice, if I want that the next move starts at the highest speed, I just do not press "space" on the keyboard in-between.
But if I want that Boe-Bots starts the next move gradually increasing speed I press "space" button on the keyboard, sending a blank space character via bluetooth connection to Boe-Bot's program, and Boe-Bots is gradually increasing speed.
I've changed my modification of your code above, so that the only way to reset starting speed to zero (750) is to press "space".
I've encountered and solved one more issue, which at first puzzled me, with the bluetooth navigation via Debug window. I had to make the keyboard's "Repeat delay" longer and "Repeat rate" slower at the control panel on my laptop. Otherwise the bluetooth connection was sometimes "overwhelmed" with large amount of characters to be transmitted.
I also noticed that if I comment out "PAUSE 20' then Boe-Bot moves faster and more smoothly, almost like via the GUI navigation. But I am not sure if it is safe not to use "PAUSE 20" in subs for servos. I've read in some post at this forum that "PAUSE 20" must always be used, however in code "Easy Bluetooth PBASIC.bs2" (http://www.parallax.com/Portals/0/Downloads/docs/prod/comm/30085_EasyBluetoothPBASIC.zip ), which comes with GUI for Easy Bluetooth Module "PAUSE 20" is not used.
I guess the role of "PAUSE 20" is played here by a delay of the character transmission via bluetooth connection.
Post Edited (Alex-VII) : 6/9/2010 1:56:02 PM GMT
I also use Easy Bluetooth
But I use ATMEGA8535
And uses two DC motors to control the wheels and a servo motor to control the camera.
Can you all help me in this program
so that I can control this robot with the keyboard on my laptop
I've tried many times but failed
I am a beginner, I use Code Vision AVR
Thank you for your attention ..
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
- Stephen
I wrote a PC-based·program (OS: windows xp) to remotely control the Boe-Bot with EmbeddedBlue Transceiver ApMod.
The robot receives commands sent from PC and moves as expected. (ex. forward, backward, leftturn and rightturn)
If EmbeddedBlue Transceiver ApMod is replaced by·my new Easy Bluetooth module, some problems occurred regarding to robot motion.
Below listed are my codes in robot, "leftSpeedW" and "rightSpeedW" are values sent from PC to control two wheels.
If i keep sending 20, 20 for these two values, the Debug window·should always·show 2020.
However, sometime i got results as:
2020
2020
2020
520
2020
020
205
If i switch back to EmbeddedBlue Transceiver ApMod , this issue disappear.
Any suggestions!!
' {$STAMP BS2}
' {$PBASIC 2.5}
leftSpeedW VAR Word
rightSpeedW VAR Word
durationW VAR Word
baudmodeW VAR Word
pulseCountW VAR Word
directionW VAR Word
calibRightW VAR Word
calibLeftW VAR Word
baudmodeW=84
durationW=5
'More positive is more backwards, more negative is more forwards
calibRightW=0
calibLeftW=34
''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
'This is the main function body
'
''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
Main:
DO
· 'Wait for the command string for this boebot
· SERIN 2, baudmodeW, [noparse][[/noparse]WAIT("CMD"), SDEC leftSpeedW, SDEC rightSpeedW]
· DEBUG SDEC leftSpeedW, SDEC rightSpeedW, CR
· 'Control the robot
· FOR pulseCountW = 1 TO durationW
··· PULSOUT 13, 750 + leftSpeedW + calibLeftW
··· PULSOUT 12, 750 - rightSpeedW + calibRightW
··· PAUSE 20
· NEXT
LOOP
Thanks in advance.
Could you attach the code you're using or include it inline with your reply using [ code ] [ /code ] tags (remove the spaces)? It will help us get a better understanding of what's going wrong.
Cheers,
Jessica
i'am using the easy bluetooth module in my simple project as same as yours but i got a simple problem is that when i send a string to the bluetooth it resends me the same string i had sent and strange characters in addition....!! what in your opinion that could be ??? and how could i solve this problem ??
Make sure the baud rate in the Debug Terminal is set to 9600. Could you also attach your code, just so we can double check?
Cheers,
Jessica
I want to know if can i send data to the Bluetooth from 4 BC in the same time ?
if it is yes . how can i do this ?
@heba ahmed ... You'll have to provide more information. What do you mean by "4 BC"? If you mean "How do I send data from 4 devices to one central controller over Bluetooth?", see my comments above. You can have four Easy Bluetooth Modules, all paired with the same PC, and you can write a program that will talk with one Module at a time, but rapidly so all of them are serviced as fast as they can send the data.
Thank you very much for answering ...
. yes this exactly what I mean ."How do I send data from 4 devices to one central controller over Bluetooth?".....
I have a movable robot in an area and I want to send to it its position via Bluetooth. This position is known through four cameras each one connected to a laptop .....
four Easy Bluetooth Modules will be too much.
IS xBee ZigBee Series 2 appropriate solution for me ?.
This could be done with Series 1 devices, but the BoeBot would have to connect to the laptops one at a time and request the current position from the laptop.
Note that you could also use the WiFly modules which provide a serial connection using WiFi. The laptops could use UDP messages sent to the BoeBot, each containing the position information. Like the Series 2 devices, these would contain the network addresses of the sender, so the BoeBot could tell who sent it. These have the advantage that most laptops have WiFi transceivers built-in and the only device you'd need would be on the BoeBot. Parallax's xBee adapters work with the WiFly modules.
Thanks very much for your time . I read about ZigBee .It is very good for my robot ,but I still have a small problem . I dont know how to connect laptop or the camera to it as an end device .
I didn't find any thing in internet explain how can I do this .
Parallax's adapter comes with socket pins that you can solder into the adapter if you want access to the xBee module's pins from a breadboard. You don't need to use these if all you're going to do is hook the xBee module to your PC.
You will need to write a program or modify an existing program that gets the data from the camera, processes it, and formats messages to send to the xBee module to be transmitted to the BoeBot. We can't help you with that. You'll have to learn the details of the ZigBee protocol for that.