Shop OBEX P1 Docs P2 Docs Learn Events
Control of Turnigy ESC AE-20A — Parallax Forums

Control of Turnigy ESC AE-20A

JBWolfJBWolf Posts: 405
edited 2013-03-05 17:33 in Propeller 1
Hello everyone,
I am starting a new project that uses the parallax model 750-90002 outrunner RC motor and a Turnigy electronic speed controller (ESC).
I have Turnigy model AE-20A ESC's and have been trying to figure out how to go about controlling it from the propeller chip.
I noticed the ESC I am using is also a very similar model to what is being used for the Elev8 project.
My project is a type of spinning clock. There is a 'blade' attached to the motor which I will be lighting up with LED's. I need the RPM to be constant or a way to trigger the LED's when in correct physical position for a steady image.

I have not connected or programmed the ESC yet... I would like to get more familiar before attempting anything as this will be my first time using an ESC.

First question... connecting to propeller for programming.
The connection from the ESC that would normally go to a radio receiver is 3-pin... I am assuming the white wire is for data, so connect the white wire to any desired prop pin?
Would connecting the red/black wire to the prop's 3.3v power be fine? Or is it a different voltage?
The ESC main power (where batteries would normally be used) will be a 12v switching power supply.

Second Q:
For programming the ESC, the instruction manual looks like it only uses 2 or maybe 3 input values (up, down, middle)... i.e. to start programming, hold throttle in 'up' position and power on the ESC, wait for tones.
So for programming the ESC from the prop, I was thinking of using 2 buttons on different prop pins to set the output of the ESC data wire at 'throttle up' position and 'throttle down' position.
So if I press button 1, the pin connected to the ESC data wire is set with outa[1]~~ to simulate a 'throttle up' position.
If I press button 2, the pin connected to the ESC data wire is set with outa[1]~ to simulate a 'throttle down' position.
Will this work? or should I use DUTY instead of outa? or does it work off of current sensing and so I should use a potentiometer?

Third Q:
This is more an extension of question2... for use after programming, how to go about controlling the speed of the motor connected to the ESC.
What kind of input does the ESC use for controlling the speed of the attached motor? Would I use DUTY on the ESC data wire for controlling the speed and simulating the throttle of an RC controller?
I am not sure yet of my desired RPM, but it will need to remain constant after finding an optimal speed.
I am worried about the project flipping on its side during startup while trying to go from 0 to set RPM due to torque, so I will need to ramp the starts.


I appreciate any help, I am worried about damaging electronics by using a trial and error process to figure this stuff out.
I see quadcopters are a hot topic right now! Hoping after this project to use the gained knowledge in building of my own :)
Sincerely,
J

