Current Reading, Phase order is still strange
This commit is contained in:
parent
7fe6ef2ab9
commit
e4c2808df5
|
@ -116,10 +116,17 @@ drivers:
|
|||
adc_freerunning_mode: false
|
||||
adc_pinmux_negative: Internal ground
|
||||
adc_pinmux_positive: ADC AIN6 pin
|
||||
adc_prescaler: Peripheral clock divided by 8
|
||||
adc_prescaler: Peripheral clock divided by 16
|
||||
adc_reference: External reference A
|
||||
adc_resolution: 12-bit
|
||||
optional_signals:
|
||||
- identifier: ADC_1:AIN/0
|
||||
pad: PB08
|
||||
mode: Enabled
|
||||
configuration: null
|
||||
definition: Atmel:SAME51_Drivers:0.0.1::SAME51J19A-MF::optional_signal_definition::ADC1.AIN.0
|
||||
name: ADC1/AIN/0
|
||||
label: AIN/0
|
||||
- identifier: ADC_1:AIN/6
|
||||
pad: PB04
|
||||
mode: Enabled
|
||||
|
|
|
@ -339,7 +339,7 @@
|
|||
// <i> These bits define the ADC clock relative to the peripheral clock (PRESCALER)
|
||||
// <id> adc_prescaler
|
||||
#ifndef CONF_ADC_1_PRESCALER
|
||||
#define CONF_ADC_1_PRESCALER 0x2
|
||||
#define CONF_ADC_1_PRESCALER 0x3
|
||||
#endif
|
||||
|
||||
// <q> Free Running Mode
|
||||
|
|
|
@ -688,7 +688,7 @@
|
|||
// <TCC_WAVE_WAVEGEN_DSTOP_Val"> Dual-slope, interrupt/event at Top (DSTOP)
|
||||
// <id> tcc_arch_wavegen
|
||||
#ifndef CONF_TCC1_WAVEGEN
|
||||
#define CONF_TCC1_WAVEGEN TCC_WAVE_WAVEGEN_NPWM_Val
|
||||
#define CONF_TCC1_WAVEGEN TCC_WAVE_WAVEGEN_DSBOTTOM_Val
|
||||
#endif
|
||||
// <q> TCC1 Auto Lock
|
||||
// <i> Indicates whether the TCC1 Auto Lock is enabled or not
|
||||
|
@ -762,7 +762,7 @@
|
|||
// <i> Indicates whether the TCC1 Lock update is enabled or not
|
||||
// <id> tcc_arch_lupd
|
||||
#ifndef CONF_TCC1_LUPD
|
||||
#define CONF_TCC1_LUPD 1
|
||||
#define CONF_TCC1_LUPD 0
|
||||
#endif
|
||||
|
||||
/* Commented intentionally. Timer uses fixed value of the following bit(s)/bitfield(s) of CTRL B register.
|
||||
|
|
|
@ -150,7 +150,7 @@
|
|||
<AcmeProjectActionInfo Action="File" Source="hri/hri_usb_e51.h" IsConfig="false" Hash="x6M7vYgNCS2oECqykr5+yw" />
|
||||
<AcmeProjectActionInfo Action="File" Source="hri/hri_wdt_e51.h" IsConfig="false" Hash="o9Rg/hyuMzwOCphVc7uG1w" />
|
||||
<AcmeProjectActionInfo Action="File" Source="main.c" IsConfig="false" Hash="k0AH7j+BrmdFhBPzCCMptA" />
|
||||
<AcmeProjectActionInfo Action="File" Source="driver_init.c" IsConfig="false" Hash="yc88NDUM9Jn6uFM5loqb3A" />
|
||||
<AcmeProjectActionInfo Action="File" Source="driver_init.c" IsConfig="false" Hash="rYZS19ftiPajVCnE2RLIkA" />
|
||||
<AcmeProjectActionInfo Action="File" Source="driver_init.h" IsConfig="false" Hash="Djt0mG2wi689XcXrLHKt0g" />
|
||||
<AcmeProjectActionInfo Action="File" Source="atmel_start_pins.h" IsConfig="false" Hash="ByCGTBpkOpAk+zk9txhJSA" />
|
||||
<AcmeProjectActionInfo Action="File" Source="examples/driver_examples.h" IsConfig="false" Hash="kvd7eb1e9guBnXkzUfLueg" />
|
||||
|
@ -207,7 +207,7 @@
|
|||
<AcmeProjectActionInfo Action="File" Source="hpl/tcc/hpl_tcc.h" IsConfig="false" Hash="rdWkAK12qkOYV59tWwzy6A" />
|
||||
<AcmeProjectActionInfo Action="File" Source="atmel_start.h" IsConfig="false" Hash="9RBG5E2ViQiSP2Gn4/FGpA" />
|
||||
<AcmeProjectActionInfo Action="File" Source="atmel_start.c" IsConfig="false" Hash="1RHIE7zTtYK4DURNPUqF9w" />
|
||||
<AcmeProjectActionInfo Action="File" Source="config/hpl_adc_config.h" IsConfig="true" Hash="vEVkM0cxO7eGY9oVPnSDjg" />
|
||||
<AcmeProjectActionInfo Action="File" Source="config/hpl_adc_config.h" IsConfig="true" Hash="49h3xITKddAgoXK8+KV9zQ" />
|
||||
<AcmeProjectActionInfo Action="File" Source="config/hpl_ccl_config.h" IsConfig="true" Hash="qVCPwh4wAVouqj+bKLxfMA" />
|
||||
<AcmeProjectActionInfo Action="File" Source="config/hpl_cmcc_config.h" IsConfig="true" Hash="bmtxQ8rLloaRtAo2HeXZRQ" />
|
||||
<AcmeProjectActionInfo Action="File" Source="config/hpl_dmac_config.h" IsConfig="true" Hash="xCXhbdBwXKUe304TPFonTw" />
|
||||
|
@ -221,7 +221,7 @@
|
|||
<AcmeProjectActionInfo Action="File" Source="config/hpl_qspi_config.h" IsConfig="true" Hash="CwZ360eeEYs7T9SYFSvDug" />
|
||||
<AcmeProjectActionInfo Action="File" Source="config/hpl_sercom_config.h" IsConfig="true" Hash="Es2tGk0V59kfHKXDA1geTw" />
|
||||
<AcmeProjectActionInfo Action="File" Source="config/hpl_tc_config.h" IsConfig="true" Hash="T93Kr6C+WDuufZob89oPeg" />
|
||||
<AcmeProjectActionInfo Action="File" Source="config/hpl_tcc_config.h" IsConfig="true" Hash="ArX2n3AAmZhG6NZ/UPLExg" />
|
||||
<AcmeProjectActionInfo Action="File" Source="config/hpl_tcc_config.h" IsConfig="true" Hash="2LU7afZ/3Yx7FE2KzF9dSQ" />
|
||||
<AcmeProjectActionInfo Action="File" Source="config/peripheral_clk_config.h" IsConfig="true" Hash="rqTY1slZEq9V5moV+8Q+hw" />
|
||||
</AcmeActionInfos>
|
||||
<NonsecureFilesInfo />
|
||||
|
@ -387,7 +387,6 @@
|
|||
<armgcc.compiler.directories.IncludePaths>
|
||||
<ListValues>
|
||||
<Value>%24(PackRepoDir)\arm\CMSIS\5.4.0\CMSIS\Core\Include\</Value>
|
||||
<Value>%24(PackRepoDir)\atmel\SAME51_DFP\1.1.139\include</Value>
|
||||
<Value>../Config</Value>
|
||||
<Value>../</Value>
|
||||
<Value>../examples</Value>
|
||||
|
@ -412,13 +411,14 @@
|
|||
<Value>../hpl/tc</Value>
|
||||
<Value>../hpl/tcc</Value>
|
||||
<Value>../hri</Value>
|
||||
<Value>%24(PackRepoDir)\atmel\SAME51_DFP\1.1.139\include</Value>
|
||||
</ListValues>
|
||||
</armgcc.compiler.directories.IncludePaths>
|
||||
<armgcc.compiler.optimization.level>Optimize more (-O2)</armgcc.compiler.optimization.level>
|
||||
<armgcc.compiler.optimization.PrepareFunctionsForGarbageCollection>True</armgcc.compiler.optimization.PrepareFunctionsForGarbageCollection>
|
||||
<armgcc.compiler.optimization.DebugLevel>Maximum (-g3)</armgcc.compiler.optimization.DebugLevel>
|
||||
<armgcc.compiler.warnings.AllWarnings>True</armgcc.compiler.warnings.AllWarnings>
|
||||
<armgcc.compiler.miscellaneous.OtherFlags>-std=gnu11 -mfloat-abi=hard -mfpu=fpv4-sp-d16</armgcc.compiler.miscellaneous.OtherFlags>
|
||||
<armgcc.compiler.miscellaneous.OtherFlags>-std=gnu99 -mfloat-abi=hard -mfpu=fpv4-sp-d16</armgcc.compiler.miscellaneous.OtherFlags>
|
||||
<armgcc.linker.general.UseNewlibNano>True</armgcc.linker.general.UseNewlibNano>
|
||||
<armgcc.linker.libraries.Libraries>
|
||||
<ListValues>
|
||||
|
@ -439,7 +439,6 @@
|
|||
<armgcc.assembler.general.IncludePaths>
|
||||
<ListValues>
|
||||
<Value>%24(PackRepoDir)\arm\CMSIS\5.4.0\CMSIS\Core\Include\</Value>
|
||||
<Value>%24(PackRepoDir)\atmel\SAME51_DFP\1.1.139\include</Value>
|
||||
<Value>../Config</Value>
|
||||
<Value>../</Value>
|
||||
<Value>../examples</Value>
|
||||
|
@ -464,13 +463,13 @@
|
|||
<Value>../hpl/tc</Value>
|
||||
<Value>../hpl/tcc</Value>
|
||||
<Value>../hri</Value>
|
||||
<Value>%24(PackRepoDir)\atmel\SAME51_DFP\1.1.139\include</Value>
|
||||
</ListValues>
|
||||
</armgcc.assembler.general.IncludePaths>
|
||||
<armgcc.assembler.debugging.DebugLevel>Default (-g)</armgcc.assembler.debugging.DebugLevel>
|
||||
<armgcc.preprocessingassembler.general.IncludePaths>
|
||||
<ListValues>
|
||||
<Value>%24(PackRepoDir)\arm\CMSIS\5.4.0\CMSIS\Core\Include\</Value>
|
||||
<Value>%24(PackRepoDir)\atmel\SAME51_DFP\1.1.139\include</Value>
|
||||
<Value>../Config</Value>
|
||||
<Value>../</Value>
|
||||
<Value>../examples</Value>
|
||||
|
@ -495,6 +494,7 @@
|
|||
<Value>../hpl/tc</Value>
|
||||
<Value>../hpl/tcc</Value>
|
||||
<Value>../hri</Value>
|
||||
<Value>%24(PackRepoDir)\atmel\SAME51_DFP\1.1.139\include</Value>
|
||||
</ListValues>
|
||||
</armgcc.preprocessingassembler.general.IncludePaths>
|
||||
<armgcc.preprocessingassembler.debugging.DebugLevel>Default (-Wa,-g)</armgcc.preprocessingassembler.debugging.DebugLevel>
|
||||
|
|
|
@ -18,13 +18,13 @@ void BldcInitStruct(BLDCMotor_t *motor, BLDCMotor_param_t *motor_param)
|
|||
motor->motor_param = motor_param;
|
||||
motor->motor_status.actualDirection = 0;
|
||||
motor->motor_setpoints.desiredDirection = 0;
|
||||
motor->motor_status.duty_cycle = 100;
|
||||
motor->motor_status.duty_cycle = 200;
|
||||
motor->motor_status.calc_rpm = 0;
|
||||
motor->motor_status.Num_Steps = 0;
|
||||
motor->motor_status.cur_comm_step = 0;
|
||||
motor->motor_status.currentHallPattern = 1;
|
||||
motor->motor_status.nextHallPattern = 3;
|
||||
motor->motor_setpoints.directionOffset = 0;
|
||||
motor->motor_setpoints.directionOffset = 8;
|
||||
|
||||
motor->Iphase_pu.A = 0;
|
||||
motor->Iphase_pu.B = 0;
|
||||
|
@ -321,4 +321,104 @@ uint8_t readHallSensorM2(void)
|
|||
return ((a << 2) |
|
||||
(b << 1) |
|
||||
(c << 0));
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------
|
||||
// Before Power up, Measure and average offset voltage for Current Sensor
|
||||
// This voltage is subtracted from all reading for Bi-Directional Current
|
||||
// Measurement
|
||||
// ----------------------------------------------------------------------
|
||||
void read_zero_current_offset_value(BLDCMotor_t *motor1, BLDCMotor_t *motor2)
|
||||
{
|
||||
uint32_t phase_A_zero_current_offset_temp = 0;
|
||||
uint32_t phase_B_zero_current_offset_temp = 0;
|
||||
volatile uint16_t zero_current_offset_temp[2] = {0,0};
|
||||
uint8_t samples = 32;
|
||||
uint8_t i;
|
||||
|
||||
// ------------------------- Motor 1 ---------------------------------
|
||||
adc_sync_enable_channel(&ADC_1, 9);
|
||||
//adc_sync_enable_channel(&ADC_1, 0);
|
||||
|
||||
ADC1->INPUTCTRL.reg = 0x1809;
|
||||
while (ADC1->STATUS.bit.ADCBUSY) {}; /* Wait for bus synchronization. */
|
||||
|
||||
for (i=0; i<samples; i++)
|
||||
{
|
||||
volatile uint16_t zero_current_offset_temp[2] = {0,0};
|
||||
|
||||
while (ADC1->STATUS.bit.ADCBUSY) {}; /* Wait for bus synchronization. */
|
||||
ADC1->SWTRIG.bit.START = true; /* Start the ADC using a software trigger. */
|
||||
while (ADC1->INTFLAG.bit.RESRDY == 0); /* Wait for the result ready flag to be set. */
|
||||
ADC1->INTFLAG.reg = ADC_INTFLAG_RESRDY; /* Clear the flag. */
|
||||
zero_current_offset_temp[0] = ADC1->RESULT.reg; /* Read the value. */
|
||||
|
||||
phase_A_zero_current_offset_temp += zero_current_offset_temp[0];
|
||||
}
|
||||
|
||||
/* Set Motor Variables */
|
||||
motor1->Voffset_lsb.A = phase_A_zero_current_offset_temp/samples;
|
||||
|
||||
ADC1->INPUTCTRL.reg = 0x1808;
|
||||
while (ADC1->STATUS.bit.ADCBUSY) {}; /* Wait for bus synchronization. */
|
||||
|
||||
for (i=0; i<samples; i++)
|
||||
{
|
||||
while (ADC1->STATUS.bit.ADCBUSY) {}; /* Wait for bus synchronization. */
|
||||
ADC1->SWTRIG.bit.START = true; /* Start the ADC using a software trigger. */
|
||||
while (ADC1->INTFLAG.bit.RESRDY == 0); /* Wait for the result ready flag to be set. */
|
||||
ADC1->INTFLAG.reg = ADC_INTFLAG_RESRDY; /* Clear the flag. */
|
||||
zero_current_offset_temp[1] = ADC1->RESULT.reg; /* Read the value. */
|
||||
|
||||
phase_B_zero_current_offset_temp += zero_current_offset_temp[1];
|
||||
}
|
||||
|
||||
|
||||
/* Set Motor Variables */
|
||||
motor1->Voffset_lsb.B = phase_B_zero_current_offset_temp/samples;
|
||||
adc_sync_disable_channel(&ADC_1, 8);
|
||||
|
||||
adc_sync_enable_channel(&ADC_1, 7);
|
||||
//adc_sync_enable_channel(&ADC_1, 0);
|
||||
|
||||
phase_A_zero_current_offset_temp = 0;
|
||||
phase_B_zero_current_offset_temp = 0;
|
||||
|
||||
ADC1->INPUTCTRL.reg = 0x1807;
|
||||
while (ADC1->STATUS.bit.ADCBUSY) {}; /* Wait for bus synchronization. */
|
||||
|
||||
for (i=0; i<samples; i++)
|
||||
{
|
||||
volatile uint16_t zero_current_offset_temp[2] = {0,0};
|
||||
|
||||
while (ADC1->STATUS.bit.ADCBUSY) {}; /* Wait for bus synchronization. */
|
||||
ADC1->SWTRIG.bit.START = true; /* Start the ADC using a software trigger. */
|
||||
while (ADC1->INTFLAG.bit.RESRDY == 0); /* Wait for the result ready flag to be set. */
|
||||
ADC1->INTFLAG.reg = ADC_INTFLAG_RESRDY; /* Clear the flag. */
|
||||
zero_current_offset_temp[0] = ADC1->RESULT.reg; /* Read the value. */
|
||||
|
||||
phase_A_zero_current_offset_temp += zero_current_offset_temp[0];
|
||||
}
|
||||
|
||||
/* Set Motor Variables */
|
||||
motor2->Voffset_lsb.A = phase_A_zero_current_offset_temp/samples;
|
||||
|
||||
ADC1->INPUTCTRL.reg = 0x1806;
|
||||
while (ADC1->STATUS.bit.ADCBUSY) {}; /* Wait for bus synchronization. */
|
||||
|
||||
for (i=0; i<samples; i++)
|
||||
{
|
||||
while (ADC1->STATUS.bit.ADCBUSY) {}; /* Wait for bus synchronization. */
|
||||
ADC1->SWTRIG.bit.START = true; /* Start the ADC using a software trigger. */
|
||||
while (ADC1->INTFLAG.bit.RESRDY == 0); /* Wait for the result ready flag to be set. */
|
||||
ADC1->INTFLAG.reg = ADC_INTFLAG_RESRDY; /* Clear the flag. */
|
||||
zero_current_offset_temp[1] = ADC1->RESULT.reg; /* Read the value. */
|
||||
|
||||
phase_B_zero_current_offset_temp += zero_current_offset_temp[1];
|
||||
}
|
||||
|
||||
/* Set Motor Variables */
|
||||
motor2->Voffset_lsb.B = phase_B_zero_current_offset_temp/samples;
|
||||
adc_sync_disable_channel(&ADC_1, 6);
|
||||
//adc_sync_disable_channel(&ADC_1, 0);
|
||||
}
|
|
@ -69,8 +69,6 @@ static const uint8_t MOTOR_COMMUTATION_STEPS[8] = {9, 1, 3, 2, 5, 6, 4, 9};
|
|||
volatile BLDCMotor_t Motor1;
|
||||
volatile BLDCMotor_t Motor2;
|
||||
|
||||
|
||||
|
||||
// ----------------------------------------------------------------------
|
||||
// functions
|
||||
// ----------------------------------------------------------------------
|
||||
|
|
|
@ -12,6 +12,7 @@
|
|||
// ----------------------------------------------------------------------
|
||||
// Header Files
|
||||
// ----------------------------------------------------------------------
|
||||
#include "atmel_start_pins.h"
|
||||
#include "bldc.h"
|
||||
#include "interrupts.h"
|
||||
|
||||
|
@ -19,12 +20,22 @@
|
|||
#define DMAC_CHANNEL_ADC_SRAM 3U
|
||||
|
||||
const uint32_t adc_seq_regs[4] = {0x1806, 0x1807, 0x1808, 0x1809};
|
||||
volatile uint16_t adc_res[4] = {0};
|
||||
//const uint32_t adc_seq_regs[5] = {0x0086, 0x0087, 0x0088, 0x0089};
|
||||
//uint32_t adc_seq_regs[4] = {0x0006, 0x0007, 0x0008, 0x0009};
|
||||
//const uint32_t adc_seq_regs[5] = {0x1800, 0x1806, 0x1807, 0x1808, 0x1809};
|
||||
volatile int16_t adc_res[4] = {0};
|
||||
struct _dma_resource *adc_sram_dma_resource;
|
||||
struct _dma_resource *adc_dmac_sequence_resource;
|
||||
|
||||
inline static void configure_tcc_pwm(void)
|
||||
{
|
||||
gpio_set_pin_pull_mode(M1_HALLA, GPIO_PULL_UP);
|
||||
gpio_set_pin_pull_mode(M1_HALLB, GPIO_PULL_UP);
|
||||
gpio_set_pin_pull_mode(M1_HALLC, GPIO_PULL_UP);
|
||||
gpio_set_pin_pull_mode(M2_HALLA, GPIO_PULL_UP);
|
||||
gpio_set_pin_pull_mode(M2_HALLB, GPIO_PULL_UP);
|
||||
gpio_set_pin_pull_mode(M2_HALLC, GPIO_PULL_UP);
|
||||
|
||||
/* TCC0 */
|
||||
hri_tcc_set_WEXCTRL_OTMX_bf(TCC0, 0x02);
|
||||
|
||||
|
|
|
@ -60,6 +60,11 @@ void ADC_0_init(void)
|
|||
void ADC_1_PORT_init(void)
|
||||
{
|
||||
|
||||
// Disable digital pin circuitry
|
||||
gpio_set_pin_direction(half_VREF, GPIO_DIRECTION_OFF);
|
||||
|
||||
gpio_set_pin_function(half_VREF, PINMUX_PB08B_ADC1_AIN0);
|
||||
|
||||
// Disable digital pin circuitry
|
||||
gpio_set_pin_direction(M1_IA, GPIO_DIRECTION_OFF);
|
||||
|
||||
|
@ -98,22 +103,16 @@ void DIGITAL_GLUE_LOGIC_0_PORT_init(void)
|
|||
{
|
||||
|
||||
gpio_set_pin_function(M1_HALLA, PINMUX_PA04N_CCL_IN0);
|
||||
gpio_set_pin_pull_mode(M1_HALLA, GPIO_PULL_UP);
|
||||
|
||||
gpio_set_pin_function(M1_HALLB, PINMUX_PA05N_CCL_IN1);
|
||||
gpio_set_pin_pull_mode(M1_HALLB, GPIO_PULL_UP);
|
||||
|
||||
gpio_set_pin_function(M1_HALLC, PINMUX_PA06N_CCL_IN2);
|
||||
gpio_set_pin_pull_mode(M1_HALLC, GPIO_PULL_UP);
|
||||
|
||||
gpio_set_pin_function(M2_HALLA, PINMUX_PA22N_CCL_IN6);
|
||||
gpio_set_pin_pull_mode(M2_HALLA, GPIO_PULL_UP);
|
||||
|
||||
gpio_set_pin_function(M2_HALLB, PINMUX_PA23N_CCL_IN7);
|
||||
gpio_set_pin_pull_mode(M2_HALLB, GPIO_PULL_UP);
|
||||
|
||||
gpio_set_pin_function(M2_HALLC, PINMUX_PA24N_CCL_IN8);
|
||||
gpio_set_pin_pull_mode(M2_HALLC, GPIO_PULL_UP);
|
||||
}
|
||||
|
||||
void DIGITAL_GLUE_LOGIC_0_CLOCK_init(void)
|
||||
|
@ -713,13 +712,6 @@ void system_init(void)
|
|||
|
||||
gpio_set_pin_function(SPI3_SS, GPIO_PIN_FUNCTION_OFF);
|
||||
|
||||
// GPIO on PB08
|
||||
|
||||
// Disable digital pin circuitry
|
||||
gpio_set_pin_direction(half_VREF, GPIO_DIRECTION_OFF);
|
||||
|
||||
gpio_set_pin_function(half_VREF, GPIO_PIN_FUNCTION_OFF);
|
||||
|
||||
// GPIO on PB22
|
||||
|
||||
gpio_set_pin_function(SPI1_CS, GPIO_PIN_FUNCTION_OFF);
|
||||
|
|
|
@ -21,17 +21,17 @@ void process_currents()
|
|||
volatile int16_t phase_A_current_raw, phase_B_current_raw;
|
||||
|
||||
/* Motor 1 */
|
||||
phase_A_current_raw = (adc_res[0] - Motor1.Voffset_lsb.A);
|
||||
phase_B_current_raw = (adc_res[1] - Motor1.Voffset_lsb.B)*-1;
|
||||
phase_A_current_raw = (adc_res[3] - Motor1.Voffset_lsb.A);
|
||||
phase_B_current_raw = (adc_res[2] - Motor1.Voffset_lsb.B)*-1;
|
||||
// Covert from LSB to PU (A) and filter out small readings
|
||||
Motor1.Iphase_pu.A = phase_A_current_raw * LSB_TO_PU;
|
||||
Motor1.Iphase_pu.B = phase_B_current_raw * LSB_TO_PU;
|
||||
// i_c = -i_a - i_b because i_a + i_b + i_c = 0
|
||||
Motor1.Iphase_pu.C = -Motor1.Iphase_pu.A - Motor1.Iphase_pu.B;
|
||||
|
||||
/* Motor 2 */
|
||||
phase_A_current_raw = (adc_res[2] - Motor2.Voffset_lsb.A);
|
||||
phase_B_current_raw = (adc_res[3] - Motor2.Voffset_lsb.B)*-1;
|
||||
/* Motor 2 negative is A instead of B*/
|
||||
phase_A_current_raw = (adc_res[1] - Motor2.Voffset_lsb.A);
|
||||
phase_B_current_raw = (adc_res[0] - Motor2.Voffset_lsb.B)*-1;
|
||||
// Covert from LSB to PU (A) and filter out small readings
|
||||
Motor2.Iphase_pu.A = phase_A_current_raw * LSB_TO_PU;
|
||||
Motor2.Iphase_pu.B = phase_B_current_raw * LSB_TO_PU;
|
||||
|
@ -148,7 +148,6 @@ inline void CONTROLLER_StateMachine(void)
|
|||
|
||||
int main(void)
|
||||
{
|
||||
volatile uint8_t m2_hall, m1_hall, x= 0;
|
||||
/* Initializes MCU, drivers and middleware */
|
||||
atmel_start_init();
|
||||
//initMotorParameters();
|
||||
|
@ -156,11 +155,11 @@ int main(void)
|
|||
BldcInitStruct(&Motor2, &FH_32mm24BXTR);
|
||||
Motor1.readHall = &readHallSensorM1;
|
||||
Motor2.readHall = &readHallSensorM2;
|
||||
|
||||
read_zero_current_offset_value(&Motor1, &Motor2);
|
||||
config_qspi();
|
||||
One_ms_timer_init();
|
||||
configure_tcc_pwm();
|
||||
adc_sync_enable_channel(&ADC_1, 0);
|
||||
adc_sync_enable_channel(&ADC_1, 6);
|
||||
adc_init_dma();
|
||||
ECAT_STATE_MACHINE();
|
||||
enable_NVIC_IRQ();
|
||||
|
|
Loading…
Reference in New Issue