Shop OBEX P1 Docs P2 Docs Learn Events
Motor Current Control — Parallax Forums

Motor Current Control

James NewmanJames Newman Posts: 133
edited 2010-03-25 03:05 in Robotics
Let's say we have a motor being controlled by a switching device, and we want to control the current to it by varying a pwm duty cycle. If we're using a 20khz or so pwm frequency, what speed of a adc would we want? I'd like to not only be able to set the current, but also display it. Would a 20k sample/second adc be the most I could control anyway since beyond that is beyond my switching freq?

Comments

  • FranklinFranklin Posts: 4,747
    edited 2010-03-24 03:26
    Could you draw a picture of the circuit? what perameters are you constrained by? What exactly do you want to display and how often do you want it to update? You will probably filter and smooth the current before measuring it.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    - Stephen
  • ercoerco Posts: 20,256
    edited 2010-03-24 03:50
    Can someone please explain why the PWM freqs are so high (20 khz) on many motor controllers? My 1980's Hero 2000 drive motor PWM is well under 100 hz and plenty torquey at low RPM (~10 RPM). They would make a great buzzing sound as they rolled, like a servo does sometimes (isn't a typical servo pwm freq·~50 hz, which explains the pause 20?).·That robot·never stalled (Scribbler and Stingray can't say that), you could really·yank some stumps.·

    Edit: I found the following·at ·http://www.picotech.com/applications/pwm_drivers/·but·the author·doesn't sound very authoritative in the article. He can't even find web links in section 5...

    "The best switching conditions are when the switch frequency is much higher than the dynamics of the motor. The motor should “think” that it is powered from a true DC voltage. Due to different references the frequency must be at least 5 times higher than the rotation speed of the motor. I.e. if the motor rotates at 6000 rpm (100 rps) the frequency must be higher than 5 * 100 Hz = 500 Hz. A theoretically better explanation is that switching frequency must be much higher than 1/Ta where Ta = L/R is the electric time constant of the motor. Here L is the inductance and R the inner resistance of the motor. For a typical DC motor (200 W, 24 V) L = 1 mH and R = 0.5 Ohm. This again means that the frequency must be much higher than 1/Ta = R/L = 0.5 / 0.001 Hz = 500 Hz. Usually a frequency around 20 kHz is used. This also avoids noise from the motor in the audio range."

    If that's true, why do RC servos still use 50 hz? Simple tradition and backwards compatability?

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    ·"If you build it, they will come."

    Post Edited (erco) : 3/24/2010 4:54:06 AM GMT
  • W9GFOW9GFO Posts: 4,010
    edited 2010-03-24 05:11
    On for 1.500mS, off for 18.500mS? That is not the same as using PWM to drive a motor.

    Inside the servo is the circuit to control the motor. The 50hz pulse stream is only telling the servo where it "should" be.

    Rich H

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    The Simple Servo Tester, a kit from Gadget Gangster.
  • Beau SchwabeBeau Schwabe Posts: 6,566
    edited 2010-03-24 06:03
    erco,

    Basically to reduce audible noise...

    Technically a motor can be modeled as a low pass filter, so the higher frequencies would make sense. The filter components being the inductor (motor coils) and a capacitor (mechanical spinning motion of the motor). The difficulty is that the L and C value would vary greatly depending on the speed of the motor. So setting a very high frequency sets an upper envelope that encompasses any motor variations that would be present.

    For another effective method of reducing noise, it helps to know the architecture of the motor as far as how many poles there are. Using a tachometer or feedback of some kind to determine the motor speed and dynamically adjusting the frequency so that it matches the number of poles times the speed or a multiple of that, you can very effectively obscure any audible motor whining noise within the normal audible range of the motor without needing the higher frequencies mentioned above.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Beau Schwabe

    IC Layout Engineer
    Parallax, Inc.
  • Phil Pilgrim (PhiPi)Phil Pilgrim (PhiPi) Posts: 23,514
    edited 2010-03-24 07:04
    erco,

    RC servos use 50 Hz (20 ms) pulses for signaling only. That's not the same PWM that actually drives the motor. Those pulses will be at a much higher frequency, as determined by the internal controller chip.

    -Phil
  • kwinnkwinn Posts: 8,697
    edited 2010-03-24 13:12
    You will probably want to filter the current signal and use an average rather than an instantaneous reading so a lower speed ADC would be fine. Taking the mechanical inertia of the motor into consideration an ADC with a 10Hz to 100Hz sampling rate should be adequate.
  • ercoerco Posts: 20,256
    edited 2010-03-24 14:34
    Gents: XLNT replies, I do appreciate the insight. I had assumed (yeah, I know) that the servo's electronics decoded the 1-2 ms control signal and translated that into a proportional duty cycle, and that the PWM applied to the motor was still 50 hz.

    @Phil, do you know the typical PWM freqs going into the servo's DC motor?

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    ·"If you build it, they will come."
  • Martin_HMartin_H Posts: 4,051
    edited 2010-03-24 23:33
    This was an interesting thread. I never thought of a motor as a low pass filter, but that makes total sense.
  • James NewmanJames Newman Posts: 133
    edited 2010-03-25 03:05
    I can't draw a picture of the circuit, as I'm still thinking it up... but just think of an h-bridge setup with a current sense resistor in line with a dc motor. The adc will be reading the voltage dropped across the current resistor. For now just assume the voltage range is well within the adc's range, using whatever resistor value and amp circuit to get it there.

    Don't really have any real restrictions at the moment as I'm brainstorming.

    I mentioned 20khz as the switching speed because I figure that the fastest I can decide to throttle current to the motor is dependent on my switching speed. I may go with some completely different value later, but I wanted to have a hard number in here incase anyone used it as a basis for some calculation/explanation. I further said 20khz because it's a common motor switching frequency as its just barely out of human hearing range.

    I don't really care about the display update frequency... it's going to be insanely slow (and filtered) compared to everything else... ever seen a digital display that updates really fast? mightaswell replace the least significant digits with 8s...

    I would have figured that the motor would do a pretty good job of filtering the current seen by a current sense resistor? Guess I need to take a look at that.

    So... really I guess my question is if a sample rate above or equal to the switching frequency will be as adequate as I will ever need?

    Stop sidetracking! >.>
Sign In or Register to comment.