21.01.2014 Views

3.22EjemploDRM007 Co..

3.22EjemploDRM007 Co..

3.22EjemploDRM007 Co..

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

Source <strong>Co</strong>de<br />

*/<br />

SINT16 PI<strong>Co</strong>ntroller (void) // 171 max, 152 typ<br />

{<br />

<strong>Co</strong>ntrolDifference = RefSpeed - Speed;<br />

if (<strong>Co</strong>ntrolDifference >= 0)<br />

{<br />

P_Portion = (SINT16)((UBYTE)(<strong>Co</strong>ntrolDifference) * (UBYTE)(P_Gain));<br />

I_Portion = (SINT16)((UBYTE)(<strong>Co</strong>ntrolDifference) * (UBYTE)(I_Gain));<br />

}<br />

else<br />

{<br />

<strong>Co</strong>ntrolDifference = -<strong>Co</strong>ntrolDifference;<br />

P_Portion = (SINT16)(-((UBYTE)(<strong>Co</strong>ntrolDifference) * (UBYTE)(P_Gain)));<br />

I_Portion = (SINT16)(-((UBYTE)(<strong>Co</strong>ntrolDifference) * (UBYTE)(I_Gain)));<br />

}<br />

if (I_PortionK_1 > MAXINTEGRAL)<br />

I_PortionK_1 = MAXINTEGRAL;<br />

else if (I_PortionK_1 < MININTEGRAL)<br />

I_PortionK_1 = MININTEGRAL;<br />

I_PortionK_1 = I_PortionK_1 + I_Portion;<br />

}<br />

return (I_PortionK_1 + P_Portion);<br />

/*****************************************************************************\<br />

* void Motor_Stalled_Protection (void): This subroutines doesn't let the *<br />

* motor to stop. It calls NextSequence if a period of *<br />

* time has passed and no hall sensor changes have<br />

*<br />

* arrived. If a longer period of time has passed with *<br />

* no hall sensor changes, the motor is stopped. *<br />

* *<br />

* Parameters: None. *<br />

* *<br />

* Return: None. *<br />

\*****************************************************************************/<br />

void MotorStalledProtection(void) // 140 max, 43 typ<br />

{<br />

extern UBYTE FAULTState;<br />

Time_Out++;<br />

/* If no hall sensor interrupt has occured in a timeframe of 250 milli<br />

second, stop the motor and quit process execution */<br />

if (Time_Out > 250)<br />

DRM007<br />

BLDC Motor <strong>Co</strong>ntrol Board for Industrial and Appliance Applications<br />

134 Source <strong>Co</strong>de MOTOROLA

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!