Loop trouble
Mark Moorcroft
Posts: 4
I'm having a very basic issue with my Serial BOE (BS2P) / Servo controllers. So far all attempts at DO LOOPs or FOR/NEXT loops are failing. I have been trying several supposedly well proven sample codes and written some very simple ones myself. I can set any one servo position directly but any loop will only result in the first servo being set. All subsequent positions fail to be set. I have tried with variables and without. I have tried sprinkling WAIT statements around but nothing seems to help.
--HELP
Sample:
Post Edited (Mark Moorcroft) : 12/13/2005 4:09:09 PM GMT
--HELP
Sample:
PSC PIN 15 ' PSC module Baud CON 1021 ' 2400 baud HServos CON 750 ' Horizontal position LVservo CON 1200 ' Left lower position RVservo CON 300 ' Right lower position Ankle CON 750 ' Ankle center ramp CON $A ' Servo speed servoAddr VAR WORD ' Servo address temp VAR WORD ' Temp variable ' Adjust horizontal servos temp = HServos FOR servoAddr = 0 TO 10 STEP 2 SEROUT PSC,Baud,[noparse][[/noparse]"!SC",servoAddr, ramp, temp.LOWBYTE, temp.HIGHBYTE, CR] NEXT ' Adjust left vertical servos temp = LVservo FOR servoAddr = 1 TO 5 STEP 2 SEROUT PSC,Baud,[noparse][[/noparse]"!SC",servoAddr, ramp, temp.LOWBYTE, temp.HIGHBYTE, CR] NEXT ' Adjust right vertical servos temp = RVservo FOR servoAddr = 7 TO 11 STEP 2 SEROUT PSC,Baud,[noparse][[/noparse]"!SC",servoAddr, ramp, temp.LOWBYTE, temp.HIGHBYTE, CR] NEXT ' Adjust ankle servos temp = Ankle FOR servoAddr = 16 TO 21 STEP 1 SEROUT PSC,Baud,[noparse][[/noparse]"!SC",servoAddr, ramp, temp.LOWBYTE, temp.HIGHBYTE, CR] NEXT END
Post Edited (Mark Moorcroft) : 12/13/2005 4:09:09 PM GMT
Comments
Cheers
·· Well for starters you're not using OPEN baud mode, as specified in the PSC docs.· I would fix that first.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Chris Savage
Parallax Tech Support
csavage@parallax.com
What kind of Robo-Monster is this with 21 servos and articulated ANKLES?
Just curious!
I'm not sure whether it makes any difference to the PSC or not, but servoAddr only needs to be a BYTE variable, not a WORD. In any case you save a valuable byte of RAM by changing it.
Regards,
Bruce Bates
·· When you say the code wouldn't work, did you mean it wouldn't download, or it wouldn't compile?· If it wouldn't download, that would be due to the settings in the laptop and could be easily remedied, depending on what board you have, and your connection to it from the laptop.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Chris Savage
Parallax Tech Support
csavage@parallax.com
HexCrawler HDATS (18 servos)
Serial BOE with BS2P24 and 2 PSC's
As far as the Stamp programming interface was concerned the code compiled AND downloaded. But even a simple dozen or so lines did not produce the expected results. As far as I could tell the serial port was set up correctly. Thanks, I now have two changes to look at in the sample code provided by CrustCrawler.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Chris Savage
Parallax Tech Support
csavage@parallax.com