Control a Cybot from your PalmOS based device and SmallBASIC using the servo controller below
What you need
- A Palm, or anything that has a serial port, your dusty HP48 is also perfect for this task,
- A Cybot with the motor controller board (only first 4 issues of the Eaglemoss magazine needed),
- My servo controller with a RS232 interface,
- An on-board programming language such as Small Basic (Open Source licensed under GPL), or anything else Open Source because it's better for your karma ! (you can find here more open languages for the Palm).
**Warning !** Using any non free programming language could be fatal for your Cybot (lockups, viruses, transistors blowing ...). For cool open source on PalmOS visit palmopensource.com ;-)
Programming the Cybot
Below, you can take a look at a SmallBasic program which shows you the basics to move your Cybot with the Palm.
0Px xx commands are described in the servo controller's documentation.
As the AVR controller is able to generate PWM signals, you can control the motors speed with a 8 bits precision. In my setup, outputs 0 to 3 of the AVR based controller are wired to pins 0 to 3 of motor board. So with a:
0P0 xxcommand you set the forward speed (to xx in hexadecimal) of the right motor,
0P1 xxcommand you set the backward speed of the right motor,
0P2 xxcommand you set the forward speed of the left motor,
0P3 xxcommand you set the backward speed of the left motor.
Warning !!! As always do not turn on forward AND backward pins (i.e. '0P0 xx' and '0P1 xx' with xx>=01), or you will burn the motor controller board !
' pwm.bas ' open the serial port at 9600 bauds OPEN "COM1:9600" AS #1 ' reset all outputs print #1, "0P0 00\n" print #1, "0P1 00\n" print #1, "0P2 00\n" print #1, "0P3 00\n" delay 3000 10 print #1, "0P0 00\n" print #1, "0P1 00\n" print #1, "0P2 00\n" print #1, "0P3 00\n" ' move forward slowly during 1 sec print #1, "0P0 30\n" print #1, "0P2 30\n" delay 1000 ' move forward at full speed during 2 sec print #1, "0P0 ff\n" print #1, "0P2 ff\n" delay 2000 ' move forward slowly during 1 sec print #1, "0P0 30\n" print #1, "0P2 30\n" delay 1000 ' make a U Turn print #1, "0P0 47\n" print #1, "0P2 00\n" print #1, "0P3 47\n" delay 400 goto 10 close #1
Of course, you can use the 5 General Purpose Inputs/Outputs of the AVR controller to implement object avoidance, the sky is the limit!