опрос внешнего порта по фолтам перенёс обратно в фон, так как нужно выйти из прерывания чтоб работали прерывания таймера для таймаута
убрал компенсацию дедтайма, так как она приводит к ошибке при больших шим, а при попытке компенсации ошибок получается слишком ресурсозатратно, по времени не вмещаемся
This commit is contained in:
parent
967dd048ee
commit
9349803bf8
@ -61,7 +61,7 @@
|
|||||||
</option>
|
</option>
|
||||||
<option IS_BUILTIN_EMPTY="false" IS_VALUE_EMPTY="false" id="com.ti.ccstudio.buildDefinitions.C2000_22.6.compilerID.DEFINE.2084039298" name="Pre-define NAME (--define, -D)" superClass="com.ti.ccstudio.buildDefinitions.C2000_22.6.compilerID.DEFINE" valueType="definedSymbols">
|
<option IS_BUILTIN_EMPTY="false" IS_VALUE_EMPTY="false" id="com.ti.ccstudio.buildDefinitions.C2000_22.6.compilerID.DEFINE.2084039298" name="Pre-define NAME (--define, -D)" superClass="com.ti.ccstudio.buildDefinitions.C2000_22.6.compilerID.DEFINE" valueType="definedSymbols">
|
||||||
<listOptionValue builtIn="false" value="${COM_TI_C2000WARE_SOFTWARE_PACKAGE_SYMBOLS}"/>
|
<listOptionValue builtIn="false" value="${COM_TI_C2000WARE_SOFTWARE_PACKAGE_SYMBOLS}"/>
|
||||||
<listOptionValue builtIn="false" value="REF1"/>
|
<listOptionValue builtIn="false" value="REF0"/>
|
||||||
<listOptionValue builtIn="false" value="NRS485"/>
|
<listOptionValue builtIn="false" value="NRS485"/>
|
||||||
<listOptionValue builtIn="false" value="USE_25MHZ_XTAL"/>
|
<listOptionValue builtIn="false" value="USE_25MHZ_XTAL"/>
|
||||||
<listOptionValue builtIn="false" value="DEBUG"/>
|
<listOptionValue builtIn="false" value="DEBUG"/>
|
||||||
|
|||||||
@ -85,6 +85,15 @@ void GpioInit(void)
|
|||||||
GpioCtrlRegs.GPCDIR.bit.GPIO95 = 1;
|
GpioCtrlRegs.GPCDIR.bit.GPIO95 = 1;
|
||||||
GpioDataRegs.GPCDAT.bit.GPIO95 = 1;
|
GpioDataRegs.GPCDAT.bit.GPIO95 = 1;
|
||||||
GpioCtrlRegs.GPCCSEL4.bit.GPIO95 = 2;
|
GpioCtrlRegs.GPCCSEL4.bit.GPIO95 = 2;
|
||||||
|
#else
|
||||||
|
GpioCtrlRegs.GPIO_Bttonclik_MUX.bit.GPIO_Bttonclik = 0;//Buttons Clik
|
||||||
|
GpioCtrlRegs.GPIO_Bttonclik_GMUX.bit.GPIO_Bttonclik = 0;
|
||||||
|
GpioCtrlRegs.GPIO_Bttonclik_DIR.bit.GPIO_Bttonclik = 0;
|
||||||
|
GpioDataRegs.GPIO_Bttonclik_DAT.bit.GPIO_Bttonclik = 0;
|
||||||
|
GpioCtrlRegs.GPIO_Bttonclik_SEL.bit.GPIO_Bttonclik = 2;
|
||||||
|
|
||||||
|
InputXbarRegs.INPUT6SELECT = GPIO_Bttonclikpin;//xint3
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
GpioCtrlRegs.GPIO_FaultPWM_MUX.bit.GPIO_FaultPWM = 0;//FaultPWM
|
GpioCtrlRegs.GPIO_FaultPWM_MUX.bit.GPIO_FaultPWM = 0;//FaultPWM
|
||||||
GpioCtrlRegs.GPIO_FaultPWM_GMUX.bit.GPIO_FaultPWM = 0;
|
GpioCtrlRegs.GPIO_FaultPWM_GMUX.bit.GPIO_FaultPWM = 0;
|
||||||
@ -94,13 +103,7 @@ void GpioInit(void)
|
|||||||
|
|
||||||
InputXbarRegs.INPUT4SELECT = GPIO_FaultPWMpin;//xint1
|
InputXbarRegs.INPUT4SELECT = GPIO_FaultPWMpin;//xint1
|
||||||
|
|
||||||
GpioCtrlRegs.GPIO_Bttonclik_MUX.bit.GPIO_Bttonclik = 0;//Buttons Clik
|
|
||||||
GpioCtrlRegs.GPIO_Bttonclik_GMUX.bit.GPIO_Bttonclik = 0;
|
|
||||||
GpioCtrlRegs.GPIO_Bttonclik_DIR.bit.GPIO_Bttonclik = 0;
|
|
||||||
GpioDataRegs.GPIO_Bttonclik_DAT.bit.GPIO_Bttonclik = 0;
|
|
||||||
GpioCtrlRegs.GPIO_Bttonclik_SEL.bit.GPIO_Bttonclik = 2;
|
|
||||||
|
|
||||||
InputXbarRegs.INPUT6SELECT = GPIO_Bttonclikpin;//xint3
|
|
||||||
|
|
||||||
|
|
||||||
GpioCtrlRegs.GPAMUX2.bit.GPIO20 = 1;//EQEP
|
GpioCtrlRegs.GPAMUX2.bit.GPIO20 = 1;//EQEP
|
||||||
|
|||||||
@ -16,6 +16,7 @@
|
|||||||
#define GPIO_FaultPWM_DAT GPCDAT
|
#define GPIO_FaultPWM_DAT GPCDAT
|
||||||
#define GPIO_FaultPWM_GMUX GPCGMUX1
|
#define GPIO_FaultPWM_GMUX GPCGMUX1
|
||||||
#define GPIO_FaultPWM_MUX GPCMUX1
|
#define GPIO_FaultPWM_MUX GPCMUX1
|
||||||
|
#define GPIO_FaultPWMpin 64
|
||||||
|
|
||||||
#define GPIO_RS485_DE 21
|
#define GPIO_RS485_DE 21
|
||||||
#define GPIO_RS485_RE 83
|
#define GPIO_RS485_RE 83
|
||||||
|
|||||||
@ -64,7 +64,7 @@
|
|||||||
<listOptionValue builtIn="false" value="${COM_TI_C2000WARE_SOFTWARE_PACKAGE_SYMBOLS}"/>
|
<listOptionValue builtIn="false" value="${COM_TI_C2000WARE_SOFTWARE_PACKAGE_SYMBOLS}"/>
|
||||||
<listOptionValue builtIn="false" value="FREEMASTER"/>
|
<listOptionValue builtIn="false" value="FREEMASTER"/>
|
||||||
<listOptionValue builtIn="false" value="NRS485"/>
|
<listOptionValue builtIn="false" value="NRS485"/>
|
||||||
<listOptionValue builtIn="false" value="REF1"/>
|
<listOptionValue builtIn="false" value="REF0"/>
|
||||||
<listOptionValue builtIn="false" value="USE_25MHZ_XTAL"/>
|
<listOptionValue builtIn="false" value="USE_25MHZ_XTAL"/>
|
||||||
<listOptionValue builtIn="false" value="DEBUG"/>
|
<listOptionValue builtIn="false" value="DEBUG"/>
|
||||||
<listOptionValue builtIn="false" value="CPU2"/>
|
<listOptionValue builtIn="false" value="CPU2"/>
|
||||||
|
|||||||
Binary file not shown.
@ -22,6 +22,7 @@
|
|||||||
#include "rele.h"
|
#include "rele.h"
|
||||||
#include "uart_4Mbit.h"
|
#include "uart_4Mbit.h"
|
||||||
#include "frm_uart.h"
|
#include "frm_uart.h"
|
||||||
|
#include "fault.h"
|
||||||
|
|
||||||
void main(void)
|
void main(void)
|
||||||
{
|
{
|
||||||
@ -35,9 +36,7 @@ void main(void)
|
|||||||
FMSTR_Poll();
|
FMSTR_Poll();
|
||||||
#endif
|
#endif
|
||||||
SyncPWMFonRun();
|
SyncPWMFonRun();
|
||||||
rele_run();
|
if(fault_read_check()) fault_read_ports();//вынесено сюда, так как нельзя вызывать в прерывании,так как не будет считать таймер таймаута
|
||||||
AdcRun();
|
|
||||||
BissClkgenRun();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -26,7 +26,7 @@
|
|||||||
#define PERIOD_BRAKE (SYS_PWM_FREQUENCY/2.0/FREQUENCY_BRAKE) //Tic
|
#define PERIOD_BRAKE (SYS_PWM_FREQUENCY/2.0/FREQUENCY_BRAKE) //Tic
|
||||||
#define PERIOD_MOTOR (SYS_PWM_FREQUENCY/2.0/FREQUENCY_MOTOR) //Tic = 5000
|
#define PERIOD_MOTOR (SYS_PWM_FREQUENCY/2.0/FREQUENCY_MOTOR) //Tic = 5000
|
||||||
|
|
||||||
#define EPWM_DB (EPWM_DB_mkS*SYS_PWM_FREQUENCY/1000000)
|
#define EPWM_DB (EPWM_DB_mkS*SYS_PWM_FREQUENCY/1000000)//4*100
|
||||||
|
|
||||||
#define SDFM_DELAY_mkS 50.0 //mkS
|
#define SDFM_DELAY_mkS 50.0 //mkS
|
||||||
#define SDFM_DELAY (SDFM_DELAY_mkS*SYS_PWM_FREQUENCY/1000000)
|
#define SDFM_DELAY (SDFM_DELAY_mkS*SYS_PWM_FREQUENCY/1000000)
|
||||||
|
|||||||
@ -21,6 +21,8 @@
|
|||||||
#include "pwm_interrupts.h"
|
#include "pwm_interrupts.h"
|
||||||
#include "SyncPWMFonRun.h"
|
#include "SyncPWMFonRun.h"
|
||||||
#include "pwm_init.h"
|
#include "pwm_init.h"
|
||||||
|
#include "biss.h"
|
||||||
|
|
||||||
|
|
||||||
volatile uint16_t AutoChange = 0;
|
volatile uint16_t AutoChange = 0;
|
||||||
volatile uint16_t PWM_out = 2500;
|
volatile uint16_t PWM_out = 2500;
|
||||||
@ -77,18 +79,21 @@ void pwm_set_volt_3F(float phaseA, float phaseB, float phaseC, float Udc, uint16
|
|||||||
else PeriodPWM[0] == PeriodPWM[1];
|
else PeriodPWM[0] == PeriodPWM[1];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
A_proc = (int16_t)((phaseA/Udc)*PeriodPWM_2);
|
A_proc = (int16_t)((phaseA/Udc)*PeriodPWM_2);
|
||||||
B_proc = (int16_t)((phaseB/Udc)*PeriodPWM_2);
|
B_proc = (int16_t)((phaseB/Udc)*PeriodPWM_2);
|
||||||
C_proc = (int16_t)((phaseC/Udc)*PeriodPWM_2);
|
C_proc = (int16_t)((phaseC/Udc)*PeriodPWM_2);
|
||||||
|
|
||||||
if(A_proc > 0) A_proc+= EPWM_DB/2;
|
|
||||||
else if(A_proc < 0) A_proc-= EPWM_DB/2;
|
// if( (A_proc > 0) && (A_proc < (PeriodPWM_2-EPWM_DB)) ) A_proc+= EPWM_DB/2;
|
||||||
if(B_proc > 0) B_proc+= EPWM_DB/2;
|
// else if((A_proc < 0) && (A_proc > -(PeriodPWM_2-EPWM_DB)) ) A_proc-= EPWM_DB/2;
|
||||||
else if(B_proc < 0) B_proc-= EPWM_DB/2;
|
//
|
||||||
if(C_proc > 0) C_proc+= EPWM_DB/2;
|
// if((B_proc > 0) && (B_proc < (PeriodPWM_2-EPWM_DB))) B_proc+= EPWM_DB/2;
|
||||||
else if(C_proc < 0) C_proc-= EPWM_DB/2;
|
// else if((B_proc < 0) && (B_proc > -(PeriodPWM_2-EPWM_DB)) ) B_proc-= EPWM_DB/2;
|
||||||
|
//
|
||||||
|
// if((C_proc > 0) && (C_proc < (PeriodPWM_2-EPWM_DB))) C_proc+= EPWM_DB/2;
|
||||||
|
// else if((C_proc < 0) && (C_proc > -(PeriodPWM_2-EPWM_DB)))C_proc-= EPWM_DB/2;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
PWM_motor.UA = PeriodPWM_2 + A_proc;
|
PWM_motor.UA = PeriodPWM_2 + A_proc;
|
||||||
PWM_motor.UB = PeriodPWM_2 + B_proc;
|
PWM_motor.UB = PeriodPWM_2 + B_proc;
|
||||||
@ -113,6 +118,9 @@ void pwm_set_volt_3F(float phaseA, float phaseB, float phaseC, float Udc, uint16
|
|||||||
EPwmRegs[PWM_A]->CMPA.bit.CMPA = PeriodPWM[0] - PWM_motor.UA;
|
EPwmRegs[PWM_A]->CMPA.bit.CMPA = PeriodPWM[0] - PWM_motor.UA;
|
||||||
EPwmRegs[PWM_B]->CMPA.bit.CMPA = PeriodPWM[0] - PWM_motor.UB;
|
EPwmRegs[PWM_B]->CMPA.bit.CMPA = PeriodPWM[0] - PWM_motor.UB;
|
||||||
EPwmRegs[PWM_C]->CMPA.bit.CMPA = PeriodPWM[0] - PWM_motor.UC;
|
EPwmRegs[PWM_C]->CMPA.bit.CMPA = PeriodPWM[0] - PWM_motor.UC;
|
||||||
|
|
||||||
|
EPwmRegs[PWM_FAN]->CMPA.bit.CMPA = PERIOD_FAN - PWM_Vent;
|
||||||
|
// EPwmRegs[3]->CMPB.bit.CMPB = PERIOD_MOTOR - PWM_Chop;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -149,7 +157,7 @@ __interrupt void epwm1_isr(void)
|
|||||||
// epwm2_isr - EPWM2 ISR
|
// epwm2_isr - EPWM2 ISR
|
||||||
//
|
//
|
||||||
uint32_t Test_ADC_PWM_Synch1=0, Test_ADC_PWM_Synch2=0;
|
uint32_t Test_ADC_PWM_Synch1=0, Test_ADC_PWM_Synch2=0;
|
||||||
uint16_t TestStopSync = 0;
|
|
||||||
|
|
||||||
__interrupt void epwm2_isr(void)
|
__interrupt void epwm2_isr(void)
|
||||||
{
|
{
|
||||||
@ -186,7 +194,6 @@ __interrupt void epwm2_isr(void)
|
|||||||
// EPwmRegs[PWM_FAN]->CMPA.bit.CMPA = PERIOD_MOTOR - PWM_Vent;
|
// EPwmRegs[PWM_FAN]->CMPA.bit.CMPA = PERIOD_MOTOR - PWM_Vent;
|
||||||
// EPwmRegs[3]->CMPB.bit.CMPB = PERIOD_MOTOR - PWM_Chop;
|
// EPwmRegs[3]->CMPB.bit.CMPB = PERIOD_MOTOR - PWM_Chop;
|
||||||
Test_ADC_PWM_Synch1++;
|
Test_ADC_PWM_Synch1++;
|
||||||
if(TestStopSync == 2) TestStopSync = 3;
|
|
||||||
// if(rele_isReleOn()) ReleOut(1);//GpioTurnOnRele();
|
// if(rele_isReleOn()) ReleOut(1);//GpioTurnOnRele();
|
||||||
// else ReleOut(0);//GpioTurnOffRele();
|
// else ReleOut(0);//GpioTurnOffRele();
|
||||||
}
|
}
|
||||||
@ -304,7 +311,9 @@ __interrupt void epwm11_isr(void)
|
|||||||
|
|
||||||
|
|
||||||
saveTimingNow(0);
|
saveTimingNow(0);
|
||||||
if(TestStopSync != 3) sdfm_start_conversion_current();
|
|
||||||
|
sdfm_start_conversion_current();
|
||||||
|
BissClkgenRun();
|
||||||
|
|
||||||
PwmFlagStartCurrentMeashure = 1;
|
PwmFlagStartCurrentMeashure = 1;
|
||||||
EPwm11Regs.ETCLR.bit.INT = 1;
|
EPwm11Regs.ETCLR.bit.INT = 1;
|
||||||
|
|||||||
@ -23,9 +23,28 @@ volatile uint16_t testMode = 0;
|
|||||||
uint16_t BisscPwrOn = 1;
|
uint16_t BisscPwrOn = 1;
|
||||||
uint16_t BrakeOn = 0;
|
uint16_t BrakeOn = 0;
|
||||||
|
|
||||||
|
void SyncPWMFondiod(void)
|
||||||
|
{
|
||||||
|
static uint16_t diod = 0;
|
||||||
|
if(counter < 100) counter++;
|
||||||
|
else
|
||||||
|
{
|
||||||
|
counter = 0;
|
||||||
|
if(counter1 < 100) counter1++;
|
||||||
|
else
|
||||||
|
{
|
||||||
|
counter1=0;
|
||||||
|
counter2++;
|
||||||
|
diod++;
|
||||||
|
if(diod > 7) diod = 0;
|
||||||
|
Gpio_rainbow(diod);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void SyncPWMFonRun(void)
|
void SyncPWMFonRun(void)
|
||||||
{
|
{
|
||||||
static uint16_t diod = 0;
|
|
||||||
|
|
||||||
if(SynchPWMFonRunEnable())
|
if(SynchPWMFonRunEnable())
|
||||||
{
|
{
|
||||||
@ -33,20 +52,9 @@ void SyncPWMFonRun(void)
|
|||||||
FMSTR_Recorder();
|
FMSTR_Recorder();
|
||||||
#endif
|
#endif
|
||||||
SynchPWMFonRunEnableClr();
|
SynchPWMFonRunEnableClr();
|
||||||
if(counter < 100) counter++;
|
AdcRun();
|
||||||
else
|
rele_run();
|
||||||
{
|
SyncPWMFondiod();
|
||||||
counter = 0;
|
|
||||||
if(counter1 < 100) counter1++;
|
|
||||||
else
|
|
||||||
{
|
|
||||||
counter1=0;
|
|
||||||
counter2++;
|
|
||||||
diod++;
|
|
||||||
if(diod > 7) diod = 0;
|
|
||||||
Gpio_rainbow(diod);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@ -67,15 +75,14 @@ void SyncPWMFonRun(void)
|
|||||||
{
|
{
|
||||||
GpioDataRegs.GPADAT.bit.GPIO14 = 0;
|
GpioDataRegs.GPADAT.bit.GPIO14 = 0;
|
||||||
}
|
}
|
||||||
|
// if(fault_read_check())
|
||||||
if(fault_read_check())
|
// {
|
||||||
{
|
// fault_read_clr();
|
||||||
fault_read_clr();
|
// fault_read_ports();
|
||||||
fault_read_ports();
|
// }else{
|
||||||
}else{
|
|
||||||
// buttonsDisp();
|
// buttonsDisp();
|
||||||
// ScreenDisp();
|
// ScreenDisp();
|
||||||
}
|
// }
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -10,6 +10,7 @@
|
|||||||
#include "biss.h"
|
#include "biss.h"
|
||||||
#include "CLB/board.h"
|
#include "CLB/board.h"
|
||||||
#include "crc.h"
|
#include "crc.h"
|
||||||
|
#include "pwm_interrupts.h"
|
||||||
|
|
||||||
|
|
||||||
#define DEVICE_SYSCLK_FREQ 250000000
|
#define DEVICE_SYSCLK_FREQ 250000000
|
||||||
@ -194,6 +195,8 @@ void BissCalc(uint64_t BissData)
|
|||||||
{
|
{
|
||||||
uint16_t BissEmptyBits = 0;
|
uint16_t BissEmptyBits = 0;
|
||||||
|
|
||||||
|
saveTimingNow(5);
|
||||||
|
|
||||||
BissData = BissData << 2;
|
BissData = BissData << 2;
|
||||||
|
|
||||||
while(((BissData & 0xC000000000000000) != 0x8000000000000000) && (BissEmptyBits < 15))
|
while(((BissData & 0xC000000000000000) != 0x8000000000000000) && (BissEmptyBits < 15))
|
||||||
@ -243,6 +246,7 @@ void BissCalc(uint64_t BissData)
|
|||||||
|
|
||||||
bissSpeed = Bissth1 - Bissth1_;
|
bissSpeed = Bissth1 - Bissth1_;
|
||||||
Bissth1_ = Bissth1;
|
Bissth1_ = Bissth1;
|
||||||
|
saveTimingNow(6);
|
||||||
}
|
}
|
||||||
BissErr = (BissAll >> (ANGLESUMM_SHIFT-1)) & 1;
|
BissErr = (BissAll >> (ANGLESUMM_SHIFT-1)) & 1;
|
||||||
BissWarn = (BissAll >> (ANGLESUMM_SHIFT-2)) & 1;
|
BissWarn = (BissAll >> (ANGLESUMM_SHIFT-2)) & 1;
|
||||||
|
|||||||
@ -19,9 +19,9 @@ __interrupt void fault_isr(void)
|
|||||||
PieCtrlRegs.PIEACK.all = PIEACK_GROUP1;
|
PieCtrlRegs.PIEACK.all = PIEACK_GROUP1;
|
||||||
|
|
||||||
faultCounter++;
|
faultCounter++;
|
||||||
fault_read = 1;
|
|
||||||
PWM_ABC_StopAllClose();
|
PWM_ABC_StopAllClose();
|
||||||
vectorFault();
|
vectorFault();
|
||||||
|
fault_read = 1;
|
||||||
vectorResCurrLoop();
|
vectorResCurrLoop();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -40,6 +40,7 @@ void fault_read_clr(void)
|
|||||||
void fault_read_ports(void)
|
void fault_read_ports(void)
|
||||||
{
|
{
|
||||||
uint16_t Fault_Bytes;
|
uint16_t Fault_Bytes;
|
||||||
|
fault_read = 0;
|
||||||
I2CWrite(I2C_FAULT_SLAVE_ADDRESS, 0, 0, false, &Fault_Bytes);
|
I2CWrite(I2C_FAULT_SLAVE_ADDRESS, 0, 0, false, &Fault_Bytes);
|
||||||
I2CRead(I2C_FAULT_SLAVE_ADDRESS, 1, true, &Fault_Bytes);
|
I2CRead(I2C_FAULT_SLAVE_ADDRESS, 1, true, &Fault_Bytes);
|
||||||
Fault1[faultCounter&0xF] = Fault_Bytes;
|
Fault1[faultCounter&0xF] = Fault_Bytes;
|
||||||
|
|||||||
@ -100,7 +100,7 @@ void InitPerif(void)
|
|||||||
ADCConfigure();
|
ADCConfigure();
|
||||||
|
|
||||||
#ifdef REF0
|
#ifdef REF0
|
||||||
temperatureInit();
|
// temperatureInit();
|
||||||
#else
|
#else
|
||||||
eqep_init();
|
eqep_init();
|
||||||
#endif
|
#endif
|
||||||
@ -120,8 +120,10 @@ void InitPerif(void)
|
|||||||
|
|
||||||
I2CMasterInit(I2C_OWN_ADDRESS,0x3C);
|
I2CMasterInit(I2C_OWN_ADDRESS,0x3C);
|
||||||
/* Init LCD */
|
/* Init LCD */
|
||||||
|
#ifndef REF0
|
||||||
SSD1306_Init();
|
SSD1306_Init();
|
||||||
buttonsInit();
|
buttonsInit();
|
||||||
|
#endif
|
||||||
faultInit();
|
faultInit();
|
||||||
rele_initRele();
|
rele_initRele();
|
||||||
|
|
||||||
|
|||||||
@ -69,16 +69,17 @@ void rele_control(int16_t UdcFiltered)
|
|||||||
{
|
{
|
||||||
if((!Rele.State) || (!Rele.StateChange))
|
if((!Rele.State) || (!Rele.StateChange))
|
||||||
{
|
{
|
||||||
|
PWM_ABC_StopAllClose();
|
||||||
vectorFault();
|
vectorFault();
|
||||||
Rele.ReleCounter = 0;
|
Rele.ReleCounter = 0;
|
||||||
Rele.Error = 0;
|
Rele.Error = 0;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
|
||||||
if(Rele.Error) vectorFault();
|
if(Rele.Error) {PWM_ABC_StopAllClose(); vectorFault();}
|
||||||
else {
|
else {
|
||||||
if(Rele.ReleCounter == 0) Rele.Udc = UdcFiltered;
|
if(Rele.ReleCounter == 0) Rele.Udc = UdcFiltered;
|
||||||
if(Rele.ReleCounter < Rele.CounterMax) {Rele.ReleCounter++; vectorFault();}
|
if(Rele.ReleCounter < Rele.CounterMax) {Rele.ReleCounter++; PWM_ABC_StopAllClose(); vectorFault();}
|
||||||
else if(Rele.ReleCounter == Rele.CounterMax)
|
else if(Rele.ReleCounter == Rele.CounterMax)
|
||||||
{
|
{
|
||||||
Rele.ReleCounter++;
|
Rele.ReleCounter++;
|
||||||
|
|||||||
@ -73,7 +73,7 @@ float FactorCurrent = FACTOR_CURRENT_MOTOR;
|
|||||||
TvectorCurrentLoop CurrLoop;
|
TvectorCurrentLoop CurrLoop;
|
||||||
TMode Mode = OffMode;
|
TMode Mode = OffMode;
|
||||||
uint16_t Step = 0, StepS, Nstep = 2, NoLoop = 0, StepShift = 6;
|
uint16_t Step = 0, StepS, Nstep = 2, NoLoop = 0, StepShift = 6;
|
||||||
float CurrentRegTuneAmpl = 0, FRM_cur = 0, CurrentRegTuneAmplInpuls = 0;
|
float CurrentRegTuneAmpld = 0, CurrentRegTuneAmplq = 0, FRM_cur = 0, CurrentRegTuneAmplInpuls = 0;
|
||||||
int16_t Angle_test=0,sin_int,cos_int, AngleErr;
|
int16_t Angle_test=0,sin_int,cos_int, AngleErr;
|
||||||
float Udc;
|
float Udc;
|
||||||
uint16_t SectorCheckOn=1;
|
uint16_t SectorCheckOn=1;
|
||||||
@ -123,7 +123,7 @@ void SetAngeOffset(void)
|
|||||||
SetAngeOffsetCounter = 0;
|
SetAngeOffsetCounter = 0;
|
||||||
Mode = OffMode;
|
Mode = OffMode;
|
||||||
}
|
}
|
||||||
CurrLoop.piId.Ref = CurrentRegTuneAmpl;
|
CurrLoop.piId.Ref = CurrentRegTuneAmpld;
|
||||||
CurrLoop.piIq.Ref = 0;
|
CurrLoop.piIq.Ref = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -131,9 +131,9 @@ void SetAngeOffset(void)
|
|||||||
void vectorFault(void)
|
void vectorFault(void)
|
||||||
{
|
{
|
||||||
Mode = OffMode;
|
Mode = OffMode;
|
||||||
#ifdef REF0
|
//#ifdef REF0
|
||||||
XintRegs.XINT2CR.bit.ENABLE = 1;
|
// XintRegs.XINT2CR.bit.ENABLE = 1;
|
||||||
#endif
|
//#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
uint16_t Num = 0;
|
uint16_t Num = 0;
|
||||||
@ -142,11 +142,12 @@ void vectorControl(int16_t CurrentA, int16_t CurrentB, int16_t CurrentC, int16_t
|
|||||||
{
|
{
|
||||||
|
|
||||||
saveTimingNow(1);
|
saveTimingNow(1);
|
||||||
|
|
||||||
pwm_clr_PwmFlagStartADC();
|
pwm_clr_PwmFlagStartADC();
|
||||||
Ia = -CurrentA;//sdfm_get(6);
|
Ia = -CurrentA;//sdfm_get(6);
|
||||||
Ib = -CurrentB;//sdfm_get(3);
|
Ib = -CurrentB;//sdfm_get(3);
|
||||||
Ic = -CurrentC;//sdfm_get(4);
|
Ic = -CurrentC;//sdfm_get(4);
|
||||||
if((Ia > IMAX_KZ)||(Ib>IMAX_KZ)||(Ic>IMAX_KZ)||(Ia<-IMAX_KZ)||(Ib<-IMAX_KZ)||(Ic<-IMAX_KZ) ) {OverCur[0] = Ia; OverCur[1] = Ib; OverCur[2] = Ic; ErrCur++; Mode = OffMode; CurFault++;}
|
if((Ia > IMAX_KZ)||(Ib>IMAX_KZ)||(Ic>IMAX_KZ)||(Ia<-IMAX_KZ)||(Ib<-IMAX_KZ)||(Ic<-IMAX_KZ) ) {OverCur[0] = Ia; OverCur[1] = Ib; OverCur[2] = Ic; ErrCur++; PWM_ABC_StopAllClose(); vectorFault(); CurFault++;}
|
||||||
|
|
||||||
|
|
||||||
UdcFiltered = Filter(sdfmUdc, &UdcFilter);
|
UdcFiltered = Filter(sdfmUdc, &UdcFilter);
|
||||||
@ -154,7 +155,7 @@ void vectorControl(int16_t CurrentA, int16_t CurrentB, int16_t CurrentC, int16_t
|
|||||||
if(VoltProcImit) UdcVolt = VoltProcImit;
|
if(VoltProcImit) UdcVolt = VoltProcImit;
|
||||||
else UdcVolt = (float)UdcFiltered*VdcFactor/BIT_MAX;
|
else UdcVolt = (float)UdcFiltered*VdcFactor/BIT_MAX;
|
||||||
|
|
||||||
if(UdcVolt < 15) Mode = OffMode;
|
if(UdcVolt < 15) vectorFault();
|
||||||
|
|
||||||
Step = Step + Nstep;
|
Step = Step + Nstep;
|
||||||
CurrLoop.piId.Ref = 0;
|
CurrLoop.piId.Ref = 0;
|
||||||
@ -164,7 +165,7 @@ void vectorControl(int16_t CurrentA, int16_t CurrentB, int16_t CurrentC, int16_t
|
|||||||
if(Mode) {XintRegs.XINT2CR.bit.ENABLE = 0; temperature_deInit();}
|
if(Mode) {XintRegs.XINT2CR.bit.ENABLE = 0; temperature_deInit();}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
vectorAngle = biss_getAngle() + AngleOffset;
|
vectorAngle = biss_getAngle() - AngleOffset;
|
||||||
|
|
||||||
switch(Mode)
|
switch(Mode)
|
||||||
{
|
{
|
||||||
@ -178,15 +179,15 @@ void vectorControl(int16_t CurrentA, int16_t CurrentB, int16_t CurrentC, int16_t
|
|||||||
if(Impuls > 0)
|
if(Impuls > 0)
|
||||||
{
|
{
|
||||||
Impuls--;
|
Impuls--;
|
||||||
CurrLoop.piIq.Ref = CurrentRegTuneAmplInpuls;
|
CurrLoop.piId.Ref = CurrentRegTuneAmplInpuls;
|
||||||
}
|
}
|
||||||
else CurrLoop.piIq.Ref = CurrentRegTuneAmpl;
|
else CurrLoop.piId.Ref = CurrentRegTuneAmpld;
|
||||||
CurrLoop.piId.Ref = 0;
|
CurrLoop.piIq.Ref = CurrentRegTuneAmplq;
|
||||||
break;
|
break;
|
||||||
case StepModeImpulses:
|
case StepModeImpulses:
|
||||||
PWM_ABC_StartOut();
|
PWM_ABC_StartOut();
|
||||||
vectorSinCos.Angle = Step;
|
vectorSinCos.Angle = Step;
|
||||||
if(ImpulsStep <= ImpulsLow) CurrLoop.piIq.Ref = CurrentRegTuneAmpl;
|
if(ImpulsStep <= ImpulsLow) CurrLoop.piIq.Ref = CurrentRegTuneAmpld;
|
||||||
else CurrLoop.piIq.Ref = CurrentRegTuneAmplInpuls;
|
else CurrLoop.piIq.Ref = CurrentRegTuneAmplInpuls;
|
||||||
if(ImpulsStep < (ImpulsLow + ImpulsHi)) ImpulsStep++;
|
if(ImpulsStep < (ImpulsLow + ImpulsHi)) ImpulsStep++;
|
||||||
else ImpulsStep = 0;
|
else ImpulsStep = 0;
|
||||||
@ -194,14 +195,15 @@ void vectorControl(int16_t CurrentA, int16_t CurrentB, int16_t CurrentC, int16_t
|
|||||||
break;
|
break;
|
||||||
case StayMode:
|
case StayMode:
|
||||||
PWM_ABC_StartOut();
|
PWM_ABC_StartOut();
|
||||||
CurrLoop.piIq.Ref = CurrentRegTuneAmpl;
|
CurrLoop.piId.Ref = CurrentRegTuneAmpld;
|
||||||
|
CurrLoop.piIq.Ref = CurrentRegTuneAmplq;
|
||||||
break;
|
break;
|
||||||
case CurrentRegTune:
|
case CurrentRegTune:
|
||||||
vectorSinCos.Angle = 0;
|
vectorSinCos.Angle = 0;
|
||||||
PWM_ABC_StartOut();
|
PWM_ABC_StartOut();
|
||||||
StepS = Step&((1<<StepShift)-1);
|
StepS = Step&((1<<StepShift)-1);
|
||||||
if(StepS > (1<<(StepShift-1))) CurrLoop.piId.Ref = 0;
|
if(StepS > (1<<(StepShift-1))) CurrLoop.piId.Ref = 0;
|
||||||
else CurrLoop.piId.Ref = CurrentRegTuneAmpl;
|
else CurrLoop.piId.Ref = CurrentRegTuneAmpld;
|
||||||
CurrLoop.piIq.Ref = 0;
|
CurrLoop.piIq.Ref = 0;
|
||||||
break;
|
break;
|
||||||
case TestPWNMode:
|
case TestPWNMode:
|
||||||
@ -213,13 +215,13 @@ void vectorControl(int16_t CurrentA, int16_t CurrentB, int16_t CurrentC, int16_t
|
|||||||
if(biss_getErr()>=3)
|
if(biss_getErr()>=3)
|
||||||
{
|
{
|
||||||
PWM_ABC_StopAllClose();
|
PWM_ABC_StopAllClose();
|
||||||
Mode = OffMode;
|
vectorFault();
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
PWM_ABC_StartOut();
|
PWM_ABC_StartOut();
|
||||||
vectorSinCos.Angle = vectorAngle;
|
vectorSinCos.Angle = vectorAngle;
|
||||||
CurrLoop.piIq.Ref = CurrentRegTuneAmpl;
|
CurrLoop.piIq.Ref = CurrentRegTuneAmplq;
|
||||||
CurrLoop.piId.Ref = 0;
|
CurrLoop.piId.Ref = 0;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
@ -228,7 +230,7 @@ void vectorControl(int16_t CurrentA, int16_t CurrentB, int16_t CurrentC, int16_t
|
|||||||
SetAngeOffset();
|
SetAngeOffset();
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
Mode = OffMode;
|
vectorFault();
|
||||||
PWM_ABC_StopAllClose();
|
PWM_ABC_StopAllClose();
|
||||||
}
|
}
|
||||||
Udc = sdfmUdc * FACTOR_VDC;
|
Udc = sdfmUdc * FACTOR_VDC;
|
||||||
@ -356,8 +358,10 @@ void vector_inversion(void)
|
|||||||
}
|
}
|
||||||
|
|
||||||
float Test1, Test2;
|
float Test1, Test2;
|
||||||
float FRM_Ud, FRM_Uq;
|
float FRM_Ud, FRM_Uq, FRM_Ud_, FRM_Uq_;
|
||||||
volatile int16_t I_fbk_int, I_ref_int;
|
volatile int16_t I_fbk_int, I_ref_int;
|
||||||
|
float UmaxVolt;
|
||||||
|
float Ulim;
|
||||||
|
|
||||||
void vector_klark_park(uint16_t SectorOn, int16_t CurrentA, int16_t CurrentB, int16_t CurrentC)
|
void vector_klark_park(uint16_t SectorOn, int16_t CurrentA, int16_t CurrentB, int16_t CurrentC)
|
||||||
{
|
{
|
||||||
@ -452,7 +456,7 @@ void vector_klark_park(uint16_t SectorOn, int16_t CurrentA, int16_t CurrentB, in
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
float UmaxVolt = VOLT_MAX_FACTOR * UdcVolt;
|
UmaxVolt = VOLT_MAX_FACTOR * UdcVolt;// 94/100*UdcVolt
|
||||||
|
|
||||||
CurrLoop.piIq.Umax = UmaxVolt; // Parameter: upper saturation limit
|
CurrLoop.piIq.Umax = UmaxVolt; // Parameter: upper saturation limit
|
||||||
CurrLoop.piIq.Umin = -UmaxVolt;
|
CurrLoop.piIq.Umin = -UmaxVolt;
|
||||||
@ -468,7 +472,7 @@ void vector_klark_park(uint16_t SectorOn, int16_t CurrentA, int16_t CurrentB, in
|
|||||||
// Test1 = my_sqrtf(Test2);
|
// Test1 = my_sqrtf(Test2);
|
||||||
|
|
||||||
|
|
||||||
float Ulim = my_sqrtf(CurrLoop.piId.Out * CurrLoop.piId.Out + CurrLoop.piIq.Out * CurrLoop.piIq.Out);
|
Ulim = my_sqrtf(CurrLoop.piId.Out * CurrLoop.piId.Out + CurrLoop.piIq.Out * CurrLoop.piIq.Out);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@ -476,6 +480,8 @@ void vector_klark_park(uint16_t SectorOn, int16_t CurrentA, int16_t CurrentB, in
|
|||||||
{
|
{
|
||||||
if(Ulim > ZERO_LVL)
|
if(Ulim > ZERO_LVL)
|
||||||
{
|
{
|
||||||
|
FRM_Ud_= CurrLoop.piId.Out;
|
||||||
|
FRM_Uq_= CurrLoop.piIq.Out;
|
||||||
float K = UmaxVolt / Ulim;
|
float K = UmaxVolt / Ulim;
|
||||||
FRM_Ud = CurrLoop.piId.Out *= K;
|
FRM_Ud = CurrLoop.piId.Out *= K;
|
||||||
FRM_Uq = CurrLoop.piIq.Out *= K;
|
FRM_Uq = CurrLoop.piIq.Out *= K;
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user