Shop OBEX P1 Docs P2 Docs Learn Events
Using SERIN to passively listen for Servo Commands — Parallax Forums

Using SERIN to passively listen for Servo Commands

jongarrjongarr Posts: 11
edited 2004-12-05 09:44 in BASIC Stamp
Hi,
·· I·have my Basic Stamp I set up with two servos and an LED light.· The Basic Stamp has one pin connected to my PC to receive Serial data.· I have it working with simple serin commands and I have been able to control the servos from the stamp, so I know it is set up properly.

·· What I want to do is have the servos move to a certain location based on two numbers that will occassionally be sent from the pc and then stay in that position until the next command is received from the PC.· It appears that SERIN waits until it receives data, which doesn' work because the servo control loop can't continue.·

·· Any help would be greatly appreciated.

Thank You,
Jon
·

Comments

  • Chris SavageChris Savage Parallax Engineering Posts: 14,406
    edited 2004-11-24 02:59
    In such a situation you would need a SSC (Basically a Servo Co-Processor) that can maintain positions that you send to it via the BASIC Stamp.· So your Stamp will listen until it receives new position information, then SEROUT the data to the SSC, which will maintain the position whilst the BS waits for new data.

    Parallax sells just such a device.



    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Chris Savage

    Knight Designs
    324 West Main Street
    P.O. Box 97
    Montour Falls, NY 14865
    (607) 535-6777

    Business Page:·· http://www.knightdesigns.com
    Personal Page:··· http://www.lightlink.com/dream/chris
    Designs Page:··· http://www.lightlink.com/dream/designs
    ·
  • jongarrjongarr Posts: 11
    edited 2004-11-24 03:32
    Thanks for your reply.

    I searched for Servo Co-Processor and SSC on parallax's site and didn't find anything.· Do you have a link?· Also, are there advantages (price/function) of using what you suggest over a digital potentiometer (like the DS1267) connected to a 555 timer to generate the consistent pulses?

    -Jon
  • Bruce BatesBruce Bates Posts: 3,045
    edited 2004-11-24 04:21
    Jon -

    Here is a link to the Parallax Servo Controller (PSC):
    http://www.parallax.com/detail.asp?product_id=28023

    With it you can individually control up to 16 R/C servos with one board. Multpile boards can be "networked" for up to 32 R/C servos if needed.

    Regards,

    Bruce Bates
  • jongarrjongarr Posts: 11
    edited 2004-11-24 04:44
    Thanks Bruce,

    That looks like a great solution, but I'm looking for the cheapest possible means of controlling just two servos. I'm thinking that for the price, the best solution is to use a serial controlled potentiometer with a 555 timer ic. I think that will cost about 7 or 8 dollars to control two servos. Can anyone suggest a better solution for the price?

    -Jon
  • allanlane5allanlane5 Posts: 3,815
    edited 2004-11-24 20:57
    NO! The servo update cycle needs to be 20mSec to 50 mSec, right?

    So, all you have to do is add a time-out value to the SERIN loop of 20 mSec, then *don't* put an additional pause in.

    So it looks like:

    Serv1Pin CON 6
    Serv2Pin CON 7

    Byte1 VAR BYTE
    Byte2 VAR BYTE

    Serv1Val VAR WORD
    Serv2Val VAR WORD

    Main:

    PULSOUT Serv1Pin, Serv1Val
    PULSOUT Serv2Pin, Serv2Val
    SERIN 16, MyBaud, 20, SerTimeout, [noparse][[/noparse]Byte1, Byte2]
    FallThrough: ' Here when data recieved
    ' Do stuff here to update Serv1Val, Serv2Val
    PAUSE 20 ' Because may have returned immediately
    GOTO MAIN

    SerTimeout:
    GOTO MAIN ' Because 20 mSec already waited for.
  • jongarrjongarr Posts: 11
    edited 2004-11-24 21:36
    Thanks for that alternative! I'll post again after I give it a try.
  • jongarrjongarr Posts: 11
    edited 2004-11-24 21:52
    I did a little research and it looks like the Basic Stamp 1 does not allow a timeout in the SERIN command. Does anybody have any other alternatives?
  • jongarrjongarr Posts: 11
    edited 2004-11-24 21:54
    I just noticed that I had used "Basic Stamp I" to say "Basic Stamp 1" in my first post. Sorry for the confusion.
  • Chris SavageChris Savage Parallax Engineering Posts: 14,406
    edited 2004-11-25 15:48
    jongarr said...
    I did a little research and it looks like the Basic Stamp 1 does not allow a timeout in the SERIN command. Does anybody have any other alternatives?
    Hence why I suggested the Parallax SSC...Sorry I didn't include a link...I almost always do...



    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Chris Savage

    Knight Designs
    324 West Main Street
    P.O. Box 97
    Montour Falls, NY 14865
    (607) 535-6777

    Business Page:·· http://www.knightdesigns.com
    Personal Page:··· http://www.lightlink.com/dream/chris
    Designs Page:··· http://www.lightlink.com/dream/designs
    ·
  • allanlane5allanlane5 Posts: 3,815
    edited 2004-11-25 21:30
    BS1, huh? Sorry about that. Go to a BS2 would be my suggestion. It might be cheaper than the SSC + BS1 combination.
  • LarryLarry Posts: 212
    edited 2004-11-25 21:58
    It might work to test the serial line during the times between PULSOUT commands to see if there is a voltage on it and then switch to a SERIN command if there is. several "junk" bytes would probably be needed in the serial stream to give the BS1 time to switch over. The BUTTON command might even do this.

    It'll probably take a bit of experimenting, though.

    Larry

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
  • jongarrjongarr Posts: 11
    edited 2004-12-05 09:44
    Thanks to all who responded.·

    In the end, I found several ways to solve this problem, including one that didn't involve buying extra equipment:

    1.· Buy a serial potentiometer and use a 555 timer ic to send the pulses to the servos, while the BS1 waits for input
    2.· Buy a pwm ic and do basically the same thing
    3.· Buy a serial servo controller
    4.··Free Solution:·(but may only be a good solution in my application)
    ···· Wait for serial in, when you get it send enough pulses that you think the servos are in the correct position, and then wait for serial input again.· The servos aren't going anywhere once they are aimed (unless an outside force acts on them).· This works very well for what I am doing, but wouldn't be a good solution in many applications.

    Thanks,
    Jon
Sign In or Register to comment.