incPID Routine - Help Needed


Closed Thread
Results 1 to 40 of 64

Hybrid View

  1. #1
    Join Date
    Oct 2005
    Location
    Sweden
    Posts
    3,612


    Did you find this post helpful? Yes | No

    Default Re: incPID Routine - Help Needed

    Hi Barry,
    It depends on how you are driving the bridge.
    If I understand correctly you're feeding the MOSFETs (thru their drivers) from two of the PWM generators - both in complementary mode, ie four outputs from the PIC. PWM0 & PWM1 are feeding the left leg while PWM2 & PWM3 are feeding the right leg of the bridge (or the other way around). Is that correct so far?

    Now, what do you do when you want the motor to turn clockwise (or counter clockwise)?
    Do you set one of the PWM generators to 0% (effectively turning on the LOW side switch of that leg) and then apply the output of the PID-filter to the other PWM generator? If you ARE doing this then the motor IS shorted thru the lower two switches during the off-period of the PWM cycle (and, obviously, when the dutycycle of both generators are 0). This will brake the motor but won't regenerate (I think), ie it won't feed energy back to the powersupply. Instead, the energy will be absorbed by the armature resistance of the motor, the rds-on of the MOSFET, wiring, connectors and so on. If this IS what you're doing please note that the braking current this generates does not flow thru your current sense resistor. If the motor is spinning, generating 200V of EMF and you suddenly set both dutycycle registers to 0% the motor will be shorted thru the bottom two switches, how much current will that result in?

    The other option is to run the bridge in what's called locked antiphase mode. In this mode you typically use a single PWM generator and drive one diagonal pair of switches with the "true" output and the other diagonal pair with the inverted output.
    In this mode the bridge switches between the two diagonal pairs during the PWM cycle. When the dutycycle is 50% each diagonal pairs are "on" for 50% of the PWM cycle resulting in a net current of zero thru the motor. When "forward torque" is to be generated the "balance" is shifted so that one diagonal pair is "on" for a larger amount of time during the PWM cycle resulting in "actual" current thru the motor. In this case the motor will brake AND regenerate when the voltage produced by the bridge is LESS than the motor produced by the EMF of the motor. The motor will never be shorted out.

    Phew, I hope I got that right....don't quote me though!

    /Henrik.

  2. #2
    Join Date
    Jan 2011
    Location
    Sydney, Australia
    Posts
    172


    Did you find this post helpful? Yes | No

    Default Re: incPID Routine - Help Needed

    Hi Henrik,

    Thank you for the detailed response.
    Yes, I am using two of the PWM generators - both in complementary mode.

    I have configured my PWM drive per your first description; I am NOT running it in locked antiphase mode.
    I plan do code my program such that the operator (ie me) cannot reverse the motor direction instantly. If the motor is spinning clockwise and the operator flicks the switch to make it spin anti-clockwise, the program will not reverse the direction until the pulse train frequency from the encoder wheel reaches zero - the motor stops spinning. I could also add a short time delay between motor stop and reverse direction.

    When the operator goes from one motor direction to "off" I plan to allow the motor to free spin rather than shorting the motor terminals via the two lower MOSFETS. This should negate any major issues with high current cycles being generated from the back EMF of the motor. If the "spin-down" time is too excessive I will look to ramp down the PWM duty cycle for a more controlled response.

    The circuit will also have an "Emergency Stop" function. In this case the PWM signal is set to zero, the bottom two MOSFETS are turned on and maximum braking is applied to the motor. I should be able to arrange the circuit such that this condition does not fry any part of the H-Bridge but I figure if I really need to hit the Emergency Stop button (worse case scenario for personal safety) then I can live with having to re-build electronics rather than losing a limb, or worse.

    Cheers
    Barry
    VK2XBP

  3. #3
    Join Date
    Oct 2005
    Location
    Sweden
    Posts
    3,612


    Did you find this post helpful? Yes | No

    Default Re: incPID Routine - Help Needed

    Hi Barry,
    OK, it seems you've got it covered.
    Keep us posted!

    /Henrik.

  4. #4
    Join Date
    Jan 2011
    Location
    Sydney, Australia
    Posts
    172


    Did you find this post helpful? Yes | No

    Default Re: incPID Routine - Help Needed

    Hi Henrik,

    I have been doing some more research on locked antiphase and I see some benefits of this configuration for my application - but some disadvantages too.
    Life is full of compromise, why would a motor speed controller design be any different?

    Before I go off on a dead end:

    1/. Can a locked antiphase arrangement be configured on a PIC18F2431 using the PCPWM Module? If not, can it be done via other hardware PWM modules within this PIC?
    2/. I have read in other posts on the forum that your incPID routine will work with locked antiphase configuration. Please confirm this is the case.
    3/. Will regenerative braking become a major issue to handle for a 180Vdc 1500W treadmill motor with a rectified mains supplied power supply?

    As usual, I don't expect anyone to do all the work for me. What I am after is some yes/no type answers from people who have dealt with this type of project and maybe some guidance on the best way forward.
    I do this type of work as a hobby and for the enjoyment of learning along the way but it is always better if I don't have to "re-invent the wheel" if someone has already "been there, done that!"

    Cheers
    Barry
    VK2XBP

  5. #5
    Join Date
    Oct 2005
    Location
    Sweden
    Posts
    3,612


    Did you find this post helpful? Yes | No

    Default Re: incPID Routine - Help Needed

    Hi Barry,
    First I want to stress that I'm in no way an expert on motor control, I only know what I've learned from my own experiments. There will certainly be things which I either don't know, is missing or even get wrong.

    1/. Can a locked antiphase arrangement be configured on a PIC18F2431 using the PCPWM Module? If not, can it be done via other hardware PWM modules within this PIC?
    Yes but as far as I know not the way you have it wired now. You need one PWM generator in complementary mode and wire it so that PWM0 drives the upper right and lower left switch while PWM1 drives the upper left and lower right switch.

    2/. I have read in other posts on the forum that your incPID routine will work with locked antiphase configuration. Please confirm this is the case.
    If you've read that you've probably also read that the incPID routine does not know, nor does it care, what it is controlling or what you do with the value it puts out - all it is doing is crunching numbers. It's up to you as the user of it to take its output and apply it accordingly. Be it locked antiphase PWM, basic "unipolar" PWM, sign magnitude PWM, a +/-10V DAC or whatever, it doesn't matter.

    3/. Will regenerative braking become a major issue to handle for a 180Vdc 1500W treadmill motor with a rectified mains supplied power supply?
    I don't think regenerative braking per se will be a problem but I think you need to make sure you don't allow "instant" reversals or stops - like you explained earlier. Never allow the setpoint value to change from one value to another "instantly", always apply ramping and I think you should be fine. Especially so since you don't really have an active current limiting scheme.

    If you rectify your 240V mains you'll end up with almost twice the rated voltage of the motor....

    I guess the only way to find out is try it. Be careful though!

    /Henrik.

  6. #6
    Join Date
    Jan 2011
    Location
    Sydney, Australia
    Posts
    172


    Did you find this post helpful? Yes | No

    Default Re: incPID Routine - Help Needed

    Thanks for the sanity check Henrik.

    I appreciate your claim not to be a motor control expert but your experimental knowledge is still quantum leaps ahead of mine. I promise to take your comments on board and apply the concepts with due diligence in my designs

    1/. OK, and understand. I need to redesign the power control PCB anyway because I want to move from phototransistor opto isolators to logic opto devices to reduce turn-on/turn-off times and thereby reduce dead-time.

    2/. I thought that was the case - I just wanted to make sure there was a proven method of adjusting pid_Out around the 50% duty cycle setting.

    3/. As described in my earlier post, potential for direction reversal will be eliminated by my program and instant stop available only in emergency situations.

    I am aware that the rail voltage of my rectified mains power supply will be twice that of the treadmill motor. My original intention was to limit the PWM to 50% maximum such that the average voltage applied would be around the motor voltage rating. Yes, peak voltages will be higher but from my knowledge of treadmill motor drive configurations, these motors are used this way all the time. Actually, it was the fact that locked antiphase configurations only apply half rail voltage to the motor at any one time that sparked my interest to their use in my application - or have I got that concept all mixed up too?

    Lots more reading and thinking to be done on my part but I will keep you updated with my progress milestones.

    Cheers
    Barry
    VK2XBP

  7. #7
    Join Date
    Oct 2005
    Location
    Sweden
    Posts
    3,612


    Did you find this post helpful? Yes | No

    Default Re: incPID Routine - Help Needed

    Hi Barry,

    1) OK. You can always run some mod wires on the one you've got to verify before committing to new FR4.

    2) Yes. At startup you set your dutycycle register so that you get a 50% dutycycle output. If pid_Out is positive you ADD it to the 50% value, if pid_Out is negative you subtract the ABSolute value of pid_Out from the 50% value.

    3) Well, in locked antiphase mode it's not only when YOU reverse direction. If the speed setpoint is changed (even though it is still in the same direction) the PID filter will react to this sudden error and, depending on the tuning of the filter, do more or less violent things with the output to bring the actual speed back to the setpoint. This can in reality mean that the polarity of the average voltage applied to the motor is reversed, ending up in series with the EMF. I'm not saying it's GOING to be an actual problem, just be aware of it. Of course you can always clamp the output to either positive or negative IF it turns out to be an issue in the future.

    In locked antiphase mode the full rail voltage is always applied across the motor (except during the dead time period). It's either applied in one polarity or the other.
    * If the duty cycle is 50% and the motor is stationary and you measure the average voltage across the motor you'll read 0V.
    * If you use a differential probe and look at the voltage with a 'scope you'll see voltage swing of +/- the rail voltage.
    * If you measure the average voltage from either motor terminal to ground (still at 50% dutycycle, stationary motor) you'll measure half the rail voltage.
    * If the dutycycle is 0% or 100% (don't do that you'll probably fry the high side driver) the voltage across the motor will obviously be + or - the full rail voltage.

    /Henrik.

Members who have read this thread : 1

You do not have permission to view the list of names.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts