мёртвое время, скорость уарт, коэфф. рег-ра
This commit is contained in:
parent
431030cd38
commit
3a9f6896ea
@ -10,7 +10,7 @@
|
|||||||
<rts value="libc.a"/>
|
<rts value="libc.a"/>
|
||||||
<createSlaveProjects value=""/>
|
<createSlaveProjects value=""/>
|
||||||
<templateProperties value="id=epwm_ex4_deadband.projectspec.epwm_ex4_deadband"/>
|
<templateProperties value="id=epwm_ex4_deadband.projectspec.epwm_ex4_deadband"/>
|
||||||
<origin value="C:\ti\c2000\C2000Ware_4_03_00_00\device_support\f2838x\examples\cpu1\epwm\CCS\epwm_ex4_deadband.projectspec"/>
|
<origin value="F:/_Motor_CPU2/Projects/epwm_test_biss_c_cpu2"/>
|
||||||
<filesToOpen value=""/>
|
<filesToOpen value=""/>
|
||||||
<connection value="common/targetdb/connections/TIXDS100v2_Connection.xml"/>
|
<connection value="common/targetdb/connections/TIXDS100v2_Connection.xml"/>
|
||||||
<isTargetManual value="false"/>
|
<isTargetManual value="false"/>
|
||||||
|
|||||||
Binary file not shown.
@ -14,7 +14,7 @@
|
|||||||
|
|
||||||
#define FREQUENCY_BRAKE 200000.0 //Hz
|
#define FREQUENCY_BRAKE 200000.0 //Hz
|
||||||
#define FREQUENCY_MOTOR 10000.0 //Hz
|
#define FREQUENCY_MOTOR 10000.0 //Hz
|
||||||
#define EPWM_DB_mkS 3.0 //mkS
|
#define EPWM_DB_mkS 4.0 //mkS
|
||||||
#define FREQUENCY_FAN 1000.0 //Hz
|
#define FREQUENCY_FAN 1000.0 //Hz
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@ -9,7 +9,7 @@
|
|||||||
#include "frm_uart.h"
|
#include "frm_uart.h"
|
||||||
|
|
||||||
#define LSPCLK_HZ 50000000.0
|
#define LSPCLK_HZ 50000000.0
|
||||||
#define BAUD 19200.0
|
#define BAUD 57600.0
|
||||||
#define BRR LSPCLK_HZ/(BAUD*8) + 1
|
#define BRR LSPCLK_HZ/(BAUD*8) + 1
|
||||||
|
|
||||||
uint16_t frmEn = 0;
|
uint16_t frmEn = 0;
|
||||||
|
|||||||
@ -22,27 +22,24 @@ void frmmstr_run(void)
|
|||||||
{
|
{
|
||||||
static uint16_t diod = 0;
|
static uint16_t diod = 0;
|
||||||
|
|
||||||
if(SciaRegs.SCIRXST.bit.RXERROR)
|
// if(SciaRegs.SCIRXST.bit.RXERROR)
|
||||||
{
|
// {
|
||||||
EALLOW;
|
// EALLOW;
|
||||||
SciaRegs.SCICTL1.bit.SWRESET = 0;
|
// SciaRegs.SCICTL1.bit.SWRESET = 0;
|
||||||
EDIS;
|
// EDIS;
|
||||||
}
|
// }
|
||||||
else
|
// else
|
||||||
{
|
// {
|
||||||
EALLOW;
|
// EALLOW;
|
||||||
SciaRegs.SCICTL1.bit.SWRESET = 1;
|
// SciaRegs.SCICTL1.bit.SWRESET = 1;
|
||||||
EDIS;
|
// EDIS;
|
||||||
}
|
// }
|
||||||
Gpio95out(Rele);
|
|
||||||
|
|
||||||
if(fault_read_check())
|
if(FMSTRIsEnable())
|
||||||
{
|
{
|
||||||
fault_read_clr();
|
FMSTR_Poll();
|
||||||
fault_read_ports();
|
FMSTR_Recorder();
|
||||||
}
|
FMSTREnableClr();
|
||||||
|
|
||||||
if(FMSTRIsEnable()) {
|
|
||||||
if(counter < 100) counter++;
|
if(counter < 100) counter++;
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@ -55,12 +52,20 @@ static uint16_t diod = 0;
|
|||||||
diod++;
|
diod++;
|
||||||
if(diod > 7) diod = 0;
|
if(diod > 7) diod = 0;
|
||||||
Gpio_rainbow(diod);
|
Gpio_rainbow(diod);
|
||||||
if(testMode) FMSTR_SCI_PUTCHAR(0xA5);
|
//if(testMode) FMSTR_SCI_PUTCHAR(0xA5);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
FMSTR_Poll();
|
|
||||||
FMSTR_Recorder();
|
|
||||||
FMSTREnableClr();
|
|
||||||
// EPwm3Regs.CMPA.bit.CMPA = PWM_Vent1;
|
// EPwm3Regs.CMPA.bit.CMPA = PWM_Vent1;
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
Gpio95out(Rele);
|
||||||
|
if(fault_read_check())
|
||||||
|
{
|
||||||
|
fault_read_clr();
|
||||||
|
fault_read_ports();
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -1,7 +1,7 @@
|
|||||||
/*
|
/*
|
||||||
* vector.c
|
* vector.c
|
||||||
*
|
*
|
||||||
* Created on: 20 сент. 2023 г.
|
* Created on: 20 сент. 2023 г.
|
||||||
* Author: seklyuts
|
* Author: seklyuts
|
||||||
*/
|
*/
|
||||||
|
|
||||||
@ -20,13 +20,13 @@
|
|||||||
#include "biss.h"
|
#include "biss.h"
|
||||||
#include "temperature.h"
|
#include "temperature.h"
|
||||||
|
|
||||||
#define IMAX_A 25.0 //A
|
#define IMAX_A 35.0 //A
|
||||||
#define IMAX (IMAX_A*BIT_MAX/FACTOR_CURRENT_MOTOR_A)
|
#define IMAX (IMAX_A*BIT_MAX/FACTOR_CURRENT_MOTOR_A)
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
int16_t Value16in; // Нефильрованное значение
|
int16_t Value16in; // Нефильрованное значение
|
||||||
int16_t Value16filtered; // Фильрованное значение
|
int16_t Value16filtered; // Фильрованное значение
|
||||||
int32_t Value32; // Конечное напряжение тренировки
|
int32_t Value32; // Конечное напряжение тренировки
|
||||||
int16_t ShiftFilter; // Filters
|
int16_t ShiftFilter; // Filters
|
||||||
} Filtered;
|
} Filtered;
|
||||||
|
|
||||||
@ -98,7 +98,7 @@ void vectorControl(int16_t CurrentA, int16_t CurrentB, int16_t CurrentC, int16_t
|
|||||||
Ib = -CurrentB;//sdfm_get(3);
|
Ib = -CurrentB;//sdfm_get(3);
|
||||||
Ic = -CurrentC;//sdfm_get(4);
|
Ic = -CurrentC;//sdfm_get(4);
|
||||||
if((Ia > IMAX)||(Ib>IMAX)||(Ic>IMAX)||(Ia<-IMAX)||(Ib<-IMAX)||(Ic<-IMAX) ) {OverCur[0] = Ia; OverCur[1] = Ib; OverCur[2] = Ic; ErrCur++; if(ErrCur >= 3) {Mode = OffMode; CurFault++;}}
|
if((Ia > IMAX)||(Ib>IMAX)||(Ic>IMAX)||(Ia<-IMAX)||(Ib<-IMAX)||(Ic<-IMAX) ) {OverCur[0] = Ia; OverCur[1] = Ib; OverCur[2] = Ic; ErrCur++; if(ErrCur >= 3) {Mode = OffMode; CurFault++;}}
|
||||||
else ErrCur = 0;
|
// else ErrCur = 0;
|
||||||
|
|
||||||
UdcFiltered = Filter(sdfmUdc, &UdcFilter);
|
UdcFiltered = Filter(sdfmUdc, &UdcFilter);
|
||||||
if(UdcFiltered < 0) UdcFiltered = 0;
|
if(UdcFiltered < 0) UdcFiltered = 0;
|
||||||
@ -151,7 +151,7 @@ void vectorInitCurrLoop(void)
|
|||||||
|
|
||||||
CurrLoop.piId.Ref = 0; // Input: reference set-point
|
CurrLoop.piId.Ref = 0; // Input: reference set-point
|
||||||
CurrLoop.piId.Fbk = 0; // Input: feedback
|
CurrLoop.piId.Fbk = 0; // Input: feedback
|
||||||
CurrLoop.piId.uCorr = 0; // Input: Коррекция выхода, для устранения перекретных связей
|
CurrLoop.piId.uCorr = 0; // Input: Коррекция выхода, для устранения перекретных связей
|
||||||
CurrLoop.piId.Out = 0; // Output: controller output
|
CurrLoop.piId.Out = 0; // Output: controller output
|
||||||
CurrLoop.piId.Kp = PI_REG_I_PROPOR; // Parameter: proportional loop gain
|
CurrLoop.piId.Kp = PI_REG_I_PROPOR; // Parameter: proportional loop gain
|
||||||
CurrLoop.piId.Ki = PI_REG_I_INTEGR; // Parameter: integral gain
|
CurrLoop.piId.Ki = PI_REG_I_INTEGR; // Parameter: integral gain
|
||||||
@ -165,7 +165,7 @@ void vectorInitCurrLoop(void)
|
|||||||
|
|
||||||
CurrLoop.piIq.Ref = 0; // Input: reference set-point
|
CurrLoop.piIq.Ref = 0; // Input: reference set-point
|
||||||
CurrLoop.piIq.Fbk = 0; // Input: feedback
|
CurrLoop.piIq.Fbk = 0; // Input: feedback
|
||||||
CurrLoop.piIq.uCorr = 0; // Input: Коррекция выхода, для устранения перекретных связей
|
CurrLoop.piIq.uCorr = 0; // Input: Коррекция выхода, для устранения перекретных связей
|
||||||
CurrLoop.piIq.Out = 0; // Output: controller output
|
CurrLoop.piIq.Out = 0; // Output: controller output
|
||||||
CurrLoop.piIq.Kp = PI_REG_I_PROPOR; // Parameter: proportional loop gain
|
CurrLoop.piIq.Kp = PI_REG_I_PROPOR; // Parameter: proportional loop gain
|
||||||
CurrLoop.piIq.Ki = PI_REG_I_INTEGR; // Parameter: integral gain
|
CurrLoop.piIq.Ki = PI_REG_I_INTEGR; // Parameter: integral gain
|
||||||
@ -180,13 +180,13 @@ void vectorInitCurrLoop(void)
|
|||||||
void vectorResCurrLoop(void)
|
void vectorResCurrLoop(void)
|
||||||
{
|
{
|
||||||
CurrLoop.piId.Ref = 0; // Input: reference set-point
|
CurrLoop.piId.Ref = 0; // Input: reference set-point
|
||||||
CurrLoop.piId.uCorr = 0; // Input: Коррекция выхода, для устранения перекретных связей
|
CurrLoop.piId.uCorr = 0; // Input: Коррекция выхода, для устранения перекретных связей
|
||||||
CurrLoop.piId.Out = 0; // Output: controller output
|
CurrLoop.piId.Out = 0; // Output: controller output
|
||||||
CurrLoop.piId.v1 = 0; // Data: pre-saturated controller output
|
CurrLoop.piId.v1 = 0; // Data: pre-saturated controller output
|
||||||
CurrLoop.piId.i1 = 0; // Data: integrator storage: ui(k-1)
|
CurrLoop.piId.i1 = 0; // Data: integrator storage: ui(k-1)
|
||||||
|
|
||||||
CurrLoop.piIq.Ref = 0; // Input: reference set-point
|
CurrLoop.piIq.Ref = 0; // Input: reference set-point
|
||||||
CurrLoop.piIq.uCorr = 0; // Input: Коррекция выхода, для устранения перекретных связей
|
CurrLoop.piIq.uCorr = 0; // Input: Коррекция выхода, для устранения перекретных связей
|
||||||
CurrLoop.piIq.Out = 0; // Output: controller output
|
CurrLoop.piIq.Out = 0; // Output: controller output
|
||||||
CurrLoop.piIq.v1 = 0; // Data: pre-saturated controller output
|
CurrLoop.piIq.v1 = 0; // Data: pre-saturated controller output
|
||||||
CurrLoop.piIq.i1 = 0; // Data: integrator storage: ui(k-1)
|
CurrLoop.piIq.i1 = 0; // Data: integrator storage: ui(k-1)
|
||||||
@ -256,14 +256,14 @@ void vector_klark_park(uint16_t SectorOn, int16_t CurrentA, int16_t CurrentB, in
|
|||||||
|
|
||||||
/* if (Inputs->UpdateUdc)
|
/* if (Inputs->UpdateUdc)
|
||||||
{
|
{
|
||||||
//Запоминаем Udc для контура тока(ограничение Umax и Umin в ПИ-регуляторе)
|
//Запоминаем Udc для контура тока(ограничение Umax Рё Umin РІ РџР<D19F>-регуляторе)
|
||||||
Outputs->Udc = PmsmVect.UdcFilter.Output;
|
Outputs->Udc = PmsmVect.UdcFilter.Output;
|
||||||
//Защита от деления на 0 и отрицательных чисел
|
//Защита от деления на 0 и отрицательных чисел
|
||||||
if (Outputs->Udc <= 0.0f)
|
if (Outputs->Udc <= 0.0f)
|
||||||
Outputs->Udc = VOLTAGE_UDC;
|
Outputs->Udc = VOLTAGE_UDC;
|
||||||
//Расчет коэффициента для расчета скважности ШИМ(один раз делим, потом каждый цикл ШИМ умножаем, это эффективнее)
|
//Расчет коэффициента для расчета скважности РЁР<D081>Рњ(РѕРґРёРЅ раз делим, потом каждый цикл РЁР<D081>Рњ умножаем, это эффективнее)
|
||||||
PmsmVect.UdcPwmFactor = 1.0f/Outputs->Udc;
|
PmsmVect.UdcPwmFactor = 1.0f/Outputs->Udc;
|
||||||
//Сброс флага
|
//Сброс флага
|
||||||
Inputs->UpdateUdc = false;
|
Inputs->UpdateUdc = false;
|
||||||
}*/
|
}*/
|
||||||
|
|
||||||
@ -298,7 +298,7 @@ void vector_klark_park(uint16_t SectorOn, int16_t CurrentA, int16_t CurrentB, in
|
|||||||
vectorIabc.c = (float)CurrentC * FactorCurrent;
|
vectorIabc.c = (float)CurrentC * FactorCurrent;
|
||||||
}
|
}
|
||||||
|
|
||||||
// преобразование Кларк
|
// преобразование Кларк
|
||||||
|
|
||||||
vectorI2ph.Alfa = vectorIabc.a;
|
vectorI2ph.Alfa = vectorIabc.a;
|
||||||
vectorI2ph.Beta = _IQmpy((vectorIabc.a +_IQmpy2(vectorIabc.b)),_IQ(ONEbySQRT3)); //vectorI2ph.Beta = _IQmpy((vectorIabc.b - vectorIabc.c),_IQ(ONEbySQRT3));
|
vectorI2ph.Beta = _IQmpy((vectorIabc.a +_IQmpy2(vectorIabc.b)),_IQ(ONEbySQRT3)); //vectorI2ph.Beta = _IQmpy((vectorIabc.b - vectorIabc.c),_IQ(ONEbySQRT3));
|
||||||
@ -309,7 +309,7 @@ void vector_klark_park(uint16_t SectorOn, int16_t CurrentA, int16_t CurrentB, in
|
|||||||
vectorSinCos.sin = ((float)sin_int)/32768.0;
|
vectorSinCos.sin = ((float)sin_int)/32768.0;
|
||||||
vectorSinCos.cos = ((float)cos_int)/32768.0;
|
vectorSinCos.cos = ((float)cos_int)/32768.0;
|
||||||
|
|
||||||
// преобразование Парка
|
// преобразование Парка
|
||||||
vectorIdq.d = _IQmpy(vectorI2ph.Alfa,vectorSinCos.cos) + _IQmpy(vectorI2ph.Beta,vectorSinCos.sin);
|
vectorIdq.d = _IQmpy(vectorI2ph.Alfa,vectorSinCos.cos) + _IQmpy(vectorI2ph.Beta,vectorSinCos.sin);
|
||||||
vectorIdq.q = _IQmpy(vectorI2ph.Beta,vectorSinCos.cos) - _IQmpy(vectorI2ph.Alfa,vectorSinCos.sin);
|
vectorIdq.q = _IQmpy(vectorI2ph.Beta,vectorSinCos.cos) - _IQmpy(vectorI2ph.Alfa,vectorSinCos.sin);
|
||||||
|
|
||||||
@ -318,7 +318,7 @@ void vector_klark_park(uint16_t SectorOn, int16_t CurrentA, int16_t CurrentB, in
|
|||||||
// AngleErr = Angle_test - vectorSinCos.Angle;
|
// AngleErr = Angle_test - vectorSinCos.Angle;
|
||||||
|
|
||||||
|
|
||||||
// CurrLoop.piIq.Ref = Inputs->IqRef;//Заданное
|
// CurrLoop.piIq.Ref = Inputs->IqRef;//Заданное
|
||||||
|
|
||||||
if (FABS(CurrLoop.piIq.Ref) > CurrLoop.CurrentLimit)
|
if (FABS(CurrLoop.piIq.Ref) > CurrLoop.CurrentLimit)
|
||||||
{
|
{
|
||||||
@ -334,7 +334,7 @@ void vector_klark_park(uint16_t SectorOn, int16_t CurrentA, int16_t CurrentB, in
|
|||||||
// CurrLoop.piId.Umax = CurrLoop.piIq.Umax = Inputs->Udc;
|
// CurrLoop.piId.Umax = CurrLoop.piIq.Umax = Inputs->Udc;
|
||||||
// CurrLoop.piId.Umin = CurrLoop.piIq.Umin = -CurrLoop.piIq.Umax;
|
// CurrLoop.piId.Umin = CurrLoop.piIq.Umin = -CurrLoop.piIq.Umax;
|
||||||
#ifdef UCORR_ENABLE
|
#ifdef UCORR_ENABLE
|
||||||
//Перекрестные связи
|
//Перекрестные связи
|
||||||
float Velectr = VFbk * CurrLoop.VelElectrFactor;
|
float Velectr = VFbk * CurrLoop.VelElectrFactor;
|
||||||
CurrLoop.piId.uCorr = Velectr * CurrLoop.PhaseInduct * CurrLoop.piIq.Fbk;
|
CurrLoop.piId.uCorr = Velectr * CurrLoop.PhaseInduct * CurrLoop.piIq.Fbk;
|
||||||
CurrLoop.piIq.uCorr = -Velectr * (CurrLoop.FluxLinkage + CurrLoop.PhaseInduct * CurrLoop.piId.Fbk);
|
CurrLoop.piIq.uCorr = -Velectr * (CurrLoop.FluxLinkage + CurrLoop.PhaseInduct * CurrLoop.piId.Fbk);
|
||||||
@ -354,7 +354,7 @@ void vector_klark_park(uint16_t SectorOn, int16_t CurrentA, int16_t CurrentB, in
|
|||||||
PI_MACRO(CurrLoop.piIq);
|
PI_MACRO(CurrLoop.piIq);
|
||||||
PI_MACRO(CurrLoop.piId);
|
PI_MACRO(CurrLoop.piId);
|
||||||
|
|
||||||
/*Пропорциональное ограничение напряжений Uq и Ud*/
|
/*Пропорциональное ограничение напряжений Uq и Ud*/
|
||||||
// Test1 = my_sqrtf(Test2);
|
// Test1 = my_sqrtf(Test2);
|
||||||
|
|
||||||
|
|
||||||
@ -362,7 +362,7 @@ void vector_klark_park(uint16_t SectorOn, int16_t CurrentA, int16_t CurrentB, in
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
if (Ulim > UmaxVolt)// максимальное напряжение в вольтах
|
if (Ulim > UmaxVolt)// максимальное напряжение в вольтах
|
||||||
{
|
{
|
||||||
if(Ulim > ZERO_LVL)
|
if(Ulim > ZERO_LVL)
|
||||||
{
|
{
|
||||||
@ -408,7 +408,7 @@ float my_sqrtf(float x)
|
|||||||
return x * x0;
|
return x * x0;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Фильтр сигнала
|
// Фильтр сигнала
|
||||||
int16_t Filter(int16_t inValue, Filtered *Struct) {
|
int16_t Filter(int16_t inValue, Filtered *Struct) {
|
||||||
(*Struct).Value16in = inValue;
|
(*Struct).Value16in = inValue;
|
||||||
(*Struct).Value32+=(int32_t)((*Struct).Value16in)-(int32_t)((*Struct).Value16filtered);
|
(*Struct).Value32+=(int32_t)((*Struct).Value16in)-(int32_t)((*Struct).Value16filtered);
|
||||||
|
|||||||
@ -1,7 +1,7 @@
|
|||||||
/*
|
/*
|
||||||
* vector.h
|
* vector.h
|
||||||
*
|
*
|
||||||
* Created on: 20 ńĺíň. 2023 ă.
|
* Created on: 20 <EFBFBD><EFBFBD><EFBFBD><EFBFBD>. 2023 <EFBFBD>.
|
||||||
* Author: seklyuts
|
* Author: seklyuts
|
||||||
*/
|
*/
|
||||||
|
|
||||||
@ -35,8 +35,8 @@
|
|||||||
|
|
||||||
#define VOLT_MAX_PROC 94.0
|
#define VOLT_MAX_PROC 94.0
|
||||||
#define VOLT_MAX_FACTOR VOLT_MAX_PROC/100.0
|
#define VOLT_MAX_FACTOR VOLT_MAX_PROC/100.0
|
||||||
#define PI_REG_I_PROPOR 30.0
|
#define PI_REG_I_PROPOR 17.0 // 30
|
||||||
#define PI_REG_I_INTEGR 0.04
|
#define PI_REG_I_INTEGR 0.02 // 0.04
|
||||||
#define CURRENT_MAX 40.0 //A
|
#define CURRENT_MAX 40.0 //A
|
||||||
#define ZERO_LVL 0.00001f
|
#define ZERO_LVL 0.00001f
|
||||||
|
|
||||||
@ -76,7 +76,7 @@ typedef struct
|
|||||||
|
|
||||||
typedef enum
|
typedef enum
|
||||||
{
|
{
|
||||||
OffMode, //Ěîňîđ îńňŕíîâëĺí
|
OffMode, //<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||||
StepMode, //
|
StepMode, //
|
||||||
StayMode,
|
StayMode,
|
||||||
CurrentRegTune,
|
CurrentRegTune,
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user