exit loop

nikosznikosz Posts: 7
edited 2004-12-10 - 05:21:57 in Robotics
·Hello everybody.
·I made o robotic arm using 8 servomotors,and i am goin to·move servos via pc(using vb).
·The pc· and the controler (both programs vb and parallax) collaborate perfectly.
·In my program that controls the servos, i use serin command like this
·:SERIN RX\CTS,Baud,varible1,variable2.
·After i have to use a loop because i wont to keep all motors in the selected position like this
·[noparse]:D[/noparse]O
··PULSOUT VAR1,VAR2
· ·PULSOUT VAR-X,VAR-X1
··· PULSOUT BLA,BLA.......
· LOOP
· Now my problem is that ,the·program refresh all the time the motor positions,as i wont to do but it
· never returns to serin command to get new data.
· How can i deal with it?
· I mean that when there are new data in SERIN command, program must exits of loop reads new data
· and enter the loop· to refresh motor positions again.
·

Comments

  • Jon WilliamsJon Williams Posts: 6,491
    edited 2004-12-09 - 14:32:07
    That's going to be very tricky -- if you can do it at all.· You might try something like this ... but I think a PSC (Parallax Servo Controller) is really what you'll need to get precise control.

    Main: 
      SERIN RX\CTS, Baud, Update, 20, [noparse][[/noparse]servoNum, servoPos.LOWBYTE, servoPos.HIGHBYTE] 
      pos(servoNum) = servoPos 
    
    Update: 
      FOR idx = 0 TO 7 
        PULSOUT (Base + idx), pos(idx) 
      NEXT 
      GOTO Main  
    

    You'll need an array of words for servo position values (let the PC do the calculation so the BASIC Stamp can focus on reception and updating).· The constant called Base is the pin for servo 0.· The rest iterate from there -- by using contiguous connections you can keep things very simple.· Also note that SERIN times out after 20 milliseconds so the servos can be refreshed if nothing comes from the PC.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Jon Williams
    Applications Engineer, Parallax
    Dallas Office
  • nikosznikosz Posts: 7
    edited 2004-12-10 - 05:21:57
    Thank you I. will try it and I let you know
Sign In or Register to comment.