OpenServo.com Forum Index OpenServo.com
Discussion of the OpenServo project
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

pwm.c

 
Post new topic   Reply to topic    OpenServo.com Forum Index -> Software
View previous topic :: View next topic  
Author Message
m_kanter



Joined: 19 Apr 2006
Posts: 31

PostPosted: Tue Aug 25, 2009 1:21 pm    Post subject: pwm.c Reply with quote

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
View user's profile Send private message
kbb



Joined: 01 Jun 2007
Posts: 180

PostPosted: Tue Aug 25, 2009 5:27 pm    Post subject: Re: pwm.c Reply with quote

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
View user's profile Send private message
m_kanter



Joined: 19 Apr 2006
Posts: 31

PostPosted: Wed Aug 26, 2009 6:54 am    Post subject: Reply with quote

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
View user's profile Send private message
kbb



Joined: 01 Jun 2007
Posts: 180

PostPosted: Wed Aug 26, 2009 7:46 am    Post subject: Reply with quote

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
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    OpenServo.com Forum Index -> Software All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group