Shop OBEX P1 Docs P2 Docs Learn Events
Idea for new 32 servo controller — Parallax Forums

Idea for new 32 servo controller

jtbrownleejtbrownlee Posts: 9
edited 2013-01-01 23:47 in Propeller 1
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.

Comments

  • Duane DegnDuane Degn Posts: 10,588
    edited 2012-12-31 16:15
    jtbrownlee wrote: »
    controls 10 servo channels at 250Hz with a resolution of 10 clock cycles(I believe that is 0.125us at 80mHz).

    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.
  • JonnyMacJonnyMac Posts: 9,108
    edited 2012-12-31 16:22
    I have never needed so many servos so my driver only handles eight, but could be expanded to 16 (by using the second counter). The upside is that it is 100% Spin (= easy) and by using the counter in a timed loop, I get very precise outputs and while the pulse for a given servo is running the loop is calculating what to do with it for the next cycle (e.g., ramping). So... if you can live with 16 servos, have precise position control, and only use one cog, a few minutes of updating this object will get you there.

    http://obex.parallax.com/objects/445/
  • jtbrownleejtbrownlee Posts: 9
    edited 2013-01-01 23:47
    The resolution is 10 clock cycles(minimum of 6 for waitcnt and 4 for xor). When tested if the values were less than 10 apart it had to wait for the counter to count all the way back up.

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