Explanation on Servo_32_v7?
Circuitbuilder9
Posts: 85
Hi, all.
I was looking at the assembly code of Servo_32_v7, and i am confused on how the servos can all operate at one time. Any answers? I am really lost on this one.
I want to use this object, but i want to understand how one cog can operate the 32 servos simultaneously, since i want to do a robotics project soon.
I was looking at the assembly code of Servo_32_v7, and i am confused on how the servos can all operate at one time. Any answers? I am really lost on this one.
I want to use this object, but i want to understand how one cog can operate the 32 servos simultaneously, since i want to do a robotics project soon.
Comments
It is a solid object. I use it all the time.
In case you haven't seen 32 servos being driven at once by a Prop, you ought to check out my 32 servo demo.
What causes the servos to act simultaneously (by pin) if they start at time periods after other servos?
In the object, it is explained that up to 8 servos are operated among 4 different time zones in a 20ms period. The zones confuse me, on how the servos can operate all at once.
As you can see, i am frustrated about this scenario of simultaneous control.
Also remember that, because the output register controls all 32 I/O pins, any combination of any number of I/O pins can be changed at the same time with one operation (within a nanosecond or so).
Welcome to the forums!!
As it has been mentioned there are 4 zones of 8 controllable servos within each zone. Each Zone is staggered by a delay 5ms before the next zone is allowed to start. By the time that each zone has had a succession, the total time each zone 'sees' is 5ms, with a repetition rate every 20ms. Within each zone, all 8 servos that are enabled will have their corresponding signal pin go high, and then each servo signal pin will go low in turn depending on if the desired pulse width was reached. After 2ms all of the servo pins should have gone LOW. The remaining 3ms within the Zone are used for processing overhead... updating new values, etc. After a total of 5ms, the next zone is started where all 8 of the servos in that zone that are enabled will have their corresponding pin go high, and thus the process repeats to the next available zone.
In the frame of one of the 4 zones, do all the servos have to move the same direction and speed? How can you control the 8 servos differently, as they may have to do different tasks, and not act in the same accord?
Lastly, Do the zones affect the timing of all the servos, since there is a 5ms zone, and 8 servos in each zone have to go after the first zone?
Beau is saying that since the min pulsewidth is 1ms, he turns on all servos outputs, then based on a scheduler algorithm, he turns off the corresponding outputs at the right time.
The simplest way to implement this is to have an array of 32 servo commanded values.
1. Turn on all outputs in the array segment you are working
2. Scan the segment of the array you are working to find the shortest pulsewidth
3. Sleep until the pulsewidth expires
4. Shut off output
5. Go to 2
Since there are only 32 pins on the Prop, Beau's code works for that. However, if you had a serial I/O expander, this method of scheduling could probably due a lot more servos, but only to a given resolution in SPIN, you would need PASM to get high enough resolution to serve a lot of servos *AND* have proper angular precision.
The servos can be controlled individually. As I linked to earlier, I demonstrated driving 32 servos with each servo moving independently from each other.
There are also several hexapods (including my popsicle stick bot) that have had all 18 servos controlled using this same servo driver.
As pedward mentioned, with IO expanders, a Propeller could drive even more servos. In this thread Beau shows how to drive 144 servos.
Short answer, no.
The servo pulses aren't started or ended one at a time. If all the servos in a zone had the same pulse length, then they'd all be turned on and off together.
The variable "ServoByte" is adjusted one servo at a time but the line:
Is the code that turns on or off the I/O pins. So all eight pins are turned on or off at the same time (assuming identical servo pulses).
Since your idea probably isn't about the original poster's question, I think a new thread is in order.
BTW, welcome to the forum. I'll be watching for your servo thread.
Just about any Propeller board that lets you access all 32 I/O pins can be used to drive 32 servos.
Here's an example of a QuickStart board driving 32 servos.