EasyManua.ls Logo

Renesas V850 Series - Page 178

Renesas V850 Series
186 pages
To Next Page IconTo Next Page
To Next Page IconTo Next Page
To Previous Page IconTo Previous Page
To Previous Page IconTo Previous Page
Loading...
CHAPTER 4 PROGRAM LIST
Application Note U17209EJ1V0AN
181
} else if ( o_iqai < -IQAMAX ) {
o_iqai = -IQAMAX ;
} else {
o_iqai += ( KSI * we ) ;
}
pwm_value = o_iqa ;
if ( pwm_value <= 0 ) {
pwm_value = 1 ;
} else if ( pwm_value >= PWM_DATA ) {
pwm_value = ( PWM_DATA ) - 1 ;
}
wk = TQ0IOC0 ;
TQ0CCR1 = pwm_value ;
TQ0CCR2 = pwm_value ;
TQ0CCR3 = pwm_value ;
cont_time1 = ( TMD0 - s_time ) * 10 / 32; /* Convert to uSEC */
}
} else {
HZA0CTL1 |= 0x08; /* PWM output off */
now_speed = 0;
cont_time1 = 0;
}
}
/****************************************************************************** /
/* Calculation processing of speed, etc. */
/****************************************************************************** /
void fcalcu( signed int *wrm, signed int *trm )
{
signed short es_trm, cur_time, delta, i ;
signed int wwrm, wk, *p1, *p2;
//
// Speed and position calculation from zero-cross point
//
cur_time = TMENC10 ;
delta = ( (RAD/6/P) * cur_time ) / sa_time ; /* Calculation of rotor position */
/* difference from reference point */
/* (radian) */
if ( object_speed >= 0 ) {
es_trm = base_position + delta;
} else {
es_trm = base_position - delta;
if ( es_trm < 0 ) es_trm += (RAD/P);
}
total_sa -= before_posi[20][1] ;
p1 = (int *)before_posi[19] ;

Table of Contents