EasyManua.ls Logo

Renesas V850 Series - Page 177

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
180
if ( ( stop_flag == OFF ) && ( error_flag == 0 ) ) {
s_time = TMD0 ;
OUT_data( WRESET, 0 ) ; /* Reset watchdog timer */
HZA0CTL1 |= 0x04; /* PWM output on */
/****************************************************************************** /
/* Initial revolution processing */
/****************************************************************************** /
if ( init_flag ) {
cow = init_upco ;
if ( cow > 4 ) cow = 4;
if ( ++init_co > ( (long)up_data[ cow ] * 34000L / ( SPEED_INIT * TS ) ) ) {
init_co = 0 ;
if ( init_flag == 2 ) {
wk = cw_data[ init_pat ][0] ;
wk2 = cw_data[ init_pat++ ][1] ;
} else {
wk = ccw_data[ init_pat ][0] ;
wk2 = ccw_data[ init_pat++ ][1] ;
}
TQ0CCR1 = PWM_INIT ;
TQ0CCR2 = PWM_INIT ;
TQ0CCR3 = PWM_INIT ;
TQ0IOC0 = wk ;
TQ0IOC3 = wk2 ;
HZA0CTL1 |= 0x04; /* PWM output on */
if ( init_pat >= 6 ) {
init_pat = 0 ;
if ( init_upco > 14 ) {
init_flag = 0 ;
} else {
init_upco++ ;
}
}
}
} else {
/****************************************************************************** /
/* Normal revolution processing */
/****************************************************************************** /
o_wre = abs(object_speed) * RPM_RADS * P / TH_U ; /* rpm -> radian conversion */
we = o_wre - wre ;
o_iqap = ( ( wre * KSP ) + ( we * KSP ) ) >> KSPGETA ;
o_iqa = o_iqap + ( o_iqai >> KSIGETA ) ;
if ( o_iqai > IQAMAX ) {
o_iqai = IQAMAX ;

Table of Contents