Shop OBEX P1 Docs P2 Docs Learn Events
Loop trouble — Parallax Forums

Loop trouble

Mark MoorcroftMark Moorcroft Posts: 4
edited 2005-12-14 17:41 in BASIC Stamp
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:

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

  • stamptrolstamptrol Posts: 1,731
    edited 2005-12-13 15:48
    If you attach your code, I'm confident someone will be able to help out.

    Cheers
  • Chris SavageChris Savage Parallax Engineering Posts: 14,406
    edited 2005-12-14 06:29
    Hello,

    ·· 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
  • Mark MoorcroftMark Moorcroft Posts: 4
    edited 2005-12-14 08:28
    Thanks, I'll look at that. For some reason the same code that totally failed to work from my Dell WindozeXP laptop using the Parallax supported interface is perfectly fine from my Powerbook using MacBS2. Any thoughts?
  • Bruce BatesBruce Bates Posts: 3,045
    edited 2005-12-14 11:08
    Mark -

    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
  • Chris SavageChris Savage Parallax Engineering Posts: 14,406
    edited 2005-12-14 15:29
    Mark,

    ·· 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
  • Mark MoorcroftMark Moorcroft Posts: 4
    edited 2005-12-14 17:22
    http://www.crustcrawler.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 SavageChris Savage Parallax Engineering Posts: 14,406
    edited 2005-12-14 17:41
    Well, let us know what happens.· That way if there's a problem we can proceed.· Thanks.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Chris Savage
    Parallax Tech Support
    csavage@parallax.com
Sign In or Register to comment.