I am currently trying to control my 3pi via serial commands from a baby orangutan. I first loaded the slave example into the 3pi and loaded the master example into the baby. I am getting very inconsistent results. Most often the 3pi just beeps and prints Bad cmd, usually with a 30, but other numbers will cycle through. Occasionally it will work and print out Connect and play the music as expected.
I also tried controlling via an Arduino. I can get more consistent results with the Arduino, I can always control and print to the LCD and I can turn the motors on and off with no problem. However, if I try to get the battery level by sending a 0xB1 I get a bad command 13.
Am I doing something wrong? Is there an easy way for me to narrow down the problem area?
How is everything connected and powered?
When using the baby orang I have 5v going into the Vin, the 3pi is battery operated. When using the arduino I have that powered by a 9v wallwart.
The Baby Orangutan is the one that is giving you trouble, so can you say what the 5V power supply is and exactly what all of your connections are for that setup? (Something like “PD3 on the Baby Orangutan is connected through a 50ft phone cable to the negative terminal of the supply, etc…”) A picture would help a lot.
Thanks for the help Paul. After playing some more I dumbed down the master example since it looks like it won’t work well with the Baby O, it is looking for button presses and sending stuff out to an LCD which the Baby O doesn’t have. I commented everything out of main() and replaced it with the code at the end. I get very inconsistent results. At first I got it to print start on the 3pi lcd and got all the way to the battery check before it reported a bad command. Now it doesn’t even print start just says bad cmd, sometimes it will get various pieces to work for example start and tune won’t print, just give bad cmd but Motors will print and the motors will turn on. Attached is a picture of how I have it wired up. Power is a USB cable that is connected to my PC, I measured it and it is giving out 5v.
Also, the arduino does not consistently work. I can always get it to drive the motors and work the LCD. But if I try to read the battery I get a bad cmd. I am going through all the cmds to see which work and which don’t. I will report back on what I find.
// load the bar graph
// configure serial clock for 115.2 kbaud
// play a tune
char tune = "\xB3 l16o6gab>c";
tune = sizeof(tune)-3;
// get the battery voltage
// read 2 bytes
if(serial_receive_blocking((char *)battery_millivolts, 2, 100))
Your picture doesn’t do a very good job of showing your connections, but I only see two wires, neither of which is ground. A lack of a common ground between your Arduino/Baby Orangutan and your 3pi would explain why you’re getting inconsistent results.
Hi Ben, thanks for the response, I don’t know why the photo was cropped when I uploaded. I attached a picture of the Baby O. So are you saying I need to add a ground pin on the 3pi and run a wire from there to ground? I hope this isn’t too basic of a question I am new to electronics and am learning as I go.
If you grounds are not connected one way or another, you need to connect them with a wire. That is one of the reasons I kept asking you for how things are connected!
Paul and Ben, thanks so much for your help. With the ground now connected everything is working much better.