Idea for new 32 servo controller
jtbrownlee
Posts: 9
I have been working on a quadcopter project over the past year and trying to get code written to fly. After searching for objects to control the speed controllers all had some feature that was missing or could be improved(Used to many cogs, low resolution, not able to control enough servos). I have a program wrote in assembly that controls 10 servo channels at 250Hz with a resolution of 10 clock cycles(I believe that is 0.125us at 80mHz).
Theory:
1. All 10 pins are turned on.
2. Values are read from main memory.
3. Values are organized from least to greatest.
4. Pins are turned off in order of least time on to greatest(only requiring a waitcnt and xor instruction per pin).
5. Waits 4ms from step 1 and loop.
All the overhead is done in the between the time the pins turn on and the first one turned off. Theoretically you could have 10 zones within a 20ms refresh(keeping the pulse length 2ms or less)
If I remember correctly the overhead never went much over 2000 clock cycles so that leaves room for more channels per zone(If using digital servos or BLDC controllers I don't think it matters about staggering pulses).
At the moment I have 3 digital servos that I am using to test moving them from channel to channel and it seems to work. Although after adding an object to read 4 channels from my DX8 radio and converting them to control 8 channels for my quad I have some problems.
I would like to improve the object so that when call upon you can specify zones, channels, and refresh rate. Then post it in the OBEX.
I was just wondering if anyone thought this is a good idea and would be useful.
Theory:
1. All 10 pins are turned on.
2. Values are read from main memory.
3. Values are organized from least to greatest.
4. Pins are turned off in order of least time on to greatest(only requiring a waitcnt and xor instruction per pin).
5. Waits 4ms from step 1 and loop.
All the overhead is done in the between the time the pins turn on and the first one turned off. Theoretically you could have 10 zones within a 20ms refresh(keeping the pulse length 2ms or less)
If I remember correctly the overhead never went much over 2000 clock cycles so that leaves room for more channels per zone(If using digital servos or BLDC controllers I don't think it matters about staggering pulses).
At the moment I have 3 digital servos that I am using to test moving them from channel to channel and it seems to work. Although after adding an object to read 4 channels from my DX8 radio and converting them to control 8 channels for my quad I have some problems.
I would like to improve the object so that when call upon you can specify zones, channels, and refresh rate. Then post it in the OBEX.
I was just wondering if anyone thought this is a good idea and would be useful.
Comments
Is the resolution ten clock cycles or ten instructions?
Do you have a check to make sure there's a minimun waitcnt time? I'm not sure what the minimum waitcnt is in PASM, I think it's somewhere between 5 and 10 clock cycles.
Do you really have a need for greater than 1us resolution? It's hard for me to see a 1us movement on a servo. I haven't tried to change any ESC signals by only 1us, but it's hard for me to imagine any ESC being able to make use of sub 1us resolution.
It would be great to see your code, I'd like to see you PASM method of sorting the pulse durations. I think this technique could also be useful for making a multi-channel PWM driver.
http://obex.parallax.com/objects/445/
Right now there is no check. The values from the object ServoInput are in microseconds. To convert them to clock cycles(what the assembly program uses) multiply by 80 and it will always be a multiple of 10.
I think it would work great for PWM and would be glad to share the code. What would be the best way to do that? I have to fix my test board(believe one of the voltage rectifiers is bad), but once it is back up and going I will get a test program wrote to demonstrate it. All the propeller programming that I have learned is from the manuals and other objects that I have looked through. My programming experience consists of some QBASIC back in high school and a couple classes in college(1996). I played around with a basic stamp before realizing the propeller was what I needed for my project. So I'm not guaranteeing how well written my code is and hoping for some constructive criticism.
As far as needing the resolution I'm not sure of the speed-controllers on the current setup I have built, but I know that Castle Creations brushless speed controllers have a 11-bit resolution(2048 steps) which is twice as much as 1us. With the 8000 steps the 0.125us resolution will give, that should guarantee full use of the speed controllers resolution. Also the radio I am using has a 2048 resolution. For just control inputs the resolution probably wouldn't matter much even with adding curves to the inputs, but I would think you could get some added stability in a quad-copter with higher resolution.
My quad project so far only requires 10 channels(8 motors and 2 servos). I started working on this driver to learn to programming the propeller(still a lot to learn) and maybe improve my project. I am hoping it will turn into a very versatile driver.