How can I control the BB2 with an external microcontroller?

Hi I’m new at this so be gentle.

Is there anyway of controlling the BB2+Basic atom using serial commands from another controller. I want to control the flow of the program generated by powerpod using a microcontroller connected to the serial port of the BB2.
Is there a specific command set that can be used that will permit this control?

The units I will be using are:

  1. Powerpod configured in serial control
  2. BB2 with basic atom 28 loaded with basic program from PowerPod
  3. SSC-32 servo controller
  4. External micro like ATmega8

Do you want to do this to control the gait in real time? I’m not sure how large the code generated by PowerPod is, but it seems this would be better done right on the Basic Atom itself. What will you expect to gain by controlling the Basic Atom from another microcontroller?

There is no existing protocol or command set that provides for this at this time. You would have to write your own protocol. I’ve set this up using Microchip PICs and text commands sent from another PIC over a serial port, but not with the Basic Atom. I have been tempted to try this sort of thing out though.

8-Dale


If I understand you, you want to send commands to a BB2 and SSC32. You’ve generated a “serial control” vers. of the Atom BASIC program.

Thus you’re good to go with the “Serial CP” windows program. Good. What you’ll want to write is a program for your micro that will generate the 7-byte strings much like the joystick:

28 FF FF A8 80 80 80 0D
00 FF FF 80 80 80 80 0D
04 FB FF 80 80 80 80 0D
20 FF DF 80 80 80 80 0D

The last one is for the “circle” command, for example. The first byte is a checksum, the next two bytes encode bits for all the buttons, and the last four bytes are 2 pairs of 2 bytes each, for the X and Y joysticks.

I use the Docklight terminal program to send these commands to my 'bot for testing, you can do the same from your micro.

I’m assuming you want to add the micro to add a higher layer of control to you 'bot. Not a bad idea. Might be easier then trying to add in your intended control to an “atonomous” version of the Atom BASIC code generated by PowerPod.

Here’s a set of commands I was working with, and their byte codings. Once you’ve got enough code in your micro to do a “Hello World”, you can send these BINARY strings instead to your BB2.

L1 tile floor
04 FF FB 80 80 80 80 0D

(start) Knee Shift
08 F7 FF 80 80 80 80 0D

(Triangle) button
10 FF EF 80 80 80 80 0D

L2 default
01 FF FE 80 80 80 80 0D

(Circle) button
20 FF DF 80 80 80 80 0D

(Square) Button
80 FF 7F 80 80 80 80 0D

(Cross) Button
40 FF BF 80 80 80 80 0D

R2 Body Low
02 FF FD 80 80 80 80 0D

(select) Lock Legs
01 FE FF 80 80 80 80 0D

R1 tall grass
08 FF F7 80 80 80 80 0D

L3 Cycle Button
02 FD FF 00 00 00 00 0D

UP Button
10 EF FF 80 80 80 80 0D

Down Button
40 BF FF 80 80 80 80 0D

Right Button
20 DF FF 80 80 80 80 0D

Left Button
80 7F FF 80 80 80 80 0D

height down
E8 FF FF 80 80 80 68 0D

Y Speed - 84
A8 FF FF 28 80 80 80 0D

steer right
20 FF FF 80 80 A0 80 0D

steer left
E7 FF F8 80 80 60 80 0D

height up
15 FF FF 80 80 80 95 0D

X Speed - 84
A8 FF FF 80 28 80 80 0D

Y Speed + 36
28 FF FF A8 80 80 80 0D

Neutral 80
00 FF FF 80 80 80 80 0D

R3 (horn) Button
04 FB FF 80 80 80 80 0D

X Speed + 36
28 FF FF 80 A8 80 80 0D

XY speed +
00 FF FF A8 A8 80 80 0D

XY Speed -
00 FF FF 28 28 80 80 0D

XY speed +-
80 FF FF A8 28 80 80 0D

XY Speed -+
80 FF FF 28 A8 80 80 0D

