PDA

View Full Version : Keyboard Controlled Boe-Bot Robot



Andy Lindsay (Parallax)
09-09-2011, 03:45 PM
This example code makes it easy to control your Boe-Bot while it is connected to a PC via the Programming cable. After you run the code, use these keys to control the Boe-Bot:

8 = forward
2 = backward
4 = rotate left
6 = rotate right
5 = stay still

There's no need to hold the key down, just press/release it once (sometimes twice if the BASIC Stamp misses the first character because it's busy sending pulses to the servos).





' {$STAMP BS2}
' {$PBASIC 2.5}

pulse VAR Word
maneuver VAR Word

FREQOUT 4, 2000, 3000
DEBUG "8 = forward", CR,
"2 = backward", CR,
"4 = rotate left", CR,
"6 = rotate right", CR,
"5 = stay still"

DO
SERIN 16, 84, 20, Timeout, [maneuver]
Timeout:
GOSUB Go
LOOP


Go:

LOOKDOWN maneuver, ["5", "8", "2", "4", "6"], maneuver
LOOKUP maneuver, [750, 850, 650, 650, 850], pulse
PULSOUT 13, pulse
LOOKUP maneuver, [750, 650, 850, 650, 850], pulse
PULSOUT 12, pulse

RETURN

bomber
09-18-2011, 02:59 PM
I was doing a similar type of remote control with the Propeller, ecept it uses the PropBOE, a C3 with the Xbee sip adapter you sent me, a SD card to store the turns in memory, and some whisker sensors for navigation. I can post the code if you want, although it will be built around the PropBOE.

Andy Lindsay (Parallax)
09-19-2011, 02:59 PM
Sounds pretty cool. I would recommend holding that for now. The production PropBOEs will be somewhat different, and we'll have a different site for projects. When all that is in place, we'll prepare to be amazed.

rock2010
11-27-2011, 06:28 AM
Thank you Andy for the useful program. i have one question in mind, how can I add a third motor that controls lets say a gun and modify the code so we can control this third motor separately. I want to move the boe-bot with some commands and use other keys to move the gun attached to the third motor right and left.

Thanks a lot.

Andy Lindsay (Parallax)
11-28-2011, 04:47 PM
Finding a toy gun that's light enough for the Boe-Bot to carry without tipping foward might be a challenge. I suppose you could attach a counterweight to the back or mount it on top. Another thing to try would be the Ping))) Ultrasonic Sensor + Mounting Bracket. The "turret" servo is included.

Product page:
http://www.parallax.com/tabid/768/ProductID/563/Default.aspx
Downloads & Resources
http://www.parallax.com/tabid/176/ProductID/92/Default.aspx
http://www.parallax.com/tabid/755/ProductID/248/Default.aspx

The simplest way to add keyboard control of the turret servo would be to duplicate elements of the wheel control servo code for a third turret servo. For example, you could start by adding a couple of variables for turret character and turret pulse control. Something like this:

turretChar VAR Byte
turretPulse VAR Word

Then, add a second SERIN command to get a second character for turret direction to the DO...LOOP:

SERIN 16, 84, 20, TimeoutTurret, [turretChar]
TimeoutTurret:

Inside the Go subroutine, you'd probably want to add something like this (assuming turret servo is connected to P14):

LOOKDOWN turretChar, ["4", "7", "8", "9", "6"], turretChar
LOOKUP turretChar, [1100, 925, 750, 550, 350], turretPulse
PULSOUT 14, turretPulse

For more information on standard servo control, download "What's a Microcontroller? v3.0 (.pdf)" from the www.parallax.com/go/WAM resource page, and check out Chapter 4.

For more information on Boe-Bot continuous rotation servo control, download "Robotics with the Boe-Bot Text v3.0 (.pdf)" from the www.parallax.com/go/Boe-Bot resource page and check Chapter 2, Activity #4, #6, and Chapter 4.

John Kauffman
12-06-2011, 01:12 AM
The name of this thread gave me an idea. "Keyboard" around my house means piano.
I'm wondering if a microphone on a PropBot could hear a note from the piano and react to the pitch. What a set of possibilities for integration of music and motion. I'll start digging through the Objects Exchange. Remember the video of the Hokey Pokey Toddler Dance Team from five years ago?

