| View previous topic :: View next topic |
| Author |
Message |
m_kanter
Joined: 19 Apr 2006 Posts: 31
|
Posted: Tue Aug 25, 2009 1:21 pm Post subject: pwm.c |
|
|
Hello,
in the pwm.c there is a comment line like this "the pwm should not changed to b-mode or brake without an proper delay"
Why is this delay needed, since delay for the h-bridge control is included above the comment?
Is this related to the rotation of the motor?
Best Regards,
Marcel |
|
| Back to top |
|
 |
kbb
Joined: 01 Jun 2007 Posts: 180
|
Posted: Tue Aug 25, 2009 5:27 pm Post subject: Re: pwm.c |
|
|
| m_kanter wrote: | Hello,
in the pwm.c there is a comment line like this "the pwm should not changed to b-mode or brake without an proper delay"
Why is this delay needed, since delay for the h-bridge control is included above the comment?
Is this related to the rotation of the motor?
|
The statement that follows turns off “b-mode”, the comment is merely a reminder that b-mode should not be re-enabled (which is done elsewhere) without a sufficient delay to allow the H-bridge time to change state. Ditto for “braking”. The enabling/disabling of a-mode/b-mode is what controls the motor direction.
Kevin. |
|
| Back to top |
|
 |
m_kanter
Joined: 19 Apr 2006 Posts: 31
|
Posted: Wed Aug 26, 2009 6:54 am Post subject: |
|
|
Mmh. That's strange. Look into the code and the command is within the reconfiguration if-statement and says not to switch to the other modes:
static void pwm_dir_a(uint8_t pwm_duty)
{
// Do we need to reconfigure PWM output for direction A?
if (!pwm_a)
{ // Yes...
// NOTE: The PWM driven state of the H-bridge should not be switched to b-mode or braking
// without a suffient delay.
}
}
The delay within the switching is handled above the comment.
So why is this comment there? |
|
| Back to top |
|
 |
kbb
Joined: 01 Jun 2007 Posts: 180
|
Posted: Wed Aug 26, 2009 7:46 am Post subject: |
|
|
| m_kanter wrote: | Mmh. That's strange. Look into the code and the command is within the reconfiguration if-statement and says not to switch to the other modes:
static void pwm_dir_a(uint8_t pwm_duty)
{
// Do we need to reconfigure PWM output for direction A?
if (!pwm_a)
{ // Yes...
// NOTE: The PWM driven state of the H-bridge should not be switched to b-mode or braking
// without a suffient delay.
}
}
The delay within the switching is handled above the comment.
So why is this comment there? |
There are two functions: the one you are quoting, pwm_dir_a, to switch off “b-mode” (if it is on) and switch on “a-mode”. But there is another, pwm_dir_b, which does the reverse: switches off “a-mode” (if it is on) and switches on “b-mode”.
Both contain the delay that is needed between switching off one mode and a switching on the other.
Both contain the comment that appears as a reminder that there must be a delay between mode switching.
The delay is important as it prevents “brownouts” and stress on the MOSFETs that are used to implement the H-bridge. The stress on the MOSFETs can cause them to heat up (more so than they would normally do) and could potentially lead to damage.
Thus I felt the need to add that comment as a reminder at the point where a particular mode had finally been switched off. In pwm_dir_a for example, you will see that “b-mode” has been switched off, and “a-mode” switched on. The comment is there to remind the reader that there must be a delay before reversing this. And in pwm_dir_b it is the other way around. If the comment is confusing it could be moved, changed or deleted.
An in-line delay has been used because of the way the original code was written.
Kevin. |
|
| Back to top |
|
 |
|