Shop OBEX P1 Docs P2 Docs Learn Events
BS2 to BS2 serin/serout — Parallax Forums

BS2 to BS2 serin/serout

ROVONEROVONE Posts: 8
edited 2007-03-09 21:55 in BASIC Stamp
I want to control 3 servos by inputting joy stick inputs to one BS2 and then sending that data to a second BS2 over a 3 wire serial cable and have the second BS2 drive the three servos. I have a setup with one servo that works. What I am having problems with is sending 3 variables and loading them as 3 separate variables to drive the 3 servos. What would be the best way to do this?

Comments

  • NewzedNewzed Posts: 2,503
    edited 2007-03-09 18:28
    Remember a Stamp can do only one thing at a time.· if the first variable is driving a servo, then you can't send the second variable until the Stamp has completed the first variable command.· Flow control would help, but that will take four wires instead of three.

    Sid

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Yesterday is history, tomorrow is a mystery, and today is a gift.

    That is why they call it the present.

    Don't have VGA?
    Newzed@aol.com
    ·
  • allanlane5allanlane5 Posts: 3,815
    edited 2007-03-09 18:51
    Have BS2 #2 suspend for 20 mSec in a SERIN with a 'wait' parameter. If BS2 #1 sends it a byte in that interval, send an 'ack' byte and then go to another SERIN to get the parameters. If BS2 #1 doesn't send it a byte in that interval, go refresh the servo positions.

    So, BS2 #1 reads the joysticks, and does a SEROUT of the 'attention' byte -- "H". It then goes into a SERIN with a WAIT of 2 mSec for BS#2 to respond. If BS2 #2 does not respond, then BS2 #1 tries again -- say three times.

    If BS2 #2 does not respond in three tries, BS2 #1 goes around to read the joystick positions again.

    Now, if BS2 #1 DOES recieve the 'acknowledge' byte -- "A" -- it waits 1 mSec (so the reciever can get into its SERIN statement) then sends the three servo positions. If BS2 #2 gets all three, again it sends the "A", before setting the servos to their new positions.

    This implements a very simple "software handshake", where both sides don't waste too much time waiting for each other, but do eventually 'synchronize' so the listener is listening when the talker wants to talk.
  • Bruce BatesBruce Bates Posts: 3,045
    edited 2007-03-09 21:55
    Make sure the DURATION parameter is a WORD sized variable!

    Regards,

    Bruce Bates

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Sign In or Register to comment.