Connect with us

PWM control with encoder regulation

Discussion in 'Electronic Design' started by Andrew, Oct 7, 2005.

Scroll to continue with content
  1. Andrew

    Andrew Guest

    This may sound crazy, but are there any chips available that will
    regulate a pwm output based on dc motor encoder input?

    For example, the chip would have encoder inputs, a desired speed input
    (0-5V), and a pwm output.

    So, basically, I select a speed 0-5V (or even input a pwm signal
    instead) and based on the encoder feedback, the chip increases or
    decreases the output pwm signal in order to adjust the dc motor speed.

    Buying a chip (or a motor driver board with this ability) could save me
    alot of time developing the PID control and circuitry to do this
    myself.

    I doubt a motor driver board exists that will do this and meet my specs
    (24VDC, 20A continuous, 20kHz), but if there is a possibility, I will
    also consider this.

    If anyone has some info on where to even look for something like this,
    I would really appreciate it.
     
  2. google motion control IC


    martin
     
  3. Tim Wescott

    Tim Wescott Guest

    Martin's suggestion of a motion control chip is good. If you can't find
    a motion control chip that'll do this it's dead easy with a PIC, AVR,
    8051, etc. In fact you could do this with a CPLD, possibly easier than
    you could with a processor.

    Get an AVR (my favorite) with an ADC and possibly a PWM generator (or
    with SPI if you were going to develop that 0-5V from an ADC). If the
    encoder is slow enough that you can keep up with it in software you
    won't need a separate encoder input, but make sure this is possible
    before doing your board!

    For the PID, read http://www.wescottdesign.com/articles/pidwophd.html.
    Even with a motion controller chip you'd still have to tune the thing,
    so the only thing you're saving with a motion control chip is a few
    lines of code.
     
  4. I was going to suggest the HCTL2000 breed, but that is very long in
    the tooth. I rembember that somebody did a clone about 10 years ago,
    but thats a long time ago


    martin
     
  5. He doesn't need true quadrature decoding.

    robert
     
  6. All this stuff exists of course. Look at the G320 from
    www.geckodrive.com. It almost does what you want. All you need to
    do is connect the G320's 'step' input to a VCO output (a 4046 for
    example) that you can control with your 0-5V input.

    I'm in no way affiliated with Geckodrive except by being a
    satisfied customer. I only know their G320, and they work like a
    charm on a VERY broad range of motors.

    robert
     
  7. Andrew

    Andrew Guest

    Thanks for the quick help guys.

    Just to clarify, this doesn't need to be a precise application - at
    all. If the speed is within 20% that is fine. Repeatability is more
    important, that is, if it is 20% off, I need it to be within, say, 5%
    of being 20% off every time (if that makes sense).

    Secondly, I already have a PWM signal available that I can control (or
    filter to a rough DAC to input to a chip). I said the 0-5V speed input
    because I figured it to be more likely that a chip would have an analog
    input of 0-5V than have a filter on board for the PWM signal already,
    and I could just filter it myself.

    Hopefully I'm not way off base, but the reason I am even doing this at
    all (using feedback) is to allow the motor to have more torque as very
    low speeds (low speed = low voltage = less torque). I am hoping (and
    almost certain) that this type of feedback control will effectively
    increase voltage (by increasing pwm) such that the motor will receive
    enough voltage to suit my torque needs under a variety of speeds
    including very slow. At very slow speeds with a large load, the speed
    would slow down to the point of "stalling," where a small increase in
    voltage (pwm signal decided by PID and the chip I need) could increase
    the voltage just enough to spin at the speed I desire. The problem now
    is that at 50% + there is enough torque, but as the duty cycle gets
    lower, there is much less torque output.
     
  8. Tim Wescott

    Tim Wescott Guest

    Can your motor ever, EVER, go in reverse? If so then the advise you've
    seen elsewhere to not bother with quadrature decoding goes out the
    window. In fact, if the motor should happen to stop right on an encoder
    transition you could have dithering from it going back and forth which a
    quadrature decoder would track just fine, but which a mere counter would
    have severe problems.

    You are correct in wanting an active controller for this. If you want
    to drive it down into the region where it'll stall due to friction you
    also want to read
    http://www.wescottdesign.com/articles/Friction/friction.html. AFAIK
    most motor controllers provide some mechanism for implementing this sort
    of thing, although it may be hidden, described in different language, or
    not be intended by the controller designer.
     
  9. Andrew

    Andrew Guest

    Thanks for the quick help guys.

    Just to clarify, this doesn't need to be a precise application - at
    all. If the speed is within 20% that is fine. Repeatability is more
    important, that is, if it is 20% off, I need it to be within, say, 5%
    of being 20% off every time (if that makes sense).

    Secondly, I already have a PWM signal available that I can control (or
    filter to a rough DAC to input to a chip). I said the 0-5V speed input
    because I figured it to be more likely that a chip would have an analog
    input of 0-5V than have a filter on board for the PWM signal already,
    and I could just filter it myself.

    Hopefully I'm not way off base, but the reason I am even doing this at
    all (using feedback) is to allow the motor to have more torque as very
    low speeds (low speed = low voltage = less torque). I am hoping (and
    almost certain) that this type of feedback control will effectively
    increase voltage (by increasing pwm) such that the motor will receive
    enough voltage to suit my torque needs under a variety of speeds
    including very slow. At very slow speeds with a large load, the speed
    would slow down to the point of "stalling," where a small increase in
    voltage (pwm signal decided by PID and the chip I need) could increase
    the voltage just enough to spin at the speed I desire. The problem now
    is that at 50% + there is enough torque, but as the duty cycle gets
    lower, there is much less torque output.
     
  10. Andrew

    Andrew Guest

    Yes it can go in reverse.

    The geckodrive 320 actually looks awesome!

    As long as I can use the PWM input into the STEP input on the unit (or
    at least my PWM input filtered), this should be awesome.

    Also, on this gecko unit, do I NEED to use 4 encoder inputs? I have
    not settled on an encoder yet, but it would be easier to only need to
    use one line of the encoder input, rather than 4 like the gecko has
    inputs for. Do I need all 4?
     
  11. Tim Wescott

    Tim Wescott Guest

    If it can go in reverse you need to look at both channels of the
    quadrature signal from the encoder -- just one channel will tell you
    speed but not direction, and in perverse situations it can tell you the
    thing is moving when it's really at rest.

    I don't know why the gecko has 4 wires but I suspect it's for separate
    ground and signal for each channel, or it's for power, ground, channel A
    and channel B. At any rate you have to understand what the thing is
    supposed to do for you.
     
  12. Rich Grise

    Rich Grise Guest

    .
    Don't drive it with voltage. Drive it with current. I made a PWM
    controller a couple of years ago, where I pulsed a bog-standard
    TIP36C current sink, and I got full torque all the way down to
    almost 0 RPM. That's what PWM is _for_! :)

    Good Luck!
    Rich
     
  13. The "step" input only commands the controller to advance the
    motor by one transition of the encoder wheel. So the motor speed
    is exactly proportional to the frequency pulses applied to the
    STEP input. If all you have is a PWM output you must filter that
    to a DC voltage, feed it into a VCO and use the VCO's output to
    drive the step input of the controller (drive)
    The geckodrive has 4 inputs: A and B from the quadrature encoder
    from the motor (providing position feedback), one for "step" and
    one for "direction".

    Yes, you need all four. The drive cannot function without the
    quadrature encoder properly connected, and of course you need the
    step input to make the drive move at all. If you don't ever want
    to change direction, you just tie the "direction" input to 5V or
    ground.

    In your original post you mentioned that you have "encoder
    feedback", so I took that as given. If you don't have a
    quadrature encoder on your motor you can't use the G320, or any
    other servo motor controller for that matter. On the other hand
    you need a quadrature encoder for your application if you need a
    "rock hard" motor control at low speeds.

    You can download the user manual from the geckodrive web site and
    find all your questions answered there.

    robert
     
  14. But he needs feedback. He can't just put his PWM signal into a
    power bridge for his application.

    robert
     
  15. Rich Grise

    Rich Grise Guest

    Well, yes, of course. The PWM drive comes out of the controller,
    which compares the current speed to the desired speed, and adjusts
    the next PWM pulse's duty cycle as needed.

    Heck, even I can do a feedback loop! (Of course, I need somebody
    smarter than me[1] to work out the compensation network. ;-) )

    Cheers!
    Rich

    1. Smarter than me are? ;-) Maybe just better-edjamacayted. ;-)
     
  16. Right. Except that from his description I gathered that he didn't
    want to add feedback to his existing PWM application but that he
    wanted to use that PWM signal to program the RPM for his motor.

    PWM --> low pass --> VCO --> servo drive --> PWM --> motor
    ^ |
    +---encoder fb ------+

    He'd also have to add a one-shot (re)triggered my his primary PWM
    to gate the VCO output pulses in order to be able to make his
    motor come to a full stop.
    Head too clear ---> smoke more.

    Something like that? ;-)

    robert
     
  17. Andrew

    Andrew Guest

    The whole purpose of adding feedback at all was to gain low RPM torque.
    I didn't want to have to add any feedback, as the exact rpm isn't
    necessary at all, the feedback will simply be used to increase voltage
    to the motor when it is stalled at low voltage (low rpms) because of
    high load. I'm thinking of it like this (and correct me if I'm wrong):

    -You have a 24V motor.
    -You want to operate at 2.4V because it is evquivalent to the speed you
    desire (say, 10rpm)
    -When operated with normal PWM control at 10% duty cycle, to get 2.4V
    (average), the motor stalls because the load is too high
    --Note that at full 24V (or even lower, lets say, 12V and up) the motor
    IS capable of turning the load.
    -In order to turn the given load at a speed that is equivalent to 2.4V,
    the voltage (duty cycle) may need to be more like, say, 5V (21%).
    -I need the motor driver / circuitry to be able to sense that the motor
    is stalled (via encoder), and increase the voltage such that the motor
    begins to spin at the rpm it would under no load.
    -For example, at no load, 2.4V, 10% duty cycle, no feedback, the motor
    spins at 10rpm. When loaded, it spins at 0rpm, BUT, with the feedback,
    it should increase the voltage until the motor spins at 10rpm!

    I hope that this helps to clarify my situation.
    I'm not quite sure what you mean by "drive it with current," in that
    I'm not sure how to do it, but it sounds interesting, because that is
    essentially what I'm trying to do with the feedback. In order to
    "drive it with current," though, this requires changing the voltage
    based on some feedback, which, in my case, will be the encoder
    feedback...
    So the "step" is a variable frequency input, is that the idea? I mean,
    a regular PWM set frequency, variable duty cycle input would NOT work,
    as well as a DAC voltage would NOT work?

    How do I know what frequency tranlates to the full 24V, max speed?
    Actually calculate it? I'm not sure I know how to calculate which
    frequency on the VCO would be good? Unless it is as easy as
    calculating how many encoder "ticks" there are per revolution, then
    determine how many rpms you want, and make the frequency equal to
    number of ticks? Will I have to determine the VCO frequencies based on
    these factors? Is a VCO variable FREQUENCY based on voltage?

    Would you mind suggesting some applicable VCOs? I have never actually
    used one.

    Thanks guys.
     
  18. Andrew

    Andrew Guest

    I did find the TI CD74HCT4046A VCO chip. Seems to do pretty much what
    I need.

    Based on the gecko data sheet, the "step pulse frequency" should be 0
    to 250kHz, which to me, also equates to the encoder signal frequency.

    My motor is operating at 8000rpm, and the encoder that I currently have
    is 500 CPT (counts per turn), meaning that the encoder frequency is
    [(8000/60) * 500] =~ 66.67kHz.

    So, if I understand this properly, running the VCO at 66.67kHz should
    run the motor at 8000rpm (full speed). Running the VCO at 33kHz is
    about 4000rpm (half speed) and so on.

    Is this correct? Will the CD74HCT4046A be a good chip for this, or are
    there some things I am failing to notice?
     
  19. Well, the upshot of which is: you need feedback. Of course you
    don't need very precise feedback, but since what I proposed uses
    standard industry components, precise is what you get.

    [explanation snipped]
    Your situation is, and has been, very clear from the beginning.
    It is also a very simple problem to solve. Your explanation
    (which I snipped due to length) primarily shows that you are
    confused about the concepts of servo motor control.
    Yes. If you are familiar with stepper motors, you might think of
    everything to the right of the VCO as a stepper motor driver.

    To make this more clear: Let's assume your motor is equipped with
    a standard 1000 line optical encoder wheel (that is, a wheel with
    1000 black lines around its circumference, separated by equally
    wide transparent spaced). The quadrature decoder in the servo
    drive will make 4000 pulses per rotation out of this. This means,
    if the VCO generates a 4000Hz signal, the motor will make one
    revolution a second.
    In my "schematic" above, just think of the PWM/low pass combo as
    DAC output.
    Just measure the rpm, and work out the frequency based on the
    encoder specs as I have outline above. Or, even easier, connect
    the motor to 24V, measure the frequency of the signal coming
    out of the quadrature encoder, and multiply by 4. Leave some
    saftey margin here, otherwise the servo loop may go bonkers when
    you try to drive the motor to full speed.
    Gosh, yes.
    You need to look at the VCO data sheet.
    Yes, you may have to re-activate a teeny weeny bit of high school
    math for this one.
    Yes, of course.
    VCO means Voltage Controlled Oscillator. Most people think that
    it would be most useful not to voltage-control the waveform or
    amplitude of the signal, so frequency is what the industry
    eventually settled on.
    You might want to look at the VCO part of the 4046.

    Before you come back for more it would be good if you told us
    what the source of the "original" PWM signal is (by any chance, a
    microcontroller you programmed yourself?). and what the min/max
    rpm of your motor is. Does the motor ever have to come to a full
    stop? Do you already have some kind of encoder on the motor
    shaft, and if you do, what kind? So-called "tacho generators"
    used to be common, and although they fit the bill for your
    app, they can't be used with the servo drive I suggested.

    robert
     
  20. Tim Wescott

    Tim Wescott Guest

    If you try to phase lock a 500 count/turn motor with a 4046 you'll be
    disappointed -- you won't be able to maintain lock, so your fancy phase
    detector will end up being a high/low frequency detector.

    You should also double check -- 'counts per turn' is usually 4 times the
    number of lines on the encoder. If you're just using one channel of the
    encoder to tell speed you want to pay attention to the fact that it's
    125 lines per turn, or 125 cycles of the square wave per turn.
     
Ask a Question
Want to reply to this thread or ask your own question?
You'll need to choose a username for the site, which only take a couple of moments (here). After that, you can post your question and our members will help you out.
Electronics Point Logo
Continue to site
Quote of the day

-