Newbie question on multitasking
Jack Ofall
Posts: 2
Hi,
Thanks for taking time to read.
I bought Boe-bot kit last week
( http://www.parallax.com/Store/Robots/AllRobots/tabid/128/ProductID/302/List/1/Default.aspx?SortField=ProductName,ProductName)
and I started with the activities in the book 'Robotics with Boe-Bot. It is fun.
I thought of doing the following. I have 3 continuous rotational servos.
I want to run Servo1 for 60 seconds.
while it is running, I want to start servo2 and servo3 to run from 15 seconds to 25 seconds during the servos 60 second rotation.
Th examples I have worked with seems to be single task oriented.
I presume the problem I am solving is a multi-tasking.
Could someone point me or help me in the right direction of how I can accomplish the above task.
Thanks
-Jack
Thanks for taking time to read.
I bought Boe-bot kit last week
( http://www.parallax.com/Store/Robots/AllRobots/tabid/128/ProductID/302/List/1/Default.aspx?SortField=ProductName,ProductName)
and I started with the activities in the book 'Robotics with Boe-Bot. It is fun.
I thought of doing the following. I have 3 continuous rotational servos.
I want to run Servo1 for 60 seconds.
while it is running, I want to start servo2 and servo3 to run from 15 seconds to 25 seconds during the servos 60 second rotation.
Th examples I have worked with seems to be single task oriented.
I presume the problem I am solving is a multi-tasking.
Could someone point me or help me in the right direction of how I can accomplish the above task.
Thanks
-Jack
Comments
Here is one way to do it;
Rich H
In your program you create an array of nibbles to hold these values. Your program consists of an outer loop which indexes though the array, and reads the value. The inner loop pulses the servos indicated in a loop for the amount of time in a segment. The program loops back to the array reading label.
With coordinated arrays you can do things like have the time segments be variable, as well as the speed and direction of the servos.
warm regards
-Jack
Start your loop for the first servo and inside that loop set up a condition to trigger a second or third servo. So you are using your pause time from the first servo to trigger a second or third servo.
It would look something like this -
Start servo one loop
Move servo one
Move servo two
Move servo three
End loop
You could do if statments, case statements, while statments or any number of statments to use the pause time in the loop of the first servo to get things to work.
In short, the theory of what you showed in your code but by utulizing the pause times instead.
Warning, if you put to much into the loop code it will slow down your servo speed.
If you think of a player piano or music box, there's a roll of paper or metal which moves past the reader. A value is encoded at that spot which the mechanism reads and this value either moves keys or tines. So the analogy is to think of the array like the paper and your servos like tines. The presence of a value can turn them on and off.
So I was talking about was a program like the one attached. A more complex program could not only lookup the servos to activate, but their speed and direction. What you would have at that point is a data driven program where you can change behaviors by changes of data.
Disclaimer, I wrote this to show what I mean and I haven't tested it.
http://www.parallax.com/StoreSearchResults/tabid/768/txtSearch/servopal/List/0/SortField/4/ProductID/481/Default.aspx
In the case of Boe-Bot, one servo and two others on the ServoPal can run independently.
The ServoPAL is a tiny module that plugs in between your BASIC Stamp and two servo motors to pulse the motors so your PBASIC program doesn't have to. In addition, it provides an alarm clock function to perform timing in the background while the BASIC Stamp is busy with other tasks.
Features:
- Plugs in between servo headers and servos: no wiring necessary.
- Simplifies PBASIC programming for both standard and continuous-rotation servos.
- Pulses two servos continuously based on single pulses received from the BASIC Stamp.
- Provides an alarm output (200mS to 30 min delay), which can be set by a single pulse.
- All interfacing is done by pulsing: no serial protocols to learn.
- Runs from the servo's power (up to 6.5VDC): no additional power source needed.
Key Specifications: