Page 695 - 2
P. 695
int free_move_x_Enable;
int free_move_y_Enable;
Vector analog; // m/s
Vector digital; // deg/s
//--------------------------------------- 모터 직접 제어--------------------
// 스텝모터 속도제어 시간 = 10ms
void motor_control()
{
if (speed.pos < 0) POS_A4988_DIR = 0; else POS_A4988_DIR = 1;
if (speed.x < 0) X_A4988_DIR = 0; else X_A4988_DIR = 1;
if (speed.y < 0) Y_A4988_DIR = 0; else Y_A4988_DIR = 1;
Clock_pos = A4988_pos_deg / (speed.pos*PERIOD);
Clock_x = A4988_x_deg / (speed.x*PERIOD);
Clock_y = A4988_y_deg / (speed.y*PERIOD);
if (Clock_pos <= TCNT_pos)
{
POS_A4988_STEP = 1;
POS_A4988_STEP = 0;
state.pos += A4988_pos_deg;
TCNT_pos = 0;
}
if (Clock_x <= TCNT_x)
{
X_A4988_STEP = 1;
X_A4988_STEP = 0;
state.x += A4988_x_deg;
TCNT_x = 0;
}
if (Clock_y <= TCNT_y)
{
Y_A4988_STEP = 1;
Y_A4988_STEP = 0;
state.y += A4988_y_deg;
TCNT_y = 0;
}
TCNT_pos++;
TCNT_x++;
TCNT_y++;
if (slide_Enable) slide_progress += PERIOD;
if (changing_object_Enable)
{
- 695 -