Shop OBEX P1 Docs P2 Docs Learn Events
Performing Multiple Commands Simultaneously — Parallax Forums

Performing Multiple Commands Simultaneously

STPSTP Posts: 2
edited 2012-11-03 15:16 in BASIC Stamp
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

Comments

  • Phil Pilgrim (PhiPi)Phil Pilgrim (PhiPi) Posts: 23,514
    edited 2012-10-30 20:18
    Sam,

    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
  • John BoardJohn Board Posts: 371
    edited 2012-10-30 23:40
    Although you probably know, and it's not practical, I'd just like to throw in that the other chip which paralax stocks, the Propeller Chip, can execute multiple things at once. I'd suggest checking it out, there's a bit of a steep learning curve involved with it, but it's well worth the effort :)
  • HumanoidoHumanoido Posts: 5,770
    edited 2012-11-02 13:22
    I would also point out that two stamps can interface together in parallel and handle multiple tasks at one time. Plus, they don't have the high learning curve of the propeller chip. For examples, the following is a short list of some machines I created with Stamps.

    AM Algorithm Machine (2 Stamps)
    SEED (10 Stamps)
    Reflective Quantum Analyzer (4 Stamps)
  • STPSTP Posts: 2
    edited 2012-11-02 18:18
    I do have access to another Stamp; perhaps this secondary Stamp could be used solely to monitor the activity of the encoder. But how do I get the two Stamps to communicate together? Both Stamps are BS2; however, the primary board is the "BOE Development Board", and the secondary board is the "Super Carrier Board".

    Thanks for the help,
    Sam
  • HumanoidoHumanoido Posts: 5,770
    edited 2012-11-03 11:00
    STP wrote: »
    I do have access to another Stamp; perhaps this secondary Stamp could be used solely to monitor the activity of the encoder. But how do I get the two Stamps to communicate together? Both Stamps are BS2; however, the primary board is the "BOE Development Board", and the secondary board is the "Super Carrier Board". 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.
  • ercoerco Posts: 20,257
    edited 2012-11-03 15:16
    Assuming that you don't miss any encoder ticks while sending serial commands, a ServoPal might be your best solution here. Don't bother with the COUNT command, that will not yield accurate encoder counts. Your program needs to run a tight, small loop doing 90% encoder counting and VERY brief periods doing other things like deciding what to do and sending the commands to do it.

    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
Sign In or Register to comment.