Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Dependencies: mbed-dev-f303 FastPWM3
Revision 57:d18e3d25ed8a, committed 2020-12-09
- Comitter:
- Ikhee
- Date:
- Wed Dec 09 06:33:30 2020 +0000
- Parent:
- 56:fe5056ac6740
- Commit message:
- Last Updated version.
Changed in this revision
--- a/Config/current_controller_config.h Thu Oct 10 15:03:12 2019 +0000 +++ b/Config/current_controller_config.h Wed Dec 09 06:33:30 2020 +0000 @@ -2,16 +2,16 @@ #define CURRENT_CONTROLLER_CONFIG_H // Current controller/// -#define K_D .05f // Loop gain, Volts/Amp -#define K_Q .05f // Loop gain, Volts/Amp +//#define K_D .05f // Loop gain, Volts/Amp +//#define K_Q .05f // Loop gain, Volts/Amp #define K_SCALE 0.0001f // K_loop/Loop BW (Hz) 0.0042 #define KI_D 0.0455f // PI zero, in radians per sample #define KI_Q 0.0455f // PI zero, in radians per sample #define V_BUS 24.0f // Volts #define OVERMODULATION 1.15f // 1.0 = no overmodulation - -#define D_INT_LIM V_BUS/(K_D*KI_D) // Amps*samples -#define Q_INT_LIM V_BUS/(K_Q*KI_Q) // Amps*samples +// +//#define D_INT_LIM V_BUS/(K_D*KI_D) // Amps*samples +//#define Q_INT_LIM V_BUS/(K_Q*KI_Q) // Amps*samples //Observer// #define DT 0.000025f
--- a/PositionSensor/PositionSensor.cpp Thu Oct 10 15:03:12 2019 +0000
+++ b/PositionSensor/PositionSensor.cpp Wed Dec 09 06:33:30 2020 +0000
@@ -29,6 +29,11 @@
spi->write(0);
wait_us(100);
}
+
+ GPIOA->ODR &= ~(1 << 15);
+ spi->write(0x8980);
+ wait_ms(20);
+
}
--- a/main.cpp Thu Oct 10 15:03:12 2019 +0000
+++ b/main.cpp Wed Dec 09 06:33:30 2020 +0000
@@ -178,6 +178,7 @@
if (TIM1->SR & TIM_SR_UIF ) {
//gpio.led->write(1);
///Sample current always ///
+ gpio.led->write(!gpio.led->read());
ADC1->CR2 |= 0x40000000; // Begin sample and conversion
//volatile int delay;
//for (delay = 0; delay < 55; delay++);
@@ -447,6 +448,14 @@
wait_us(100);
drv.write_CSACR(0x0, 0x1, 0x0, CSA_GAIN_40, 0x0, 0x1, 0x1, 0x1, SEN_LVL_1_0); // calibrate shunt amplifiers
wait_us(100);
+
+
+ drv.write_HSR(LOCK_OFF, IDRIVEP_HS_330MA, IDRIVEN_HS_660MA);
+ wait_us(100);
+ drv.write_LSR(0x1, TDRIVE_4000NS, IDRIVEP_LS_330MA, IDRIVEN_LS_660MA);
+ wait_us(100);
+
+
zero_current(&controller.adc1_offset, &controller.adc2_offset);
wait_us(100);
drv.write_CSACR(0x0, 0x1, 0x0, CSA_GAIN_40, 0x1, 0x0, 0x0, 0x0, SEN_LVL_1_0);
@@ -523,7 +532,7 @@
//drv.print_faults();
wait(.1);
//printf("%.3f %.3f\n\r" , observer.temperature, observer.q_in);
- if(controller.otw_flag){gpio.led->write(!gpio.led->read());}
+ //if(controller.otw_flag){gpio.led->write(!gpio.led->read());}
/*
if(state == MOTOR_MODE)
{