Performing Multiple Commands Simultaneously
STP
Posts: 2
I am using the Parallax BS2 module to power a servo motor and count the number of ticks from an encoder on the motor. I am using the COUNT function to keep track of the transitions from high to low from the encoder, which seems to work fine. The problem, however, is that I cannot power the servo and use the COUNT function at the same time. Currently, I am powering on the servo, then using the COUNT function. Once the desired number of ticks is reached, I power the servo off. In doing it this way, I am confident that I am missing some of the ticks from the encoder, which will lead to error propagation pretty quickly.
Ideally, I would like to count the ticks from the encoder at all times, even while performing other tasks. Then I can ask for it's position when needed. Any suggestions as how to accomplish this?
Thanks,
Sam
Ideally, I would like to count the ticks from the encoder at all times, even while performing other tasks. Then I can ask for it's position when needed. Any suggestions as how to accomplish this?
Thanks,
Sam
Comments
Welcome to the Parallax forum!
The BASIC Stamp can do only one thing at a time. However, if your encoder pulses are spread far enough apart (i.e. much greater than 20 ms.) you can pulse the servo, then look for encoder edges. This document shows you how (PDF):
If your encoder has a finer resolution and produces pulses too quickly, then you will need a coprocessor to help you multi-task. The Parallax ServoPAL (which appears to be out of stock right now, unfortunately) is one such accessory which could help you in your quest.
-Phil
AM Algorithm Machine (2 Stamps)
SEED (10 Stamps)
Reflective Quantum Analyzer (4 Stamps)
Thanks for the help,
Sam
You can mix most Stamp processors and boards. I use a one wire interface on P0. Did you look at the schematic here? The Parallax Basic Stamp manual and the Parallax Software Programmer have examples. The software I use is found here and also found here.
I got relatively amazing accuracy out of a BS2 using wheel encoders ("tach sensors" according to Wiki, since they were not quadrature encoders), relays and DC gearmotors, so I didn't have to deal with servo pulsouts, just fast high/low statements to control motor speed relays. http://forums.parallax.com/showthread.php?118861-Homebuilt-Robotic-Platform-AKA-Retrobot&p=872766&viewfull=1#post872766
http://www.youtube.com/watch?v=PX0IhUqnwrk