From: Xavier L. <Ba...@us...> - 2011-03-18 01:23:17
|
This is an automated email from the git hooks/post-receive script. It was generated because a ref change was pushed to the repository containing the project "krobot". The branch, master has been updated via d7f900098e0a3b09db5aeed55ba47b71d321a862 (commit) from e3df2a4bc33737f4e785502892d2d2015c795122 (commit) Those revisions listed above that are new to this repository have not appeared on any other notification email; so we list those revisions in full, below. - Log ----------------------------------------------------------------- commit d7f900098e0a3b09db5aeed55ba47b71d321a862 Author: Xavier Lagorce <Xav...@cr...> Date: Fri Mar 18 02:21:35 2011 +0100 [Controller_Motor_STM32] Some little modifications * Increased kernel stack * Initialize initial reference value when creating controller * new demo program to test motor_controller * Controller and estimators should be correctly set for drive motors ----------------------------------------------------------------------- Changes: diff --git a/elec/boards/Controller_Motor_STM32/Firmware/controller_motor_stm32/cfg/cfg_proc.h b/elec/boards/Controller_Motor_STM32/Firmware/controller_motor_stm32/cfg/cfg_proc.h index 382e0d4..257cab0 100644 --- a/elec/boards/Controller_Motor_STM32/Firmware/controller_motor_stm32/cfg/cfg_proc.h +++ b/elec/boards/Controller_Motor_STM32/Firmware/controller_motor_stm32/cfg/cfg_proc.h @@ -86,7 +86,7 @@ * $WIZ$ type = "int" * $WIZ$ min = 0 */ -#define CONFIG_KERN_HEAP_SIZE 4096L +#define CONFIG_KERN_HEAP_SIZE 8192L /** * Module logging level. diff --git a/elec/boards/Controller_Motor_STM32/Firmware/controller_motor_stm32/controller_motor_stm32.mk b/elec/boards/Controller_Motor_STM32/Firmware/controller_motor_stm32/controller_motor_stm32.mk index 14a7de9..7d1317b 100644 --- a/elec/boards/Controller_Motor_STM32/Firmware/controller_motor_stm32/controller_motor_stm32.mk +++ b/elec/boards/Controller_Motor_STM32/Firmware/controller_motor_stm32/controller_motor_stm32.mk @@ -9,7 +9,7 @@ Firmware_DEBUG = 1 # Our target application TRG += controller_motor_stm32 -controller_motor_stm32_PREFIX = "arm-none-eabi-" +controller_motor_stm32_PREFIX = "/home/lxir/opt/arm/bin/arm-none-eabi-" controller_motor_stm32_SUFFIX = "" @@ -22,14 +22,14 @@ controller_motor_stm32_WIZARD_CSRC = \ bertos/cpu/cortex-m3/drv/can_stm32.c \ bertos/cpu/cortex-m3/hw/switch_ctx_cm3.c \ bertos/mware/event.c \ - bertos/kern/monitor.c \ bertos/cpu/cortex-m3/drv/timer_cm3.c \ bertos/struct/heap.c \ bertos/drv/can.c \ - bertos/mware/formatwr.c \ + bertos/kern/monitor.c \ bertos/drv/timer.c \ bertos/kern/signal.c \ bertos/kern/proc.c \ + bertos/mware/formatwr.c \ bertos/mware/hex.c \ # diff --git a/elec/boards/Controller_Motor_STM32/Firmware/controller_motor_stm32/main.c b/elec/boards/Controller_Motor_STM32/Firmware/controller_motor_stm32/main.c index 89df632..370f723 100644 --- a/elec/boards/Controller_Motor_STM32/Firmware/controller_motor_stm32/main.c +++ b/elec/boards/Controller_Motor_STM32/Firmware/controller_motor_stm32/main.c @@ -37,6 +37,12 @@ static void init(void) // Initialize CAN_MONITOR canMonitorInit(); + // Start control of drive motors + float k[] = {-68.0325, -1.0205}; + float l0[] = {0.0236, 3.9715}; + mc_new_controller(MOTOR3, ENCODER3, 360.0/2000.0/15.0, 0.833, 0.015, 0.005, k, -k[0], l0); + mc_new_controller(MOTOR4, ENCODER4, 360.0/2000.0/15.0, 0.833, 0.015, 0.005, k, -k[0], l0); + // Blink to say we are ready for (uint8_t i=0; i < 2; i++) { LED1_ON(); @@ -57,46 +63,61 @@ static void NORETURN square_process(void) // Let's roll ! while (1) { - motorSetSpeed(MOTOR3 | MOTOR4, 500); - timer_delay(1000); - motorSetSpeed(MOTOR3, -500); - timer_delay(1000); - motorSetSpeed(MOTOR3 | MOTOR4, 500); - timer_delay(1000); - motorSetSpeed(MOTOR4, -500); - timer_delay(1000); - motorSetSpeed(MOTOR3 | MOTOR4, 500); + motorSetSpeed(MOTOR3 | MOTOR4, 1500); timer_delay(1000); - motorSetSpeed(MOTOR3 | MOTOR4, 1000); + motorSetSpeed(MOTOR3 | MOTOR4, -1500); timer_delay(1000); motorSetSpeed(MOTOR3 | MOTOR4, 1500); timer_delay(1000); - // - disableMotor(MOTOR3 | MOTOR4); - /*motorSetSpeed(MOTOR3 | MOTOR4, 2000); - timer_delay(1000); - motorSetSpeed(MOTOR3 | MOTOR4, 2500); + motorSetSpeed(MOTOR3 | MOTOR4, -1500); timer_delay(1000); - motorSetSpeed(MOTOR3 | MOTOR4, 3000); + motorSetSpeed(MOTOR3 | MOTOR4, 1500); timer_delay(1000); - motorSetSpeed(MOTOR3 | MOTOR4, 3500); + motorSetSpeed(MOTOR3 | MOTOR4, -1500); timer_delay(1000); - motorSetSpeed(MOTOR3 | MOTOR4, 0); - timer_delay(1000);*/ + disableMotor(MOTOR3 | MOTOR4); break; } } +static void NORETURN goto_process(void) +{ + float inc = 100; + float ref = 0; + int32_t dt=1000; + uint8_t ind = 0; + + // Make the wheels turn + while(ref < 1500) + { + mc_gotoPosition(MOTOR3, ref); + mc_gotoPosition(MOTOR4, ref); + //position += speed * ((float)dt)/1000.0; + ref = ref + inc; + timer_delay(dt); + if(ind) { + LED1_ON(); + ind = 0; + } else { + LED1_OFF(); + ind = 1; + } + } + mc_delete_controller(MOTOR3); + mc_delete_controller(MOTOR4); +} + int main(void) { init(); /* Create a new child process */ - proc_new(square_process, NULL, KERN_MINSTACKSIZE * 2, NULL); + proc_new(goto_process, NULL, KERN_MINSTACKSIZE * 8, NULL); - enableMotor(MOTOR3 | MOTOR4); - LED1_ON(); LED2_ON(); + //timer_delay(4000); + //mc_delete_controller(MOTOR3); + //mc_delete_controller(MOTOR4); /* * The main process is kept to periodically report the stack diff --git a/elec/boards/Controller_Motor_STM32/Firmware/controller_motor_stm32/motor_controller.c b/elec/boards/Controller_Motor_STM32/Firmware/controller_motor_stm32/motor_controller.c index cd19110..680f3e1 100644 --- a/elec/boards/Controller_Motor_STM32/Firmware/controller_motor_stm32/motor_controller.c +++ b/elec/boards/Controller_Motor_STM32/Firmware/controller_motor_stm32/motor_controller.c @@ -195,6 +195,7 @@ uint8_t mc_new_controller(uint8_t motor, uint8_t encoder, float encoder_gain, fl params->last_estimate[0] = 0; params->last_estimate[1] = 0; params->last_output = params->last_estimate[0]; params->last_encoder_pos = getEncoderPosition(encoder); + params->reference = 0; params->F[0] = 1; params->F[1] = tau*(1-exp(-T/tau)); diff --git a/elec/boards/Controller_Motor_STM32/Firmware/project.bertos b/elec/boards/Controller_Motor_STM32/Firmware/project.bertos index 33b0c75..e2a1b7f 100644 --- a/elec/boards/Controller_Motor_STM32/Firmware/project.bertos +++ b/elec/boards/Controller_Motor_STM32/Firmware/project.bertos @@ -29,11 +29,11 @@ p13 (lp14 S'signal' p15 -aS'debug' -p16 aS'kernel' -p17 +p16 aS'monitor' +p17 +aS'debug' p18 aS'timer' p19 hooks/post-receive -- krobot |