X Speed max
7C FF FF 80 FC 80 80 0D

Y Speed max
7C FF FF FC 80 80 80 0D

HTH

Alan KM6VV


Hey Alan
Thanks for the info.

From what I understand the first seven bytes are for the command and the last byte is a “CR”

Can I send these to the BB2 over the serial port like I send commands to the SSC-32

The syntax that I use to send commands to the SSC-32 is

Print #1 , “#0 P2200 t200” ; Chr(13)

can I do

Print #1, “20 FF DF 80 80 80 80”; Chr(13) to send the circle command to the BB2?

Can you please provide an code example for?

(e.i Stand up at a height of X and walk forward with a speed of Y).

Thanks for you time

A.N.

You will have to program the Basic Atom to understand what the hex codes mean and what to do for each one of them, such as which sequence to run, etc.

Getting your robot to walk should be easy using PowerPod. You will still have to do some programing beyond what PowerPod does for you to make all this work. I suggest just tinkering with PowerPod and having your robot run with the sequences it generates for awhile. Once you have your gait the way you want it, you can start working on the Atmel to Basic Atom communication.

8-Dale

Yes, that’s it. Just send the strings. You’ll have to go over the various PS2 type commands (I listed some samples), and send them. Study the PS2 commands in the instructions on the CH3.

The Joystick moves you forward and allows turns, various L buttons set the height as I recall. No specific speed to specify, you’ll have to experiment with the range of the parameters. I specified some to get you started. They are “center off” (80h), and go + and - from there.

It’s already programmed! The PowerPod will generate the program for the ABB. It will interpret the serial commands I have been describing. NO code to write for the ABB processor!

The PowerPod does all the ABB code needed (serial mode). You’re basically simulating a PS2 controller with your new processor, and you simply send the strings that activate the various actions you want. I believe the ABB sends an “ACK” back to your processor. You can wait for this reply before sending the next command.

Start off with a random walk, change the direction when an obsticle is encountered with a sensor. Leave all the driving to the ABB!

Alan KM6VV

Its good to know that there is someone out there that knows how to do this.

Alan can you please explain the following

  1. How to you calculate the value of the checksum in the first byte?
  2. How can a find which bit belongs to which button for the second and third byte?

I checked out this tutorial but cannot find this info
lynxmotion.com/images/html/build99c.htm

Thanks for your time
A.N

Hi An,

The PS2 bits are documented:

[code]byte0 checksum

     Bit0 Bit1 Bit2 Bit3 Bit4 Bit5 Bit6 Bit7

byte1 SLCT JOYL JOYR STRT UP RGHT DOWN LEFT
byte2 L2 R2 L1 R1 /\ O X ]
byte3 Right Joy 0x00 = Left 0xFF = Right
byte4 Right Joy 0x00 = Up 0xFF = Down
byte5 Left Joy 0x00 = Left 0xFF = Right
byte6 Left Joy 0x00 = Up 0xFF = Down[/code]

	/* calculate a replacement checksum */

DualShock[0] = DualShock[1] ^ DualShock[2] ^ DualShock[3] ^ DualShock[4] ^ DualShock[5] ^ DualShock[6];

‘^’ is the exclusive-or operator.

Looks like 99c describes the buttons, but does not identify the bits. But with this information along with the information above should help.

Some additional references:

sophiateam.undrgnd.free.fr/psx/index.html

look here for more PS2 on the LM website.
lynxmotion.com/Product.aspx? … ategoryID=

Alan KM6VV

Alan, the bit explanation was great.
what is dualshock?
Care to explain the the calculation of the checksum (maybe an example ??)

Remember, I’m new at this.

Thanks for your time

A.N

Hi An,

I did it in C, you’ll probably want to do it in BASIC, it will be very similar.

/* calculate a replacement checksum */ CheckSum = DualShock(1) ^ DualShock(2) ^ DualShock(3) ^ DualShock(4) ^ DualShock(5) ^ DualShock(6)

