Shop OBEX P1 Docs P2 Docs Learn Events
BS2, 2 Servos, and multiple variables inputed through SERIN — Parallax Forums

BS2, 2 Servos, and multiple variables inputed through SERIN

staulkorstaulkor Posts: 5
edited 2006-12-06 01:27 in BASIC Stamp
I am working on a 360 degree pan and tilt device. I have 2 parallax continuous rotation servos. I am using an older Homework Board Rev B. I am trying to figure out how to use the SERIN command. I have played with it so i can enter "1" and it turns on a LED, but I havent got it so I can enter a few numbers and for the program to use those numbers to position the servos.

This is pretty much what I need done, but I have no clue how to do it:

- Able to enter multi-digit numbers, like 850, 50, etc to position the servos

I have tried using Arrays, but I have only been able to get a 1 digit number instead of multi-digit numbers.

Here is an excerpt from the code i am using now:

result VAR Byte(2)
counter VAR Word 
SERIN 15, 16468, [noparse][[/noparse]STR result \2]
FOR counter = 1 TO result(0)
  PULSOUT 14, 650
  PAUSE 10
NEXT

FOR counter = 1 TO result(1)
  PULSOUT 13, 650
  PAUSE 10
NEXT



Also, with the current code, I have phantom movements with the servos. They just go crazy and spin until I plug the serial cable into the port I made on port 15.

Comments

  • allanlane5allanlane5 Posts: 3,815
    edited 2006-12-04 23:41
    With a Servo, you can either position it pretty exactly within 180 degrees, or you can 'modify' it so it rotates continuously -- but you then lose the positioning ability. Unfortunately, they don't make 360 degree exactly positioned servo's. That I know of, anyway.

    So, if you DO use a modified servo, you'll need a 'position encoder' to tell you exactly what position the rotor is in.
  • staulkorstaulkor Posts: 5
    edited 2006-12-05 01:21
    Well I dont need exact locations. This is just something im playing with. Thanks for the info though [noparse]:)[/noparse]
  • TechnoRobboTechnoRobbo Posts: 323
    edited 2006-12-06 01:27
    SERIN 15, 16468, [noparse][[/noparse]DEC3 result(0),DEC3 result(1)] 'press space after if the number is less then 3 digits

    You declared "result" as a byte array so your limited from 0 to 255 per byte

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Have Fun


    TR

    Post Edited (TechnoRobbo) : 12/6/2006 1:31:32 AM GMT
Sign In or Register to comment.