CHAPTER 4 PROGRAM LIST
Application Note U17209EJ1V0AN
175
init_flag = 2 ; /* CCW initial request */
start_init() ; /* Initialize revolution start */
_ _EI() ;
proc_no = 1 ; /* Set next processing number */
} else if ( sw_mode == CCW ) {
_ _DI() ;
stop_flag = OFF ; /* Stop flag off */
object_speed = -SPEED_MINI ; /* Set target speed to minimum value */
timer_count = WATCH_START ; /* Set speed monitor start time to 5 SEC */
accel_count = ACCEL_VAL_1ST ; /* Set acceleration/deceleration counter */
init_flag = 3 ; /* CCW initial request */
start_init() ; /* Initialize revolution start */
_ _EI() ;
proc_no = 4 ; /* Set CCW processing number */
}
break ;
/* CW processing, acceleration */
case 1 :
if ( accel_count == 0 ) {
accel_count = ACCEL_VAL ; /* Set acceleration/deceleration counter */
if ( object_speed < speed ) {
object_speed += accel_spd ;
if ( object_speed > speed ) object_speed = speed;
timer_count = WATCH_START ;/* Set speed monitor start time to 5 SEC */
} else if ( object_speed > speed ) {
object_speed -= accel_spd ;
if ( object_speed < speed ) object_speed = speed;
timer_count = WATCH_START ;/* Set speed monitor start time to 5 SEC */
} else {
proc_no = 2 ; /* Constant-speed processing */
}
}
if ( (sw_mode == CCW) || (sw_mode == STOP) ) {
proc_no = 3 ; /* Deceleration, set processing number */
}
break ;
/* CW processing, constant-speed */
case 2 :
object_speed = speed ;
if ( (sw_mode == CCW) || (sw_mode == STOP) ) {
proc_no = 3 ; /* Deceleration, set processing number */
}
break ;
/* CW stop processing */
case 3 :
if ( accel_count == 0 ) {
accel_count = ACCEL_VAL ; /* Set acceleration/deceleration counter */
if ( object_speed > SPEED_MINI ) {