Connect with us

PWM Motor Control Using MOSFETS

Discussion in 'Electronic Design' started by Gerrard Shaw, May 30, 2004.

Scroll to continue with content
  1. Gerrard Shaw

    Gerrard Shaw Guest

    Hi, my name is Gerrard Shaw, I am doing my A-levels at the moment,
    including one in Electronics (Systems and Control Technology). My
    final design paper concerns cordless power tools and variable
    electronic speed controls. After looking at various systems available
    to do this job (darlington pair + simple potentiometer) I have what I
    think is quite a good circuit. Check it out at: -

    http://www.orient.fsworld.co.uk/Motors/Motor1.GIF

    (you probably need to take a look to understand any of the stuff
    below)

    The voltage regulator would be a 7805 to give 5V regulated from a
    12/24V battery whilst still giving the motor the high voltage. As seen
    on this site, the DPDT switch gives motor direction control.

    It uses two MOSFETS driven by a PIC microcontroller to give out the
    PWM pulses. This would allow input from a linear potentiometer on the
    trigger and an algorithm to produce the right pulse train. Another
    input switch could set high or low speed setting as well, which would
    be easy to do in the PIC program.

    The circuit turns on one MOSFET in antiphase to the other from the
    output of the PIC (i.e. when 1 on the other is off).

    The flywheel MOSFET works like a reverse bias diode to prevent voltage
    spikes under normal conditions but when the output of the controller
    decreases (i.e. motor slowing down / stopping) it also allows reverse
    current to flow back into the battery, thus recharging it and slowing
    down the motor in one go.

    I could also interface a temperature sensor that checks the
    temperature of the motor / drive MOSFET to ensure that the system
    doesn't overheat.

    What I wanted to check is that MOSFETS do conduct in either direction
    when switched on and that this circuit would work in practice. What do
    you guys think? A second opinion would be very useful!

    Any help much appreciated.

    Regards,

    Gerrard Shaw
     
  2. Hi Gerrard,

    Sounds straightforward, but there is an obvious danger here that at
    some point you will accidentally turn on both together, in which case
    you will get "shoot through" and smoke! This is especially likely
    since the sparks from the motor and the reversing switch will likely
    make the PIC crash.

    I have been through this myself, buy plenty of MOSFETs because you
    will blow up a lot before you are finished :)
    Q3 won't work I'm afraid. To turn it on, the "control voltage" on the
    gate needs to rise several volts above the drain, which for Q3 will be
    at 24V! This is a general problem when driving N channel MOSFETs in
    this configuration. There are driver ICs available to do the job that
    contain the required "boost" circuitry. Or you could hack something up
    yourself. Alternatively, can you not just use a diode for Q3? A power
    Schottky type would probably be best, e.g. 1N5822.

    I would also put some resistors between the MOSFETS and the PIC, to
    protect it.
     
  3. Gareth

    Gareth Guest

    Yes they do, but there are some other things you should consider:

    1) MOSFETs are controlled by the gate voltage relative to the source
    (V_gs). Now since the source voltage for Q3 could be anything between 0
    and 24V (or even outside this range due to spikes from the motor) I
    don't think Q3 will behave as you intend.

    2) MOSFETs have an intrinsic diode so they will always conduct backwards
    regardless of V_gs. Sometimes this is a problem, but with motor
    controllers the diode is often helpful. In your case when you switch Q2
    off the intrinsic diode in Q3 will conduct and clamp the spike caused by
    the motor inductance. In fact I think you may be better off replacing
    Q3 with a diode.

    3) Check the on resistance of the MOSFETs you use at V_gs = 5V - most
    MOSFETs only get down to the on resistance values on the front of the
    datasheet with a V_gs of 10V. There are lots of logic level MOSFETs
    around which are, as the name suggests, intended to be controlled
    directly from digital logic outputs at 5V.

    One other thing - what is the maximum input voltage of the ADC input to
    the PIC, and do you need to make R1 bigger? you may have already
    checked this, I didn't check the PIC datasheet.

    Gareth.
    --
     
  4. Sorry, I meant "source" not "drain" in the above! (Although it amounts
    to the same thing in this case).
     
  5. legg

    legg Guest

    One of your DPDST switch positions places the unlimited supply voltage
    directly across the lower fet in the half bridge.

    If you connect one end of the motor permanently to the bridge output,
    you can manually switch the other end of the motor between the + and -
    supply rails using one spdt switch.

    You will not be able to drive both the fet switches directly from the
    PIC, as the PIC output is voltage limited in compliance to within it's
    own supply rails, and the upper fet gate is expected to exceed the
    motor supply rail, when enhanced.

    RL
     
  6. Gerrard Shaw

    Gerrard Shaw Guest

    Hi everyone, thanks for your help. I'm glad I checked this circuit
    here first as it would have looked a bit dodgy on the design paper! I
    think I'll put the regen idea down as an idea but then dismiss it
    because of the source-gate voltage problem. There's also a way using
    discrete components but it uses more components + is probably less
    reliable. A few more questions now...

    1) if not using the regen braking, how would I make the motor stop
    when pressure is released from the trigger - I've heard about shunt
    braking but I'm not too sure how it works - can anyone advise?

    2) From the following post...

    "Check the on resistance of the MOSFETs you use at V_gs = 5V - most
    MOSFETs only get down to the on resistance values on the front of the
    datasheet with a V_gs of 10V. There are lots of logic level MOSFETs
    around which are, as the name suggests, intended to be controlled
    directly from digital logic outputs at 5V.

    - what would be a suitable MOSFET to use? I've seen an IRF530
    suggested in the manual - would this be OK?

    "One other thing - what is the maximum input voltage of the ADC input
    to
    the PIC, and do you need to make R1 bigger? you may have already
    checked this, I didn't check the PIC datasheet."

    - The ADC is an integrated function on the PicAXE18X IC and can be
    calibrated from the pot - the manual shows a 10k connected so I won't
    argue with that!

    3) From another post

    "One of your DPDST switch positions places the unlimited supply
    voltage
    directly across the lower fet in the half bridge. If you connect one
    end of the motor permanently to the bridge output, you can manually
    switch the other end of the motor between the + and - supply rails
    using one spdt switch."

    - Is this a mistake that will stop the circuit working properly? How
    should I wire it if it is wrong. I have seen another PWM circuit on
    the WWW at http://www.aaroncake.net/circuits/motorcon.htm with the
    DPDT switch wired, but where should I put the diode?

    With regards to that circuit does the it actually vary the mark /
    space ratio of the output wave or does it just change the frequency of
    the output wave or both? I am right in thinking that the mark / space
    ratio changes the on/off time of the output and the frequency just
    keeps the motor moving smoothly? Will it always go the same speed no
    matter what the frequency is if the mark/space ratio is the same in
    each case – I'm a bit confused as you can guess! If the circuit does
    vary the mark/space ratio how does it work as I saw something similar
    that uses 2 sets of resistor / capacitor combos to make the PWM
    output.

    4) "You will not be able to drive both the fet switches directly from
    the
    PIC, as the PIC output is voltage limited in compliance to within it's
    own supply rails, and the upper fet gate is expected to exceed the
    motor supply rail, when enhanced."

    - It looks like I'll only be driving one, should this be OK?

    I know it looks like a lot of questions but I need to get this sorted
    one way or another before my test!

    Regards,

    Gerrard
     
  7. Gareth

    Gareth Guest

    I would expect mechanical friction to stop the motor in a reasonable
    time but I don't know how quickly you want it to stop. I don't think
    you would have had regen braking even with the top FET - current from
    the motor would just go through the FET not back to the battery.
    Look at the datasheet and find out what the on resistance of the MOSFET
    is with a gate voltage (V_gs) of 5 Volts (there is usually a graph) then
    work out the power dissipation when the MOSFET is on:

    P = I^2*R (where I is the motor current)

    Compare this to the power dissipation values given in the MOSFET
    datasheet. Also consider how the voltage drop caused by the on
    resistance will reduce the power of the motor and waste battery power.

    [SNIP]
    Yes, but you need to replace the top FET with a diode as John and I
    suggested.


    --
     
  8. legg

    legg Guest

    This would fuse the lower fet bond wires open circuit.
    A single-pole double-throw switch will perform the intended function.
    Instructions for rewiring are in the original response's text,
    reposted above.
    If you want to compare the two html wiring diagrams that you
    reference, please do so. The 'motorcon' reference does not have the
    wiring fault present in 'motor1'.
    You are the designer. It's your choice.

    The average voltage is being varied in order to control the dc motor's
    speed.

    We assume this is through pulse width modulation at a fixed
    frequency, however a fixed pulse width, variable frequency scheme
    could produce the same change in average voltage.
    If it's the one that is within the compliance of the PIC, the PIC will
    not be damaged, however you should probably buffer the PIC to isolate
    it from gate reverse transfer currents and straight gate capacitive
    loading.

    It should function assymetrically as a buck converter, providing the
    freewheeling energy is given a diode path, in the switch 'off' time.

    The simpler SPDT switch would not provide the reversing function in
    that case.

    RL
     
  9. Gerrard Shaw

    Gerrard Shaw Guest

    A single-pole double-throw switch will perform the intended function.
    I have made a few changes to the circuit: -

    - hopefully fixed the motor switch problem (I copied the wiring from
    the 'motorcon' diagram). The DPDT switch does give the advantage that
    when it is in the centre position the drill won't turn - a safety
    feature. Does the wiring diagram for the switch at the bottom of the
    image work for what I want it to do?

    - added a temperature sensor which would be used to monitor the
    temperature of the FET in operation and using the program could slow
    it down / switch off (all wiring info shown on image)

    - added switch for Hi/Lo speed - when switch off low speed, with
    switch on high speed (hopefully all connections are OK)

    - changed output connections so that FET is on correct pin for PWM
    (command only works on output 3)
    - I have checked this on a PicAXE forum and the chip can do frequency
    would used fixed frequency as that is easiest and most effective. I
    still don't know how to make the motor stop instantly (presumably
    using shunt braking) - anyone have any ideas?

    - the circuit may run on any voltage from 12-24V as I don't know
    exactly what power tool they're going to ask about - same reason that
    I can't choose a specific FET (I'll write IRF530 as that's shown in
    the PicAXE manual).

    Hopefully I'm getting near to a finished circuit - once I have that I
    then have to attempt a PCB layout!

    As always your help is very much appreciated - you guys have saved me
    on this!

    Regards,

    Gerrard
     
  10. Gerrard Shaw

    Gerrard Shaw Guest

  11. R.Legg

    R.Legg Guest

    It depends on the type of motor, type of internal connection, and
    amount of force being exerted by the load.

    Small dc motors are effectively braked by shorting their terminals,
    rather than opening them, as you propose.

    http://alpha400.ee.unsw.edu.au/elec4216/2003 Lecture 3 DC Motor Charac.pdf

    RL
     
  12. Gerrard Shaw

    Gerrard Shaw Guest

    After looking a little harder at a website on motor control I found a
    wonderful IC called the TD340 which gives full H-bridge control along
    with microprocessor support (5V regulator, digital or analgoue PWM
    input, temperature control, standby etc).

    It automatically performs all switching needed for motor acceleration
    / braking as well as direction control in a 20pin IC. All you need to
    do is give it direction signal, pulse and away you go! I have used
    this chip, together with the PIC chip from before to make a much
    better circuit.

    The new circuit is at: -

    www.orient.fsworld.co.uk/Motors/motor3.GIF
    www.orient.fsworld.co.uk/Motors/TD340.GIF

    The datasheet is at: -

    http://www.orient.fsworld.co.uk/Motors/TD340 MOSFET IC.pdf

    Technically I could just use a potentiometer as the PWM input but I
    feel that the microcontroller gives me more flexibility e.g. can set
    lo/hi speed and sense high temperature to reduce PWM etc. The circuit
    can also have over-current monitoring and reverse battery protection
    included, which seems to make it the easiest solution for most motor
    control applications.


    Hopefully this will be the FINAL circuit with no more major changes
    because I've then got to practice drawing the schematic by hand for my
    test (thankfully I can take the original diagram in to copy!). What do
    you think of this one? Can you see any glaring errors as after a few
    hours staring at trails of wires on a slightly blurred monitor it gave
    me a headache!

    Regards,

    Gerrard
     
  13. Gerrard Shaw wrote...
    You indicate B1 as a 12-24V supply, but the TD340 specifies
    6.5 - 18.5V operation, and has an over-voltage lockout that
    activates at nominally 20V (see page 11).

    You should connect the TD340's reset line to the uP's reset.

    You certainly will want to make use of the TD340 standby pin
    to handle the H-bridge when the uP is starting up, etc.

    The TD340 provides a rather high fixed 2.5us deadtime during
    switching, so you may need snubber networks for all the FETs
    to handle the inductance flyback.

    You have 100-ohm gate resistors, but for large high-current
    FETs, a different gate-drive network may be appropriate.

    The FET you specified is not now and probably never was made.

    Thanks,
    - Win

    (email: use hill_at_rowland-dot-org for now)
     
  14. Gerrard Shaw

    Gerrard Shaw Guest

    I'll change that value to 8.5 - 18.5V. Actually very few power tools
    use 24V batteries so I'm OK there.
    I'm not sure how useful this function is - can you advise? The PicAXE
    controller has a 4K7 resistor pulling the input pin high then a PTM
    switch from the pin to ground. If I used the reset pin would I just
    connect the input into the pin with the pull-up resistor or would a
    different arrangement be necessary?
    I'll connect this one straight up to the PicAXE controller. Am I right
    in thinking that I should provide a high output to the pin on
    microcontroller startup to enable the IC and then send it low when
    there is no pressure on the trigger i.e. motor off?
    Since the circuit is a theoretical idea I'll write the values for
    resistors etc that I have there now and maybe state an example FET
    (any ideas what one would work with the current components?) I'll then
    put in the evaluation that it would be necessary to match the
    components used to the requirements of the motor / FETS

    Thanks for your ideas,

    Gerrard
     
  15. Gerrard Shaw wrote...
    I'm sorry Gerrard not to have time now to answer your questions
    and comments. But rest assured my advice is good, and do think
    about it. Maybe someone else will have time to discuss issues
    I raised in more detail.

    Are you planning on making an operating prototype? What would
    its specs be?

    Thanks,
    - Win

    (email: use hill_at_rowland-dot-org for now)
     
  16. Gerrard Shaw

    Gerrard Shaw Guest

    I'm sorry Gerrard not to have time now to answer your questions
    Thanks for your help, I'm really grateful to you and everyone else who
    has given me advice on how to improve my design - I would never have
    got to this stage otherwise!
    No, it will be purely theoretical, it's just going down on the test
    paper to get marks! That's why I don't need to worry about the
    component values - only the way it *should* operate, that's why I was
    interested to hear about the value of the reset / standby functions.
    The test is a design paper so the examiners are looking for good ideas
    that could be used in an actual product and justification of my
    choices. All I have to do is note that different motors have different
    component requirements and identify what would need to be changed i.e.
    MOSFETS, resistors / capacitors from TD340 to MOSFETS etc.

    Seeing as I don't know what power tool it will be I obviously can't
    choose a motor / FET to match (it could be a screwdriver, drill,
    rotary cutter or a chainsaw for all I know!)

    Regards,

    Gerrard
     
  17. Gerrard Shaw wrote...
    You can read the datasheets more carefully to answer this question.

    Your controller, an 18-pin PIC16F627, programmed with PICAXE basic
    (Is that such a good idea? Slow, hidden black-box machine opcode
    instructions, etc), may have a robust internal reset function, but
    it's wise to use the TS340's reset output. Consider, you certainly
    don't want the PIC16 trying to run the TD340 when the TD340 thinks
    it's in a reset-disabled configuration, right? So you should make
    the PIC16 respect the TD340's reset output. Read the datasheet,
    you'll see the TD340 has an internal 75k pullup resistor, so you
    can just tie the two !reset pins together.

    With respect to the rest of my suggestions, you can use them as a
    basis for some thought, study and investigation.

    Thanks,
    - Win

    (email: use hill_at_rowland-dot-org for now)
     
  18. Gerrard Shaw

    Gerrard Shaw Guest

    No, it will be purely theoretical, it's just going down on the test
    I had a look at those when I first found the IC (I have printed out
    the relevant pages for research), but needed to check on their
    operation.
    In practice no, it's probably not too clever, but the PicAXE IC is the
    one I know the best having used it for 2 years now, so I understand
    the wiring and what functions it can provide. Again, this is one for
    the evaluation as it would be likely that the company would have a
    custom IC designed for them, probably programmed in assembler in a
    smaller package that provides exactly the functions needed (PWM,
    temperature control etc).
    I have connected the two reset pins together and the standby from the
    TD340 to an output on the PicAXE IC, which would be high until
    pressure is relieved from the trigger, then it is sent low after a
    short delay to allow the motor and MOSFETs to stop (as specified in
    the datasheet). I have also corrected a glaring error when I noticed
    that the TD340 was not actually connected to the power supply - I
    don't know why but I missed out the connection entirely!
    It is also possible to add the watchdog signal to monitor the PIC chip
    but it's just more complexity that will use up time in the exam (and
    besides the examiner probably won't have heard of a TD340 or know its
    feature set anway). I think they may be a bit confused when they first
    see this circuit!

    There are also a current monitoring and battery reversal features that
    I will include in the evaluation - again it needs a lot more
    components and wiring to be feasible in the time I have to draw and
    explain everything!

    Regards,

    Gerrard
     
  19. Gerrard Shaw wrote...
    In addition to picking a non-existant MOSFET, you picked a
    nearly unobtainium controller IC. No stock anywhere, and
    minimum order of 3000 from one "supplier" with a shipping
    delay of who knows how long. And no second sources, natch.
    No apparent provision for engineering samples. Sounds like
    a non-starter component. Mark that kid down for a "D." :>)

    Thanks,
    - Win

    (email: use hill_at_rowland-dot-org for now)
     
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

-