Shop OBEX P1 Docs P2 Docs Learn Events
Controlling Tricopter esc's — Parallax Forums

Controlling Tricopter esc's

teganburnsteganburns Posts: 134
edited 2013-06-12 16:10 in Propeller 1
Working /w my tricopter i need help finding the right object to control the ESC's.

I need to make a 51Hz pwm signal with a 5 to 7 duty cycle.

Now here is the catch all of the object that i have found only give me a 5, 6, or 7 duty cycle and i need 5.1 & 6.4 ect. to control the motors accurately.

If I could control it down to the hundredths or thousandths place that would be even better!

Thanks in advance!
«1

Comments

  • W9GFOW9GFO Posts: 4,010
    edited 2013-05-25 17:56
    51Hz? 50Hz is the standard. The Servo32 object can drive 32 servos at 50Hz with one microsecond resolution. Not sure what you mean by 5.1 duty cycle...
  • teganburnsteganburns Posts: 134
    edited 2013-05-25 18:25
    It works with both 50Hz & 51Hz when i did readings from the receiver of the RC craft with my multimeter and the prop the signals were closer to 51 Hz so i just stuck with that.

    I uploaded code("Example") that uses the FREQOUT_X31.spin object. (shows "duty")

    Duty cycle is explained here -->http://www.youtube.com/watch?v=FKKcVR-2a1I


  • Duane DegnDuane Degn Posts: 10,588
    edited 2013-05-25 18:38
    Do you know how to control a servo with a Propeller? If not forget about the ESCs for now and learn to control a servo. ESC use the same pulse length signal for their control.

    Servos and ESCs don't use duty cycle for control, it's the pulse length that's important.

    As Rich says, use the Servo32 object for both servo and ESC control.

    What Propeller board are you using?

    Do you need to read the pulses in from the receiver?
  • W9GFOW9GFO Posts: 4,010
    edited 2013-05-25 18:38
    I didn't watch it all but that video is talking about pwm as it applies to motor control not servo pulses (ESCs expect servo pulses). Of course you can express a pulse width in terms of duty but for driving servos you want to specify the pulse width. For example a pulse width of 1,500 microseconds is generally considered the center value. If you use duty cycle to express that pulse width then it will change if the frequency changes, which you don't want. The pulse width is what is important, the frequency, not so much.

    I think Servo32v8 is the most current servo driver object, Servo32v7 is included with the Propeller tool.
  • Cluso99Cluso99 Posts: 18,069
    edited 2013-05-25 19:08
    IIRC I posted a driver that I used to control my 4 escs (and read from the remote receiver) on obex. If not, then it is in an old QuadCopter thread of about 2 years ago.
  • kuronekokuroneko Posts: 3,623
    edited 2013-05-25 19:20
    W9GFO wrote: »
    I think Servo32v8 is the most current servo driver object, Servo32v7 is included with the Propeller tool.
    We're at v9 now (http://forums.parallax.com/showthread.php/147219-CODE-UPDATE-Servo32v9).
  • teganburnsteganburns Posts: 134
    edited 2013-05-25 19:33
    Duane Degn wrote: »
    Do you know how to control a servo with a Propeller?

    Servos and ESCs don't use duty cycle for control, it's the pulse length that's important.

    As Rich says, use the Servo32 object for both servo and ESC control.

    What Propeller board are you using?

    Do you need to read the pulses in from the receiver?

    I CAN control a servo with the propeller, do i completely understand the full concept... not quite.

    I'm using the Prop plug.

    and i read the pulses from the receiver using "_FreqCount.spin"

    I added pictures and data to help clarify.
    1024 x 768 - 80K
    1024 x 768 - 87K
    1024 x 768 - 80K
  • teganburnsteganburns Posts: 134
    edited 2013-05-25 19:35
    Cluso99 wrote: »
    IIRC I posted a driver that I used to control my 4 escs (and read from the remote receiver) on obex. If not, then it is in an old QuadCopter thread of about 2 years ago.

    If you could post a link that would be awesome!

    It's impossible to find anything in OBEX with all the old links broken
  • Duane DegnDuane Degn Posts: 10,588
    edited 2013-05-25 19:40
    I modified an object which reads six (or fewer) RC signal lines. The original code had to have the lines connected to the first six Propeller pins. I modified so it could use any of the Prop's I/O pins (they don't need to be consecutive either).
  • Duane DegnDuane Degn Posts: 10,588
    edited 2013-05-25 19:47
    teganburns wrote: »
    I CAN control a servo with the propeller,

    Good, that makes using an ESC easy. The off state uses a pulse that would turn the servo all the way clockwise (1000us or so (if can vary)). Full throttle would use the same pulse as moving the servo all the way counterclockwise (2000us or so).

    Like servos the pulses should be sent 50 times a second (servo32v9.spin takes care of this for you).

    I'd suggest using Cluso99's object or the object I linked to to read in the pulses.

    (BTW, I think that's a Prop Stick. A Prop Plug is used to program a Propeller board that doesn't have its own USB connection.)
  • Duane DegnDuane Degn Posts: 10,588
    edited 2013-05-25 19:58
    Tegan,

    IIRC, you have a QuickStart board. You could test out your ESCs with my QuickStart servo tester program. Connect the signal line to on of the pins between P8 and P15 (inclusive) and watch the terminal window as you adjust the pulse length. Post #2 of the thread has instructions on how to adjust the pulses and end points (you probably don't need to adjust the endpoints for an ESC).
  • Duane DegnDuane Degn Posts: 10,588
    edited 2013-05-26 23:23
    Duane Degn wrote: »
    Like servos the pulses should be sent 50 times a second (servo32v9.spin takes care of this for you).

    I wanted to correct the above statement. Apparently many ESCs work well with a higher refresh rate than 50Hz. Jason Dorie's quadcopter code uses 250Hz refresh rate on the ESCs.

    Now that I think of it, I seem to remember Rich telling me many ESCs can make use of a higher refresh rate than normal servos. Servo32v9 will still work with ESCs but if you want to use a faster refresh rate you can use the object in Jason's program (its name is Servo8Fast.spin). It's not a drop in replacement for Servo32v9 so make sure to read the comments to see how to use the object.
  • teganburnsteganburns Posts: 134
    edited 2013-06-02 19:19
    So I tried a few of the suggestions and i found that this object fit my needs best--> (http://obex.parallax.com/object/225) Thank @cluso99 btw

    And i have ran into another bump in the road that i will need help with.

    I am messing around with the code and can't get multiple esc'c running.

    I am not very fluent with the PASM language.

    I have attached the altered code, with notes, that i have so far.

    Thanks all
  • Duane DegnDuane Degn Posts: 10,588
    edited 2013-06-02 19:39
    I think you picked the wrong object. I think you'd be a lot better off starting with an object that can control multiple servos/ESCs.

    The objects I mentioned in post #14 would be a better match for your application IMO.

    Do you have a servo to move the third motor? Tricopters need one of the motors to be able to rotate in order to control yaw. There a different beast than quadcopters.

    Besides controlling the three ESC, you also need to control the position of one servo.

    I'd think it would be easier to make a quadcopter than a tricopter.
  • teganburnsteganburns Posts: 134
    edited 2013-06-02 21:08
    Duane you are correct thank you!

    I tried to use the servo8fast program before but couldn't figure out what to set for the parameters. I looked at the "Main - Hoverfly open" object but there was a simple error in the code when i attempted to compile it to the prop.(guess i gave up too quickly)

    All in all I fixed the error and looked at the program more closely and all esc's and the servo are working! (Yay!!)

    The reason i made a Tricopter over a quad is the Yaw movement makes outdoor maneuvers and obstacle avoidance far easier.
  • W9GFOW9GFO Posts: 4,010
    edited 2013-06-02 21:28
    teganburns wrote: »
    The reason i made a Tricopter over a quad is the Yaw movement makes outdoor maneuvers and obstacle avoidance far easier.

    Uh, quads can yaw, I don't understand the reasoning,
  • teganburnsteganburns Posts: 134
    edited 2013-06-02 22:01
    Yes but when trying to write a program for the yaw on a tricopter its just adjusting the signal on the back servo attached to the motor.

    Compared to a quad you need to reduce the speed on some props while increasing the speed on other props to get the same motion.

    And if you are in flight moving forward all of this becomes more complex and tends to be more difficult to make smooth.
  • JasonDorieJasonDorie Posts: 1,930
    edited 2013-06-03 00:47
    I'm going to go out on a limb and guess you've never actually seen anyone who knows what they're doing fly a quad copter. :)

    This clip shows a quad running the code that Duane posted the link to.
    Watch it yaw at about 15 seconds in:

    [video=youtube_share;do0gaTNWtpU]

    Granted, a tri will yaw quicker, but you may need to compensate for the drop in lift as you tilt the propeller over, or your tail will drop a bit. The Servo8Fast code will handle a tri with no problems. If you're running an analog tail servo, be sure to use AddSlowPin to set the output pin for it. The ESCs can all be set with AddFastPin.
  • xanaduxanadu Posts: 3,347
    edited 2013-06-03 01:07
    The largest benefit of tricopters is that the rotors are further apart than a quad copter, giving front facing cameras an unobstructed view. For maneuverability 4 motors are better than 3 especially when it comes to stability. I'm looking forward to adding one to my hangar.
  • teganburnsteganburns Posts: 134
    edited 2013-06-03 01:31
    @JasonDorie Great video! Super stable Quad!

    I don't think the drop in lift for the rear motor will be a big issue but its definitely something that i will need to consider when writing and testing programs.

    Servo8Fast looks like it will be spot on for controlling the tricopter thanks!

    Gonna run some tests and get some ideas going and write some more programs tomorrow during the day.

    As for the servo I have a digital all metal gear servo and the AddFastPin method worked like a charm.
  • JasonDorieJasonDorie Posts: 1,930
    edited 2013-06-03 13:17
    Tegan - You should be able to take my QuadX main loop and modify just the "output" section and have it work for you. The block of code near the bottom that does the final mixing is all that would need to be changed to drive a tri instead of a quad. Look for:

    if( FrameConfiguration == 0 )

    Change the code under that to this:
            PartialPitch := (PitchOut * 222) ~> 8    'equivalent to PitchOut * sin(60), which should be correct if your arms are 120 degrees apart
    
            Output[OUT_FL] := Thro + ((-PartialPitch - RollOut) * ThroMix) ~> 6
            Output[OUT_FR] := Thro + ((-PartialPitch + RollOut) * ThroMix) ~> 6
            Output[OUT_TM] := Thro + (PitchOut * ThroMix) ~> 6      'TM = tail motor - you'll need to change the consts up top to match
            Output[OUT_TS] := ((YawOut) * ThroMix) ~> 6      'TS = tail servo
    

    ...and also remove the if(FrameConfiguration) thing and else case altogether. You'll probably need to change the OUT_xx consts to match your outputs, too.

    I haven't actually *tried* this, but I've been itching to do it.
  • teganburnsteganburns Posts: 134
    edited 2013-06-03 20:47
    Have any of you ever accidentally reprogrammed the escs while doing testing?

    I think i may have done this, so i ordered a esc programming card for my type of esc because i know i messed it up trying to manually reprogram the esc... :/

    Rather just spend ten dollars to save some time and effort and I have a feeling that i might do this again.
  • JasonDorieJasonDorie Posts: 1,930
    edited 2013-06-03 23:09
    As long as you always power up with the throttle held low it shouldn't happen. ESC usually interpret full throttle on power up as a signal to enter program mode. It's generally much better than the alternative. :)
  • AnubispodAnubispod Posts: 42
    edited 2013-06-04 14:24
    Hi, i am working for a few weeks now on a Quadcopter code , and i also fly quadcopter with Multiwii, and what i can tell you about the esc
    is that you should have way more then 50Hz update more like 500-800Hz. So you need some better esc or you will deal with a lot of woublle in flight :)
    Get some esc what can be reprogramed with the SimonK firmware (best esc firmware there is ...).

    I have some multistar esc von Hobbyking and reflashed them with the simonK firmware, and they run way smother then the original firmware what already is for quadcopter.so my esc
    went from 499Hz stock to 800 and wow what a big diffrence.

    Beside of that i just wait at the moment for my pcbs to arrive and then i will thest the prop version of a multiwii/Crazyfly gcc port to prop gcc :)
    As soon i have some code cleaning done i will post it here :)

    MfG
    Oliver .R
  • JasonDorieJasonDorie Posts: 1,930
    edited 2013-06-04 15:01
    The SimonK firmware's biggest improvement is not the rate at which it accepts input from the controller, but how quickly it will change the motor speed. Most ESCs have built-in speed ramping to prevent the motor from stripping gears, wasting power, or reacting to spikes in the R/C signal caused by dirty potentiometers on the transmitter. In a multi-rotor, the flight controller is dealing with all the signal conditioning, so the SimonK flash just feeds the throttle signal pretty much straight to the motor control loop, resulting in a MUCH quicker throttle response.

    I hear people say all the time that you should run your ESCs at 400 Hz or higher, but I've seen lots of quad and tricopters that were quite stable using off-the-shelf rate gyros, and those only run at 50 Hz. I'm not saying that a higher frame rate won't help, but I don't think it's the holy grail people seem to think it is. Maybe *with* the SimonK flash it'd make more difference.

    First video is showing the difference between a standard ESC and the same ESC flashed with SimonK. Note that the thing he's testing it with is just a standard servo tester, so it's only outputting a 50 Hz signal:


    This video shows a similar comparison using a heading lock gyro to control the ESC, first with a normal flash, then with SimonK, but it's using the same frame rate in both cases. In this case it's a high-rate gyro, so it's probably running at 280Hz:
  • Heater.Heater. Posts: 21,230
    edited 2013-06-05 06:14
    Anubisod,
    you should have way more then 50Hz update more like 500-800Hz.

    I'm sorry but I think this is nuts. I love to know who started this rumour and what evidence there is to back it up.

    There are a few things which make me think this is pointless:

    1) There is no point driving your control outputs at a faster rate than the rate at which you sampling your sensors, gyro etc. This does not make the control loop react faster. In fact I think it might create more problems than it solves.

    2) What about the inertia of the motor and propeller? There is no way the props can change speed, hence thrust, at 500Hz. I bet if you measured the propeller speed whilst giving the ESC a blip of full power lasting 2ms you would hardly see it respond. Consider how small and light a loud speaker cone is to reproduce sound at 500Hz, do you really expect your motor and Prop mass to be able to respond at that speed?

    3) What about the inertia of the entire copter. Even if the motor could go from zero to full thrust for 2ms and back again I bet you would hardly see the copter twitch.

    What we have is a control feedback loop from sensor to processor to ESC to motor to copter movement back to sensor. There is no point in running one link in that chain ten times faster than all the others can respond.

    I would imagine that the lowest possible control loop frequency might have advantages in keeping noise out of the system.

    If anyone has done any tests that contradict my assertions I would be glad to hear about them.
  • ShawnaShawna Posts: 508
    edited 2013-06-05 08:00
    I would have to agree with Jason and Heater on the refresh rate for the ESC's. I am also building a quad copter and awhile back I was having problems with my ESC Object. During these problems I switched my ESC refresh rate from 250Hz down to 50Hz and I saw no noticeable difference in the stability of the quad. I did not extensively test it, but there was no apparent difference to me.

    Faster is probably better, but only to a certain point, and I am not sure what that point is.

    Just my 2 cents
  • W9GFOW9GFO Posts: 4,010
    edited 2013-06-05 12:09
    I agree about the refresh rates. I suspect that only the smaller quads realize a real benefit from the higher values.
  • Heater.Heater. Posts: 21,230
    edited 2013-06-05 13:05
    Smaller quads may get benefit as they have less mass and can react faster. At the end of the day the whole control loop has a certain bandwidth and there is no point in one part of it having a much bigger bandwidth than the rest.
    That's my theory and I'm sticking to it.

    I didn't get the idea of a tricopter having it's motors further apart so as to get a better camera view either. What's that about? If you want the motors further apart put them further apart. Anyway surely a tri is harder to design and control than a quad as the rotational forces are not balanced nicely?
Sign In or Register to comment.