Commit 79c6aff7 authored by Nathan Girard's avatar Nathan Girard
Browse files

Merge branch 'position_m3508' into HEAD

Merging position_m3508 after cleaning
parents 9bb93b89 65cb078f
Subproject commit a77a79c82a93154e6f458d65f994cce0f163f52a
Subproject commit 524bf74534be534ca21b117d224b07750df06173
......@@ -157,92 +157,31 @@ int main(void)
/* USER CODE END WHILE */
/* USER CODE BEGIN 3 */
/* scan is key be pressed down to change target speed and pwm pulse */
if (key_scan())
{
m3508_frontleft.target += 500;
m3508_frontright.target += 500;
m3508_backleft.target += 500;
m3508_backright.target += 500;
if (m3508_frontleft.target > 2000)
{
m3508_frontleft.target = 0;
m3508_frontright.target = 0;
m3508_backleft.target = 0;
m3508_backright.target = 0;
}
// PWM_SetAllDuty(&htim1, 0.1f, 0.1f, 0.1f, 0.1f);
// HAL_Delay(2500);
// PWM_SetAllDuty(&htim1, 0, 0, 0, 0);
}
if (rc_ctrl.rc.sw[0] == 2)
{
m2006.target = 0;
};
if (rc_ctrl.rc.sw[0] == 3)
{
m2006.target = 2000;
};
if (rc_ctrl.rc.sw[0] == 1)
{
m2006.target = 5000;
};
/******************************************************************/
/* PENSER A CHANGER LE TYPE DE ROBOT SI BESOIN */
/* (aller dans motor.h et changer ROBOT_TYPE) */
/******************************************************************/
if (rc_ctrl.rc.sw[1] == 2)
{
PWM_SetAllDuty(&htim1, 0.0f, 0.0f, 0.0f, 0.0f);
};
if (rc_ctrl.rc.sw[1] == 3)
{
PWM_SetAllDuty(&htim1, 0.25f, 0.25f, 0.25f, 0.25f);
};
if (rc_ctrl.rc.sw[1] == 1)
/* scan if key is pressed down */
if (key_scan())
{
PWM_SetAllDuty(&htim1, 0.5f, 0.5f, 0.5f, 0.5f);
};
m3508_frontleft.target = -MAX_BASE_SPEED_COEFF*(rc_ctrl.rc.ch[0] + rc_ctrl.rc.ch[1] + rc_ctrl.rc.ch[4]);
m3508_frontright.target = MAX_BASE_SPEED_COEFF*(rc_ctrl.rc.ch[0] - rc_ctrl.rc.ch[1] - rc_ctrl.rc.ch[4]);
m3508_backleft.target = MAX_BASE_SPEED_COEFF*(rc_ctrl.rc.ch[0] + rc_ctrl.rc.ch[1] - rc_ctrl.rc.ch[4]);
m3508_backright.target = -MAX_BASE_SPEED_COEFF*(rc_ctrl.rc.ch[0] - rc_ctrl.rc.ch[1] + rc_ctrl.rc.ch[4]);
gm6020_down.target = gm6020_down.target - rc_ctrl.rc.ch[3]*0.1;
gm6020_up.target = gm6020_up.target + rc_ctrl.rc.ch[2]*0.04;
/* put here the actions you want to do when key is pressed */
}
if (gm6020_down.target > gm6020_down.MAX_POSITION){gm6020_down.target = gm6020_down.MAX_POSITION;}
if (gm6020_down.target < gm6020_down.MIN_POSITION){gm6020_down.target = gm6020_down.MIN_POSITION;}
if (gm6020_up.target > gm6020_up.MAX_POSITION){gm6020_up.target = gm6020_up.MAX_POSITION;}
if (gm6020_up.target < gm6020_up.MIN_POSITION){gm6020_up.target = gm6020_up.MIN_POSITION;}
/* Setting the target for all motors according to the data received from the remote controler */
set_all_targets_from_rc();
get_motor_data(&m3508_frontleft);
get_motor_data(&m3508_frontright);
get_motor_data(&m3508_backleft);
get_motor_data(&m3508_backright);
get_motor_data(&m2006);
get_motor_data(&gm6020_up);
get_motor_data(&gm6020_down);
/* Command all motors according to the target fixed */
command_all_motors();
/*Affichage de donnees sur le OLED*/
oled_clear(Pen_Clear);
oled_printf(1, 1, "M3508");
oled_printf(2, 1," Target: %f", m3508_frontleft.target);
oled_printf(3, 1," Speed: %i", m3508_frontleft.info.M3508_info.speed);
oled_printf(4, 1," Angle: %i", m3508_frontleft.info.M3508_info.angle);
oled_printf(1, 1," Down: %i", gm6020_down.MAX_POSITION);
oled_printf(2, 1," Up: %i", gm6020_down.MIN_POSITION);
oled_printf(3, 1," Target: %f", gm6020_down.target);
oled_printf(4, 1," Target: %i", rc_ctrl.rc.ch[3]);
oled_refresh_gram();
// oled_clear(Pen_Clear);
// oled_printf(0, 1, "Manette");
// oled_printf(1, 1," CH1: %i", rc_ctrl.rc.ch[0]);
// oled_printf(2, 1," CH2: %i", rc_ctrl.rc.ch[1]);
// oled_printf(3, 1," CH3: %i", rc_ctrl.rc.ch[2]);
// oled_printf(4, 1," CH4: %i", rc_ctrl.rc.ch[3]);
// oled_refresh_gram();
/* led blink */
led_cnt ++;
......@@ -252,17 +191,6 @@ int main(void)
LED_RED_TOGGLE(); //blink cycle 500ms
}
set_motor_speed(&m3508_frontleft);
set_motor_speed(&m3508_frontright);
set_motor_speed(&m3508_backleft);
set_motor_speed(&m3508_backright);
set_motor_speed(&m2006);
set_motor_position(&gm6020_up);
set_motor_position(&gm6020_down);
set_motor_voltage(0, &m3508_frontleft, &m3508_frontright, &m3508_backleft, &m3508_backright); //0x200
set_motor_voltage(1, &gm6020_up, &gm6020_down, &m2006, NULL); //0x1ff
HAL_Delay(10);
}
/* USER CODE END 3 */
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment