ActivityBot - SimpleIDE - BlueTooth and Robot Basic

twm47099twm47099 Posts: 845
edited 2016-06-07 - 01:22:11 in Robotics
I’ve previously posted code for running the ActivityBot using different remote control methods combined with whiskers for reacting to obstacles using C and the SimpleIDE libraries.

One method used the Sony Infrared Remote Control (SIRC) and is described here:

SIRC discussion link:

The other used BlueTooth with an Android tablet and the “Joystick Blue Tooth Commander” (JSBTC) app available for free from Google Play and is described here:

JSBTC discussion link:

One of the things I’ve wanted to do was when using either remote control or bot autonomous actions was to get data back from the bot which could be looked at in real time and saved to a file if desired. While I used the SD card on the Activity Bot to save data I can’t see it real time, and while JSBTC has the ability to collect and display real time data, it is very limited.

I was looking for books on the Propeller and found a book titled: A Hardware Interfacing and Control Protocol using RobotBasic and the Propeller Chip. That book is about the free program RobotBasic (RB) and is a detailed tutorial on using RB and Spin to pass commands and data between the propeller and a PC running RB. While I’ve followed a number of the lessons, I’m still not very comfortable with SPIN so I decided to try programming the Propeller in C using the basics of the SIRC program above but adding 2 way communication between the Activity Bot (with the RN42 BT radio I used in the JSBTC program) and RB program using its graphic interface.

For wiring for the ActivityBot I am using the interface board and mechanical setup described in the JSBTC link above.

One other thing I needed was a touch screen windows tablet with BT to run RB so I wouldn’t be tied down. I was able to find an inexpensive RCA Cambio windows 10 tablet. It had BT and runs RB very well, although the 10 inch screen seems pretty small. However, with a capacitive touch screen stylus it’s pretty usable.

This is a first try at using RB to control the ActivityBot and to get data (wheel speed in ticks) back from the bot.
I've attached a zip from SimpleIDE of the C project, however it contains all of the libraries used, so you may not want all that. I’ve also attached text files of both the C program and the Robot Basic program.
I've been able to open them with "notepad".

I also attached a jpg of the RB program generated control screen. It could use some prettying up. The commands on the screen are:
fwd= starts forward motion,
rev= goes in reverse at the defined minimum speed,
stp = stops bot and resets speed to defined spd0,
+spd and -spd = increase or decrease current speed
cvl and cvr = curve left or curve right (left or right wheel speed respectively is reduced by 20 ticks). Increasing speed with +spd increases turn radius, decreasing speed with -spd does opposite. use fwd to straighten movement.
lft and rgt = stop and pivot left or right 45 degrees.
end = stop bot and end program.

To use the C program I open the text file, start SimpleIDE and click on new project. Enter abot_rbasic_bt_01 for the C file name, then erase all of the new program stuff in the main IDE window, and cut and paste the text file into Simple IDE.

For the Robot Basic file simply rename the file to eliminate the .txt and open it using Robot Basic.

Before running for the first time it will be necessary to pair the tablet BT with the BT radio on the ActivityBot.
My BT radio on the Bot is set for 115200 baud. If using a different baud, it will be necessary to change it in both programs. It is also necessary to make sure that the "Port" number identified in line 6 of the Basic program is set to the port number being used by the tablet for Blue Tooth. My tablet shows 2 port numbers for bluetooth, one for TX and one for Rx. The number in line 6 is the TX port.

Once set up to run the programs, connect the ActivityBot to the SimpleIDE computer as usual, send the C program to the bot using F11. Start RobotBasic and open the program. Once the ABot beeps, run the basic program. After a few moments the radios will connect and the control screen will be displayed. Then you can use the controls with the touch screen. First time I recommend having the ABot supported so that it is not on its wheels (just in case). Test the command buttons, and the whiskers.

If you press "end" the programs will stop and you will need to use the reset button on the ABot to restart and then when the bot beeps run the basic program.

Issues: Sometimes when starting to run the basic program I get an error: "The specified com port is not valid". I'm not sure why this happens, but assuming that the port number is set up correctly (see above), just click ok and tap the 'run" arrow on the RB editor, and it should work (some times 2 or 3 tries are needed). In the worst case I've had to turn off the abot, exit RB, restart RB, open the basic file, turn on the abot, and when it beeps start the basic program.



Sign In or Register to comment.