From db49ec9cf394fd6841ee729decb9585a0d757e4c Mon Sep 17 00:00:00 2001 From: Nicolas Trimborn Date: Wed, 28 Apr 2021 09:26:14 +0200 Subject: [PATCH] initial branch commit --- BLDC_E54/.gitignore | 23 ++ BLDC_E54/.vs/BLDC_E54/v14/.atsuo | Bin 203776 -> 203776 bytes BLDC_E54/BLDC_E54/BLDC_E54.cproj | 3 + BLDC_E54/BLDC_E54/bldc.c | 4 +- BLDC_E54/BLDC_E54/bldc.h | 385 +++++++++++++------------------ BLDC_E54/BLDC_E54/motor_params.h | 126 ++++++++++ 6 files changed, 308 insertions(+), 233 deletions(-) create mode 100644 BLDC_E54/.gitignore create mode 100644 BLDC_E54/BLDC_E54/motor_params.h diff --git a/BLDC_E54/.gitignore b/BLDC_E54/.gitignore new file mode 100644 index 0000000..fe57f80 --- /dev/null +++ b/BLDC_E54/.gitignore @@ -0,0 +1,23 @@ + +## Ignore Atmel Studio temporary files and build results +# https://www.microchip.com/mplab/avr-support/atmel-studio-7 + +# Atmel Studio is powered by an older version of Visual Studio, +# so most of the project and solution files are the same as VS files, +# only prefixed by an `at`. + +#Build Directories +[Dd]ebug/ +[Rr]elease/ + +#Build Results +*.o +*.d +*.eep +*.elf +*.hex +*.map +*.srec + +#User Specific Files +*.atsuo diff --git a/BLDC_E54/.vs/BLDC_E54/v14/.atsuo b/BLDC_E54/.vs/BLDC_E54/v14/.atsuo index b13348b64f523e5bb11cbe42447ec27751361642..260493293680280005a4919b17e3dbe6c459c442 100644 GIT binary patch delta 965 zcmaKqT}YEr7{|}^`fhA)eh|9NoH)J6B+X9@zc)0|0)0&h>B6REWNGTO6fbHm7*RL6 zLk_73R)kkk9wH%Y3(&aM7MtQ!PSsKM^N3;vv04G2u*g$?0w88HHM?e;E z0q#}pW?8r&L4r)osHK;x;n;|=8rTCe2^v5=7y^|*?%D)904zXmau{|M90Pkn31|kV zz(F828L+o@d>I$PHvkhT18&CjTfz$7rL!8OL@w^tebsBenT^fu+b@ZAeF<$HU4GV3 z$xGF|>i=EX0Z}I?09C*a@Gv9g&=OV+d?B%jk62oatPg$80UoJM;qLNOzHVtYk}Q{l+|F8U zik|qmwTUk%MY<*QNEAPEUXeN&ldPdIcb{-rI%r$#=U#iZ$hLn>4fM4K!x61@I5_E6 zs`CC$D?0ZW=nt1IjBp$9=5i9k(lLDc7 z{@hx~M?%`xOL}4#h)WS`Au|PwhmbKZ^}PK_oo#9PeoTlApigX delta 908 zcmZwEUr5tY6bJC#>)o%Pb6ft|a7%4#X=+WgiCPjmn^2g|zeu5oWR?#?DnZgiEgwdY zwS&7)5sZ=^B5YSmBFLbJs2&u0@JSYg)Qi33quTe@9)!B^;oN)A`TfrMZLuYLY{`DV zn>D}aDdEP#+}l?ln`xTQvQ@Rk>zTFNVzK<98sVc()8*gIt{ucaWG+H490Hx9m?&j7 zdT18YqNs8V+bZh z!R5#%JEx)(X_jiV&98Hw-dJJ6hdJm=Lon5zpX%T;G{tAs%)mXbE=Wy_#H>(a<1-UY z**ZDpW=T1DlY8XCDmUfx74B5;XNGdf?|LdKbycR-MH$yPeQ*ZphP#U*IVbYQknrQX zu;l6%lX5f7{j$YiHnn^^Y)uTAcXE&xU6WVQk8w0**i>R6#Wyg<}we8mNUj&@a>f*#Mg8yRU#8usa&3WjA3lN1a=!PEXg+91U?*>aAO!~`4akv6w xa22k>IOtI(brCHOhNUjB`g&D=dVL4UAVzbG3lFcW1{5QdW3VHwl diff --git a/BLDC_E54/BLDC_E54/BLDC_E54.cproj b/BLDC_E54/BLDC_E54/BLDC_E54.cproj index ea25ccf..0f61d09 100644 --- a/BLDC_E54/BLDC_E54/BLDC_E54.cproj +++ b/BLDC_E54/BLDC_E54/BLDC_E54.cproj @@ -1011,6 +1011,9 @@ compile + + compile + compile diff --git a/BLDC_E54/BLDC_E54/bldc.c b/BLDC_E54/BLDC_E54/bldc.c index aac6c4f..fb7b0eb 100644 --- a/BLDC_E54/BLDC_E54/bldc.c +++ b/BLDC_E54/BLDC_E54/bldc.c @@ -79,7 +79,7 @@ void BLDC_init(BLDCMotor_t *motor) motor->VdcBus_pu = DEVICE_DC_VOLTAGE_V; motor->VoneByDcBus_pu = 1.0f/DEVICE_DC_VOLTAGE_V; - motor->motor_commutation_Pattern = COMMUTATION_PATTERN; + motor->motor_commutation_Pattern = COMMUTATION_PATTERN_M1; motor->desired_torque = 0.0; motor->desired_speed = 0; @@ -225,7 +225,7 @@ void exec_commutation(void) //} - TCC1->PATTBUF.reg = COMMUTATION_PATTERN[(Motor1.currentHallPattern + Motor1.directionOffset)]; + TCC1->PATTBUF.reg = COMMUTATION_PATTERN_M1[(Motor1.currentHallPattern + Motor1.directionOffset)]; TCC1->CCBUF->reg = (uint16_t)Motor1.duty_cycle; //hri_tcc_write_PATTBUF_reg(TCC1, (COMMUTATION_PATTERN[(Motor1.currentHallPattern + Motor1.directionOffset)])); diff --git a/BLDC_E54/BLDC_E54/bldc.h b/BLDC_E54/BLDC_E54/bldc.h index a96e409..3d91c2d 100644 --- a/BLDC_E54/BLDC_E54/bldc.h +++ b/BLDC_E54/BLDC_E54/bldc.h @@ -1,234 +1,157 @@ -/* - * bldc.h - * - * Created: 10/03/2021 14:38:14 - * Author: Nick-XMG - */ - -#ifndef BLDC_H_ -#define BLDC_H_ - -// ---------------------------------------------------------------------- -// header files -// ---------------------------------------------------------------------- -#include "arm_math.h" -#include "atmel_start.h" -#include "control.h" - - -// ---------------------------------------------------------------------- -// Current Sensor -// ---------------------------------------------------------------------- - -#define DRV_ISEN_A_CH ADC_INPUTCTRL_MUXPOS_AIN2_Val -#define DRV_ISEN_B_CH ADC_INPUTCTRL_MUXPOS_AIN1_Val - -// ---------------------------------------------------------------------- -// Hall Parameters -// ---------------------------------------------------------------------- - -#define HALL_A_PIN GPIO(GPIO_PORTA, 6) #define HALL_A_PORT PORT_PA06 #define HALL_A_MASK ~(1<<2) #define HALL_A_LSR HALL_A_PIN - HALL_A_GROUP*32 -2 -#define HALL_A_GROUP HALL_A_PIN/32 #define HALL_B_PIN GPIO(GPIO_PORTA, 5) -#define HALL_B_PORT PORT_PA05 -#define HALL_B_MASK ~(1<<1) -#define HALL_B_LSR HALL_B_PIN - HALL_B_GROUP*32 -1 -#define HALL_B_GROUP HALL_B_PIN/32 - -#define HALL_C_PIN GPIO(GPIO_PORTA, 4) -#define HALL_C_PORT PORT_PA04 -#define HALL_C_MASK ~(1<<0) -#define HALL_C_LSR HALL_C_PIN - HALL_C_GROUP*32 -0 -#define HALL_C_GROUP HALL_C_PIN/32 - -/* if the Hall sensor reads 0x0 or 0x7 that means either one of the hall sensor is damaged or disconnected*/ -#define INVALID_HALL_0 (0U) -#define INVALID_HALL_7 (7U) - -// ---------------------------------------------------------------------- -// ADC Parameters -// ---------------------------------------------------------------------- -#define ADC_VOLTAGE_REFERENCE (3.3f) -#define ADC_RESOLUTION (12) -#define ADC_MAX_COUNTS (1<