biss-c переделан на более универсальный вариант, может работать с разной разрядностью:
#define SINGLETURN - бит на один оборот #define MULTITURN - бит на количество оборотов их сумма -- общее кол-во бит Скорость фримастера уменьшил на 57600, так как на 115200 уарт сыпет ошибками Добавил вычисление смещения угла датчика.
This commit is contained in:
parent
0f29a7eb48
commit
57dca5e05a
@ -99,7 +99,7 @@ SECTIONS
|
|||||||
MSGRAM_CM_TO_CPU : > CMTOCPURAM, type=NOINIT
|
MSGRAM_CM_TO_CPU : > CMTOCPURAM, type=NOINIT
|
||||||
|
|
||||||
/* The following section definition are for SDFM examples */
|
/* The following section definition are for SDFM examples */
|
||||||
// Filter_RegsFile : > RAMGS10
|
|
||||||
// Filter1_RegsFile : > RAMLS1
|
// Filter1_RegsFile : > RAMLS1
|
||||||
// Filter2_RegsFile : > RAMLS2
|
// Filter2_RegsFile : > RAMLS2
|
||||||
// Filter3_RegsFile : > RAMLS3
|
// Filter3_RegsFile : > RAMLS3
|
||||||
@ -107,8 +107,8 @@ SECTIONS
|
|||||||
|
|
||||||
Filter6_RegsFile : > RAMLS6
|
Filter6_RegsFile : > RAMLS6
|
||||||
|
|
||||||
ADC_RegsFile0 : > RAMGS0 | RAMGS1 | RAMGS2
|
ADC_RegsFile0 : > RAMLS1
|
||||||
ADC_RegsFile1 : > RAMGS3 | RAMGS4 | RAMGS5
|
|
||||||
|
|
||||||
|
|
||||||
// Filter14_RegsFile : > RAMGS14
|
// Filter14_RegsFile : > RAMGS14
|
||||||
|
|||||||
Binary file not shown.
@ -25,14 +25,15 @@
|
|||||||
|
|
||||||
void main(void)
|
void main(void)
|
||||||
{
|
{
|
||||||
|
asm (" NOP");
|
||||||
InitPerif();
|
InitPerif();
|
||||||
|
|
||||||
for(;;)
|
for(;;)
|
||||||
{
|
{
|
||||||
// asm (" NOP");
|
|
||||||
// frmmstr_run();
|
|
||||||
UartErrorReset();
|
UartErrorReset();
|
||||||
|
#ifdef FREEMASTER
|
||||||
FMSTR_Poll();
|
FMSTR_Poll();
|
||||||
|
#endif
|
||||||
SyncPWMFonRun();
|
SyncPWMFonRun();
|
||||||
rele_run();
|
rele_run();
|
||||||
AdcRun();
|
AdcRun();
|
||||||
|
|||||||
@ -73,8 +73,8 @@ void SyncPWMFonRun(void)
|
|||||||
fault_read_clr();
|
fault_read_clr();
|
||||||
fault_read_ports();
|
fault_read_ports();
|
||||||
}else{
|
}else{
|
||||||
buttonsDisp();
|
// buttonsDisp();
|
||||||
ScreenDisp();
|
// ScreenDisp();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -171,6 +171,25 @@ uint64_t BissAll = 0;
|
|||||||
uint32_t WrongCS =0, RightCS = 0, bisscErr = 0;
|
uint32_t WrongCS =0, RightCS = 0, bisscErr = 0;
|
||||||
int16_t bissSpeed;
|
int16_t bissSpeed;
|
||||||
|
|
||||||
|
|
||||||
|
//#define SINGLETURN 19
|
||||||
|
//#define MULTITURN 17
|
||||||
|
|
||||||
|
#define SINGLETURN 17
|
||||||
|
#define MULTITURN 12
|
||||||
|
|
||||||
|
|
||||||
|
//#define SUMMTURN (SINGLETURN+MULTITURN)
|
||||||
|
//#define ANGLESUMM_SHIFT (64-SUMMTURN)
|
||||||
|
//#define MASK_SINGLETURN (((uint64_t)1<<SINGLETURN)-1)
|
||||||
|
//#define ANGLE16bit_SHIFT (SINGLETURN - 16)
|
||||||
|
|
||||||
|
|
||||||
|
const uint16_t SUMMTURN = (SINGLETURN + MULTITURN);//29
|
||||||
|
const uint16_t ANGLESUMM_SHIFT = (64 - SUMMTURN);//35
|
||||||
|
const uint32_t MASK_SINGLETURN = (((uint64_t)1<<SINGLETURN)-1);//
|
||||||
|
const uint16_t ANGLE16bit_SHIFT= (SINGLETURN - 16);
|
||||||
|
|
||||||
void BissCalc(uint64_t BissData)
|
void BissCalc(uint64_t BissData)
|
||||||
{
|
{
|
||||||
uint16_t BissEmptyBits = 0;
|
uint16_t BissEmptyBits = 0;
|
||||||
@ -193,12 +212,21 @@ void BissCalc(uint64_t BissData)
|
|||||||
{
|
{
|
||||||
BissAll = BissData << 2;
|
BissAll = BissData << 2;
|
||||||
|
|
||||||
BiSStheta = (BissAll & 0xFFFFFFFFF0000000) >> 28;
|
BiSStheta = BissAll >> ANGLESUMM_SHIFT;//
|
||||||
Bissth1 = (BiSStheta & 0x7FFFF);
|
Bissth1 = (BiSStheta & MASK_SINGLETURN); //угол внутри одного оборота
|
||||||
Bissth2 = Bissth1 >> 3;
|
Bissth2 = Bissth1 >> ANGLE16bit_SHIFT;
|
||||||
BissCRC = (BissAll & 0x0000000003F00000) >> 20;
|
BissCRC = (BissAll >> (ANGLESUMM_SHIFT - 8)) & 0x3F;
|
||||||
BissAllCRC = (BissAll & 0xFFFFFFFFFC000000) >> 26; //38 bit
|
BissAllCRC = BissAll >> (ANGLESUMM_SHIFT-2);
|
||||||
BissCRC2_ = crcbitbybitfast(BissAllCRC);
|
BissCRC2_ = crcbitbybitfast(BissAllCRC);
|
||||||
|
|
||||||
|
|
||||||
|
// BiSStheta = (BissAll & 0xFFFFFFFFF0000000) >> 28;
|
||||||
|
// Bissth1 = (BiSStheta & 0x7FFFF); //угол внутри одного оборота
|
||||||
|
// Bissth2 = Bissth1 >> 3;
|
||||||
|
// BissCRC = (BissAll & 0x0000000003F00000) >> 20;
|
||||||
|
// BissAllCRC = (BissAll & 0xFFFFFFFFFC000000) >> 26; //38 bit
|
||||||
|
// BissCRC2_ = crcbitbybitfast(BissAllCRC);
|
||||||
|
|
||||||
if(BissCRC2_ != BissCRC)
|
if(BissCRC2_ != BissCRC)
|
||||||
{
|
{
|
||||||
WrongCS++;
|
WrongCS++;
|
||||||
@ -208,16 +236,19 @@ void BissCalc(uint64_t BissData)
|
|||||||
else
|
else
|
||||||
{
|
{
|
||||||
RightCS++;
|
RightCS++;
|
||||||
Angle = -Bissth2*5;
|
Angle = Bissth2*5;
|
||||||
dAngle = Angle - Angle_;
|
dAngle = Angle - Angle_;
|
||||||
Angle_ = Angle_;
|
Angle_ = Angle;
|
||||||
bisscErr = 0;
|
bisscErr = 0;
|
||||||
|
|
||||||
bissSpeed = Bissth1 - Bissth1_;
|
bissSpeed = Bissth1 - Bissth1_;
|
||||||
Bissth1_ = Bissth1;
|
Bissth1_ = Bissth1;
|
||||||
}
|
}
|
||||||
BissErr = (BissAll & 0x0000000008000000) >> 27;
|
BissErr = (BissAll >> (ANGLESUMM_SHIFT-1)) & 1;
|
||||||
BissWarn = (BissAll & 0x0000000004000000) >> 26;
|
BissWarn = (BissAll >> (ANGLESUMM_SHIFT-2)) & 1;
|
||||||
|
|
||||||
|
// BissErr = (BissAll & 0x0000000008000000) >> 27;
|
||||||
|
// BissWarn = (BissAll & 0x0000000004000000) >> 26;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -10,7 +10,7 @@
|
|||||||
#include "SyncPWMFonRun.h"
|
#include "SyncPWMFonRun.h"
|
||||||
|
|
||||||
#define LSPCLK_HZ 100000000.0
|
#define LSPCLK_HZ 100000000.0
|
||||||
#define BAUD 115200.0
|
#define BAUD 57600.0
|
||||||
#define BRR LSPCLK_HZ/(BAUD*8)
|
#define BRR LSPCLK_HZ/(BAUD*8)
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@ -13,10 +13,10 @@
|
|||||||
#define BAUD 4000000.0
|
#define BAUD 4000000.0
|
||||||
#define BRR LSPCLK_HZ/(BAUD*8)
|
#define BRR LSPCLK_HZ/(BAUD*8)
|
||||||
|
|
||||||
//uint16_t AdcaResult0_[4096];
|
uint16_t AdcaResult0_[1024];
|
||||||
//uint16_t AdcaResult1_[4096];
|
//uint16_t AdcaResult1_[4096];
|
||||||
|
|
||||||
//#pragma DATA_SECTION(AdcaResult0_,"ADC_RegsFile0");
|
#pragma DATA_SECTION(AdcaResult0_,"ADC_RegsFile0");
|
||||||
//#pragma DATA_SECTION(AdcaResult1_,"ADC_RegsFile1");
|
//#pragma DATA_SECTION(AdcaResult1_,"ADC_RegsFile1");
|
||||||
|
|
||||||
uint16_t N = 0;
|
uint16_t N = 0;
|
||||||
@ -24,7 +24,7 @@ uint16_t N = 0;
|
|||||||
|
|
||||||
__interrupt void Uart_ISR(void)
|
__interrupt void Uart_ISR(void)
|
||||||
{
|
{
|
||||||
// if(N < 4096) {AdcaResult0_[N] = SciaRegs.SCIRXBUF.all; N++;}
|
if(N < 4096) {AdcaResult0_[N] = SciaRegs.SCIRXBUF.all; N++;}
|
||||||
PieCtrlRegs.PIEACK.all = PIEACK_GROUP9;
|
PieCtrlRegs.PIEACK.all = PIEACK_GROUP9;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -82,12 +82,15 @@ void UartInit(void)
|
|||||||
EDIS;
|
EDIS;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
uint16_t UartErr=0;
|
||||||
|
|
||||||
void UartErrorReset(void)
|
void UartErrorReset(void)
|
||||||
{
|
{
|
||||||
if(SciaRegs.SCIRXST.bit.RXERROR)
|
if(SciaRegs.SCIRXST.bit.RXERROR)
|
||||||
{
|
{
|
||||||
EALLOW;
|
EALLOW;
|
||||||
SciaRegs.SCICTL1.bit.SWRESET = 0;
|
SciaRegs.SCICTL1.bit.SWRESET = 0;
|
||||||
|
UartErr++;
|
||||||
EDIS;
|
EDIS;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
|||||||
@ -87,11 +87,45 @@ uint32_t ImpulsHi = 0;
|
|||||||
uint32_t ImpulsLow = 0;
|
uint32_t ImpulsLow = 0;
|
||||||
uint32_t ImpulsStep = 0;
|
uint32_t ImpulsStep = 0;
|
||||||
int16_t AngleOffset = 0xc000, vectorAngle;
|
int16_t AngleOffset = 0xc000, vectorAngle;
|
||||||
|
uint16_t SetAngeOffsetCounterTime[4] = {10000,20000,30000,40000};
|
||||||
|
uint16_t SetAngeOffsetCounter = 0;
|
||||||
|
|
||||||
|
int32_t ThetaL,ThetaH;
|
||||||
|
|
||||||
|
void SetAngeOffset(void)
|
||||||
|
{
|
||||||
|
|
||||||
|
SetAngeOffsetCounter++;
|
||||||
|
if(SetAngeOffsetCounter < SetAngeOffsetCounterTime[0])
|
||||||
|
{
|
||||||
|
vectorSinCos.Angle = 0x4000;
|
||||||
|
}
|
||||||
|
else if(SetAngeOffsetCounter < SetAngeOffsetCounterTime[1])
|
||||||
|
{
|
||||||
|
vectorSinCos.Angle = 0;
|
||||||
|
}
|
||||||
|
else if(SetAngeOffsetCounter == SetAngeOffsetCounterTime[1])
|
||||||
|
{
|
||||||
|
ThetaL = biss_getAngle();
|
||||||
|
}
|
||||||
|
else if(SetAngeOffsetCounter < SetAngeOffsetCounterTime[2])
|
||||||
|
{
|
||||||
|
vectorSinCos.Angle = 0xC000;
|
||||||
|
}
|
||||||
|
else if(SetAngeOffsetCounter < SetAngeOffsetCounterTime[3])
|
||||||
|
{
|
||||||
|
vectorSinCos.Angle = 0;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
ThetaH = biss_getAngle();
|
||||||
|
AngleOffset = (ThetaL + ThetaH)/2;
|
||||||
|
SetAngeOffsetCounter = 0;
|
||||||
|
Mode = OffMode;
|
||||||
|
}
|
||||||
|
CurrLoop.piId.Ref = CurrentRegTuneAmpl;
|
||||||
|
CurrLoop.piIq.Ref = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
void vectorFault(void)
|
void vectorFault(void)
|
||||||
@ -147,6 +181,7 @@ void vectorControl(int16_t CurrentA, int16_t CurrentB, int16_t CurrentC, int16_t
|
|||||||
CurrLoop.piIq.Ref = CurrentRegTuneAmplInpuls;
|
CurrLoop.piIq.Ref = CurrentRegTuneAmplInpuls;
|
||||||
}
|
}
|
||||||
else CurrLoop.piIq.Ref = CurrentRegTuneAmpl;
|
else CurrLoop.piIq.Ref = CurrentRegTuneAmpl;
|
||||||
|
CurrLoop.piId.Ref = 0;
|
||||||
break;
|
break;
|
||||||
case StepModeImpulses:
|
case StepModeImpulses:
|
||||||
PWM_ABC_StartOut();
|
PWM_ABC_StartOut();
|
||||||
@ -155,6 +190,7 @@ void vectorControl(int16_t CurrentA, int16_t CurrentB, int16_t CurrentC, int16_t
|
|||||||
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;
|
||||||
|
CurrLoop.piId.Ref = 0;
|
||||||
break;
|
break;
|
||||||
case StayMode:
|
case StayMode:
|
||||||
PWM_ABC_StartOut();
|
PWM_ABC_StartOut();
|
||||||
@ -166,6 +202,7 @@ void vectorControl(int16_t CurrentA, int16_t CurrentB, int16_t CurrentC, int16_t
|
|||||||
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 = CurrentRegTuneAmpl;
|
||||||
|
CurrLoop.piIq.Ref = 0;
|
||||||
break;
|
break;
|
||||||
case TestPWNMode:
|
case TestPWNMode:
|
||||||
NoLoop = 0;
|
NoLoop = 0;
|
||||||
@ -186,6 +223,10 @@ void vectorControl(int16_t CurrentA, int16_t CurrentB, int16_t CurrentC, int16_t
|
|||||||
CurrLoop.piId.Ref = 0;
|
CurrLoop.piId.Ref = 0;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
case SetAngleOffsetMode:
|
||||||
|
PWM_ABC_StartOut();
|
||||||
|
SetAngeOffset();
|
||||||
|
break;
|
||||||
default:
|
default:
|
||||||
Mode = OffMode;
|
Mode = OffMode;
|
||||||
PWM_ABC_StopAllClose();
|
PWM_ABC_StopAllClose();
|
||||||
|
|||||||
@ -80,14 +80,15 @@ typedef struct
|
|||||||
|
|
||||||
typedef enum
|
typedef enum
|
||||||
{
|
{
|
||||||
OffMode,
|
OffMode,//0
|
||||||
StepMode,
|
StepMode,//1
|
||||||
StepModeImpulses,
|
StepModeImpulses,//2
|
||||||
StayMode,
|
StayMode,//3
|
||||||
CurrentRegTune,
|
CurrentRegTune,//4
|
||||||
TestPWNMode,
|
TestPWNMode,//5
|
||||||
VectorModeU,
|
VectorModeU,//6
|
||||||
VectorModeI
|
VectorModeI,//7
|
||||||
|
SetAngleOffsetMode//8
|
||||||
}TMode;
|
}TMode;
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@ -1,29 +1,55 @@
|
|||||||
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
||||||
<configurations XML_version="1.2" id="configurations_0">
|
<configurations XML_version="1.2" id="configurations_0">
|
||||||
|
|
||||||
|
|
||||||
<configuration XML_version="1.2" id="Texas Instruments XDS100v2 USB Debug Probe_0">
|
<configuration XML_version="1.2" id="Texas Instruments XDS100v2 USB Debug Probe_0">
|
||||||
|
|
||||||
<instance XML_version="1.2" desc="Texas Instruments XDS100v2 USB Debug Probe_0" href="connections/TIXDS100v2_Connection.xml" id="Texas Instruments XDS100v2 USB Debug Probe_0" xml="TIXDS100v2_Connection.xml" xmlpath="connections"/>
|
<instance XML_version="1.2" desc="Texas Instruments XDS100v2 USB Debug Probe_0" href="connections/TIXDS100v2_Connection.xml" id="Texas Instruments XDS100v2 USB Debug Probe_0" xml="TIXDS100v2_Connection.xml" xmlpath="connections"/>
|
||||||
|
|
||||||
<connection XML_version="1.2" id="Texas Instruments XDS100v2 USB Debug Probe_0">
|
<connection XML_version="1.2" id="Texas Instruments XDS100v2 USB Debug Probe_0">
|
||||||
|
|
||||||
<instance XML_version="1.2" href="drivers/tixds100v2icepick_c.xml" id="drivers" xml="tixds100v2icepick_c.xml" xmlpath="drivers"/>
|
<instance XML_version="1.2" href="drivers/tixds100v2icepick_c.xml" id="drivers" xml="tixds100v2icepick_c.xml" xmlpath="drivers"/>
|
||||||
|
|
||||||
<instance XML_version="1.2" href="drivers/tixds100v2c28x.xml" id="drivers" xml="tixds100v2c28x.xml" xmlpath="drivers"/>
|
<instance XML_version="1.2" href="drivers/tixds100v2c28x.xml" id="drivers" xml="tixds100v2c28x.xml" xmlpath="drivers"/>
|
||||||
|
|
||||||
<instance XML_version="1.2" href="drivers/tixds100v2cla2.xml" id="drivers" xml="tixds100v2cla2.xml" xmlpath="drivers"/>
|
<instance XML_version="1.2" href="drivers/tixds100v2cla2.xml" id="drivers" xml="tixds100v2cla2.xml" xmlpath="drivers"/>
|
||||||
|
|
||||||
<instance XML_version="1.2" href="drivers/tixds100v2cs_child.xml" id="drivers" xml="tixds100v2cs_child.xml" xmlpath="drivers"/>
|
<instance XML_version="1.2" href="drivers/tixds100v2cs_child.xml" id="drivers" xml="tixds100v2cs_child.xml" xmlpath="drivers"/>
|
||||||
|
|
||||||
<instance XML_version="1.2" href="drivers/tixds100v2cs_dap.xml" id="drivers" xml="tixds100v2cs_dap.xml" xmlpath="drivers"/>
|
<instance XML_version="1.2" href="drivers/tixds100v2cs_dap.xml" id="drivers" xml="tixds100v2cs_dap.xml" xmlpath="drivers"/>
|
||||||
|
|
||||||
<instance XML_version="1.2" href="drivers/tixds100v2cortexM.xml" id="drivers" xml="tixds100v2cortexM.xml" xmlpath="drivers"/>
|
<instance XML_version="1.2" href="drivers/tixds100v2cortexM.xml" id="drivers" xml="tixds100v2cortexM.xml" xmlpath="drivers"/>
|
||||||
|
|
||||||
<instance XML_version="1.2" href="drivers/tixds510ajsm.xml" id="drivers" xml="tixds510ajsm.xml" xmlpath="drivers"/>
|
<instance XML_version="1.2" href="drivers/tixds510ajsm.xml" id="drivers" xml="tixds510ajsm.xml" xmlpath="drivers"/>
|
||||||
|
|
||||||
<platform XML_version="1.2" id="platform_0">
|
<platform XML_version="1.2" id="platform_0">
|
||||||
|
|
||||||
<instance XML_version="1.2" desc="TMS320F28388D_0" href="devices/f28388d.xml" id="TMS320F28388D_0" xml="f28388d.xml" xmlpath="devices"/>
|
<instance XML_version="1.2" desc="TMS320F28388D_0" href="devices/f28388d.xml" id="TMS320F28388D_0" xml="f28388d.xml" xmlpath="devices"/>
|
||||||
<device HW_revision="1" XML_version="1.2" description="" id="TMS320F28388D_0" partnum="TMS320F28388D">
|
|
||||||
|
<device HW_revision="1" XML_version="1.2" description="" id="TMS320F28388D_0" partnum="TMS320F28388D" simulation="no">
|
||||||
|
|
||||||
<router HW_revision="1.0" XML_version="1.2" description="ICEPick_C router" id="IcePick_C_0" isa="ICEPICK_C">
|
<router HW_revision="1.0" XML_version="1.2" description="ICEPick_C router" id="IcePick_C_0" isa="ICEPICK_C">
|
||||||
|
|
||||||
<subpath id="Subpath_1">
|
<subpath id="Subpath_1">
|
||||||
|
|
||||||
<property Type="numericfield" Value="0x11" desc="Port Number_0" id="Port Number"/>
|
<property Type="numericfield" Value="0x11" desc="Port Number_0" id="Port Number"/>
|
||||||
|
|
||||||
</subpath>
|
</subpath>
|
||||||
|
|
||||||
<subpath id="CM">
|
<subpath id="CM">
|
||||||
|
|
||||||
<property Type="numericfield" Value="0x12" desc="Port Number_1" id="Port Number"/>
|
<property Type="numericfield" Value="0x12" desc="Port Number_1" id="Port Number"/>
|
||||||
|
|
||||||
</subpath>
|
</subpath>
|
||||||
|
|
||||||
</router>
|
</router>
|
||||||
|
|
||||||
</device>
|
</device>
|
||||||
|
|
||||||
</platform>
|
</platform>
|
||||||
|
|
||||||
</connection>
|
</connection>
|
||||||
|
|
||||||
</configuration>
|
</configuration>
|
||||||
|
|
||||||
</configurations>
|
</configurations>
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user