Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added 2FOC V3.5 application. #91

Closed
wants to merge 8 commits into from
11 changes: 11 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
# Build products
**/build*/
**/debug/
**/dist/

# System hidden files
.DS_Store

# Linux temp files
*~

Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,11 @@ typedef union
unsigned has_hall:1;
unsigned has_tsens:1;
unsigned has_index:1;

unsigned has_speed_qe:1;
unsigned verbose:1;
unsigned unused:1;
unsigned configured:1;
};

unsigned int bitmask;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,18 +10,21 @@
#include "MeasCurr.h"

// number of samples taken to calculate zero calibration
#define ADC_CAL_N_SAMPLES 200
#define ADC_CAL_N_SAMPLES 1024

// Timeout for polling loops during zero calibration
#define ADC_CAL_TIMEOUT 1000

extern SFRAC16 ADCBuffer[4];

extern volatile tMeasCurrParm MeasCurrParm;

int ADCGetVDCLink();
// read dclink voltage in [100mV] units
unsigned int ADCVDCLinkTo100mV(int vdc);
// pewrform offset calibration
void ADCDoOffsetCalibration();
void ADCDoGainCalibration();
// setup ADC for PWM sync and DMA
void ADCConfigPWMandDMAMode();
void ADCInterruptAndDMAEnable();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@

extern void DHESInit();
extern unsigned char DHESRead();
extern char DHESSector();
extern long DHESPosition();
extern int DHESVelocity();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,10 +41,10 @@ typedef struct {
SFRAC16 Offseta;

SFRAC16 qKb; // Q15
SFRAC16 Offsetbc;
SFRAC16 Offsetc;

SFRAC16 qKc; // Q15
} tMeasCurrParm;
} tMeasCurrParm;

void MeasAndCompIaIcCalculateIb();
void MeasAndCompIaIb();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,13 @@

//#define UDEF_CURRENT_MAX 4000 // 4 A
#define UDEF_SPEED_MAX 32767
#ifndef RELENTLESS
#define UDEF_PWM_MAX 25600 // 800*32 = 80%
#else
#define UDEF_PWM_MAX 25600 // 800*32 = 80%
#endif

#define HALL_ERROR_MAX_CNT 1000

//
// Quadrature (incremental) Encoders parameters
Expand Down Expand Up @@ -122,7 +128,7 @@
#define CAN_CMD_ALWAYS_ACCEPT

// Oscillator Parameters
#define PLLIN 10000000 // External Crystal or Clock Frequency (Hz)
#define PLLIN 10000000 // External Crystal or Clock Frequency (Hz)
#define DESIREDMIPS 40000000 // Enter desired MIPS

// number of elements in the list of possible contents of periodic message
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,8 @@

/************ FIRMWARE AND CAN PROTOCOL VERSION DEFINITION *******************************************/
#define FW_VERSION_MAJOR 3
#define FW_VERSION_MINOR 3
#define FW_VERSION_BUILD 3
#define FW_VERSION_MINOR 5
#define FW_VERSION_BUILD 0

#define CAN_PROTOCOL_VERSION_MAJOR 1
#define CAN_PROTOCOL_VERSION_MINOR 6
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ typedef struct {
//void ClarkePark(void); // Calculate qId,qIq from qCos,qSin,qIa,qIb
//void InvPark(void); // Calculate qValpha, qVbeta from qSin,qCos,qVd,qVq

extern tParkParm ParkParm;
extern volatile tParkParm ParkParm;
#endif


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,11 +37,16 @@ extern volatile BOOL qe_ready;
extern volatile int QE_RESOLUTION;
#define QEready() qe_ready

// MECAPION
//#define QEgetRaw() (POSCNT<<5)
//#define QEgetElettrDeg() ((int)(__builtin_muluu(POSCNT,360)>>11))

extern void QEinit(int qe_resolution,int motor_num_poles,char use_index);
extern unsigned int QEgetRaw();
extern int QEcountError();
extern void QEcountErrorClear();
extern int QEgetElettrDeg();
extern int QEgetPos();
extern void QEsignalZeroCrossing(int UPDN);

#endif
Loading