DualShock was just the name of the array used to hold the bytes.

OK I got it

One more question.
Do the serial outputs of my micro require a MAX232 to interface to the serial inputs (S_IN, S_OUT) of the BB2 or can I connect it directly to the BB2 serial port ?

Hi.

I’m trying to make my bot autonomous using the powerpod generated serial code. The bot is controlled using an external micro (atmega128) via the SER_IN port of the the BA pro28.
I have managed to send command like "&H80 ; &HFF ; &H7F ; &H80 ; &H80 ; &H80 ; &H80 'press square button (fly posture) " or
&H40 ; &HFF ; &HBF ; &H80 ; &H80 ; &H80 ; &H80 'press cross button (attack posture).

These work great and the bot responds without any problems. What I’m trying to do know is make the bot respond to navigation commands to make it go forward, backward or to turn.
The serial data for the “fly” and “attack” commands were straight forward but I’m having a hard time as to what serial data should I send for the movement (navigation) commands.
Does anyone care to explain as to how I would go about doing this ?

It has been awhile since I looked at this code, but I believe that this serial packet is emulating the PS2 controller input. So the last 4 values which you are currently sending H80s to control the walking and rotating. I believe the values are:

0 = Checksum of bytes 1 through 6 1 = first byte of button values - bit goes low of button pressed. 2 = second byte of buttons... 3 = y Direction for moving - 80 hex is zero 4 = X direction for moving 5 = Rotation 6 = Height

So try changing the values of bytes 3 and 4. The value 80 hex is the center point which implies 0 dont move. The values 81-FF will go one direction as the values get farther from 80 will go faster. The values 79-0 will go the opposit direction again the farther from 80 will go faster…

Byte 5 is the rotation value. Again the value of 80hex is zero and will not rotate. Like the move values the farther from 80 in each direction will rotate faster and one way will rotate clockwise the other will rotate counter clockwise.

Again remember to calculate your checksum in byte 0…

I hope this helps.

Kurt

Apostolos,

Kurte’s given you the essence of it. Try sending some X and Y values as I’ve suggested, and watch the results! The moves are simply a matter of encoding the two bytes.

Alan KM6VV

Hi guys and thanks for the replies.

Do I have to continuously send the data so it can move or is this a one-shot deal (send data once-it moves in set direction until it receives other data)?

Apostolos,

I believe you’ll have to re-send the move command in order to get continuous motion.

Alan KM6VV

OK, I’ll try it out and report my progress

Hi again:

If you look at the main loop of code, which starts with:

[code];-------------Main loop
main

;SerialQuery
serout S_OUT,i9600,“Rd”] ; ‘Ready’ to recieve data now
serin S_OUT,i9600,100,NoData,[str DualShock(0)\7]

CheckSum = DualShock(1) ^ DualShock(2) ^ DualShock(3) ^ |
	DualShock(4) ^ DualShock(5) ^ DualShock(6)

;serout S_OUT,i9600,[CheckSum]

if CheckSum <> DualShock(0) then
Sound 9,[50\2000]
NoData
DualShock(1) = $FF
DualShock(2) = $FF
for Index = 3 to 6
DualShock(Index) = $80
next
endif[/code]

You will notice that each time it does a query and it does not get any information, it sets the two button bytes to FFh (nothing pressed) and the other four bytes to 80h. Obviously you could change this code to do anything you want, like if I received a move operation continue with the last movement. You might want to put some form of timeout in, so that if you lose connection, it does not walk foreever…

Kurt

Hi people

V useful thread!

I have my laptop connected to the serial on my Mini-abb board. The atom has the powerpod serial pc control program on it as mentioned.

As i want to simulate a “triangle button press” by sending a data string from my pc terminal window, what exactly do i need to send as triangle as posted above is

(Triangle) button
10 FF EF 80 80 80 80 0D

But when i send that i dont get any response, do i need to send some “standby to Rx command” etc???

:open_mouth: