Multitasking BX-24 w/ servo motors

Started by unix1020 February 9, 2006
Hello 
I am new to the bx-24 and programming so I hope you don't think I'm a 
chump with dumb questions.  I am building a walking Robot and I want to 
use the BX-24 as the brain.  I am going to have 17 servo motors,sharp 
IR range detector and a 5g accelerometer.  So far it is coming together 
very well, I have the distance senor and accelerometer working well 
with the BX-24.  My problem is with controlling the servo motors, it 
looks like I have to loop the pulseout command to get the servo to hold 
in its position. I have written a program to control 6 servos that move 
to a postiion and hold then move to another position and hold.  I used 
the mulitasking feature in the BX-24 operating system to accompish this 
but I have run into a problem.  The BX-24 has a max program size of 400 
bytes and each servo movement has its own task which requries a 32 byte 
stack, so I have maxed out the onboard RAM. Is there an easier way to 
control multiple servo motors?  I was thinking of purchasing a 
lynxmotion servo controller, would this be my best option?  

Thanks for the help
Unix-21
	
Hi!

I would suggest using a single task to control all of the servos. The pulses
occur at the same interval, with only the duration changing.
I have some pseudo code (IOW, not tested) on the BXDocs.com site that
illustrates this idea.

Basically, the task steps through each servo, sending the pulse for that
servo, and adding up the total of the pulses. It then subtracts the total of
the pulses from the interval, and does a sleep for that amount of time.

On the other hand, you said you need to control 17 servos. First, since
there aren't 17 pins available, you would have to multiplex the pins in
order to come up with enough pins. Secondly, you would need more than one
task, since the total of the pulses could exceed the interval. Could be
done, but wouldn't leave much ram or time for other tasks. Using a servo
controller or two might be your best option. I'm one to avoid buying extra
stuff, but sometimes that's the least expensive way to go. It would
certainly free up resources on the BX for other things like deciding where
the servos should be...

Sloan

----- Original Message ----- 
From: "unix1020" <unix-21@unix...>
To: <basicx@basi...>
Sent: Thursday, February 09, 2006 12:28 PM
	>I have written a program to control 6 servos that move
> to a postiion and hold then move to another
position and hold.  I used
> the mulitasking feature in the BX-24 operating system to accompish this
> but I have run into a problem.  The BX-24 has a max program size of 400
> bytes and each servo movement has its own task which requries a 32 byte
> stack, so I have maxed out the onboard RAM. Is there an easier way to
> control multiple servo motors?  I was thinking of purchasing a
> lynxmotion servo controller, would this be my best option?