can't get going with PBasic - need help!
I built my first·robot arm·using a Parallax Servo Controller (PSC) to control 3 servos.· I used the CPSCI program to capture key sequences and it works great!·· Now I would like to write my own program using PBasic 2.5.·· I tried all of the snippets in the Parallax Servo Controller (#28023) - Rev B manual, but can't get any to work.· If I could just get the Position Command to work then I could probably·figure out·the rest.
Here is what I tried:
1. I used the Basic Stamp editor to create the source file and check syntax.
2. I tried running the program from the editor, but it gives me a stamp-not-found error, so...
3. I tried running it with hyperterminal.· Didn't work, so...
4. I copied the program using via DOS, e.g. "copy myfoo.bas COM3"
5. The program loaded into the PSC, but nothing happened.· The servo did not move.
6. I tried using different file extensions, e.g. .bas, .bsx, etc
7. I tried compiling to a .exe and .obj and executing/loading those, still no response from the servos.
7. I tried using different channels: the·three I use are 0, 1, and 2
8. I tried sending the other snippets, no luck.· If I put them all together in a program (I thought maybe the baud rate had to be set/reset first), I get a few odd shakes of the robot arm but that's it.
If PBasic works for you on PSC, please tell me how to get started.· I'm working in Windows XP.· Here is the snippet:
'{$PBASIC 2.5}
ch· VAR· Byte
pw· VAR· Word
ra·· VAR· Byte
Sdat· CON 15···· ' << it is 15 in the example, but I also tried 2, since the serial pin on the PSC chip is 2.
baud· CON· 396
······· ra = 7
······· ch = 11··· ' << i used 0 instead of 11, since this is the first channel i am using on the PSC.· Also tried 1 and 2
DO
······· pw = 1250
······· SEROUT Sdat, Baud+$8000, {"!SC", ch, ra, pw.LOWBYTE, pw.HIGHBYTE, CR}
······· PAUSE· 1000
······· pw = 250
······· SEROUT Sdat, Baud+$8000, {"!SC", ch, ra, pw.LOWBYTE, pw.HIGHBYTE, CR}
······· PAUSE· 1000
LOOP
Here is what I tried:
1. I used the Basic Stamp editor to create the source file and check syntax.
2. I tried running the program from the editor, but it gives me a stamp-not-found error, so...
3. I tried running it with hyperterminal.· Didn't work, so...
4. I copied the program using via DOS, e.g. "copy myfoo.bas COM3"
5. The program loaded into the PSC, but nothing happened.· The servo did not move.
6. I tried using different file extensions, e.g. .bas, .bsx, etc
7. I tried compiling to a .exe and .obj and executing/loading those, still no response from the servos.
7. I tried using different channels: the·three I use are 0, 1, and 2
8. I tried sending the other snippets, no luck.· If I put them all together in a program (I thought maybe the baud rate had to be set/reset first), I get a few odd shakes of the robot arm but that's it.
If PBasic works for you on PSC, please tell me how to get started.· I'm working in Windows XP.· Here is the snippet:
'{$PBASIC 2.5}
ch· VAR· Byte
pw· VAR· Word
ra·· VAR· Byte
Sdat· CON 15···· ' << it is 15 in the example, but I also tried 2, since the serial pin on the PSC chip is 2.
baud· CON· 396
······· ra = 7
······· ch = 11··· ' << i used 0 instead of 11, since this is the first channel i am using on the PSC.· Also tried 1 and 2
DO
······· pw = 1250
······· SEROUT Sdat, Baud+$8000, {"!SC", ch, ra, pw.LOWBYTE, pw.HIGHBYTE, CR}
······· PAUSE· 1000
······· pw = 250
······· SEROUT Sdat, Baud+$8000, {"!SC", ch, ra, pw.LOWBYTE, pw.HIGHBYTE, CR}
······· PAUSE· 1000
LOOP
Comments
·
The PSC does have a microcontroller on it, but it's not user programmable. It receives serial commands from a PC or another microcontroller and produces servo control pulses as commanded.
Post Edited (Mike Green) : 5/28/2009 2:31:24 PM GMT
thanks for responding
-=Rich
In the case of the movement command you showed, you have to send the characters "!", "S", "C", then the channel number as a single byte value, then the ramp value as a single byte value, then the pulse width value as two byte values with the least significant byte first, then a carriage return character (value 13).
The details of how to write this sort of thing depend on the programming language you plan to use.
What you are trying to do is precisely what we did in the Robot Vision project shown in the following video
·http://www.youtube.com/watch?v=LwvspYFXJMM&feature=channel_page
All the controls were performed with the programming language RobotBASIC· http://www.RobotBASIC.com.
In the program you can find examples for how to control the Parallax Servo Controller using RobotBASIC
which is what you are trying to do here is a link:
·http://www.robotbasic.org/resources/Humanoid+Vision.zip
There was an article about all this in Servo
·http://www.servomagazine.com/media-files/971/A_Robotic_Puppet-SV200811.pdf
If you want to see how to use RobotBASIC's serial IO see this document
·http://www.robotbasic.org/resources/RobotBASIC_To_BS2_Comms.pdf
Also see this to see how to set the BS2 to do serial IO with RB
·http://www.robotbasic.org/resources/RobotBASIC_Serial_IO.pdf
I hope that helps
Regards
Post Edited (SamMishal) : 5/28/2009 5:08:17 PM GMT
-=Rich