EasyManua.ls Logo

Renesas V850 Series

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
157
//
cur_time = TP2CNT ;
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] ;
p2 = (int *)before_posi[20] ;
for ( i = 0; i <= 19 ; i++ ) {
*p2-- = *p1-- ;
}
before_posi[0][0] = *trm = es_trm % (RAD/P) ;
wk = before_posi[0][0] - before_posi[1][0] ;
if ( abs(wk) > (RAD/2/P) ) {
if ( wk < 0 ) {
wk = (RAD/P) + wk ;
} else {
wk = wk - (RAD/P) ;
}
}
before_posi[1][1] = wk ;
total_sa += wk ; /* Total difference in average buffer */
wwrm = ( total_sa * ( 1000000 / 20 / TH_U ) / TS );
*wrm = wwrm ; /* Speed radian/second */
}
4.4.8 Zero-cross interrupt processing function
/****************************************************************************** /
/* U zero-cross point interrupt */
/****************************************************************************** /
_ _interrupt
void int_U(void)
{
unsigned char wk, wk2 ;
/* */
if ( ( ( init_flag == 0 ) && ( stop_flag == OFF) ) ) {
sa_time = TP2CNT ;

Table of Contents