joecooldeejay
02-05-2012, 01:36 PM
i have absolutely no idea how to code but i have the basic stamp 2 homework board. i want to use this program with like p0 and p1 to control hobby motors. could someone take the time to do it? i dont get all of that fancy new code stuff!!!!!:smile:

Andy Lindsay (Parallax)
02-08-2012, 11:38 PM
You can run the code as-is if you instead connect the servos to P12 and P13. You'll still need to consult Robotics with the Boe-Bot for wiring examples. (Free pdf download from www.parallax.com/go/Boe-Bot.) The schematic and wiring diagram is in Robotics with the Boe-Bot Chapter 2, Activity #3. There are instructions for two different boards there; make sure to follow the instructions for the HomeWork Board. You'll also need to follow the instructions in chapter 1 for installing the software.

If you'd like to be able to do more, I'd recommend going to www.parallax.com/go/WAM and downloading the What's a Microcontroller PDF. Each chapter has a few activities, and each activity takes about 15 minutes to work through. You can skip the 5th activity in chapters 2 and 3. By the time you are through with Chapter 4, you'll be able to do it on your own, and you'll know all about the "fancy new code stuff" and lots more.

joecooldeejay
02-12-2012, 12:19 AM
it's so close, but im using rc car type motors, not servos. i can tell its close because i hear a buzzing noise that changes when i hit keys.

Andy Lindsay (Parallax)
02-14-2012, 04:58 PM
Have you connected the I/O pins to the motor controller input where the hobby RF receiver output would normally go? If not, a detailed description of your setup would help.

joecooldeejay
02-15-2012, 01:23 AM
Have you connected the I/O pins to the motor controller input where the hobby RF receiver output would normally go? If not, a detailed description of your setup would help.

I'm sorry I'm being so confusing. I'm trying to use a snap rover base from elenco's snap circuits that has the regular small motors found in rc cars. I'm trying to control that from a laptop that is on board the snap rover. I am controlling it using logmein so it is as if I am sitting at the laptop controlling it. I hope this makes sense.

joecooldeejay
02-15-2012, 01:25 AM
I'm sorry I'm being so confusing. I'm trying to use a snap rover base from elenco's snap circuits that has the regular small motors found in rc cars. I'm trying to control that from a laptop that is on board the snap rover. I am controlling it using logmein so it is as if I am sitting at the laptop controlling it. I hope this makes sense.

I am connecting the basic stamp homework board to the motor inputs on the snap rover. This is the snap rover. http://www.amazon.com/Elenco-SCROV-10-Snap-Circuits-Rover/dp/B000GG7XXK. I'm just using the yellow base with the motors in it.

Andy Lindsay (Parallax)
02-18-2012, 02:10 AM
Alright, I found a PDF manual for this rover at http://www.pololu.com/catalog/product/1675.

It looks to me like you'll need to control the U8 motor control block with I/O pins and series resistors. I'd recommend this circuit:

Homework.......Series................U8 Motor
Board..............Resistor.............Control Block
P15-----------------R=1k-----------------LF
P14-----------------R=1k-----------------LB
P13-----------------R=1k-----------------RF
P12-----------------R=1k-----------------RB

With that circuit, this code should work. You might need to reduce the series resistor values from R=1k to R=470, but try it with 1k first.



' {$STAMP BS2}
' {$PBASIC 2.5}

pulse VAR Word
maneuver VAR Word

FREQOUT 4, 2000, 3000
DEBUG "8 = forward", CR,
"2 = backward", CR,
"4 = rotate left", CR,
"6 = rotate right", CR,
"5 = stay still"

DO
SERIN 16, 84, 20, Timeout, [maneuver]
Timeout:
LOOKDOWN maneuver, ["5", "8", "2", "4", "6"], maneuver
ON maneuver GOSUB StayStill, Forward, Backward, Left, Right
LOOP

StayStill:
INPUT 15
INPUT 14
INPUT 13
INPUT 12
RETURN

Forward:
HIGH 15
INPUT 14
HIGH 13
INPUT 12
RETURN

Backward:
INPUT 15
HIGH 14
INPUT 13
HIGH 12
RETURN

Left:
INPUT 15
HIGH 14
HIGH 13
INPUT 12
RETURN

Right:
HIGH 15
INPUT 14
INPUT 13
HIGH 12
RETURN