PDA

View Full Version : BS2, 2 Servos, and multiple variables inputed through SERIN



staulkor
12-05-2006, 06:17 AM
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, [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.

allanlane5
12-05-2006, 06:41 AM
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.

staulkor
12-05-2006, 08:21 AM
Well I dont need exact locations. This is just something im playing with. Thanks for the info though :)

TechnoRobbo
12-06-2006, 08:27 AM
SERIN 15, 16468, [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