This commit is contained in:
parent
79b54f286c
commit
7db543f79a
|
@ -1049,6 +1049,9 @@
|
|||
<Compile Include="main.c">
|
||||
<SubType>compile</SubType>
|
||||
</Compile>
|
||||
<Compile Include="motorparameters.h">
|
||||
<SubType>compile</SubType>
|
||||
</Compile>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Folder Include="Config\" />
|
||||
|
|
|
@ -14,6 +14,16 @@
|
|||
// ----------------------------------------------------------------------
|
||||
#include "atmel_start.h"
|
||||
#include "arm_math.h"
|
||||
#include "motorparameters.h"
|
||||
|
||||
#define PWM_TOP (1000)
|
||||
#define MAX_PWM (600)
|
||||
//#define MAX_VEL 3800
|
||||
|
||||
#define CW (0) //CBA
|
||||
#define DIRECTION_CW_OFFSET (0) //CBA
|
||||
#define CCW (1) //ABC
|
||||
#define DIRECTION_CCW_OFFSET (8) //CBA
|
||||
|
||||
|
||||
static uint32_t adc_seq_regs[5] = {0x1800, 0x1806, 0x1807, 0x1808, 0x1809};
|
||||
|
@ -76,50 +86,6 @@ volatile typedef struct
|
|||
volatile uint8_t prev_comm_step;
|
||||
} MOTOR_Status;
|
||||
|
||||
// ----------------------------------------------------------------------
|
||||
// M1 Hall Parameters
|
||||
// ----------------------------------------------------------------------
|
||||
|
||||
#define M1_HALL_A_PIN GPIO(GPIO_PORTA, 22)
|
||||
#define M1_HALL_A_PORT PORT_PA22
|
||||
#define M1_HALL_A_MASK ~(1<<0)
|
||||
#define M1_HALL_A_LSR M1_HALL_A_PIN - M1_HALL_A_GROUP*32 -0
|
||||
#define M1_HALL_A_GROUP M1_HALL_A_PIN/32
|
||||
|
||||
#define M1_HALL_B_PIN GPIO(GPIO_PORTA, 23)
|
||||
#define M1_HALL_B_PORT PORT_PA23
|
||||
#define M1_HALL_B_MASK ~(1<<1)
|
||||
#define M1_HALL_B_LSR M1_HALL_B_PIN - M1_HALL_B_GROUP*32 -1
|
||||
#define M1_HALL_B_GROUP M1_HALL_B_PIN/32
|
||||
|
||||
#define M1_HALL_C_PIN GPIO(GPIO_PORTA, 24)
|
||||
#define M1_HALL_C_PORT PORT_PA24
|
||||
#define M1_HALL_C_MASK ~(1<<2)
|
||||
#define M1_HALL_C_LSR M1_HALL_C_PIN - M1_HALL_C_GROUP*32 -2
|
||||
#define M1_HALL_C_GROUP M1_HALL_C_PIN/32
|
||||
|
||||
// ----------------------------------------------------------------------
|
||||
// M2 Hall Parameters
|
||||
// ----------------------------------------------------------------------
|
||||
|
||||
#define M2_HALL_A_PIN GPIO(GPIO_PORTA, 4)
|
||||
#define M2_HALL_A_PORT PORT_PA04
|
||||
#define M2_HALL_A_MASK ~(1<<0)
|
||||
#define M2_HALL_A_LSR M2_HALL_A_PIN - M2_HALL_A_GROUP*32 -0
|
||||
#define M2_HALL_A_GROUP M2_HALL_A_PIN/32
|
||||
|
||||
#define M2_HALL_B_PIN GPIO(GPIO_PORTA, 5)
|
||||
#define M2_HALL_B_PORT PORT_PA05
|
||||
#define M2_HALL_B_MASK ~(1<<1)
|
||||
#define M2_HALL_B_LSR M2_HALL_B_PIN - M2_HALL_B_GROUP*32 -1
|
||||
#define M2_HALL_B_GROUP M2_HALL_B_PIN/32
|
||||
|
||||
#define M2_HALL_C_PIN GPIO(GPIO_PORTA, 6)
|
||||
#define M2_HALL_C_PORT PORT_PA06
|
||||
#define M2_HALL_C_MASK ~(1<<2)
|
||||
#define M2_HALL_C_LSR M2_HALL_C_PIN - M2_HALL_C_GROUP*32 -2
|
||||
#define M2_HALL_C_GROUP M2_HALL_C_PIN/32
|
||||
|
||||
|
||||
static inline uint8_t readM1Hall(void)
|
||||
{
|
||||
|
|
|
@ -0,0 +1,120 @@
|
|||
/*
|
||||
* motorparameters.h
|
||||
*
|
||||
* Created: 04/08/2021 21:23:43
|
||||
* Author: Nick-XMG
|
||||
*/
|
||||
|
||||
|
||||
#ifndef MOTORPARAMETERS_H_
|
||||
#define MOTORPARAMETERS_H_
|
||||
#include "atmel_start.h"
|
||||
|
||||
|
||||
// ----------------------------------------------------------------------
|
||||
// M1 Hall Parameters
|
||||
// ----------------------------------------------------------------------
|
||||
|
||||
#define M1_HALL_A_PIN GPIO(GPIO_PORTA, 22)
|
||||
#define M1_HALL_A_PORT PORT_PA22
|
||||
#define M1_HALL_A_MASK ~(1<<0)
|
||||
#define M1_HALL_A_LSR M1_HALL_A_PIN - M1_HALL_A_GROUP*32 -0
|
||||
#define M1_HALL_A_GROUP M1_HALL_A_PIN/32
|
||||
|
||||
#define M1_HALL_B_PIN GPIO(GPIO_PORTA, 23)
|
||||
#define M1_HALL_B_PORT PORT_PA23
|
||||
#define M1_HALL_B_MASK ~(1<<1)
|
||||
#define M1_HALL_B_LSR M1_HALL_B_PIN - M1_HALL_B_GROUP*32 -1
|
||||
#define M1_HALL_B_GROUP M1_HALL_B_PIN/32
|
||||
|
||||
#define M1_HALL_C_PIN GPIO(GPIO_PORTA, 24)
|
||||
#define M1_HALL_C_PORT PORT_PA24
|
||||
#define M1_HALL_C_MASK ~(1<<2)
|
||||
#define M1_HALL_C_LSR M1_HALL_C_PIN - M1_HALL_C_GROUP*32 -2
|
||||
#define M1_HALL_C_GROUP M1_HALL_C_PIN/32
|
||||
|
||||
// ----------------------------------------------------------------------
|
||||
// M2 Hall Parameters
|
||||
// ----------------------------------------------------------------------
|
||||
|
||||
#define M2_HALL_A_PIN GPIO(GPIO_PORTA, 4)
|
||||
#define M2_HALL_A_PORT PORT_PA04
|
||||
#define M2_HALL_A_MASK ~(1<<0)
|
||||
#define M2_HALL_A_LSR M2_HALL_A_PIN - M2_HALL_A_GROUP*32 -0
|
||||
#define M2_HALL_A_GROUP M2_HALL_A_PIN/32
|
||||
|
||||
#define M2_HALL_B_PIN GPIO(GPIO_PORTA, 5)
|
||||
#define M2_HALL_B_PORT PORT_PA05
|
||||
#define M2_HALL_B_MASK ~(1<<1)
|
||||
#define M2_HALL_B_LSR M2_HALL_B_PIN - M2_HALL_B_GROUP*32 -1
|
||||
#define M2_HALL_B_GROUP M2_HALL_B_PIN/32
|
||||
|
||||
#define M2_HALL_C_PIN GPIO(GPIO_PORTA, 6)
|
||||
#define M2_HALL_C_PORT PORT_PA06
|
||||
#define M2_HALL_C_MASK ~(1<<2)
|
||||
#define M2_HALL_C_LSR M2_HALL_C_PIN - M2_HALL_C_GROUP*32 -2
|
||||
#define M2_HALL_C_GROUP M2_HALL_C_PIN/32
|
||||
|
||||
// ----------------------------------------------------------------------
|
||||
// Motor Physical Parameters
|
||||
// ----------------------------------------------------------------------
|
||||
|
||||
const typedef struct
|
||||
{
|
||||
const uint16_t Poles;
|
||||
const uint16_t polePairs;
|
||||
const uint16_t commutationStates;
|
||||
const float32_t motor_RS_Ohm;
|
||||
const float32_t motor_LD_H;
|
||||
const float32_t motor_Flux_WB;
|
||||
const float32_t motor_Max_Spd_RPM;
|
||||
const float32_t motor_Max_Spd_ELEC;
|
||||
const float32_t motor_MeasureRange_RPM; // give 20% headroom
|
||||
const float32_t motor_Max_Current_IDC_A;
|
||||
} BLDCMotor_param_t;
|
||||
|
||||
const BLDCMotor_param_t FH_32mm24BXTR = {
|
||||
.Poles = 14,
|
||||
.polePairs = 7,
|
||||
.commutationStates = 42, //polePairs * 6
|
||||
|
||||
};
|
||||
const BLDCMotor_param_t FH_22mm24BXTR;
|
||||
|
||||
|
||||
|
||||
/* ----------------------------------------------------------------------
|
||||
// Commutation Patterns
|
||||
// ----------------------------------------------------------------------
|
||||
/**
|
||||
** ____|___TCC0_____OTMX ||____TCC1____ OTMX|
|
||||
** W0 | M1_0 | CC0 || M2_0 | CC0 |
|
||||
** W1 | M1_0 | CC0 || M2_0 | CC0 |
|
||||
** W2 | M1_0 | CC0 || M2_0 | CC0 |
|
||||
** W3 | M1_0 | CC0 || M2_0 | CC0 |
|
||||
** W4 | M1_0 | CC0 || M2_0 | CC0 |
|
||||
** W5 | M1_0 | CC0 || M2_0 | CC0 |
|
||||
** W6 | M1_0 | CC0 || M2_0 | CC0 |
|
||||
** W7 | M1_0 | CC0 || M2_0 | CC0 |
|
||||
*/
|
||||
|
||||
static const uint16_t COMMUTATION_PATTERN[] = {
|
||||
0x00FF, // (0) invalid state
|
||||
0x30F8, // (1)
|
||||
0x50F5, // (2)
|
||||
0x60F8, // (3)
|
||||
0x607D, // (4)
|
||||
0x507D, // (5)
|
||||
0x30F5, // (6)
|
||||
0x00FF, // (7) invalid state
|
||||
0x00FF, // (8) invalid state
|
||||
0x30F5, // (9)
|
||||
0x507D, // (10)
|
||||
0x607D, // (11)
|
||||
0x60F8, // (12)
|
||||
0x50F5, // (13)
|
||||
0x30F8, // (14)
|
||||
0x00FF // (15) invalid state
|
||||
};
|
||||
|
||||
#endif /* MOTORPARAMETERS_H_ */
|
Loading…
Reference in New Issue