Comments

  • Duane DegnDuane Degn Posts: 10,588
    edited 2013-02-27 12:21
    JBWolf wrote: »
    First question... connecting to propeller for programming.
    The connection from the ESC that would normally go to a radio receiver is 3-pin... I am assuming the white wire is for data, so connect the white wire to any desired prop pin?
    Would connecting the red/black wire to the prop's 3.3v power be fine? Or is it a different voltage?
    The ESC main power (where batteries would normally be used) will be a 12v switching power supply.

    No. Don't connect the red line to the 3.3V line. Many ESCs have battery elimination circuits (BEC) to provide the radio receiver with 5V. This would harm the Propeller. If this ESC doesn't have a BEC, then 3.3V wouldn't be enough to power the ESC circuit (if it requires an addtional 5v line).

    The white line is the signal line which connects to the Prop. The black ground line should connect to both the ESC's power supply and the Prop's ground (you need a common ground connection).

    Do you have a normal servo to experiment with? If so if might be easier to get a feel for controlling a servo before learning to control an ESC.
    Second Q:
    For programming the ESC, the instruction manual looks like it only uses 2 or maybe 3 input values (up, down, middle)... i.e. to start programming, hold throttle in 'up' position and power on the ESC, wait for tones.
    So for programming the ESC from the prop, I was thinking of using 2 buttons on different prop pins to set the output of the ESC data wire at 'throttle up' position and 'throttle down' position.
    So if I press button 1, the pin connected to the ESC data wire is set with outa[1]~~ to simulate a 'throttle up' position.
    If I press button 2, the pin connected to the ESC data wire is set with outa[1]~ to simulate a 'throttle down' position.
    Will this work? or should I use DUTY instead of outa? or does it work off of current sensing and so I should use a potentiometer?

    An ESC is controlled the same way a servo is controlled. The Servo32v7 object in the Propeller Tool library will do this for you. You could either have a special program to calibrate your ESC or have the Prop do the calibration with each start up using a set times to send the appropriate pulses or you could use your button idea.
    Third Q:
    This is more an extension of question2... for use after programming, how to go about controlling the speed of the motor connected to the ESC.
    What kind of input does the ESC use for controlling the speed of the attached motor? Would I use DUTY on the ESC data wire for controlling the speed and simulating the throttle of an RC controller?
    I am not sure yet of my desired RPM, but it will need to remain constant after finding an optimal speed.
    I am worried about the project flipping on its side during startup while trying to go from 0 to set RPM due to torque, so I will need to ramp the starts.

    The servo object has a ramping feature but I usually do my own ramping as part of the control program. Ramping is probably a good idea in this case but the ESC might take care of some of that for you.
  • waymond91waymond91 Posts: 15
    edited 2013-02-27 13:30
    Basically you control a servos position by writing a high pulse on the data that is between 1us and 2us. If the pulse is only 1us the servo will go to I tv s lowest position and 2 Millie will set it to its highest. I believe most servos expect a pulse every 20 millis, but I may be wrong.

    I expect your escs range to be within this pulse width range. You can use your cogs timer to set these pulses. You will probably need to write an arm sequence as well for your esc.
  • Duane DegnDuane Degn Posts: 10,588
    edited 2013-02-27 13:40
    waymond91 wrote: »
    Basically you control a servos position by writing a high pulse on the data that is between 1us and 2us. If the pulse is only 1us the servo will go to I tv s lowest position and 2 Millie will set it to its highest. I believe most servos expect a pulse every 20 millis, but I may be wrong.

    Almost, the pulse should be between 1ms (1000us) and 2ms (2000us). There are some servos that can operate will outside this range (the small blue HobbyKing servos) but 1000us to 2000us is a good range for an ESC.
    I expect your escs range to be within this pulse width range. You can use your cogs timer to set these pulses. You will probably need to write an arm sequence as well for your esc.

    It's even easier than using a cog timer, just use the object "servo32v7" and you can control up to 32 servos.

    Many ESCs need to brought to a low throttle setting before they may be used at other settings.
  • JBWolfJBWolf Posts: 405
    edited 2013-02-27 14:32
    I managed to burglarize a servo from one of my RC toys... an Airtronics 94102
    Do servos need a power supply? I cannot find a spec sheet for this servo and there are 3 wires, Red + black + black... not sure what to connect where
  • Mark_TMark_T Posts: 1,981
    edited 2013-02-27 15:08
    JBWolf wrote: »
    I managed to burglarize a servo from one of my RC toys... an Airtronics 94102
    Do servos need a power supply? I cannot find a spec sheet for this servo and there are 3 wires, Red + black + black... not sure what to connect where

    Pretty much everything needs a power supply!

    Yes, you'll need a supply of 5 or 6V or so capable of at least 0.5A, preferably 1A, and don't share this supply with the digital electronics.
    4 AA cells (alkaline or NiMH) will make a reasonable supply.

    To distinquish which of the two black wires is 0V might involve some investigation - you did take a note of how it was connected in the RC toy
    I hope...
  • JBWolfJBWolf Posts: 405
    edited 2013-02-27 15:37
    yes, it was connected to the receiver port marked 'throt' lol
    Not much help there as I cannot visually determine much.
    Without destroying the receiver case I cannot access the board, it does not simply unscrew and come apart.
    This is an expensive receiver and I am not willing to risk destruction.

    My best guess would be that the red wire is anode and next closest wire is gnd.... or maybe the 2 blacks are +/- and red is signal... hmm
  • JBWolfJBWolf Posts: 405
    edited 2013-02-27 17:27
    ok searched everywhere trying to find something to identify the wires... here is something I think will help:
    http://www.airtronics.net/index.php/airtronics-adaptor-z-servo-to-older-atx-receiver.html

    It's a legacy adapter... shows the wires changing color to red/black/blue.
    I think blue is it... so farthest wire from red. ill give it a try
  • JBWolfJBWolf Posts: 405
    edited 2013-02-27 20:20
    ok I hooked it up but no movement.... turns out servos dont fare well after sitting in a damp basement for 12 years.
    Serious corrosion, it wont budge even with pliers! I may just have to try it with the ESC
    IMG_2739 - Copy.jpg
    1024 x 768 - 87K
  • waymond91waymond91 Posts: 15
    edited 2013-02-27 20:57
    Wow! I have never seen anything like that before! I think you should be okay testing directly on the esc, with the esc connected to the motor. JUST MAKE SURE YOU LEAVE THE PROPELLER OFF THE MOTOR WHILE YOU ARE TESTING. That can be a painful lesson lol.
    Basically, your should will have an arming sequence (normally this is done on the transmitter by pulling the throttle low, then high, then low again). You can do this with a pre-made servo object if you like. You may have to map the esc values against the servo values. (ie, writing the servo to 0 degrees may not be 0 on the esc, likewise, writing the servo to 180 might not be writing the esc to 100% throttle).
    This is because on most rc airplanes, you do not typically use the full 180 degrees of the servo, it is most often centered at 90 and then can go 45 degrees forward or back.
    I am curious to see how your quadrotor turns out. I started an autopilot earlier this summer, and I am getting close to figure it out. I posted an instructable explaining some of the basic concepts, and I also signed up with DIY drones, a lot of help to be found there as well.
  • Heater.Heater. Posts: 21,230
    edited 2013-02-27 23:22
    JBWolf,
    I can't help but think that an outrunner RC motor and ESC are expensive solutions to building a propeller clock. Not to mention that they are over the top in capability for such a simple task. Do you really need speed control on your LED propeller? Hundreds of Propeller clocks have been built with much lower tech motors, or motors salvaged from hard disk drives, VCR's etc, all sorts of things. YouTube is full of such videos.

    I'd take up the challenge of doing the clock the minimalist way and save the motor/ESC for something that needs them like, you know, flying things.
  • JBWolfJBWolf Posts: 405
    edited 2013-02-28 08:45
    I agree, it is a bit expensive and I do literally have a box full of random motors.
    The spinner/blade is machined aluminum so it weighs a bit more, but balanced well.
    I have used stepper motors triggered with a ULN2803 on the prop for high torque/low speed applications.... but this will be my first time working with a high speed & precise position application.
    I was hoping to learn what I set out for in this thread so I could accomplish this project and also use the gained knowledge for working on a quadcopter later on.
    I do not find the price of these components overly expensive as I am not planning to make more than two, I owe a friend a favor and he really seemed impressed the first time we saw a spinning clock... this would make a perfect gift.
  • JBWolfJBWolf Posts: 405
    edited 2013-02-28 09:40
    How should I modify the Servo32v7 to work with an ESC, especially for programming.
    I see the first movement command in the demo is :
    SERVO.Set(ServoCh1,1500) 'Move Servo to Center
    So I'm assuming changing 1500 to 0 would simulate a full off and 3000 full on?

    Now I also see the changes in movevents are done by 'panning' via ramping:
    'SetRamp(Pin, Width,Delay)<-- 100 = 1 sec 6000 = 1 min
    SERVO.SetRamp(ServoCh1,2000,200) 'Pan Servo

    So for programming the ESC on first run...
    SERVO.Set(ServoCh1,3000) 'full on to start programming
    ' delay for tones
    SERVO.Set(ServoCh1,0) 'full off to finish programming


    If that works for programming... then this for bringing up to desired rpm?
    SERVO.SetRamp(ServoCh1,2000,200)

    What you guys think?
  • JBWolfJBWolf Posts: 405
    edited 2013-02-28 11:03
    Trying to understand how the ESC works...
    So if the ESC just uses PWM for speed control and programming... how exactly does it use the pulses?
    Does it simply turn on full power when it receives a pulse and by limiting the amount of time on/off = stable rate of revolution?
    Or is there an IC doing interpretation such as waiting for the pulse to finish then uses voltage modulation to control the rpm?
    I think if I can understand the concept behind the ESC it would help me in control of it.
  • Heater.Heater. Posts: 21,230
    edited 2013-02-28 11:22
    For sure there is a chip in there.
    A motor requires a sequence of power pulses on 3 lines to get the thing to turn. Modern brushless RC motors are not using old fashioned mechanical comutators to do that. Some electronics has to do that for you.
    Meanwhile on the input side you are providing a pulse width command to say what power you want.

    If it were me I'd just start sending it normal RC servo pulse width modulated signal, as described above, and see what happens.
  • JasonDorieJasonDorie Posts: 1,930
    edited 2013-03-01 12:36
    Servo.Set() takes a microsecond pulse length value to send to the servo / ESC. The range of allowable values is 1000 to 2000, corresponding to 1000us to 2000us. You don't have to modify anything - you can just use it right out of the box. 1000 will be "motor off" and 2000 will be "full throttle".

    The ESC has a microcontroller on it that measures the duration of the pulses you send, and uses that to set the amount of power applied to the motor. It generally does not control RPM, though some helicopter ESCs do have a governor option which will do that.

    For your motor clock, the best thing you can do is use a sensor to detect the RPM of the motor. Either an infrared LED / detector pair, a hall-effect sensor and magnet, or whatever else you can come up with. Having the propeller chip measure the RPM is easy, and every time you get a hit on your sensor, you know *where* in the rotation you are as well, so it's easy to compute the correct delays for lighting up your lights.

    I did it using an infra-red emitter / detector pair years ago, on a much less capable chip:
    http://jasondorie.com/WordPress/?p=18
  • JBWolfJBWolf Posts: 405
    edited 2013-03-03 03:36
    Very clever, I do not think I have seen a clock like that with backlighting pulsed to make hands. I like it!

    Ok I almost have enough to go on to give it a go... The one thing I am still unsure of is the breaks and active time of pulse duration commands.
    For example in the 'servo32v7_RampDemo' code, the 'servo.set()' commands are one directly after another without a waitcnt or repeat... it appears to me as if it just sends a single pulse command and then the pin output ceases, but I may be wrong.
    The reason for this concern is that I need to simulate a constantly held down 'throttle down' and 'throttle up'.
    If I sent a command such as 'set(1000)' to simulate a 'throttle down', does it just send it a single pulse and then idles? or does it keep that pulse going to hold a servo in position until another set command is sent?
    so im wondering if would I need a repeat in there to keep the signal alive for simulating a held down throttle down/up... or not.

    I noticed that following a 'servo.setramp()' command, there is a repeat in the code to wait until the ramping is complete. But I understand ramping is a delayed movement as opposed to the servo.set.

    Does servo.set() output stay 'alive' ?
    Thanks
  • JBWolfJBWolf Posts: 405
    edited 2013-03-04 01:52
    Cool, it works! The reason they call this motor an 'outrunner' slipped my mind, got a little surprise starting it up while it was laying on it's side lol.
    Set the throttle and tried it out... works nicely, however I will need to implement ramping as the speed changes feel very violent.

    Heres what I am currently using:
    CON
        _clkmode = xtal1 + pll16x                           
        _xinfreq = 5_000_000           '80mhz
    
        ServoCh1 = 3                   'ESC Controller Pin
        Button1  = 26                  'Momentary Throttle  UP  Simulator
        Button2  = 20                  'Momentary Throttle DOWN Simulator
        LED1     = 13                  'Green  LED
        LED2     = 14                  'Yellow LED
        LED3     = 15                  'Red    LED
    
    VAR
        
    OBJ
      SERVO : "Servo32v7.spin"
    
    PUB Servo32_DEMO | temp
    dira[Button1]~
    dira[Button2]~
    dira[LED1..LED3]~~
    
        SERVO.Start                 'Start Servo handler
      
    
    
    Repeat
    
        if ina[button1] == 1
           SERVO.Set(ServoCh1,2000)               'Throttle Up
           outa[led2]~
           outa[led1]~~
             Repeat while ina[button1] == 1
               waitcnt(clkfreq / 10 + cnt)
    
        
        if ina[button2] == 1
           SERVO.Set(ServoCh1,1000)               'Throttle Down
           outa[led2]~
           outa[led3]~~
             Repeat while ina[button2] == 1
               waitcnt(clkfreq / 10 + cnt)
    
        outa[led1]~
        outa[led3]~          
        SERVO.Set(ServoCh1,1500)                  'Throttle Center Idle
        outa[led2]~~ 
        waitcnt(clkfreq / 10 + cnt)
    
  • Cats92Cats92 Posts: 149
    edited 2013-03-04 02:23
    Nice , but using outrunners with ESC be carefull :

    An outrunner motor running at full speed without load may be damaged.
    Better try it with values near 1300 for your tests.

    I understand you try it for a POV clock : an outrunner seems much too fast.
    I used a simple DC motor and a Hall detector to build things like that.
    It runs at about 350 RPM so that the leds are on at the same location every turn
    (depends on the radius of the circle you use , about 16 cm in my case)

    You can find many exemples of POV with the Arduino Microcontroller.

    Try : http://carlitoscontraptions.com/2007/08/arduino-pov-prototype/

    Cats92
  • Heater.Heater. Posts: 21,230
    edited 2013-03-04 11:30
    Cats92,

    I'm surprised, I would have thought you want a refresh rate of 20Hz minimum. That would be 20 revs per second or 1200 revs per minute. Still I've never built a POV device so maybe less is OK.
    ..depends on the radius of the circle you use..
    Also I don't see how that can be. Surely X revs per second is the same refresh rate no matter what the radius.
  • Heater.Heater. Posts: 21,230
    edited 2013-03-04 11:38
    Cats92,

    Hey want's up with the photos of your POV device in the link above?

    When I click on them I get a rotating "waiting, wating..." thing, my computer goes into overdrive (I can tell because the fan goes to full speed) and after 5 minutes nothing has happened.
  • JBWolfJBWolf Posts: 405
    edited 2013-03-04 14:28
    Yes I understand an outrunner is a bit overkill (and very noisy)... but for now I am just getting through the learning curve as this is my first time using servos with the prop.
    I have several other servo motors that will be better suited for this job, and I will switch over to one of them when ready.

    If I were to go with a different servo motor and not use the fancy Turnigy ESC... what should I use to control the speed of the servo?
    Do all servos require an H-Bridge or equivalent? Is there a cost efficient solution to this?
    Or can most servos be directly powered with DC and just limit the current?
    I also have old HDD's I can take apart, what did you guys use to control the motor speed?



    I did implement ramping to the previous code posted except now a new problem has started. It works well except that after about 5 seconds of running at a specific speed setting.. it starts to do something funny, every 1/2 sec it sounds like it goes up about 10rpm then 1/2 sec later goes back down and repeats. For example it sounds as if there were a blinking LED interfering with the power and causing it to lose a little speed every time the LED turns on (there isnt a blinking LED though)
    This is happening both with and without ramping.
    I am wondering if this is caused by the 'jitter problem' mentioned inside the servo32v7.spin header?
  • Cats92Cats92 Posts: 149
    edited 2013-03-04 15:42
    Heater,

    At a speed near 350-360 RPM it works (with a bit of flicker).
    By the way : some people have put LEDs on their bike wheels for POV and a bike wheel give this range of RPM.

    Perhaps between 1200_1500 RPM is better but we have built a POV five years ago with a group of kids .We have a DC motor and gears in a Meccano box and used what we have.

    The link i gave is Carlitos site (not mine) : he wrote a very good description of POV with an Arduino board in 2007 : now it shows only part of his first desription..

    Cats92
  • JBWolfJBWolf Posts: 405
    edited 2013-03-05 13:04
    Ok I have taken apart an old maxtor hdd and identified the power wire and 3-coil wires.
    What do you guys recommend to use to spin this instead of a turnigy esc?
  • JBWolfJBWolf Posts: 405
    edited 2013-03-05 15:32
    In the meantime I seem to have found a work-around for the speed jitter. It appears as if only certain RPM's have that weird up/down speed problem.
    For example I have the throttle range set between 1000-2000... at 1000, 1500 and 2000 the speed problem happens. By changing the speeds to 1200, 1450 and 1850 the problem is resolved and the motor runs steady.
  • JBWolfJBWolf Posts: 405
    edited 2013-03-05 17:33
    I just realized I have a stack of SN754410 IC's from a previous project. Can these be used to run the HDD motor?
    If so, any advice?
Sign In or Register to comment.