PID and PWM to control a motor - please help!!!

Hi,
I have written a PID routine (in C) to control current in a BLDC motor. At first i would just like to implement P control.
What i don't understand, is that if the error is negative (ie. Iactual

the duty cycle of the PWM can only be between 0 and 100% how do you actually reduce the current in the motor through the PWM? Surely you cannot take the absoulte value of the PID result and apply it on the PWM?? Because then wouldn't that also be the same thing as saying increase the current?
Im really confused on this issue, and if anyone could help you'd be absolute lifesavers!! (This is for a Thesis you see...).
Thanks so much in advance, Jess
Add pictures here
<% if( /^image/.test(type) ){ %>
<% } %>
<%-name%>
Add image file
Upload
wrote:

Try <http://www.wescottdesign.com/articles/Friction/friction.html and other articles at this site.
Kelvin B. Hales Kelvin Hales Associates Limited Consulting Control Engineers Web: www.khace.com
Add pictures here
<% if( /^image/.test(type) ){ %>
<% } %>
<%-name%>
Add image file
Upload
snipped-for-privacy@yahoo.com.au (Jess) wrote in

PWM-schemed systems can send current through a motor in both directions using an H-bridge circuit. Often, a zero input corresponds to some medium pulse width. Also, the duty cycles valid for input might not cover the full 0-100% range, but might be allowed between two values, like 1-2ms, with 1.5 ms being centered.
Scott
Add pictures here
<% if( /^image/.test(type) ){ %>
<% } %>
<%-name%>
Add image file
Upload
On 13 Oct 2004 00:47:40 -0700, the renowned snipped-for-privacy@yahoo.com.au (Jess) wrote:

The output just saturates at 0 (and at 100%). So, for (control output <= 0) the PWM is off.
Best regards, Spehro Pefhany
--
"it's the network..." "The Journey is the reward"
snipped-for-privacy@interlog.com Info for manufacturers: http://www.trexon.com
  Click to see the full signature.
Add pictures here
<% if( /^image/.test(type) ){ %>
<% } %>
<%-name%>
Add image file
Upload
Jess wrote:

As touched on by both Scott and Spehro, you need to know what your PWM driver is doing, and therefore what your PWM value means. You may have a PWM driver that can only go one direction, like the model that Spehro was talking about, you may have a PWM driver that uses an H-bridge with 50% duty cycle corresponding to 0, or you may have a PWM driver that takes a duty cycle and a direction command (essentially a sign bit -- and don't laugh, I've done it, it works well and it makes excellent sense for the particular situation I was dealing with).
_Any_ drive that you use is going to have a limited range; it's up to you to know what this range is and design your controller accordingly. If you have a PWM drive that's only positive and a motor that only has to go one direction (say to control the speed of a conveyor), then for negative errors you just set the PWM to zero, and count on friction & whatnot to slow the motor. If you have an H-bridge where 50% duty cycle applies an average drive of zero to the motor then you need to shift your control output by -50%, etc.
--

Tim Wescott
Wescott Design Services
  Click to see the full signature.
Add pictures here
<% if( /^image/.test(type) ){ %>
<% } %>
<%-name%>
Add image file
Upload
Jess,
In 'professional' controllers it is very common to use the velocity form algorithm. What this means is that changes in deviation result in changes in output. In this case a negative deviation means to reduce the value of the current output by an error * PID amount.
Otherwise the position form is used. In that case a 'constant' is added to the output to bring the process variable of the loop to the setpoint. (This is done with the I and D terms off.) This eliminates the offset experienced by all P only controllers. Now you have an elevated zero on which both + and - deviation can act.
These are the tricks they don't teach you in school.
Walter.

Add pictures here
<% if( /^image/.test(type) ){ %>
<% } %>
<%-name%>
Add image file
Upload

Actually, they did teach us all that stuff in school; but then my first (Bachelors) degree was in: 'Instrumentation and Control Engineering', and took four years!
:)
Kelvin B. Hales Kelvin Hales Associates Limited Consulting Process Control Engineers Web: www.khace.com
Add pictures here
<% if( /^image/.test(type) ){ %>
<% } %>
<%-name%>
Add image file
Upload

Polytechforum.com is a website by engineers for engineers. It is not affiliated with any of manufacturers or vendors discussed here. All logos and trade names are the property of their respective owners.