Compare commits
No commits in common. "45beae37403ae19b6b79097b4fb58c7e5b7ed27c" and "affe05dc547214d11b1e2d7a2299d287ed11cfed" have entirely different histories.
45beae3740
...
affe05dc54
@ -5,21 +5,27 @@
|
|||||||
#include "DSP281x_Device.h"
|
#include "DSP281x_Device.h"
|
||||||
#include "global_time.h"
|
#include "global_time.h"
|
||||||
#include "TuneUpPlane.h"
|
#include "TuneUpPlane.h"
|
||||||
|
#include "profile_interrupt.h"
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
int CanTimeOutErrorTR = 0;
|
unsigned int CanTimeOutErrorTR = 0;
|
||||||
|
unsigned int CanBusOffError = 0;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
int enable_can_recive_after_units_box = 0;
|
int enable_can_recive_after_units_box = 0;
|
||||||
int flag_enable_can_from_mpu=0;
|
int flag_enable_can_from_mpu=0;
|
||||||
int flag_enable_can_from_terminal=0;
|
int flag_enable_can_from_terminal=0;
|
||||||
long time_pause_enable_can_from_mpu=0;
|
long time_pause_enable_can_from_mpu=0;
|
||||||
long time_pause_enable_can_from_terminal=0;
|
long time_pause_enable_can_from_terminal=0;
|
||||||
|
int flag_disable_update_modbus_in_can_from_mpu=0;
|
||||||
|
|
||||||
//unsigned long can_base_adr_terminal, can_base_adr_units, can_base_adr_mpu1, can_base_adr_alarm_log;
|
//unsigned long can_base_adr_terminal, can_base_adr_units, can_base_adr_mpu1, can_base_adr_alarm_log;
|
||||||
|
|
||||||
unsigned int enable_profile_led1_can = 1;
|
//unsigned int enable_profile_led1_can = 1;
|
||||||
unsigned int enable_profile_led2_can = 0;
|
//unsigned int enable_profile_led2_can = 0;
|
||||||
|
|
||||||
#pragma DATA_SECTION(cycle,".slow_vars")
|
#pragma DATA_SECTION(cycle,".slow_vars")
|
||||||
CYCLE cycle[UNIT_QUA];
|
CYCLE cycle[UNIT_QUA];
|
||||||
@ -77,7 +83,7 @@ int CAN_count_cycle_input_units[UNIT_QUA_UNITS];
|
|||||||
#pragma DATA_SECTION(CAN_timeout_cicle,".fast_vars")
|
#pragma DATA_SECTION(CAN_timeout_cicle,".fast_vars")
|
||||||
//#pragma DATA_SECTION(CAN_timeout_cicle, ".slow_vars")
|
//#pragma DATA_SECTION(CAN_timeout_cicle, ".slow_vars")
|
||||||
// ñ÷åò÷èê
|
// ñ÷åò÷èê
|
||||||
int CAN_timeout_cicle[UNIT_QUA];
|
unsigned int CAN_timeout_cicle[UNIT_QUA];
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@ -205,7 +211,7 @@ int init_alarm_log_can_boxs(ALARM_LOG_CAN_SETUP *p )
|
|||||||
int c,e;
|
int c,e;
|
||||||
|
|
||||||
e = 0;
|
e = 0;
|
||||||
for (c=0;c<MAX_COUNT_UNITES_TERMINAL;c++)
|
for (c=0;c<MAX_COUNT_UNITES_ALARM_LOG;c++)
|
||||||
{
|
{
|
||||||
if (p->active_box[c])
|
if (p->active_box[c])
|
||||||
{
|
{
|
||||||
@ -404,17 +410,24 @@ void reset_CAN_timeout_cicle(int box)
|
|||||||
#pragma CODE_SECTION(inc_CAN_timeout_cicle, ".fast_run2");
|
#pragma CODE_SECTION(inc_CAN_timeout_cicle, ".fast_run2");
|
||||||
void inc_CAN_timeout_cicle()
|
void inc_CAN_timeout_cicle()
|
||||||
{
|
{
|
||||||
int i;
|
unsigned int i, t_refresh;
|
||||||
|
static unsigned int old_time = 0;
|
||||||
|
|
||||||
|
t_refresh = get_delta_milisec(&old_time, 1);
|
||||||
|
if (t_refresh>1000)
|
||||||
|
t_refresh = 1000;
|
||||||
|
|
||||||
|
|
||||||
for(i = 0; i < UNIT_QUA; i++)
|
for(i = 0; i < UNIT_QUA; i++)
|
||||||
{
|
{
|
||||||
if (CAN_timeout_cicle[i] < MAX_CAN_WAIT_TIMEOUT)
|
if (CAN_timeout_cicle[i] < MAX_CAN_WAIT_TIMEOUT)
|
||||||
{
|
{
|
||||||
CAN_timeout_cicle[i]++;
|
CAN_timeout_cicle[i] += t_refresh;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
CAN_timeout[i] = 1;
|
CAN_timeout[i] = 1;
|
||||||
|
CAN_refresh_cicle[i] = -1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -543,22 +556,44 @@ void InitCan(unsigned long can_base_adr_units, unsigned long can_base_adr_mpu, u
|
|||||||
ECanaShadow.CANBTC.all = ECanaRegs.CANBTC.all;
|
ECanaShadow.CANBTC.all = ECanaRegs.CANBTC.all;
|
||||||
// ECanaShadow.CANBTC.bit.SJWREG = 1;
|
// ECanaShadow.CANBTC.bit.SJWREG = 1;
|
||||||
|
|
||||||
|
#if (CAN_SPEED_BITS==125000)
|
||||||
|
// ECanaShadow.CANBTC.bit.BRPREG = 23;//11;// 47; //59;//49;//4;//9; // (BRPREG + 1) = 10 feeds a 15 MHz CAN clock
|
||||||
|
// ECanaShadow.CANBTC.bit.TSEG1REG = 15;// 15; //5;//7;//14;//10;//7; // Bit time = 15
|
||||||
|
// ECanaShadow.CANBTC.bit.TSEG2REG = 2; // 2; //4;//5;//7;//2;//5 ; // to the CAN module. (150 / 10 = 15)
|
||||||
|
// ECanaShadow.CANBTC.bit.SJWREG=1;
|
||||||
|
ECanaShadow.CANBTC.bit.BRPREG = 63;//29;//11;// 47; //59;//49;//4;//9; // (BRPREG + 1) = 10 feeds a 15 MHz CAN clock
|
||||||
|
ECanaShadow.CANBTC.bit.TSEG1REG = 9;//9;// 15; //5;//7;//14;//10;//7; // Bit time = 15
|
||||||
|
ECanaShadow.CANBTC.bit.TSEG2REG = 3;//4; // 2; //4;//5;//7;//2;//5 ; // to the CAN module. (150 / 10 = 15)
|
||||||
|
ECanaShadow.CANBTC.bit.SJWREG = 3;//3;
|
||||||
|
// ECanaShadow.CANBTC.bit.BRPREG = 31;//29;//11;// 47; //59;//49;//4;//9; // (BRPREG + 1) = 10 feeds a 15 MHz CAN clock
|
||||||
|
// ECanaShadow.CANBTC.bit.TSEG1REG = 6;//9;// 15; //5;//7;//14;//10;//7; // Bit time = 15
|
||||||
|
// ECanaShadow.CANBTC.bit.TSEG2REG = 1;//4; // 2; //4;//5;//7;//2;//5 ; // to the CAN module. (150 / 10 = 15)
|
||||||
|
// ECanaShadow.CANBTC.bit.SJWREG = 1;//3;
|
||||||
|
#else
|
||||||
#if (CAN_SPEED_BITS==250000)
|
#if (CAN_SPEED_BITS==250000)
|
||||||
ECanaShadow.CANBTC.bit.BRPREG = 23;//11;// 47; //59;//49;//4;//9; // (BRPREG + 1) = 10 feeds a 15 MHz CAN clock
|
// ECanaShadow.CANBTC.bit.BRPREG = 23;//11;// 47; //59;//49;//4;//9; // (BRPREG + 1) = 10 feeds a 15 MHz CAN clock
|
||||||
ECanaShadow.CANBTC.bit.TSEG1REG = 15;// 15; //5;//7;//14;//10;//7; // Bit time = 15
|
// ECanaShadow.CANBTC.bit.TSEG1REG = 15;// 15; //5;//7;//14;//10;//7; // Bit time = 15
|
||||||
ECanaShadow.CANBTC.bit.TSEG2REG = 2; // 2; //4;//5;//7;//2;//5 ; // to the CAN module. (150 / 10 = 15)
|
// ECanaShadow.CANBTC.bit.TSEG2REG = 2; // 2; //4;//5;//7;//2;//5 ; // to the CAN module. (150 / 10 = 15)
|
||||||
|
// ECanaShadow.CANBTC.bit.SJWREG = 1;
|
||||||
|
|
||||||
|
|
||||||
|
ECanaShadow.CANBTC.bit.BRPREG = 47;//29;//11;// 47; //59;//49;//4;//9; // (BRPREG + 1) = 10 feeds a 15 MHz CAN clock
|
||||||
|
ECanaShadow.CANBTC.bit.TSEG1REG = 6;//9;// 15; //5;//7;//14;//10;//7; // Bit time = 15
|
||||||
|
ECanaShadow.CANBTC.bit.TSEG2REG = 1;//4; // 2; //4;//5;//7;//2;//5 ; // to the CAN module. (150 / 10 = 15)
|
||||||
|
ECanaShadow.CANBTC.bit.SJWREG = 1;//3;
|
||||||
#else
|
#else
|
||||||
#if (CAN_SPEED_BITS==500000)
|
#if (CAN_SPEED_BITS==500000)
|
||||||
ECanaShadow.CANBTC.bit.BRPREG = 14;//11;//23;//11;// 47; //59;//49;//4;//9; // (BRPREG + 1) = 10 feeds a 15 MHz CAN clock
|
ECanaShadow.CANBTC.bit.BRPREG = 14;//11;//23;//11;// 47; //59;//49;//4;//9; // (BRPREG + 1) = 10 feeds a 15 MHz CAN clock
|
||||||
ECanaShadow.CANBTC.bit.TSEG1REG = 11;//12;//15;// 15; //5;//7;//14;//10;//7; // Bit time = 15
|
ECanaShadow.CANBTC.bit.TSEG1REG = 11;//12;//15;// 15; //5;//7;//14;//10;//7; // Bit time = 15
|
||||||
ECanaShadow.CANBTC.bit.TSEG2REG = 2; // 2; //4;//5;//7;//2;//5 ; // to the CAN module. (150 / 10 = 15)
|
ECanaShadow.CANBTC.bit.TSEG2REG = 2; // 2; //4;//5;//7;//2;//5 ; // to the CAN module. (150 / 10 = 15)
|
||||||
|
ECanaShadow.CANBTC.bit.SJWREG=1;
|
||||||
#else
|
#else
|
||||||
#error "Set Can speed in CAN_project.h!!!"
|
#error "Set Can speed in CAN_project.h!!!"
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
#endif
|
#endif
|
||||||
ECanaShadow.CANBTC.bit.SJWREG=1;
|
#endif
|
||||||
|
|
||||||
ECanaRegs.CANBTC.all = ECanaShadow.CANBTC.all;
|
ECanaRegs.CANBTC.all = ECanaShadow.CANBTC.all;
|
||||||
|
|
||||||
ECanaShadow.CANMC.all = ECanaRegs.CANMC.all;
|
ECanaShadow.CANMC.all = ECanaRegs.CANMC.all;
|
||||||
@ -598,18 +633,18 @@ void InitCan(unsigned long can_base_adr_units, unsigned long can_base_adr_mpu, u
|
|||||||
PieVectTable.ECAN0INTA = &CAN_handler;
|
PieVectTable.ECAN0INTA = &CAN_handler;
|
||||||
PieCtrlRegs.PIEIER9.bit.INTx5=1; // PIE Group 9, INT6
|
PieCtrlRegs.PIEIER9.bit.INTx5=1; // PIE Group 9, INT6
|
||||||
|
|
||||||
ECanaShadow.CANGIM.bit.AAIM=1;
|
ECanaShadow.CANGIM.bit.AAIM=1; //Abort Acknowledge Interrupt Mask.
|
||||||
ECanaShadow.CANGIM.bit.BOIM=1;
|
ECanaShadow.CANGIM.bit.BOIM=1; // Bus-off interrupt mask
|
||||||
ECanaShadow.CANGIM.bit.EPIM=1;
|
ECanaShadow.CANGIM.bit.EPIM=1; // Error-passive interrupt mask
|
||||||
ECanaShadow.CANGIM.bit.RMLIM=1;
|
ECanaShadow.CANGIM.bit.RMLIM=1; // Received-message-lost interrupt mask
|
||||||
ECanaShadow.CANGIM.bit.WUIM=1;
|
ECanaShadow.CANGIM.bit.WUIM=1; // Wake-up interrupt mask
|
||||||
ECanaShadow.CANGIM.bit.WLIM=1;
|
ECanaShadow.CANGIM.bit.WLIM=1; // Warning level interrupt mask
|
||||||
ECanaShadow.CANGIM.bit.WDIM=1;
|
ECanaShadow.CANGIM.bit.WDIM=1; // Write denied interrupt mask
|
||||||
ECanaShadow.CANGIM.bit.TCOM=1;
|
ECanaShadow.CANGIM.bit.TCOM=1; // Time stamp counter overflow mask
|
||||||
|
|
||||||
ECanaShadow.CANGIM.bit.MTOM = 1;
|
ECanaShadow.CANGIM.bit.MTOM = 1; //Mailbox time-out interrupt mask
|
||||||
ECanaShadow.CANGIM.bit.I1EN = 1;
|
ECanaShadow.CANGIM.bit.I1EN = 1; //Interrupt 1 enable
|
||||||
ECanaShadow.CANGIM.bit.GIL = 1;
|
ECanaShadow.CANGIM.bit.GIL = 1; // Global interrupt level for the interrupts TCOF, WDIF, WUIF, BOIF, EPIF, RMLIF, AAIF and WLIF.
|
||||||
ECanaRegs.CANGIM.all = ECanaShadow.CANGIM.all;
|
ECanaRegs.CANGIM.all = ECanaShadow.CANGIM.all;
|
||||||
|
|
||||||
PieVectTable.ECAN1INTA = &CAN_reset_err;
|
PieVectTable.ECAN1INTA = &CAN_reset_err;
|
||||||
@ -638,14 +673,14 @@ void InitCan(unsigned long can_base_adr_units, unsigned long can_base_adr_mpu, u
|
|||||||
for(i=0;i<UNIT_QUA;i++)
|
for(i=0;i<UNIT_QUA;i++)
|
||||||
{
|
{
|
||||||
CAN_timeout[i]=1;
|
CAN_timeout[i]=1;
|
||||||
CAN_timeout_cicle[i]=0;
|
CAN_timeout_cicle[i] = MAX_CAN_WAIT_TIMEOUT;
|
||||||
CAN_refresh_cicle[i]=0;
|
CAN_refresh_cicle[i] = -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
for(i=0;i<UNIT_QUA_UNITS;i++)
|
for(i=0;i<UNIT_QUA_UNITS;i++)
|
||||||
{
|
{
|
||||||
CAN_count_cycle_input_units[i]=0;
|
CAN_count_cycle_input_units[i] = 0;
|
||||||
for(c=0;c<UNIT_LEN;c++)
|
for(c=0;c<UNIT_LEN;c++)
|
||||||
Unites[i][c]=0;
|
Unites[i][c]=0;
|
||||||
}
|
}
|
||||||
@ -655,7 +690,7 @@ void InitCan(unsigned long can_base_adr_units, unsigned long can_base_adr_mpu, u
|
|||||||
{
|
{
|
||||||
// CAN_count_cycle_input_units[i]=0;
|
// CAN_count_cycle_input_units[i]=0;
|
||||||
for(c=0;c<TERMINAL_UNIT_LEN;c++)
|
for(c=0;c<TERMINAL_UNIT_LEN;c++)
|
||||||
TerminalUnites[i][c]=0;
|
TerminalUnites[i][c] = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -1286,7 +1321,7 @@ void CAN_cycle_send(int type_box, int box, unsigned long Addr, int * Data, unsig
|
|||||||
|
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////
|
||||||
// èíêðåìåí ñ÷åò÷èêà ïîëíûõ ïîñûëîê
|
// èíêðåìåí ñ÷åò÷èêà ïîëíûõ ïîñûëîê äëÿ ÓÊÑÑ
|
||||||
////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////
|
||||||
void detect_time_refresh_units(int box, int adr)
|
void detect_time_refresh_units(int box, int adr)
|
||||||
{
|
{
|
||||||
@ -1294,10 +1329,30 @@ void detect_time_refresh_units(int box, int adr)
|
|||||||
return;
|
return;
|
||||||
|
|
||||||
if (adr==unites_can_setup.adr_detect_refresh[box])
|
if (adr==unites_can_setup.adr_detect_refresh[box])
|
||||||
CAN_count_cycle_input_units[box]++;
|
{
|
||||||
|
//CAN_count_cycle_input_units[box]++;
|
||||||
|
if (box<MAX_COUNT_UNITES_UKSS)
|
||||||
|
unites_can_setup.CAN_count_cycle_input_units[box]++;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
////////////////////////////////////////////////////////////////
|
||||||
|
// èíêðåìåí ñ÷åò÷èêà ïîëíûõ ïîñûëîê äëÿ ÌÏÓ
|
||||||
|
////////////////////////////////////////////////////////////////
|
||||||
|
void detect_time_refresh_mpu(int box, int adr)
|
||||||
|
{
|
||||||
|
if (box>=MPU_UNIT_QUA_UNITS)
|
||||||
|
return;
|
||||||
|
|
||||||
|
if (adr==mpu_can_setup.adr_detect_refresh[box])
|
||||||
|
{
|
||||||
|
//CAN_count_cycle_input_units[box]++;
|
||||||
|
if (box<MAX_COUNT_UNITES_MPU)
|
||||||
|
mpu_can_setup.CAN_count_cycle_input_units[box]++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////
|
||||||
////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////
|
||||||
void messagePaserToUnitesIngitim(int box, unsigned long h_word, unsigned long l_word)
|
void messagePaserToUnitesIngitim(int box, unsigned long h_word, unsigned long l_word)
|
||||||
@ -1399,9 +1454,11 @@ void parse_data_from_mbox(unsigned int box, unsigned long hiword,
|
|||||||
timer_pause_enable_can_from_mpu();
|
timer_pause_enable_can_from_mpu();
|
||||||
if (adr<SIZE_MODBUS_TABLE)
|
if (adr<SIZE_MODBUS_TABLE)
|
||||||
{
|
{
|
||||||
if ((adr>0) && flag_enable_can_from_mpu)
|
if (adr>0)
|
||||||
{
|
{
|
||||||
|
if (flag_enable_can_from_mpu && flag_disable_update_modbus_in_can_from_mpu==0)
|
||||||
modbus_table_can_in[adr-1].all = /*(unsigned int)*/((hiword ) & 0xffff);
|
modbus_table_can_in[adr-1].all = /*(unsigned int)*/((hiword ) & 0xffff);
|
||||||
|
detect_time_refresh_mpu(local_number_box,adr-1);
|
||||||
}
|
}
|
||||||
adr++;
|
adr++;
|
||||||
}
|
}
|
||||||
@ -1415,9 +1472,11 @@ void parse_data_from_mbox(unsigned int box, unsigned long hiword,
|
|||||||
timer_pause_enable_can_from_mpu();
|
timer_pause_enable_can_from_mpu();
|
||||||
if (adr<SIZE_MODBUS_TABLE)
|
if (adr<SIZE_MODBUS_TABLE)
|
||||||
{
|
{
|
||||||
if ((adr>0) && flag_enable_can_from_mpu)
|
if (adr>0)
|
||||||
{
|
{
|
||||||
|
if (flag_enable_can_from_mpu && flag_disable_update_modbus_in_can_from_mpu==0)
|
||||||
modbus_table_can_in[adr-1].all = /*(unsigned int)*/((loword>>16) & 0xffff);
|
modbus_table_can_in[adr-1].all = /*(unsigned int)*/((loword>>16) & 0xffff);
|
||||||
|
detect_time_refresh_mpu(local_number_box,adr-1);
|
||||||
}
|
}
|
||||||
adr++;
|
adr++;
|
||||||
}
|
}
|
||||||
@ -1432,9 +1491,11 @@ void parse_data_from_mbox(unsigned int box, unsigned long hiword,
|
|||||||
timer_pause_enable_can_from_mpu();
|
timer_pause_enable_can_from_mpu();
|
||||||
if (adr<SIZE_MODBUS_TABLE)
|
if (adr<SIZE_MODBUS_TABLE)
|
||||||
{
|
{
|
||||||
if ((adr>0) && flag_enable_can_from_mpu)
|
if (adr>0)
|
||||||
{
|
{
|
||||||
|
if (flag_enable_can_from_mpu && flag_disable_update_modbus_in_can_from_mpu==0)
|
||||||
modbus_table_can_in[adr-1].all = /*(unsigned int)*/((loword) & 0xffff);
|
modbus_table_can_in[adr-1].all = /*(unsigned int)*/((loword) & 0xffff);
|
||||||
|
detect_time_refresh_mpu(local_number_box,adr-1);
|
||||||
}
|
}
|
||||||
adr++;
|
adr++;
|
||||||
}
|
}
|
||||||
@ -1564,11 +1625,11 @@ interrupt void CAN_handler(void)
|
|||||||
PieCtrlRegs.PIEACK.all = 0xFFFF; // Enable PIE interrupts
|
PieCtrlRegs.PIEACK.all = 0xFFFF; // Enable PIE interrupts
|
||||||
|
|
||||||
#if (_ENABLE_INTERRUPT_PROFILE_LED1)
|
#if (_ENABLE_INTERRUPT_PROFILE_LED1)
|
||||||
if (enable_profile_led1_can)
|
if (profile_interrupt.for_led1.bits.can)
|
||||||
i_led1_on_off_special(1);
|
i_led1_on_off_special(1);
|
||||||
#endif
|
#endif
|
||||||
#if (_ENABLE_INTERRUPT_PROFILE_LED2)
|
#if (_ENABLE_INTERRUPT_PROFILE_LED2)
|
||||||
if (enable_profile_led2_can)
|
if (profile_interrupt.for_led2.bits.can)
|
||||||
i_led2_on_off_special(1);
|
i_led2_on_off_special(1);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
@ -1694,11 +1755,11 @@ interrupt void CAN_handler(void)
|
|||||||
PieCtrlRegs.PIEIER9.all = TempPIEIER;
|
PieCtrlRegs.PIEIER9.all = TempPIEIER;
|
||||||
|
|
||||||
#if (_ENABLE_INTERRUPT_PROFILE_LED1)
|
#if (_ENABLE_INTERRUPT_PROFILE_LED1)
|
||||||
if (enable_profile_led1_can)
|
if (profile_interrupt.for_led1.bits.can)
|
||||||
i_led1_on_off_special(0);
|
i_led1_on_off_special(0);
|
||||||
#endif
|
#endif
|
||||||
#if (_ENABLE_INTERRUPT_PROFILE_LED2)
|
#if (_ENABLE_INTERRUPT_PROFILE_LED2)
|
||||||
if (enable_profile_led2_can)
|
if (profile_interrupt.for_led2.bits.can)
|
||||||
i_led2_on_off_special(0);
|
i_led2_on_off_special(0);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
@ -1719,25 +1780,47 @@ interrupt void CAN_reset_err(void)
|
|||||||
|
|
||||||
|
|
||||||
#if (_ENABLE_INTERRUPT_PROFILE_LED1)
|
#if (_ENABLE_INTERRUPT_PROFILE_LED1)
|
||||||
if (enable_profile_led1_can)
|
if (profile_interrupt.for_led1.bits.can)
|
||||||
i_led1_on_off_special(1);
|
i_led1_on_off_special(1);
|
||||||
#endif
|
#endif
|
||||||
#if (_ENABLE_INTERRUPT_PROFILE_LED2)
|
#if (_ENABLE_INTERRUPT_PROFILE_LED2)
|
||||||
if (enable_profile_led2_can)
|
if (profile_interrupt.for_led2.bits.can)
|
||||||
i_led2_on_off_special(1);
|
i_led2_on_off_special(1);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
EINT;
|
EINT;
|
||||||
|
|
||||||
if (ECanaRegs.CANGIF1.bit.AAIF1)
|
|
||||||
|
// ECanaShadow.CANGIM.bit.AAIM=1; //Abort Acknowledge Interrupt Mask.
|
||||||
|
// ECanaShadow.CANGIM.bit.BOIM=1; // Bus-off interrupt mask
|
||||||
|
// ECanaShadow.CANGIM.bit.EPIM=1; // Error-passive interrupt mask
|
||||||
|
// ECanaShadow.CANGIM.bit.RMLIM=1; // Received-message-lost interrupt mask
|
||||||
|
// ECanaShadow.CANGIM.bit.WUIM=1; // Wake-up interrupt mask
|
||||||
|
// ECanaShadow.CANGIM.bit.WLIM=1; // Warning level interrupt mask
|
||||||
|
// ECanaShadow.CANGIM.bit.WDIM=1; // Write denied interrupt mask
|
||||||
|
// ECanaShadow.CANGIM.bit.TCOM=1; // Time stamp counter overflow mask
|
||||||
|
//
|
||||||
|
// ECanaShadow.CANGIM.bit.MTOM = 1; //Mailbox time-out interrupt mask
|
||||||
|
|
||||||
|
|
||||||
|
if (ECanaRegs.CANGIF1.bit.AAIF1) // Abort-acknowledge interrupt flag
|
||||||
{
|
{
|
||||||
ECanaRegs.CANAA.all = ECanaRegs.CANAA.all;
|
ECanaRegs.CANAA.all = ECanaRegs.CANAA.all;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (ECanaRegs.CANGIF1.bit.WDIF1)
|
if (ECanaRegs.CANGIF1.bit.WDIF1) //Write-denied interrupt flag
|
||||||
{
|
{
|
||||||
ECanaRegs.CANGIF1.bit.WDIF1=1;
|
ECanaRegs.CANGIF1.bit.WDIF1=1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (ECanaRegs.CANGIF1.bit.BOIF1) // Bus off interrupt flag
|
||||||
|
{
|
||||||
|
ECanaRegs.CANGIF1.bit.BOIF1=1;
|
||||||
|
CanBusOffError++;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// ECanaRegs.CANTRR.all = 1;
|
// ECanaRegs.CANTRR.all = 1;
|
||||||
CanTimeOutErrorTR++;
|
CanTimeOutErrorTR++;
|
||||||
|
|
||||||
@ -1750,11 +1833,11 @@ interrupt void CAN_reset_err(void)
|
|||||||
|
|
||||||
|
|
||||||
#if (_ENABLE_INTERRUPT_PROFILE_LED1)
|
#if (_ENABLE_INTERRUPT_PROFILE_LED1)
|
||||||
if (enable_profile_led1_can)
|
if (profile_interrupt.for_led1.bits.can)
|
||||||
i_led1_on_off_special(0);
|
i_led1_on_off_special(0);
|
||||||
#endif
|
#endif
|
||||||
#if (_ENABLE_INTERRUPT_PROFILE_LED2)
|
#if (_ENABLE_INTERRUPT_PROFILE_LED2)
|
||||||
if (enable_profile_led2_can)
|
if (profile_interrupt.for_led2.bits.can)
|
||||||
i_led2_on_off_special(0);
|
i_led2_on_off_special(0);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
@ -1805,6 +1888,311 @@ unsigned int test_can_live_terminal(int n)
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
void InitCanSoft(void)
|
||||||
|
{
|
||||||
|
struct ECAN_REGS ECanaShadow;
|
||||||
|
int i, c;
|
||||||
|
volatile struct MBOX *tmbox;
|
||||||
|
volatile Uint32 *tmoto;
|
||||||
|
|
||||||
|
unsigned long canme_bits = 0;
|
||||||
|
unsigned long canmd_bits = 0;
|
||||||
|
unsigned long canmim_bits = 0;
|
||||||
|
|
||||||
|
|
||||||
|
// Configure CAN pins using GPIO regs here
|
||||||
|
EALLOW;
|
||||||
|
|
||||||
|
// GpioMuxRegs.GPFMUX.bit.CANTXA_GPIOF6 = 1;
|
||||||
|
// GpioMuxRegs.GPFMUX.bit.CANRXA_GPIOF7 = 1;
|
||||||
|
|
||||||
|
// Configure the eCAN RX and TX pins for eCAN transmissions
|
||||||
|
// ECanaRegs.CANTIOC.all = 8; // only 3rd bit, TXFUNC, is significant
|
||||||
|
// ECanaRegs.CANRIOC.all = 8; // only 3rd bit, RXFUNC, is significant
|
||||||
|
|
||||||
|
|
||||||
|
// Specify that 8 bits will be sent/received
|
||||||
|
// for (c=0;c<32;c++)
|
||||||
|
// {
|
||||||
|
// tmbox = &ECanaMboxes.MBOX0 + c;
|
||||||
|
// tmbox->MSGCTRL.all = 0x00000008;
|
||||||
|
// }
|
||||||
|
|
||||||
|
// Disable all Mailboxes
|
||||||
|
// Required before writing the MSGIDs
|
||||||
|
// ECanaRegs.CANME.all = 0;
|
||||||
|
|
||||||
|
canme_bits = 0;
|
||||||
|
canmd_bits = 0;
|
||||||
|
canmim_bits = 0;
|
||||||
|
|
||||||
|
// receive+transive //Ura
|
||||||
|
for (c=0;c<32;c++)
|
||||||
|
{
|
||||||
|
|
||||||
|
if (mailboxs_can_setup.can_mbox_adr[c])
|
||||||
|
{
|
||||||
|
// tmbox = &ECanaMboxes.MBOX0 + c;
|
||||||
|
// if(mailboxs_can_setup.type_box[c] == UNITS_TYPE_BOX)
|
||||||
|
// {
|
||||||
|
//// tmbox->MSGID.bit.IDE = 0;
|
||||||
|
//// tmbox->MSGID.bit.STDMSGID = mailboxs_can_setup.can_mbox_adr[c];
|
||||||
|
// tmbox->MSGID.all = mailboxs_can_setup.can_mbox_adr[c];
|
||||||
|
// }
|
||||||
|
// else
|
||||||
|
// {
|
||||||
|
// if(mailboxs_can_setup.type_box[c] == CANOPEN_TYPE_BOX)
|
||||||
|
// {
|
||||||
|
// tmbox->MSGID.bit.IDE = 0;
|
||||||
|
// tmbox->MSGID.bit.STDMSGID = mailboxs_can_setup.can_mbox_adr[c];
|
||||||
|
// //tmbox->MSGID.all = mailboxs_can_setup.can_mbox_adr[c];
|
||||||
|
// }
|
||||||
|
// else
|
||||||
|
// tmbox->MSGID.all = mailboxs_can_setup.can_mbox_adr[c];
|
||||||
|
// }
|
||||||
|
|
||||||
|
canme_bits |= ((unsigned long)1<<c); // set select box bits
|
||||||
|
canmim_bits |= ((unsigned long)1<<c); // set interrupt bits
|
||||||
|
|
||||||
|
if (mailboxs_can_setup.type_in_out_box[c] == CAN_BOX_TYPE_IN)
|
||||||
|
{
|
||||||
|
canmd_bits |= ((unsigned long)1<<c); // set receive bits
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
if (mailboxs_can_setup.type_in_out_box[c] == CAN_BOX_TYPE_OUT)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// Ðåæèì ðàáîòû þùèêîâ (ïðè¸ì-ïåðåäà÷à)
|
||||||
|
// ECanaRegs.CANMD.all = canmd_bits;//0x0000FFFF;
|
||||||
|
// Âûáèðàåì þùèêè äëó ðàáîòû
|
||||||
|
// ECanaRegs.CANME.all = canme_bits;
|
||||||
|
|
||||||
|
// Clear all TAn bits
|
||||||
|
ECanaRegs.CANTA.all = 0xFFFFFFFF;
|
||||||
|
// Clear all RMPn bits
|
||||||
|
ECanaRegs.CANRMP.all = 0xFFFFFFFF;
|
||||||
|
// Clear all interrupt flag bits
|
||||||
|
ECanaRegs.CANGIF0.all = 0xFFFFFFFF;
|
||||||
|
ECanaRegs.CANGIF1.all = 0xFFFFFFFF;
|
||||||
|
// Clear all error and status bits
|
||||||
|
ECanaRegs.CANES.all=0xffffffff;
|
||||||
|
|
||||||
|
ECanaRegs.CANMIM.all = 0xFFFFFFFF;
|
||||||
|
|
||||||
|
// Request permission to change the configuration registers
|
||||||
|
ECanaShadow.CANMC.all = ECanaRegs.CANMC.all;
|
||||||
|
ECanaShadow.CANMC.all = 0;
|
||||||
|
ECanaShadow.CANMC.bit.MBCC = 1; // Mailbox timestamp counter clear bit
|
||||||
|
ECanaShadow.CANMC.bit.TCC = 1; // Time stamp counter MSB clear bit
|
||||||
|
ECanaShadow.CANMC.bit.SCB = 1; // eCAN mode (reqd to access 32 mailboxes)
|
||||||
|
ECanaShadow.CANMC.bit.WUBA = 1; // Wake up on bus activity
|
||||||
|
ECanaShadow.CANMC.bit.ABO = 1; // Auto bus on
|
||||||
|
ECanaShadow.CANMC.bit.CCR = 1;
|
||||||
|
// ECanaShadow.CANMC.bit.CCE = 0;
|
||||||
|
|
||||||
|
// ECanaShadow.CANMC.bit.STM = 1; // self-test loop-back
|
||||||
|
ECanaRegs.CANMC.all = ECanaShadow.CANMC.all;
|
||||||
|
EDIS;
|
||||||
|
|
||||||
|
|
||||||
|
do
|
||||||
|
{
|
||||||
|
ECanaShadow.CANES.all = ECanaRegs.CANES.all;
|
||||||
|
} while(ECanaShadow.CANES.bit.CCE != 1 ); // Wait for CCE bit to be set..
|
||||||
|
// while(!ECanaRegs.CANES.bit.CCE);
|
||||||
|
|
||||||
|
|
||||||
|
// íàñòðèâàåì ñêîðîñòü CAN
|
||||||
|
EALLOW;
|
||||||
|
/*
|
||||||
|
EALLOW;
|
||||||
|
ECanaShadow.CANBTC.all = ECanaRegs.CANBTC.all;
|
||||||
|
|
||||||
|
#if (CAN_SPEED_BITS==125000)
|
||||||
|
// ECanaShadow.CANBTC.bit.BRPREG = 23;//11;// 47; //59;//49;//4;//9; // (BRPREG + 1) = 10 feeds a 15 MHz CAN clock
|
||||||
|
// ECanaShadow.CANBTC.bit.TSEG1REG = 15;// 15; //5;//7;//14;//10;//7; // Bit time = 15
|
||||||
|
// ECanaShadow.CANBTC.bit.TSEG2REG = 2; // 2; //4;//5;//7;//2;//5 ; // to the CAN module. (150 / 10 = 15)
|
||||||
|
// ECanaShadow.CANBTC.bit.SJWREG=1;
|
||||||
|
ECanaShadow.CANBTC.bit.BRPREG = 63;//29;//11;// 47; //59;//49;//4;//9; // (BRPREG + 1) = 10 feeds a 15 MHz CAN clock
|
||||||
|
ECanaShadow.CANBTC.bit.TSEG1REG = 9;//9;// 15; //5;//7;//14;//10;//7; // Bit time = 15
|
||||||
|
ECanaShadow.CANBTC.bit.TSEG2REG = 3;//4; // 2; //4;//5;//7;//2;//5 ; // to the CAN module. (150 / 10 = 15)
|
||||||
|
ECanaShadow.CANBTC.bit.SJWREG = 3;//3;
|
||||||
|
#else
|
||||||
|
#if (CAN_SPEED_BITS==250000)
|
||||||
|
// ECanaShadow.CANBTC.bit.BRPREG = 23;//11;// 47; //59;//49;//4;//9; // (BRPREG + 1) = 10 feeds a 15 MHz CAN clock
|
||||||
|
// ECanaShadow.CANBTC.bit.TSEG1REG = 15;// 15; //5;//7;//14;//10;//7; // Bit time = 15
|
||||||
|
// ECanaShadow.CANBTC.bit.TSEG2REG = 2; // 2; //4;//5;//7;//2;//5 ; // to the CAN module. (150 / 10 = 15)
|
||||||
|
// ECanaShadow.CANBTC.bit.SJWREG = 1;
|
||||||
|
|
||||||
|
|
||||||
|
ECanaShadow.CANBTC.bit.BRPREG = 47;//29;//11;// 47; //59;//49;//4;//9; // (BRPREG + 1) = 10 feeds a 15 MHz CAN clock
|
||||||
|
ECanaShadow.CANBTC.bit.TSEG1REG = 6;//9;// 15; //5;//7;//14;//10;//7; // Bit time = 15
|
||||||
|
ECanaShadow.CANBTC.bit.TSEG2REG = 1;//4; // 2; //4;//5;//7;//2;//5 ; // to the CAN module. (150 / 10 = 15)
|
||||||
|
ECanaShadow.CANBTC.bit.SJWREG = 1;//3;
|
||||||
|
#else
|
||||||
|
#if (CAN_SPEED_BITS==500000)
|
||||||
|
ECanaShadow.CANBTC.bit.BRPREG = 14;//11;//23;//11;// 47; //59;//49;//4;//9; // (BRPREG + 1) = 10 feeds a 15 MHz CAN clock
|
||||||
|
ECanaShadow.CANBTC.bit.TSEG1REG = 11;//12;//15;// 15; //5;//7;//14;//10;//7; // Bit time = 15
|
||||||
|
ECanaShadow.CANBTC.bit.TSEG2REG = 2; // 2; //4;//5;//7;//2;//5 ; // to the CAN module. (150 / 10 = 15)
|
||||||
|
ECanaShadow.CANBTC.bit.SJWREG=1;
|
||||||
|
#else
|
||||||
|
#error "Set Can speed in CAN_project.h!!!"
|
||||||
|
|
||||||
|
#endif
|
||||||
|
#endif
|
||||||
|
#endif
|
||||||
|
|
||||||
|
ECanaRegs.CANBTC.all = ECanaShadow.CANBTC.all;
|
||||||
|
*/
|
||||||
|
ECanaShadow.CANMC.all = ECanaRegs.CANMC.all;
|
||||||
|
ECanaShadow.CANMC.bit.CCR = 0; // Set CCR = 0
|
||||||
|
ECanaRegs.CANMC.all = ECanaShadow.CANMC.all;
|
||||||
|
EDIS;
|
||||||
|
|
||||||
|
|
||||||
|
// Wait until the CPU no longer has permission to change the
|
||||||
|
// configuration registers
|
||||||
|
do
|
||||||
|
{
|
||||||
|
ECanaShadow.CANES.all = ECanaRegs.CANES.all;
|
||||||
|
} while(ECanaShadow.CANES.bit.CCE != 0 );
|
||||||
|
|
||||||
|
// while(ECanaRegs.CANES.bit.CCE); // Wait for CCE bit to be cleared..
|
||||||
|
|
||||||
|
EALLOW;
|
||||||
|
// çàäàåì òàéìàóòû äëà îæèäàíèà îòïðàâêè ïîëó÷åíèà ïîñûëêè
|
||||||
|
for (c=0;c<32;c++)
|
||||||
|
{
|
||||||
|
tmoto = &ECanaMOTORegs.MOTO0 + c;
|
||||||
|
(*(volatile Uint32 *)( tmoto )) = 550000;
|
||||||
|
}
|
||||||
|
|
||||||
|
ECanaRegs.CANTOC.all = 0;//0x000000ff;
|
||||||
|
ECanaRegs.CANTOS.all = 0; // clear all time-out flags
|
||||||
|
ECanaRegs.CANTSC = 0; // clear time-out counter
|
||||||
|
|
||||||
|
ECanaShadow.CANGIM.all = 0;
|
||||||
|
|
||||||
|
|
||||||
|
ECanaRegs.CANMIM.all = canmim_bits; // 26.01.2011 Dimas
|
||||||
|
ECanaRegs.CANMIL.all = 0x00000000; // All mailbox interrupts are generated on interrupt line 0.
|
||||||
|
ECanaShadow.CANGIM.bit.I0EN = 1;
|
||||||
|
|
||||||
|
// PieVectTable.ECAN0INTA = &CAN_handler;
|
||||||
|
PieCtrlRegs.PIEIER9.bit.INTx5=1; // PIE Group 9, INT6
|
||||||
|
|
||||||
|
ECanaShadow.CANGIM.bit.AAIM=1; //Abort Acknowledge Interrupt Mask.
|
||||||
|
ECanaShadow.CANGIM.bit.BOIM=1; // Bus-off interrupt mask
|
||||||
|
ECanaShadow.CANGIM.bit.EPIM=1; // Error-passive interrupt mask
|
||||||
|
ECanaShadow.CANGIM.bit.RMLIM=1; // Received-message-lost interrupt mask
|
||||||
|
ECanaShadow.CANGIM.bit.WUIM=1; // Wake-up interrupt mask
|
||||||
|
ECanaShadow.CANGIM.bit.WLIM=1; // Warning level interrupt mask
|
||||||
|
ECanaShadow.CANGIM.bit.WDIM=1; // Write denied interrupt mask
|
||||||
|
ECanaShadow.CANGIM.bit.TCOM=1; // Time stamp counter overflow mask
|
||||||
|
|
||||||
|
ECanaShadow.CANGIM.bit.MTOM = 1; //Mailbox time-out interrupt mask
|
||||||
|
ECanaShadow.CANGIM.bit.I1EN = 1; //Interrupt 1 enable
|
||||||
|
ECanaShadow.CANGIM.bit.GIL = 1; // Global interrupt level for the interrupts TCOF, WDIF, WUIF, BOIF, EPIF, RMLIF, AAIF and WLIF.
|
||||||
|
ECanaRegs.CANGIM.all = ECanaShadow.CANGIM.all;
|
||||||
|
|
||||||
|
// PieVectTable.ECAN1INTA = &CAN_reset_err;
|
||||||
|
PieCtrlRegs.PIEIER9.bit.INTx6=1; // PIE Group 9, INT6
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
// çàâåðøèëè íàñòðîéêó CAN àùèêîâ
|
||||||
|
|
||||||
|
// for(i=0;i<UNIT_QUA;i++)
|
||||||
|
// {
|
||||||
|
// cycle[i].busy = 0;
|
||||||
|
// cycle[i].FLY = 0;
|
||||||
|
// cycle[i].extended = 0;
|
||||||
|
// cycle[i].adr = 0;
|
||||||
|
// cycle[i].adr_from = 0;
|
||||||
|
// cycle[i].adr_to = 0;
|
||||||
|
// cycle[i].quant = 0;
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// fifo.adr=0;
|
||||||
|
// refo.adr=0;
|
||||||
|
|
||||||
|
CanTimeOutErrorTR=0;
|
||||||
|
|
||||||
|
// for(i=0;i<UNIT_QUA;i++)
|
||||||
|
// {
|
||||||
|
// CAN_timeout[i]=1;
|
||||||
|
// CAN_timeout_cicle[i] = MAX_CAN_WAIT_TIMEOUT;
|
||||||
|
// CAN_refresh_cicle[i] = -1;
|
||||||
|
// }
|
||||||
|
|
||||||
|
|
||||||
|
// for(i=0;i<UNIT_QUA_UNITS;i++)
|
||||||
|
// {
|
||||||
|
// CAN_count_cycle_input_units[i] = 0;
|
||||||
|
// for(c=0;c<UNIT_LEN;c++)
|
||||||
|
// Unites[i][c]=0;
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
//
|
||||||
|
// for(i=0;i<TERMINAL_UNIT_QUA_UNITS;i++)
|
||||||
|
// {
|
||||||
|
// for(c=0;c<TERMINAL_UNIT_LEN;c++)
|
||||||
|
// TerminalUnites[i][c] = 0;
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
// new_cycle_fifo.index_data = 0;
|
||||||
|
// new_cycle_fifo.index_send = 0;
|
||||||
|
// new_cycle_fifo.count_lost = 0;
|
||||||
|
// new_cycle_fifo.count_load = 0;
|
||||||
|
// new_cycle_fifo.count_free = 0;
|
||||||
|
// new_cycle_fifo.flag_inter = 0;
|
||||||
|
//
|
||||||
|
// for(i=0;i<NEW_CYCLE_FIFO_LEN;i++)
|
||||||
|
// {
|
||||||
|
// new_cycle_fifo.cycle_data[i].busy = 0;
|
||||||
|
// new_cycle_fifo.cycle_data[i].FLY = 0;
|
||||||
|
// new_cycle_fifo.cycle_data[i].extended = 0;
|
||||||
|
// new_cycle_fifo.cycle_data[i].adr = 0;
|
||||||
|
// new_cycle_fifo.cycle_data[i].adr_from = 0;
|
||||||
|
// new_cycle_fifo.cycle_data[i].adr_to = 0;
|
||||||
|
// new_cycle_fifo.cycle_data[i].quant = 0;
|
||||||
|
// new_cycle_fifo.cycle_data[i].box = 0;
|
||||||
|
// new_cycle_fifo.cycle_data[i].priority = 0;
|
||||||
|
// new_cycle_fifo.cycle_data[i].quant_block = 0;
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
//
|
||||||
|
// for(i=0;i<UNIT_QUA;i++)
|
||||||
|
// {
|
||||||
|
// new_cycle_fifo.cycle_box[i] = 0;
|
||||||
|
// new_cycle_fifo.lost_box[i] = 0;
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
|
||||||
|
|
||||||
|
//IER |= M_INT9; // Enable CPU INT
|
||||||
|
|
||||||
|
// EDIS;
|
||||||
|
|
||||||
|
enable_can_recive_after_units_box = 1;
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
//===========================================================================
|
//===========================================================================
|
||||||
// No more.
|
// No more.
|
||||||
|
@ -473,6 +473,8 @@ typedef struct {
|
|||||||
int adr_detect_refresh[MAX_COUNT_UNITES_UKSS];
|
int adr_detect_refresh[MAX_COUNT_UNITES_UKSS];
|
||||||
int revers_box[MAX_COUNT_UNITES_UKSS];
|
int revers_box[MAX_COUNT_UNITES_UKSS];
|
||||||
|
|
||||||
|
unsigned int CAN_count_cycle_input_units[MAX_COUNT_UNITES_UKSS];
|
||||||
|
|
||||||
int max_number;
|
int max_number;
|
||||||
|
|
||||||
} UNITES_CAN_SETUP;
|
} UNITES_CAN_SETUP;
|
||||||
@ -490,6 +492,11 @@ typedef struct {
|
|||||||
|
|
||||||
int active_box[MAX_COUNT_UNITES_MPU];
|
int active_box[MAX_COUNT_UNITES_MPU];
|
||||||
|
|
||||||
|
unsigned int CAN_count_cycle_input_units[MAX_COUNT_UNITES_MPU];
|
||||||
|
|
||||||
|
|
||||||
|
int adr_detect_refresh[MAX_COUNT_UNITES_MPU];
|
||||||
|
|
||||||
int max_number;
|
int max_number;
|
||||||
|
|
||||||
} MPU_CAN_SETUP;
|
} MPU_CAN_SETUP;
|
||||||
@ -507,6 +514,8 @@ typedef struct {
|
|||||||
|
|
||||||
int active_box[MAX_COUNT_UNITES_TERMINAL];
|
int active_box[MAX_COUNT_UNITES_TERMINAL];
|
||||||
|
|
||||||
|
unsigned int CAN_count_cycle_input_units[MAX_COUNT_UNITES_TERMINAL];
|
||||||
|
|
||||||
int max_number;
|
int max_number;
|
||||||
|
|
||||||
} TERMINAL_CAN_SETUP;
|
} TERMINAL_CAN_SETUP;
|
||||||
@ -525,52 +534,69 @@ typedef struct {
|
|||||||
|
|
||||||
int active_box[MAX_COUNT_UNITES_ALARM_LOG];
|
int active_box[MAX_COUNT_UNITES_ALARM_LOG];
|
||||||
|
|
||||||
|
unsigned int CAN_count_cycle_input_units[MAX_COUNT_UNITES_ALARM_LOG];
|
||||||
|
|
||||||
int max_number;
|
int max_number;
|
||||||
|
|
||||||
} ALARM_LOG_CAN_SETUP;
|
} ALARM_LOG_CAN_SETUP;
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
#define _UNITS_DEFAULT_ZERO {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}
|
||||||
|
#define _UNITS_DEFAULT_MINUS_ONE {-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1}
|
||||||
|
|
||||||
#define UNITES_CAN_SETUP_DEFAULT { START_CAN_ADR_UNITS_DEFAULT, {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}, \
|
#define UNITES_CAN_SETUP_DEFAULT { START_CAN_ADR_UNITS_DEFAULT, _UNITS_DEFAULT_ZERO, \
|
||||||
{0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}, \
|
_UNITS_DEFAULT_ZERO, \
|
||||||
{-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1}, \
|
_UNITS_DEFAULT_MINUS_ONE, \
|
||||||
{-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1}, \
|
_UNITS_DEFAULT_MINUS_ONE, \
|
||||||
{-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1}, \
|
_UNITS_DEFAULT_MINUS_ONE, \
|
||||||
{USE_UKSS_0,USE_UKSS_1,USE_UKSS_2,USE_UKSS_3,USE_UKSS_4,USE_UKSS_5, \
|
{USE_UKSS_0,USE_UKSS_1,USE_UKSS_2,USE_UKSS_3,USE_UKSS_4,USE_UKSS_5, \
|
||||||
USE_UKSS_6,USE_UKSS_7,USE_UKSS_8,USE_UKSS_9,USE_UKSS_10, \
|
USE_UKSS_6,USE_UKSS_7,USE_UKSS_8,USE_UKSS_9,USE_UKSS_10, \
|
||||||
USE_UKSS_11,USE_UKSS_12,USE_UKSS_13,USE_UKSS_14,USE_UKSS_15}, \
|
USE_UKSS_11,USE_UKSS_12,USE_UKSS_13,USE_UKSS_14,USE_UKSS_15}, \
|
||||||
{0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}, \
|
_UNITS_DEFAULT_ZERO, \
|
||||||
{USE_R_B_0,USE_R_B_1,USE_R_B_2,USE_R_B_3,USE_R_B_4,USE_R_B_5,USE_R_B_6,USE_R_B_7,USE_R_B_8,USE_R_B_9,USE_R_B_10,USE_R_B_11,USE_R_B_12,USE_R_B_13,USE_R_B_14,USE_R_B_15}, \
|
{USE_R_B_0,USE_R_B_1,USE_R_B_2,USE_R_B_3,USE_R_B_4,USE_R_B_5,USE_R_B_6,USE_R_B_7,USE_R_B_8, \
|
||||||
|
USE_R_B_9,USE_R_B_10,USE_R_B_11,USE_R_B_12,USE_R_B_13,USE_R_B_14,USE_R_B_15}, \
|
||||||
|
_UNITS_DEFAULT_ZERO, \
|
||||||
0}
|
0}
|
||||||
|
|
||||||
/////////////////////////////////////////////////////////////////////
|
/////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
#define _MPU_DEFAULT_ZERO {0,0,0,0}
|
||||||
|
#define _MPU_DEFAULT_MINUS_ONE {-1,-1,-1,-1}
|
||||||
|
|
||||||
#define MPU_CAN_SETUP_DEFAULT { CAN_ADR_MPU_DEFAULT, {0,0,0,0}, \
|
#define MPU_CAN_SETUP_DEFAULT { CAN_ADR_MPU_DEFAULT, _MPU_DEFAULT_ZERO, \
|
||||||
{0,0,0,0}, \
|
_MPU_DEFAULT_ZERO, \
|
||||||
{-1,-1,-1,-1}, \
|
_MPU_DEFAULT_MINUS_ONE, \
|
||||||
{-1,-1,-1,-1}, \
|
_MPU_DEFAULT_MINUS_ONE, \
|
||||||
{-1,-1,-1,-1}, \
|
_MPU_DEFAULT_MINUS_ONE, \
|
||||||
{USE_MPU_0,USE_MPU_1,USE_MPU_2,USE_MPU_3}, \
|
{USE_MPU_0,USE_MPU_1,USE_MPU_2,USE_MPU_3}, \
|
||||||
|
_MPU_DEFAULT_ZERO, \
|
||||||
|
_MPU_DEFAULT_ZERO, \
|
||||||
0}
|
0}
|
||||||
|
|
||||||
//-------------------------------------------------------------------------------//
|
//-------------------------------------------------------------------------------//
|
||||||
|
|
||||||
#define TERMINAL_CAN_SETUP_DEFAULT {CAN_ADR_TERMINAL_DEFAULT, {0,0,0,0}, \
|
#define _TERMINAL_DEFAULT_ZERO {0,0,0,0}
|
||||||
{0,0,0,0}, \
|
#define _TERMINAL_DEFAULT_MINUS_ONE {-1,-1,-1,-1}
|
||||||
{-1,-1,-1,-1}, \
|
|
||||||
{-1,-1,-1,-1}, \
|
#define TERMINAL_CAN_SETUP_DEFAULT {CAN_ADR_TERMINAL_DEFAULT, _TERMINAL_DEFAULT_ZERO, \
|
||||||
{-1,-1,-1,-1}, \
|
_TERMINAL_DEFAULT_ZERO, \
|
||||||
|
_TERMINAL_DEFAULT_MINUS_ONE, \
|
||||||
|
_TERMINAL_DEFAULT_MINUS_ONE, \
|
||||||
|
_TERMINAL_DEFAULT_MINUS_ONE, \
|
||||||
{USE_TERMINAL_1_OSCIL,USE_TERMINAL_1_CMD,USE_TERMINAL_2_OSCIL,USE_TERMINAL_2_CMD}, \
|
{USE_TERMINAL_1_OSCIL,USE_TERMINAL_1_CMD,USE_TERMINAL_2_OSCIL,USE_TERMINAL_2_CMD}, \
|
||||||
|
_TERMINAL_DEFAULT_ZERO, \
|
||||||
0}
|
0}
|
||||||
//-------------------------------------------------------------------------------//
|
//-------------------------------------------------------------------------------//
|
||||||
|
#define _ALARM_LOG_DEFAULT_ZERO {0,0}
|
||||||
|
#define _ALARM_LOG_DEFAULT_MINUS_ONE {-1,-1}
|
||||||
|
|
||||||
#define ALARM_LOG_CAN_SETUP_DEFAULT {CAN_ADR_ALARM_LOG_DEFAULT, {0,0}, \
|
#define ALARM_LOG_CAN_SETUP_DEFAULT {CAN_ADR_ALARM_LOG_DEFAULT, _ALARM_LOG_DEFAULT_ZERO, \
|
||||||
{0,0}, \
|
_ALARM_LOG_DEFAULT_ZERO, \
|
||||||
{-1,-1}, \
|
_ALARM_LOG_DEFAULT_MINUS_ONE, \
|
||||||
{-1,-1}, \
|
_ALARM_LOG_DEFAULT_MINUS_ONE, \
|
||||||
{-1,-1}, \
|
_ALARM_LOG_DEFAULT_MINUS_ONE, \
|
||||||
{USE_ALARM_LOG_0,USE_ALARM_LOG_1}, \
|
{USE_ALARM_LOG_0,USE_ALARM_LOG_1}, \
|
||||||
|
_ALARM_LOG_DEFAULT_ZERO, \
|
||||||
0}
|
0}
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
@ -605,7 +631,7 @@ extern FIFO fifo;
|
|||||||
|
|
||||||
extern int CAN_timeout[];
|
extern int CAN_timeout[];
|
||||||
extern int CAN_request_sent[];
|
extern int CAN_request_sent[];
|
||||||
extern int CAN_timeout_cicle[];
|
extern unsigned int CAN_timeout_cicle[];
|
||||||
|
|
||||||
|
|
||||||
//////////////////////////////////////////////////
|
//////////////////////////////////////////////////
|
||||||
@ -663,12 +689,14 @@ void inc_CAN_timeout_cicle();
|
|||||||
|
|
||||||
unsigned int test_can_live_mpu(void);
|
unsigned int test_can_live_mpu(void);
|
||||||
unsigned int test_can_live_terminal(int n);
|
unsigned int test_can_live_terminal(int n);
|
||||||
|
void InitCanSoft(void);
|
||||||
|
|
||||||
void timer_pause_enable_can_from_mpu(void);
|
void timer_pause_enable_can_from_mpu(void);
|
||||||
void timer_pause_enable_can_from_terminal(void);
|
void timer_pause_enable_can_from_terminal(void);
|
||||||
void read_manch_can(void);
|
void read_manch_can(void);
|
||||||
void write_manch_can(void);
|
void write_manch_can(void);
|
||||||
void detect_time_refresh_units(int box, int adr);
|
void detect_time_refresh_units(int box, int adr);
|
||||||
|
void detect_time_refresh_mpu(int box, int adr);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@ -713,6 +741,11 @@ interrupt void CAN_reset_err(void);
|
|||||||
|
|
||||||
|
|
||||||
extern UNITES_CAN_SETUP unites_can_setup;
|
extern UNITES_CAN_SETUP unites_can_setup;
|
||||||
|
extern MPU_CAN_SETUP mpu_can_setup;
|
||||||
|
|
||||||
|
|
||||||
|
extern unsigned int CanTimeOutErrorTR;
|
||||||
|
extern unsigned int CanBusOffError;
|
||||||
|
|
||||||
#endif // _CAN_SETUP
|
#endif // _CAN_SETUP
|
||||||
|
|
||||||
|
@ -11,16 +11,16 @@
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
#pragma DATA_SECTION(p_analog_data_in, ".logs");
|
//#pragma DATA_SECTION(p_analog_data_in, ".logs");
|
||||||
MODBUS_REG_STRUCT *p_analog_data_in;
|
MODBUS_REG_STRUCT *p_analog_data_in;
|
||||||
|
|
||||||
#pragma DATA_SECTION(p_analog_data_out, ".logs");
|
//#pragma DATA_SECTION(p_analog_data_out, ".logs");
|
||||||
MODBUS_REG_STRUCT *p_analog_data_out;
|
MODBUS_REG_STRUCT *p_analog_data_out;
|
||||||
|
|
||||||
#pragma DATA_SECTION(p_discrete_data_out, ".logs");
|
//#pragma DATA_SECTION(p_discrete_data_out, ".logs");
|
||||||
MODBUS_REG_STRUCT *p_discrete_data_out;
|
MODBUS_REG_STRUCT *p_discrete_data_out;
|
||||||
|
|
||||||
#pragma DATA_SECTION(p_discrete_data_in, ".logs");
|
//#pragma DATA_SECTION(p_discrete_data_in, ".logs");
|
||||||
MODBUS_REG_STRUCT *p_discrete_data_in;
|
MODBUS_REG_STRUCT *p_discrete_data_in;
|
||||||
|
|
||||||
static int adres_wait_answer_cmd1 = 0;
|
static int adres_wait_answer_cmd1 = 0;
|
||||||
@ -73,6 +73,7 @@ void ModbusRTUsend1(RS_DATA_STRUCT *rs_arr, int adr_contr, unsigned int adr_star
|
|||||||
rs_arr->buffer[9] = 0;
|
rs_arr->buffer[9] = 0;
|
||||||
|
|
||||||
rs_arr->RS_DataWillSend = 1;
|
rs_arr->RS_DataWillSend = 1;
|
||||||
|
rs_arr->RS_DataWillSend2 = 1;
|
||||||
|
|
||||||
RS_Send(rs_arr, rs_arr->buffer, 10);
|
RS_Send(rs_arr, rs_arr->buffer, 10);
|
||||||
|
|
||||||
@ -260,6 +261,7 @@ void ModbusRTUsend3(RS_DATA_STRUCT *rs_arr, int adr_contr, unsigned int adr_star
|
|||||||
rs_arr->buffer[9] = 0;
|
rs_arr->buffer[9] = 0;
|
||||||
|
|
||||||
rs_arr->RS_DataWillSend = 1;
|
rs_arr->RS_DataWillSend = 1;
|
||||||
|
rs_arr->RS_DataWillSend2 = 1;
|
||||||
|
|
||||||
RS_Send(rs_arr, rs_arr->buffer, 10);
|
RS_Send(rs_arr, rs_arr->buffer, 10);
|
||||||
|
|
||||||
@ -351,6 +353,7 @@ void ModbusRTUsend4(RS_DATA_STRUCT *rs_arr, int adr_contr, unsigned int adr_star
|
|||||||
rs_arr->buffer[9] = 0;
|
rs_arr->buffer[9] = 0;
|
||||||
|
|
||||||
rs_arr->RS_DataWillSend = 1;
|
rs_arr->RS_DataWillSend = 1;
|
||||||
|
rs_arr->RS_DataWillSend2 = 1;
|
||||||
|
|
||||||
RS_Send(rs_arr, rs_arr->buffer, 10);
|
RS_Send(rs_arr, rs_arr->buffer, 10);
|
||||||
|
|
||||||
@ -512,6 +515,7 @@ void ModbusRTUsend5(RS_DATA_STRUCT *rs_arr, int adr_contr, unsigned int adr_star
|
|||||||
rs_arr->buffer[8] = 0;
|
rs_arr->buffer[8] = 0;
|
||||||
rs_arr->buffer[9] = 0;
|
rs_arr->buffer[9] = 0;
|
||||||
rs_arr->RS_DataWillSend = 1;
|
rs_arr->RS_DataWillSend = 1;
|
||||||
|
rs_arr->RS_DataWillSend2 = 1;
|
||||||
RS_Send(rs_arr, rs_arr->buffer, 10);
|
RS_Send(rs_arr, rs_arr->buffer, 10);
|
||||||
|
|
||||||
/* æäåì îòâåòà */
|
/* æäåì îòâåòà */
|
||||||
@ -586,6 +590,7 @@ void ModbusRTUsend6(RS_DATA_STRUCT *rs_arr, int adr_contr, unsigned int adr_star
|
|||||||
rs_arr->buffer[9] = 0;
|
rs_arr->buffer[9] = 0;
|
||||||
|
|
||||||
rs_arr->RS_DataWillSend = 1;
|
rs_arr->RS_DataWillSend = 1;
|
||||||
|
rs_arr->RS_DataWillSend2 = 1;
|
||||||
|
|
||||||
RS_Send(rs_arr, rs_arr->buffer, 10);
|
RS_Send(rs_arr, rs_arr->buffer, 10);
|
||||||
// control_station.flag_waiting_answer[CONTROL_STATION_INGETEAM_PULT_RS485] = 1;
|
// control_station.flag_waiting_answer[CONTROL_STATION_INGETEAM_PULT_RS485] = 1;
|
||||||
@ -717,6 +722,7 @@ void ModbusRTUsend15(RS_DATA_STRUCT *rs_arr, int adr_contr, unsigned int adr_sta
|
|||||||
rs_arr->buffer[count_data_bytes + 10] = 0;
|
rs_arr->buffer[count_data_bytes + 10] = 0;
|
||||||
|
|
||||||
rs_arr->RS_DataWillSend = 1;
|
rs_arr->RS_DataWillSend = 1;
|
||||||
|
rs_arr->RS_DataWillSend2 = 1;
|
||||||
|
|
||||||
// RS_Send(rs_arr, rs_arr->buffer, (count_data_bytes + 10 + 2));
|
// RS_Send(rs_arr, rs_arr->buffer, (count_data_bytes + 10 + 2));
|
||||||
RS_Send(rs_arr, rs_arr->buffer, (count_data_bytes + 10));
|
RS_Send(rs_arr, rs_arr->buffer, (count_data_bytes + 10));
|
||||||
@ -879,6 +885,7 @@ void ModbusRTUsend16(RS_DATA_STRUCT *rs_arr, int adr_contr, unsigned int adr_sta
|
|||||||
rs_arr->buffer[count_word * 2 + 10] = 0;
|
rs_arr->buffer[count_word * 2 + 10] = 0;
|
||||||
|
|
||||||
rs_arr->RS_DataWillSend = 1;
|
rs_arr->RS_DataWillSend = 1;
|
||||||
|
rs_arr->RS_DataWillSend2 = 1;
|
||||||
|
|
||||||
RS_Send(rs_arr, rs_arr->buffer, (count_word * 2 + 10));
|
RS_Send(rs_arr, rs_arr->buffer, (count_word * 2 + 10));
|
||||||
// control_station.flag_waiting_answer[CONTROL_STATION_INGETEAM_PULT_RS485] = 1;
|
// control_station.flag_waiting_answer[CONTROL_STATION_INGETEAM_PULT_RS485] = 1;
|
||||||
@ -886,6 +893,7 @@ void ModbusRTUsend16(RS_DATA_STRUCT *rs_arr, int adr_contr, unsigned int adr_sta
|
|||||||
// æäåì îòâåòà
|
// æäåì îòâåòà
|
||||||
if (adr_contr > 0 && adr_contr < 0xff)
|
if (adr_contr > 0 && adr_contr < 0xff)
|
||||||
{
|
{
|
||||||
|
//rs_arr->RS_Length = -1;
|
||||||
RS_Len[CMD_RS232_MODBUS_16] = 8;
|
RS_Len[CMD_RS232_MODBUS_16] = 8;
|
||||||
RS_SetControllerLeading(rs_arr, true);
|
RS_SetControllerLeading(rs_arr, true);
|
||||||
RS_SetAdrAnswerController(rs_arr, adr_contr);
|
RS_SetAdrAnswerController(rs_arr, adr_contr);
|
||||||
|
@ -15,3 +15,10 @@ float build_time_f = BUILD_TIME;
|
|||||||
|
|
||||||
int build_data_i = (BUILD_DATA*1000);
|
int build_data_i = (BUILD_DATA*1000);
|
||||||
int build_time_i = (BUILD_TIME*1000);
|
int build_time_i = (BUILD_TIME*1000);
|
||||||
|
|
||||||
|
int build_year = BUILD_YEAR;
|
||||||
|
int build_month = BUILD_MONTH;
|
||||||
|
int build_day = BUILD_DAY;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@ -23,4 +23,8 @@ extern int build_data_i;
|
|||||||
extern int build_time_i;
|
extern int build_time_i;
|
||||||
|
|
||||||
|
|
||||||
|
extern int build_year, build_month, build_day;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
#endif /* SRC_N12_LIBS_BUILD_VERSION_H_ */
|
#endif /* SRC_N12_LIBS_BUILD_VERSION_H_ */
|
||||||
|
@ -20,7 +20,7 @@ CONTROL_STATION control_station = CONTROL_STATION_DEFAULTS;
|
|||||||
|
|
||||||
void control_station_clear(CONTROL_STATION_handle cs)
|
void control_station_clear(CONTROL_STATION_handle cs)
|
||||||
{
|
{
|
||||||
int i,k;
|
int i,k,j;
|
||||||
|
|
||||||
for (i=0;i<COUNT_CONTROL_STATION;i++)
|
for (i=0;i<COUNT_CONTROL_STATION;i++)
|
||||||
{
|
{
|
||||||
@ -49,10 +49,21 @@ void control_station_clear(CONTROL_STATION_handle cs)
|
|||||||
cs->time_detect_answer_485[i] = 0;
|
cs->time_detect_answer_485[i] = 0;
|
||||||
|
|
||||||
for (k=0;k<CONTROL_STATION_MAX_RAW_DATA;k++)
|
for (k=0;k<CONTROL_STATION_MAX_RAW_DATA;k++)
|
||||||
|
{
|
||||||
cs->raw_array_data[i][k].all = 0;
|
cs->raw_array_data[i][k].all = 0;
|
||||||
|
for (j=0;j<CONTROL_STATION_MAX_RAW_DATA_TEMP;j++)
|
||||||
|
cs->raw_array_data_temp[i][k][j].all = 0;
|
||||||
|
}
|
||||||
|
|
||||||
cs->flag_refresh_array[i] = 0;
|
cs->flag_refresh_array[i] = 0;
|
||||||
|
|
||||||
|
cs->prev_CAN_count_cycle_input_units[i] = 0;
|
||||||
|
cs->count_raw_array_data_temp[i] = 0;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
for (k=0;k<CONTROL_STATION_CMD_LAST;k++)
|
||||||
|
cs->active_array_cmd[k] = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
///////////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////////
|
||||||
|
@ -31,6 +31,7 @@
|
|||||||
#define CONTROL_STATION_SETUP_TIME_SEND_CMD_AFTER_OFF 5 // â òèêàõ îò CONTROL_STATION_TIME_WAIT
|
#define CONTROL_STATION_SETUP_TIME_SEND_CMD_AFTER_OFF 5 // â òèêàõ îò CONTROL_STATION_TIME_WAIT
|
||||||
|
|
||||||
#define CONTROL_STATION_MAX_RAW_DATA 256 //128 // ìàêñèìàëüíîå êîë-âî äàííûõ äëÿ ñûðûõ äàííûõ ïîëó÷åííûõ îò ïîñòîâ
|
#define CONTROL_STATION_MAX_RAW_DATA 256 //128 // ìàêñèìàëüíîå êîë-âî äàííûõ äëÿ ñûðûõ äàííûõ ïîëó÷åííûõ îò ïîñòîâ
|
||||||
|
#define CONTROL_STATION_MAX_RAW_DATA_TEMP 3 //128 // ñêîëüêî äàííûõ õðàíèì äëÿ âðåìåííîãî áóôåðà
|
||||||
|
|
||||||
//////////////////////////////////////////////////////////////////////////////////////
|
//////////////////////////////////////////////////////////////////////////////////////
|
||||||
//////////////////////////////////////////////////////////////////////////////////////
|
//////////////////////////////////////////////////////////////////////////////////////
|
||||||
@ -58,6 +59,7 @@ typedef struct {
|
|||||||
int active_array_cmd[CONTROL_STATION_CMD_LAST]; // ìàññèâ äàííûõ àêòóàëüíûõ äëÿ àâòèâíîãî ïîñòà, äàííûå ïîñëå parse
|
int active_array_cmd[CONTROL_STATION_CMD_LAST]; // ìàññèâ äàííûõ àêòóàëüíûõ äëÿ àâòèâíîãî ïîñòà, äàííûå ïîñëå parse
|
||||||
|
|
||||||
WORD_UINT2BITS_STRUCT raw_array_data[COUNT_CONTROL_STATION][CONTROL_STATION_MAX_RAW_DATA]; // ñûðîé ìàññèâ äàííûõ ïîëó÷åííûõ îò êàæäîãî èç ïîñòîâ, áåç parse.
|
WORD_UINT2BITS_STRUCT raw_array_data[COUNT_CONTROL_STATION][CONTROL_STATION_MAX_RAW_DATA]; // ñûðîé ìàññèâ äàííûõ ïîëó÷åííûõ îò êàæäîãî èç ïîñòîâ, áåç parse.
|
||||||
|
WORD_UINT2BITS_STRUCT raw_array_data_temp[COUNT_CONTROL_STATION][CONTROL_STATION_MAX_RAW_DATA][CONTROL_STATION_MAX_RAW_DATA_TEMP]; // âðåìåííûé ñûðîé ìàññèâ äàííûõ ïîëó÷åííûõ îò êàæäîãî èç ïîñòîâ, áåç parse.
|
||||||
|
|
||||||
unsigned int flag_message_sent[COUNT_CONTROL_STATION]; // ôëàã íà îæèäàíèå îòâåòà ïî ñèñòåìå çàïðîñ-îòâåò
|
unsigned int flag_message_sent[COUNT_CONTROL_STATION]; // ôëàã íà îæèäàíèå îòâåòà ïî ñèñòåìå çàïðîñ-îòâåò
|
||||||
unsigned int flag_waiting_answer[COUNT_CONTROL_STATION]; // îæèäàòü ëè îòâåò ïî ñèñòåìå çàïðîñ-îòâåò
|
unsigned int flag_waiting_answer[COUNT_CONTROL_STATION]; // îæèäàòü ëè îòâåò ïî ñèñòåìå çàïðîñ-îòâåò
|
||||||
@ -76,6 +78,8 @@ typedef struct {
|
|||||||
unsigned int cmd_checkback_from_control_station[COUNT_CONTROL_STATION]; // êâèòèðîâàíèå îò ïîñòà
|
unsigned int cmd_checkback_from_control_station[COUNT_CONTROL_STATION]; // êâèòèðîâàíèå îò ïîñòà
|
||||||
unsigned int cmd_test_leds_from_control_station[COUNT_CONTROL_STATION]; // òåñò ëàìï îò ïîñòà
|
unsigned int cmd_test_leds_from_control_station[COUNT_CONTROL_STATION]; // òåñò ëàìï îò ïîñòà
|
||||||
*/
|
*/
|
||||||
|
unsigned int prev_CAN_count_cycle_input_units[COUNT_CONTROL_STATION]; // ïðåä êîë-âî îáíîâëåíèé èç CAN
|
||||||
|
unsigned int count_raw_array_data_temp[COUNT_CONTROL_STATION]; // èíäåêñ ïåðåáîðà ïî CONTROL_STATION_MAX_RAW_DATA_TEMP
|
||||||
|
|
||||||
void (*clear)(); // Clear buffers
|
void (*clear)(); // Clear buffers
|
||||||
void (*update_timers)(); // Îáíóëÿåì òàéìåðû íà ïîñòàõ ñ êîòîðûìè åñòü îáìåí
|
void (*update_timers)(); // Îáíóëÿåì òàéìåðû íà ïîñòàõ ñ êîòîðûìè åñòü îáìåí
|
||||||
@ -105,6 +109,9 @@ typedef CONTROL_STATION *CONTROL_STATION_handle;
|
|||||||
{0}, \
|
{0}, \
|
||||||
{0}, \
|
{0}, \
|
||||||
{0}, \
|
{0}, \
|
||||||
|
{0}, \
|
||||||
|
{0}, \
|
||||||
|
{0}, \
|
||||||
control_station_clear, \
|
control_station_clear, \
|
||||||
control_station_update_timers, \
|
control_station_update_timers, \
|
||||||
control_station_detect_active_station \
|
control_station_detect_active_station \
|
||||||
|
@ -278,6 +278,9 @@ _iq19 exp_regul_iq19(_iq19 k_exp_regul, _iq19 InpVarCurr, _iq19 InpVarInstant)
|
|||||||
|
|
||||||
|
|
||||||
#pragma CODE_SECTION(exp_regul_iq,".fast_run");
|
#pragma CODE_SECTION(exp_regul_iq,".fast_run");
|
||||||
|
//
|
||||||
|
// Tñåê = Tïåðèîä/k_exp_regul
|
||||||
|
//
|
||||||
_iq exp_regul_iq(_iq k_exp_regul, _iq InpVarFiltered, _iq InpVarInstant)
|
_iq exp_regul_iq(_iq k_exp_regul, _iq InpVarFiltered, _iq InpVarInstant)
|
||||||
{
|
{
|
||||||
_iq t1;
|
_iq t1;
|
||||||
|
@ -65,9 +65,6 @@ void exp_regul_iq_fast(_iq k_exp_regul, _iq *InpVarCurr, _iq InpVarInstant);
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
@ -7,9 +7,13 @@ GLOBAL_TIME global_time = GLOBAL_TIME_DEFAULTS;
|
|||||||
void init_global_time_struct(unsigned int freq_pwm)
|
void init_global_time_struct(unsigned int freq_pwm)
|
||||||
{
|
{
|
||||||
global_time.total_seconds = 0;
|
global_time.total_seconds = 0;
|
||||||
|
global_time.total_seconds10 = 0;
|
||||||
|
global_time.total_seconds10full = 0;
|
||||||
global_time.microseconds = 0;
|
global_time.microseconds = 0;
|
||||||
|
global_time.microseconds_temp = 0;
|
||||||
global_time.pwm_tics = 0;
|
global_time.pwm_tics = 0;
|
||||||
global_time.miliseconds = 0;
|
global_time.miliseconds = 0;
|
||||||
|
global_time.miliseconds_long = 0;
|
||||||
global_time.seconds = 0;
|
global_time.seconds = 0;
|
||||||
global_time.minuts = 0;
|
global_time.minuts = 0;
|
||||||
global_time.hours = 0;
|
global_time.hours = 0;
|
||||||
@ -20,14 +24,40 @@ void init_global_time_struct(unsigned int freq_pwm)
|
|||||||
#pragma CODE_SECTION(global_time_calc,".fast_run2");
|
#pragma CODE_SECTION(global_time_calc,".fast_run2");
|
||||||
void global_time_calc(GLOBAL_TIME_handle gt)
|
void global_time_calc(GLOBAL_TIME_handle gt)
|
||||||
{
|
{
|
||||||
|
unsigned int miliseconds_temp = 0;
|
||||||
|
static unsigned int miliseconds_temp10 = 0;
|
||||||
|
|
||||||
gt->pwm_tics++;
|
gt->pwm_tics++;
|
||||||
gt->microseconds += gt->microseconds_add;
|
gt->microseconds += gt->microseconds_add;
|
||||||
gt->miliseconds = gt->microseconds / 1000;
|
gt->microseconds_temp += gt->microseconds_add;
|
||||||
|
|
||||||
|
if (gt->microseconds_temp>=1000)
|
||||||
|
{
|
||||||
|
if (gt->microseconds_temp>=2000)
|
||||||
|
{
|
||||||
|
miliseconds_temp = gt->microseconds_temp/1000;
|
||||||
|
gt->microseconds_temp -= miliseconds_temp*1000;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
miliseconds_temp = 1;
|
||||||
|
gt->microseconds_temp -= 1000;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// gt->miliseconds = gt->microseconds / 1000;
|
||||||
|
|
||||||
|
gt->miliseconds += miliseconds_temp;
|
||||||
|
miliseconds_temp10 += miliseconds_temp;
|
||||||
|
|
||||||
if(gt->pwm_tics == gt->freq_pwm_hz)
|
if(gt->pwm_tics == gt->freq_pwm_hz)
|
||||||
{
|
{
|
||||||
gt->total_seconds++;
|
gt->total_seconds++;
|
||||||
|
gt->total_seconds10 += 10;
|
||||||
|
|
||||||
gt->seconds++;
|
gt->seconds++;
|
||||||
gt->pwm_tics = 0;
|
gt->pwm_tics = 0;
|
||||||
|
miliseconds_temp10 = 0;
|
||||||
|
|
||||||
if(gt->seconds == 60)
|
if(gt->seconds == 60)
|
||||||
{
|
{
|
||||||
@ -41,6 +71,9 @@ void global_time_calc(GLOBAL_TIME_handle gt)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//gt->total_seconds10 += 10;
|
||||||
|
gt->total_seconds10full = gt->total_seconds10 + miliseconds_temp10/100;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -57,9 +90,17 @@ void init_timer_milisec(unsigned int *start_time)
|
|||||||
int detect_pause_sec(unsigned int wait_pause, unsigned int *old_time)
|
int detect_pause_sec(unsigned int wait_pause, unsigned int *old_time)
|
||||||
{
|
{
|
||||||
unsigned long delta;
|
unsigned long delta;
|
||||||
delta = (unsigned int)((unsigned int)global_time.total_seconds - *old_time);
|
|
||||||
|
|
||||||
if (delta>wait_pause)
|
if(global_time.total_seconds >= *old_time)
|
||||||
|
{
|
||||||
|
delta = (unsigned int)((unsigned int)global_time.total_seconds - *old_time);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
delta = (unsigned int)((unsigned int)global_time.total_seconds + (0xFFFFUL - *old_time));
|
||||||
|
}
|
||||||
|
|
||||||
|
if (delta>=wait_pause)
|
||||||
{
|
{
|
||||||
*old_time = (unsigned int)global_time.total_seconds;
|
*old_time = (unsigned int)global_time.total_seconds;
|
||||||
return 1;
|
return 1;
|
||||||
@ -80,7 +121,7 @@ int detect_pause_milisec(unsigned int wait_pause, unsigned int *old_time)
|
|||||||
delta = (unsigned int)((unsigned int)global_time.miliseconds + (0xFFFFUL - *old_time));
|
delta = (unsigned int)((unsigned int)global_time.miliseconds + (0xFFFFUL - *old_time));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (delta>wait_pause)
|
if (delta>=wait_pause)
|
||||||
{
|
{
|
||||||
*old_time = (unsigned int)global_time.miliseconds;
|
*old_time = (unsigned int)global_time.miliseconds;
|
||||||
return 1;
|
return 1;
|
||||||
@ -88,3 +129,21 @@ int detect_pause_milisec(unsigned int wait_pause, unsigned int *old_time)
|
|||||||
else
|
else
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
unsigned int get_delta_milisec(unsigned int *old_time, unsigned int upd)
|
||||||
|
{
|
||||||
|
unsigned long delta;
|
||||||
|
|
||||||
|
if(global_time.miliseconds >= *old_time)
|
||||||
|
{
|
||||||
|
delta = (unsigned int)((unsigned int)global_time.miliseconds - *old_time);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
delta = (unsigned int)((unsigned int)global_time.miliseconds + (0xFFFFUL - *old_time));
|
||||||
|
}
|
||||||
|
if (upd)
|
||||||
|
*old_time = (unsigned int)global_time.miliseconds;
|
||||||
|
|
||||||
|
return delta;
|
||||||
|
}
|
||||||
|
@ -3,8 +3,13 @@
|
|||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
unsigned long total_seconds; //Âñåãî ñåêóíä ñ ìîìåíòà âêëþ÷åíèß
|
unsigned long total_seconds; //Âñåãî ñåêóíä ñ ìîìåíòà âêëþ÷åíèß
|
||||||
|
unsigned long total_seconds10; //Âñåãî ñåêóíä ñ ìîìåíòà âêëþ÷åíèß ñ äåñÿòûìè
|
||||||
|
unsigned long total_seconds10full; //Âñåãî ñåêóíä ñ ìîìåíòà âêëþ÷åíèß ñ äåñÿòûìè
|
||||||
unsigned long microseconds;
|
unsigned long microseconds;
|
||||||
|
unsigned int microseconds_temp;
|
||||||
|
|
||||||
unsigned int miliseconds; //???
|
unsigned int miliseconds; //???
|
||||||
|
unsigned long miliseconds_long; //???
|
||||||
unsigned int pwm_tics;
|
unsigned int pwm_tics;
|
||||||
unsigned int seconds;
|
unsigned int seconds;
|
||||||
unsigned int minuts;
|
unsigned int minuts;
|
||||||
@ -29,6 +34,10 @@ Default initalizer for the GLOBAL_TIME object.
|
|||||||
0, \
|
0, \
|
||||||
0, \
|
0, \
|
||||||
0, \
|
0, \
|
||||||
|
0, \
|
||||||
|
0, \
|
||||||
|
0, \
|
||||||
|
0, \
|
||||||
0, \
|
0, \
|
||||||
0, \
|
0, \
|
||||||
global_time_calc \
|
global_time_calc \
|
||||||
@ -44,5 +53,6 @@ void init_timer_sec(unsigned int *start_time); //
|
|||||||
void init_timer_milisec(unsigned int *start_time); //Èíèöèàëèçèðóåò ïåðåìåííóþ, âðåìß ñòàðòà â ìèëèñåêóíäàõ
|
void init_timer_milisec(unsigned int *start_time); //Èíèöèàëèçèðóåò ïåðåìåííóþ, âðåìß ñòàðòà â ìèëèñåêóíäàõ
|
||||||
int detect_pause_sec(unsigned int wait_pause, unsigned int *old_time); //ïàóçà â ñåêóíäàõ
|
int detect_pause_sec(unsigned int wait_pause, unsigned int *old_time); //ïàóçà â ñåêóíäàõ
|
||||||
int detect_pause_milisec(unsigned int wait_pause, unsigned int *old_time); //Ïàóçà â ìèëèñåêóíäàõ (íå áîëåå 60000ìëñåê)
|
int detect_pause_milisec(unsigned int wait_pause, unsigned int *old_time); //Ïàóçà â ìèëèñåêóíäàõ (íå áîëåå 60000ìëñåê)
|
||||||
|
unsigned int get_delta_milisec(unsigned int *old_time, unsigned int upd); // âåðíóëè ñêîëüêî âðåìåíè ïðîøëî îò âðåìåíè old_time ; upd=1 - îáíîâèòü old_time - òåêóùèì
|
||||||
|
|
||||||
#endif //_GLOBAL_TIME
|
#endif //_GLOBAL_TIME
|
||||||
|
@ -12,9 +12,24 @@
|
|||||||
#define CONST_SQRT3 29058990 //1.7320508075688772935274463415059 = sqrt(3)
|
#define CONST_SQRT3 29058990 //1.7320508075688772935274463415059 = sqrt(3)
|
||||||
#define CONST_SQRT3_2 14529495 //1.7320508075688772935274463415059/2=0.8660254 = sqrt(3)/2
|
#define CONST_SQRT3_2 14529495 //1.7320508075688772935274463415059/2=0.8660254 = sqrt(3)/2
|
||||||
#define CONST_IQ_1 16777216 //1
|
#define CONST_IQ_1 16777216 //1
|
||||||
#define CONST_IQ_05 8388608 //0.5
|
|
||||||
|
|
||||||
#define CONST_IQ_2 33554432 //2
|
#define CONST_IQ_2 33554432 //2
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
#define CONST_IQ_01 1677721 //0.1
|
||||||
|
#define CONST_IQ_02 3355442 //0.2
|
||||||
|
#define CONST_IQ_03 5033163 //0.3
|
||||||
|
#define CONST_IQ_04 6710884 //0.4
|
||||||
|
#define CONST_IQ_05 8388608 //0.5
|
||||||
|
|
||||||
|
#define CONST_IQ_06 10066329 //0.6
|
||||||
|
#define CONST_IQ_07 11744051 //0.7
|
||||||
|
#define CONST_IQ_08 13421772 //0.8
|
||||||
|
#define CONST_IQ_09 15099494 //0.9
|
||||||
|
|
||||||
|
|
||||||
#define CONST_IQ_PI6 8784530 //30
|
#define CONST_IQ_PI6 8784530 //30
|
||||||
#define CONST_IQ_PI3 17569060 // 60
|
#define CONST_IQ_PI3 17569060 // 60
|
||||||
#define CONST_IQ_PI05 26353589 // 90
|
#define CONST_IQ_PI05 26353589 // 90
|
||||||
|
@ -19,13 +19,13 @@
|
|||||||
#include "DSP281x_Device.h" // DSP281x Headerfile Include File
|
#include "DSP281x_Device.h" // DSP281x Headerfile Include File
|
||||||
#include "DSP281x_Examples.h" // DSP281x Examples Include File
|
#include "DSP281x_Examples.h" // DSP281x Examples Include File
|
||||||
#include <math.h>
|
#include <math.h>
|
||||||
|
|
||||||
|
|
||||||
#include "mathlib.h"
|
#include "mathlib.h"
|
||||||
|
|
||||||
#include <params_norma.h>
|
#include "params_norma.h"
|
||||||
|
#include "math_pi.h"
|
||||||
|
#include "params_pwm24.h"
|
||||||
|
#include <math.h>
|
||||||
|
#include "params_norma.h"
|
||||||
|
|
||||||
_iq SQRT_32 = _IQ(0.8660254037844);
|
_iq SQRT_32 = _IQ(0.8660254037844);
|
||||||
_iq CONST_23 = _IQ(2.0/3.0);
|
_iq CONST_23 = _IQ(2.0/3.0);
|
||||||
@ -36,28 +36,38 @@ _iq CONST_15 = _IQ(1.5);
|
|||||||
|
|
||||||
#define real float
|
#define real float
|
||||||
|
|
||||||
float my_satur_float(float Input, float Positive, float Negative)
|
float my_satur_float(float Input, float Positive, float Negative, float DeadZone)
|
||||||
{
|
{
|
||||||
|
if (fabs(DeadZone)>0.000001 && Input>-DeadZone && Input<DeadZone)
|
||||||
|
Input = 0;
|
||||||
|
else
|
||||||
if (Input>=Positive) Input=Positive;
|
if (Input>=Positive) Input=Positive;
|
||||||
|
else
|
||||||
if (Input<=Negative) Input=Negative;
|
if (Input<=Negative) Input=Negative;
|
||||||
|
|
||||||
return Input;
|
return Input;
|
||||||
}
|
}
|
||||||
|
|
||||||
int my_satur_int(int Input, int Positive, int Negative)
|
int my_satur_int(int Input, int Positive, int Negative, int DeadZone)
|
||||||
{
|
{
|
||||||
|
if (DeadZone!=0 && Input>-DeadZone && Input<DeadZone)
|
||||||
|
Input = 0;
|
||||||
|
else
|
||||||
if (Input>=Positive) Input=Positive;
|
if (Input>=Positive) Input=Positive;
|
||||||
|
else
|
||||||
if (Input<=Negative) Input=Negative;
|
if (Input<=Negative) Input=Negative;
|
||||||
|
|
||||||
return Input;
|
return Input;
|
||||||
}
|
}
|
||||||
|
|
||||||
long my_satur_long(long Input, long Positive, long Negative)
|
long my_satur_long(long Input, long Positive, long Negative, long DeadZone)
|
||||||
{
|
{
|
||||||
|
|
||||||
|
if (DeadZone!=0 && Input>-DeadZone && Input<DeadZone)
|
||||||
|
Input = 0;
|
||||||
|
else
|
||||||
if (Input>=Positive) Input=Positive;
|
if (Input>=Positive) Input=Positive;
|
||||||
|
else
|
||||||
if (Input<=Negative) Input=Negative;
|
if (Input<=Negative) Input=Negative;
|
||||||
|
|
||||||
return Input;
|
return Input;
|
||||||
@ -142,9 +152,12 @@ real exp_regul(real Tperiod_regul, real Texp_regul, real InpVarCurr, real InpVar
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
real zad_intensiv(real StepP, real StepN, real InpVarCurr, real InpVarInstant)
|
|
||||||
|
*/
|
||||||
|
|
||||||
|
float zad_intensiv(float StepP, float StepN, float InpVarCurr, float InpVarInstant)
|
||||||
{
|
{
|
||||||
real deltaVar, VarOut;
|
float deltaVar, VarOut;
|
||||||
|
|
||||||
deltaVar = InpVarInstant-InpVarCurr;
|
deltaVar = InpVarInstant-InpVarCurr;
|
||||||
|
|
||||||
@ -160,7 +173,7 @@ real zad_intensiv(real StepP, real StepN, real InpVarCurr, real InpVarInstant)
|
|||||||
VarOut = InpVarCurr;
|
VarOut = InpVarCurr;
|
||||||
return VarOut;
|
return VarOut;
|
||||||
}
|
}
|
||||||
*/
|
|
||||||
#pragma CODE_SECTION(zad_intensiv_q,".fast_run");
|
#pragma CODE_SECTION(zad_intensiv_q,".fast_run");
|
||||||
_iq zad_intensiv_q(_iq StepP, _iq StepN, _iq InpVarCurr, _iq InpVarInstant)
|
_iq zad_intensiv_q(_iq StepP, _iq StepN, _iq InpVarCurr, _iq InpVarInstant)
|
||||||
{
|
{
|
||||||
@ -337,3 +350,88 @@ float fast_round(float x)
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
float fast_round_with_delta(float prev, float x, float delta)
|
||||||
|
{
|
||||||
|
float d;
|
||||||
|
long i;
|
||||||
|
|
||||||
|
|
||||||
|
i = (long)x;
|
||||||
|
|
||||||
|
if (x<0)
|
||||||
|
{
|
||||||
|
d = i - x;
|
||||||
|
if (d>=0.5)
|
||||||
|
i = i - 1;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
d = x - i;
|
||||||
|
if (d>=0.5)
|
||||||
|
i = i + 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (fabs(prev-x)>=delta)
|
||||||
|
return (float)i;
|
||||||
|
else
|
||||||
|
return (float)prev;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
float fast_round_with_limiter(float x, float lim)
|
||||||
|
{
|
||||||
|
float d;
|
||||||
|
long i;
|
||||||
|
|
||||||
|
|
||||||
|
if (fabs(x)<=lim)
|
||||||
|
return 0;
|
||||||
|
|
||||||
|
i = (long)x;
|
||||||
|
|
||||||
|
if (x<0)
|
||||||
|
{
|
||||||
|
d = i - x;
|
||||||
|
if (d>=0.5)
|
||||||
|
i = i - 1;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
d = x - i;
|
||||||
|
if (d>=0.5)
|
||||||
|
i = i + 1;
|
||||||
|
}
|
||||||
|
return (float)i;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
#pragma CODE_SECTION(calc_rms,".fast_run");
|
||||||
|
_iq calc_rms(_iq input, _iq input_prev, _iq freq_signal)
|
||||||
|
{
|
||||||
|
static _iq pi_pwm = _IQ(PI*NORMA_FROTOR/(FREQ_PWM/5.0));
|
||||||
|
|
||||||
|
_iq cosw, sinw, wdt, y2, z1, z2, z3, y;
|
||||||
|
|
||||||
|
wdt = _IQmpy(pi_pwm,freq_signal);
|
||||||
|
sinw = _IQsinPU(wdt);
|
||||||
|
cosw = _IQcosPU(wdt);
|
||||||
|
|
||||||
|
if (cosw==0)
|
||||||
|
return 0;
|
||||||
|
|
||||||
|
z1 = input_prev - _IQmpy(input,cosw);
|
||||||
|
// z2 = sinw;
|
||||||
|
z3 = _IQdiv(z1,sinw);
|
||||||
|
|
||||||
|
y2 = _IQmpy(input,input)+_IQmpy(z3,z3);
|
||||||
|
|
||||||
|
// cosw = _IQsin();
|
||||||
|
|
||||||
|
y = _IQsqrt(y2);
|
||||||
|
return y;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@ -4,6 +4,7 @@
|
|||||||
|
|
||||||
#include "IQmathLib.h"
|
#include "IQmathLib.h"
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
|
||||||
real pi_regul(real Kp_regul, real Tintegral_regul, real Tperiod_regul,
|
real pi_regul(real Kp_regul, real Tintegral_regul, real Tperiod_regul,
|
||||||
@ -11,7 +12,7 @@ real pi_regul(real Kp_regul, real Tintegral_regul, real Tperiod_regul,
|
|||||||
|
|
||||||
real exp_regul(real Tperiod_regul, real Texp_regul, real InpVarCurr, real InpVarInstant);
|
real exp_regul(real Tperiod_regul, real Texp_regul, real InpVarCurr, real InpVarInstant);
|
||||||
|
|
||||||
real zad_intensiv(real StepP, real StepN, real InpVarCurr, real InpVarInstant);
|
|
||||||
|
|
||||||
real pid_regul2(real Kp_regul, real Tperiod_regul, real Minimum, real Maximum,
|
real pid_regul2(real Kp_regul, real Tperiod_regul, real Minimum, real Maximum,
|
||||||
real yk, real *uk1, real *yk1, real *yk2, real *yzad,
|
real yk, real *uk1, real *yk1, real *yk2, real *yzad,
|
||||||
@ -28,6 +29,8 @@ real pi_regul4(real Kp_regul, real ki_regul, real Tperiod_regul, real Minimum, r
|
|||||||
real InpVar, real *InpVarPrev, real *OutVarPrev);
|
real InpVar, real *InpVarPrev, real *OutVarPrev);
|
||||||
|
|
||||||
*/
|
*/
|
||||||
|
float zad_intensiv(float StepP, float StepN, float InpVarCurr, float InpVarInstant);
|
||||||
|
|
||||||
_iq zad_intensiv_q(_iq StepP, _iq StepN, _iq InpVarCurr, _iq InpVarInstant);
|
_iq zad_intensiv_q(_iq StepP, _iq StepN, _iq InpVarCurr, _iq InpVarInstant);
|
||||||
_iq im_calc( _iq ia, _iq ib, _iq ic);
|
_iq im_calc( _iq ia, _iq ib, _iq ic);
|
||||||
|
|
||||||
@ -35,9 +38,10 @@ float exp_regul(float Tperiod_regul, float Texp_regul, float InpVarCurr, float I
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
float my_satur_float(float Input, float Positive, float Negative);
|
float my_satur_float(float Input, float Positive, float Negative, float DeadZone);
|
||||||
int my_satur_int(int Input, int Positive, int Negative);
|
|
||||||
long my_satur_long(long Input, long Positive, long Negative);
|
int my_satur_int(int Input, int Positive, int Negative, int DeadZone);
|
||||||
|
long my_satur_long(long Input, long Positive, long Negative, long DeadZone);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@ -68,7 +72,10 @@ typedef struct {
|
|||||||
_iq calc_rms_array_var_period(RMS_CALC_ARRAY_THINNING *v);
|
_iq calc_rms_array_var_period(RMS_CALC_ARRAY_THINNING *v);
|
||||||
_iq calc_rms_array_var_period_IQ15(RMS_CALC_ARRAY_THINNING *v);
|
_iq calc_rms_array_var_period_IQ15(RMS_CALC_ARRAY_THINNING *v);
|
||||||
float fast_round(float x);
|
float fast_round(float x);
|
||||||
|
float fast_round_with_limiter(float x, float lim);
|
||||||
|
float fast_round_with_delta(float prev, float x, float delta);
|
||||||
|
|
||||||
|
_iq calc_rms(_iq input, _iq input_prev, _iq freq_signal);
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
@ -31,6 +31,8 @@ MODBUS_REG_STRUCT modbus_table_can_in[SIZE_MODBUS_TABLE];
|
|||||||
#pragma DATA_SECTION(modbus_table_can_out,".logs");
|
#pragma DATA_SECTION(modbus_table_can_out,".logs");
|
||||||
MODBUS_REG_STRUCT modbus_table_can_out[SIZE_MODBUS_TABLE];
|
MODBUS_REG_STRUCT modbus_table_can_out[SIZE_MODBUS_TABLE];
|
||||||
|
|
||||||
|
#pragma DATA_SECTION(modbus_table_can_out_temp,".logs");
|
||||||
|
MODBUS_REG_STRUCT modbus_table_can_out_temp[SIZE_MODBUS_TABLE];
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@ -40,8 +42,8 @@ int i;
|
|||||||
|
|
||||||
for (i=0;i<SIZE_MODBUS_TABLE;i++)
|
for (i=0;i<SIZE_MODBUS_TABLE;i++)
|
||||||
{
|
{
|
||||||
modbus_table_rs_in[i].all=0;
|
modbus_table_rs_in[i].all = 0;
|
||||||
modbus_table_can_in[i].all=0;
|
modbus_table_can_in[i].all = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -53,8 +55,9 @@ void clear_modbus_table_out()
|
|||||||
|
|
||||||
for (i=0;i<SIZE_MODBUS_TABLE;i++)
|
for (i=0;i<SIZE_MODBUS_TABLE;i++)
|
||||||
{
|
{
|
||||||
modbus_table_rs_out[i].all= 0;
|
modbus_table_rs_out[i].all = 0;
|
||||||
modbus_table_can_out[i].all= 0;
|
modbus_table_can_out[i].all = 0;
|
||||||
|
modbus_table_can_out_temp[i].all = 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -24,6 +24,7 @@ extern MODBUS_REG_STRUCT modbus_table_rs_out[SIZE_MODBUS_TABLE];
|
|||||||
extern MODBUS_REG_STRUCT modbus_table_rs_in[SIZE_MODBUS_TABLE];
|
extern MODBUS_REG_STRUCT modbus_table_rs_in[SIZE_MODBUS_TABLE];
|
||||||
|
|
||||||
extern MODBUS_REG_STRUCT modbus_table_can_out[SIZE_MODBUS_TABLE];
|
extern MODBUS_REG_STRUCT modbus_table_can_out[SIZE_MODBUS_TABLE];
|
||||||
|
extern MODBUS_REG_STRUCT modbus_table_can_out_temp[SIZE_MODBUS_TABLE];
|
||||||
extern MODBUS_REG_STRUCT modbus_table_can_in[SIZE_MODBUS_TABLE];
|
extern MODBUS_REG_STRUCT modbus_table_can_in[SIZE_MODBUS_TABLE];
|
||||||
|
|
||||||
|
|
||||||
|
@ -26,6 +26,7 @@
|
|||||||
#include "svgen_dq.h"
|
#include "svgen_dq.h"
|
||||||
#include "svgen_mf.h"
|
#include "svgen_mf.h"
|
||||||
#include "dq_to_alphabeta_cos.h"
|
#include "dq_to_alphabeta_cos.h"
|
||||||
|
#include "params_norma.h"
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@ -175,6 +176,7 @@ void uf_disbalance_uzpt(_iq Uzad_uf1, unsigned int disable_alg_u_disbalance, _iq
|
|||||||
_iq pwm_t,delta_U,Uplus,Uminus;
|
_iq pwm_t,delta_U,Uplus,Uminus;
|
||||||
volatile _iq Kplus;
|
volatile _iq Kplus;
|
||||||
static _iq u1=0,u2=0;
|
static _iq u1=0,u2=0;
|
||||||
|
static _iq delta_U_minimal = _IQ (25.0/NORMA_ACP);
|
||||||
|
|
||||||
volatile _iq KplusMax;
|
volatile _iq KplusMax;
|
||||||
|
|
||||||
@ -187,6 +189,9 @@ void uf_disbalance_uzpt(_iq Uzad_uf1, unsigned int disable_alg_u_disbalance, _iq
|
|||||||
|
|
||||||
delta_U = Uplus - Uminus;
|
delta_U = Uplus - Uminus;
|
||||||
|
|
||||||
|
if (_IQabs(delta_U) < delta_U_minimal)
|
||||||
|
delta_U = 0;
|
||||||
|
|
||||||
if (disable_alg_u_disbalance==0)
|
if (disable_alg_u_disbalance==0)
|
||||||
{
|
{
|
||||||
if (kplus_u_disbalance!=0) // åñëè ìû çàäàëè èçâíå, òî åãî è èñïîëüçóåì, ýòî äëÿ òåñòà.
|
if (kplus_u_disbalance!=0) // åñëè ìû çàäàëè èçâíå, òî åãî è èñïîëüçóåì, ýòî äëÿ òåñòà.
|
||||||
@ -350,10 +355,15 @@ void uf_const_f_24_Ing(_iq Fzad_uf1,_iq Fzad_uf2,_iq Uzad_uf1, _iq Uzad_uf2,
|
|||||||
|
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
//#pragma CODE_SECTION(test_calc_simple_dq_pwm24_Ing,".v_24pwm_run");
|
#pragma CODE_SECTION(test_calc_simple_dq_pwm24_Ing,".v_24pwm_run");
|
||||||
void test_calc_simple_dq_pwm24_Ing(_iq Fzad_uf1,_iq Uzad_uf1,
|
void test_calc_simple_dq_pwm24_Ing(_iq Fzad_uf1,
|
||||||
unsigned int disable_alg_u_disbalance, _iq kplus_u_disbalance, _iq k_u_disbalance,
|
_iq Uzad_uf1,
|
||||||
_iq U_1, _iq U_2, unsigned int flag_km_0,
|
unsigned int disable_alg_u_disbalance,
|
||||||
|
_iq kplus_u_disbalance,
|
||||||
|
_iq k_u_disbalance,
|
||||||
|
_iq U_1,
|
||||||
|
_iq U_2,
|
||||||
|
unsigned int flag_km_0,
|
||||||
_iq Uzad_max,
|
_iq Uzad_max,
|
||||||
_iq master_tetta,
|
_iq master_tetta,
|
||||||
_iq master_Uzad_uf1,
|
_iq master_Uzad_uf1,
|
||||||
@ -601,11 +611,14 @@ void test_calc_vect_dq_pwm24_Ing(_iq Theta_zad,_iq Ud_zad, _iq Uq_zad,
|
|||||||
////////////////////////////////////////
|
////////////////////////////////////////
|
||||||
Umod = _IQsqrt(_IQmpy(Ud_zad, Ud_zad) + _IQmpy(Uq_zad, Uq_zad));
|
Umod = _IQsqrt(_IQmpy(Ud_zad, Ud_zad) + _IQmpy(Uq_zad, Uq_zad));
|
||||||
if (Umod > max_Km) {
|
if (Umod > max_Km) {
|
||||||
Uq = _IQsqrt(max_Km_square - _IQmpy(Ud_zad, Ud_zad));
|
Uq_zad = _IQsqrt(max_Km_square - _IQmpy(Ud_zad, Ud_zad));
|
||||||
}
|
}
|
||||||
|
Umod = _IQsqrt(_IQmpy(Ud_zad, Ud_zad) + _IQmpy(Uq_zad, Uq_zad));
|
||||||
|
|
||||||
uf_disbalance_uzpt(Umod, disable_alg_u_disbalance, kplus_u_disbalance,
|
uf_disbalance_uzpt(Umod, disable_alg_u_disbalance, kplus_u_disbalance,
|
||||||
k_u_disbalance, U_1, U_2, Uzad_max, &Kplus);
|
k_u_disbalance, U_1, U_2, Uzad_max, &Kplus);
|
||||||
*Kplus_out = Kplus;
|
*Kplus_out = Kplus;
|
||||||
|
|
||||||
*Uzad_out = Umod;
|
*Uzad_out = Umod;
|
||||||
////////////////////////////////////////
|
////////////////////////////////////////
|
||||||
////////////////////////////////////////
|
////////////////////////////////////////
|
||||||
|
@ -2,9 +2,9 @@
|
|||||||
#include "alg_pll.h"
|
#include "alg_pll.h"
|
||||||
#include "params_pll.h"
|
#include "params_pll.h"
|
||||||
|
|
||||||
|
#include "params_norma.h"
|
||||||
|
|
||||||
|
//#define NORMA_ACP 3000
|
||||||
#define NORMA_ACP 3000
|
|
||||||
//#define FREQ_PWM_VIPR 1975
|
//#define FREQ_PWM_VIPR 1975
|
||||||
|
|
||||||
//#define SIZE_PLL_AVG 50
|
//#define SIZE_PLL_AVG 50
|
||||||
@ -12,8 +12,9 @@
|
|||||||
//_iq w_in_avg[SIZE_PLL_AVG];
|
//_iq w_in_avg[SIZE_PLL_AVG];
|
||||||
//_iq w_out_avg[SIZE_PLL_AVG];
|
//_iq w_out_avg[SIZE_PLL_AVG];
|
||||||
|
|
||||||
#define DETECT_PLL_D (100.0/NORMA_ACP) // ampl
|
#define DETECT_PLL_D (2000.0/NORMA_ACP) // ampl
|
||||||
#define DETECT_PLL_Q (100.0/NORMA_ACP) // zero
|
#define DETECT_PLL_Q (500.0/NORMA_ACP) // zero
|
||||||
|
|
||||||
_iq iqDetect_PLL_d=_IQ(DETECT_PLL_D);
|
_iq iqDetect_PLL_d=_IQ(DETECT_PLL_D);
|
||||||
_iq iqDetect_PLL_q=_IQ(DETECT_PLL_Q);
|
_iq iqDetect_PLL_q=_IQ(DETECT_PLL_Q);
|
||||||
|
|
||||||
@ -104,7 +105,7 @@ void AB_BC_CA_To_ABC(_iq U_AB, _iq U_BC, _iq U_CA, _iq *Ua, _iq *Ub, _iq *Uc)
|
|||||||
|
|
||||||
|
|
||||||
/////////////////////////////////////////////////
|
/////////////////////////////////////////////////
|
||||||
//#pragma CODE_SECTION(PLLController,".fast_run");
|
#pragma CODE_SECTION(PLLController,".fast_run");
|
||||||
/////////////////////////////////////////////////
|
/////////////////////////////////////////////////
|
||||||
void PLLController(PLL_REC *v)
|
void PLLController(PLL_REC *v)
|
||||||
{
|
{
|
||||||
@ -318,9 +319,9 @@ void PLLController(PLL_REC *v)
|
|||||||
//////////////////////////////////////////////////
|
//////////////////////////////////////////////////
|
||||||
//////////////////////////////////////////////////
|
//////////////////////////////////////////////////
|
||||||
/////////////////////////////////////////////////
|
/////////////////////////////////////////////////
|
||||||
#pragma CODE_SECTION(pll_get_freq,".fast_run");
|
//#pragma CODE_SECTION(pll_get_freq,".fast_run");
|
||||||
/////////////////////////////////////////////////
|
/////////////////////////////////////////////////
|
||||||
void pll_get_freq(PLL_REC *v)
|
void pll_get_freq_float(PLL_REC *v)
|
||||||
{
|
{
|
||||||
|
|
||||||
if (v->output.flag_find_pll)
|
if (v->output.flag_find_pll)
|
||||||
@ -336,9 +337,22 @@ void pll_get_freq(PLL_REC *v)
|
|||||||
|
|
||||||
//////////////////////////////////////////////////
|
//////////////////////////////////////////////////
|
||||||
//////////////////////////////////////////////////
|
//////////////////////////////////////////////////
|
||||||
|
void pll_get_freq_iq(PLL_REC *v)
|
||||||
|
{
|
||||||
|
|
||||||
|
if (v->output.flag_find_pll)
|
||||||
|
{
|
||||||
|
v->output.iq_freq_net = v->vars.w_shtrih;//_IQtoF( v->vars.w_shtrih) * v->setup.freq_run_pll / PI * 50.00; // freq*100
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
v->output.iq_freq_net = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
//////////////////////////////////////////////////
|
//////////////////////////////////////////////////
|
||||||
|
//#pragma CODE_SECTION(detect_phase_count,".fast_run");
|
||||||
void detect_phase_count(PLL_REC *v)
|
void detect_phase_count(PLL_REC *v)
|
||||||
{
|
{
|
||||||
static _iq prev_Ua = 0;
|
static _iq prev_Ua = 0;
|
||||||
|
@ -59,10 +59,11 @@ typedef struct { _iq Input_U_AB; //
|
|||||||
|
|
||||||
typedef struct { int flag_find_pll;
|
typedef struct { int flag_find_pll;
|
||||||
int int_freq_net;
|
int int_freq_net;
|
||||||
|
_iq iq_freq_net;
|
||||||
int status;
|
int status;
|
||||||
} PLL_OUTPUT;
|
} PLL_OUTPUT;
|
||||||
|
|
||||||
#define PLL_OUTPUT_DEFAULT {0, 0, STATUS_PLL_NOT_INITED}
|
#define PLL_OUTPUT_DEFAULT {0, 0, 0, STATUS_PLL_NOT_INITED}
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////
|
||||||
////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////
|
||||||
@ -139,7 +140,8 @@ typedef struct { PLL_INPUT input;
|
|||||||
PLL_VARS vars;
|
PLL_VARS vars;
|
||||||
void (*init)(); // Pointer to calculation function
|
void (*init)(); // Pointer to calculation function
|
||||||
void (*calc_pll)(); // Pointer to calculation function
|
void (*calc_pll)(); // Pointer to calculation function
|
||||||
void (*get_freq)(); // Pointer to calculation function
|
void (*get_freq_float)(); // Pointer to calculation function
|
||||||
|
void (*get_freq_iq)();
|
||||||
}PLL_REC;
|
}PLL_REC;
|
||||||
|
|
||||||
typedef PLL_REC *PLL_REC_handle;
|
typedef PLL_REC *PLL_REC_handle;
|
||||||
@ -151,12 +153,14 @@ typedef PLL_REC *PLL_REC_handle;
|
|||||||
PLL_VARS_DEFAULT,\
|
PLL_VARS_DEFAULT,\
|
||||||
(void (*)(unsigned long))pll_init,\
|
(void (*)(unsigned long))pll_init,\
|
||||||
(void (*)(unsigned long))pll_calc,\
|
(void (*)(unsigned long))pll_calc,\
|
||||||
(void (*)(unsigned long))pll_get_freq\
|
(void (*)(unsigned long))pll_get_freq_float,\
|
||||||
|
(void (*)(unsigned long))pll_get_freq_iq \
|
||||||
}
|
}
|
||||||
|
|
||||||
void pll_init(PLL_REC_handle);
|
void pll_init(PLL_REC_handle);
|
||||||
void pll_calc(PLL_REC_handle);
|
void pll_calc(PLL_REC_handle);
|
||||||
void pll_get_freq(PLL_REC_handle);
|
void pll_get_freq_float(PLL_REC_handle);
|
||||||
|
void pll_get_freq_iq(PLL_REC_handle);
|
||||||
|
|
||||||
void Find_zero_Uabc(PLL_REC_handle);
|
void Find_zero_Uabc(PLL_REC_handle);
|
||||||
void PLLController(PLL_REC *v);
|
void PLLController(PLL_REC *v);
|
||||||
|
@ -32,7 +32,7 @@ void init_teta_calc_struct()
|
|||||||
tetta_calc.hz_to_angle = _IQ(2.0 * PI * NORMA_FROTOR / FREQ_PWM);
|
tetta_calc.hz_to_angle = _IQ(2.0 * PI * NORMA_FROTOR / FREQ_PWM);
|
||||||
}
|
}
|
||||||
|
|
||||||
#pragma CODE_SECTION(calc_teta_Id,".fast_run");
|
//#pragma CODE_SECTION(calc_teta_Id,".fast_run");
|
||||||
void calc_teta_Id(_iq Frot, _iq Id, _iq Iq, _iq *theta_out, _iq *theta_to_slave, _iq *Fsl_out, _iq *Fstator_out,
|
void calc_teta_Id(_iq Frot, _iq Id, _iq Iq, _iq *theta_out, _iq *theta_to_slave, _iq *Fsl_out, _iq *Fstator_out,
|
||||||
unsigned int master, int reset) {
|
unsigned int master, int reset) {
|
||||||
|
|
||||||
@ -56,9 +56,10 @@ void calc_teta_Id(_iq Frot, _iq Id, _iq Iq, _iq *theta_out, _iq *theta_to_slave,
|
|||||||
} else {
|
} else {
|
||||||
Fsl = 0;
|
Fsl = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (Fsl > MAX_Ud_Pid_Out_Id) { Fsl = MAX_Ud_Pid_Out_Id;}
|
if (Fsl > MAX_Ud_Pid_Out_Id) { Fsl = MAX_Ud_Pid_Out_Id;}
|
||||||
// if (Fsl < -MAX_Ud_Pid_Out_Id) { Fsl = -MAX_Ud_Pid_Out_Id;}
|
if (Fsl < -MAX_Ud_Pid_Out_Id) { Fsl = -MAX_Ud_Pid_Out_Id;}
|
||||||
if (Fsl < 0) { Fsl = 0;}
|
// if (Fsl < 0) { Fsl = 0;}
|
||||||
|
|
||||||
Fst = Frot * POLUS + Fsl;
|
Fst = Frot * POLUS + Fsl;
|
||||||
add_to_tic = _IQmpy(Fst, tetta_calc.hz_to_angle);
|
add_to_tic = _IQmpy(Fst, tetta_calc.hz_to_angle);
|
||||||
|
@ -85,7 +85,7 @@ void vectorControlConstId (_iq Pzad, _iq Fzad, int direction, _iq Frot,
|
|||||||
_iq P_measured = 0;
|
_iq P_measured = 0;
|
||||||
static _iq Ud_zad1 = 0, Uq_zad1 = 0, Ud_zad2 = 0, Uq_zad2 = 0;
|
static _iq Ud_zad1 = 0, Uq_zad1 = 0, Ud_zad2 = 0, Uq_zad2 = 0;
|
||||||
|
|
||||||
if(direction < 0) { Frot = -Frot; }
|
// if(direction < 0) { Frot = -Frot; }
|
||||||
|
|
||||||
if (reset) {
|
if (reset) {
|
||||||
Ud_zad1 = 0;
|
Ud_zad1 = 0;
|
||||||
@ -134,8 +134,13 @@ void vectorControlConstId (_iq Pzad, _iq Fzad, int direction, _iq Frot,
|
|||||||
vect_control.iqUqKm = Uq_zad1 + vect_control.iqUqCompensation;
|
vect_control.iqUqKm = Uq_zad1 + vect_control.iqUqCompensation;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
vect_control.sqrtIdq1 = _IQsqrt(_IQmpy(vect_control.iqId1, vect_control.iqId1) + _IQmpy(vect_control.iqIq1, vect_control.iqIq1));
|
||||||
analog_Udq_calc(Ud_zad1, Uq_zad1, Ud_zad2, Uq_zad2);
|
analog_Udq_calc(Ud_zad1, Uq_zad1, Ud_zad2, Uq_zad2);
|
||||||
*Iq_to_slave = Iq_zad;
|
*Iq_to_slave = Iq_zad;
|
||||||
|
|
||||||
|
vect_control.Iq_zad1 = Iq_zad;
|
||||||
|
vect_control.Id_zad1 = Id_zad;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -49,12 +49,22 @@ typedef struct {
|
|||||||
_iq koef_Ud_comp;
|
_iq koef_Ud_comp;
|
||||||
_iq koef_Uq_comp;
|
_iq koef_Uq_comp;
|
||||||
_iq koef_zero_Uzad;
|
_iq koef_zero_Uzad;
|
||||||
|
_iq add_tetta;
|
||||||
|
|
||||||
|
_iq sqrtIdq1;
|
||||||
|
_iq sqrtIdq2;
|
||||||
|
|
||||||
|
_iq Iq_zad1;
|
||||||
|
_iq Id_zad1;
|
||||||
|
|
||||||
|
_iq add_bpsi;
|
||||||
|
|
||||||
} VECTOR_CONTROL;
|
} VECTOR_CONTROL;
|
||||||
|
|
||||||
#define VECTOR_CONTROL_DEFAULTS {PIDREG3_DEFAULTS, PIDREG3_DEFAULTS, \
|
#define VECTOR_CONTROL_DEFAULTS {PIDREG3_DEFAULTS, PIDREG3_DEFAULTS, \
|
||||||
PIDREG3_DEFAULTS, PIDREG3_DEFAULTS, \
|
PIDREG3_DEFAULTS, PIDREG3_DEFAULTS, \
|
||||||
0,0,0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0, \
|
0,0,0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0, \
|
||||||
0,0,0,0,0,0,0,0,0,0,0}
|
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}
|
||||||
|
|
||||||
void vectorControlConstId (_iq Pzad, _iq Fzad, int direction, _iq Frot,
|
void vectorControlConstId (_iq Pzad, _iq Fzad, int direction, _iq Frot,
|
||||||
int n_alg, unsigned int master, _iq mzz_zad,
|
int n_alg, unsigned int master, _iq mzz_zad,
|
||||||
|
@ -73,6 +73,9 @@ typedef struct
|
|||||||
CMD_DIGIT_BYTE_STRUCT Byte03;
|
CMD_DIGIT_BYTE_STRUCT Byte03;
|
||||||
CMD_DIGIT_BYTE_STRUCT Byte04;
|
CMD_DIGIT_BYTE_STRUCT Byte04;
|
||||||
|
|
||||||
|
CMD_DIGIT_BYTE_STRUCT Byte05;
|
||||||
|
CMD_DIGIT_BYTE_STRUCT Byte06;
|
||||||
|
|
||||||
} CMD_DIGIT_DATA_STRUCT;
|
} CMD_DIGIT_DATA_STRUCT;
|
||||||
|
|
||||||
typedef struct
|
typedef struct
|
||||||
@ -112,6 +115,13 @@ typedef struct
|
|||||||
CHAR analog1_hi; // ñòàðøèé áàéò çàäàííîé ñêîðîñòè
|
CHAR analog1_hi; // ñòàðøèé áàéò çàäàííîé ñêîðîñòè
|
||||||
CHAR analog2_lo; // ìëàäøèé áàéò çàäàííîé ñêîðîñòè
|
CHAR analog2_lo; // ìëàäøèé áàéò çàäàííîé ñêîðîñòè
|
||||||
CHAR analog2_hi; // ñòàðøèé áàéò çàäàííîé ñêîðîñòè
|
CHAR analog2_hi; // ñòàðøèé áàéò çàäàííîé ñêîðîñòè
|
||||||
|
CHAR analog3_lo; // ìëàäøèé áàéò çàäàííîé ñêîðîñòè
|
||||||
|
CHAR analog3_hi; // ñòàðøèé áàéò çàäàííîé ñêîðîñòè
|
||||||
|
CHAR analog4_lo; // ìëàäøèé áàéò çàäàííîé ñêîðîñòè
|
||||||
|
CHAR analog4_hi; // ñòàðøèé áàéò çàäàííîé ñêîðîñòè
|
||||||
|
CHAR analog5_lo; // ìëàäøèé áàéò çàäàííîé ñêîðîñòè
|
||||||
|
CHAR analog5_hi; // ñòàðøèé áàéò çàäàííîé ñêîðîñòè
|
||||||
|
|
||||||
} CMD_ANALOG_DATA_TEST_ALL_STRUCT;
|
} CMD_ANALOG_DATA_TEST_ALL_STRUCT;
|
||||||
|
|
||||||
typedef struct
|
typedef struct
|
||||||
@ -211,6 +221,19 @@ typedef struct
|
|||||||
CMD_DIGIT_BYTE_STRUCT byte49;
|
CMD_DIGIT_BYTE_STRUCT byte49;
|
||||||
CMD_DIGIT_BYTE_STRUCT byte50;
|
CMD_DIGIT_BYTE_STRUCT byte50;
|
||||||
|
|
||||||
|
CMD_DIGIT_BYTE_STRUCT byte51;
|
||||||
|
CMD_DIGIT_BYTE_STRUCT byte52;
|
||||||
|
|
||||||
|
CMD_DIGIT_BYTE_STRUCT byte53;
|
||||||
|
CMD_DIGIT_BYTE_STRUCT byte54;
|
||||||
|
|
||||||
|
CMD_DIGIT_BYTE_STRUCT byte55;
|
||||||
|
CMD_DIGIT_BYTE_STRUCT byte56;
|
||||||
|
|
||||||
|
CMD_DIGIT_BYTE_STRUCT byte57;
|
||||||
|
CMD_DIGIT_BYTE_STRUCT byte58;
|
||||||
|
CMD_DIGIT_BYTE_STRUCT byte59;
|
||||||
|
CMD_DIGIT_BYTE_STRUCT byte60;
|
||||||
|
|
||||||
} ANS_DIGIT_DATA_TO_TERMINAL_STRUCT; // Äèñêðåòíûå âåëè÷èíû ïîñûëêè îò ÑÓ
|
} ANS_DIGIT_DATA_TO_TERMINAL_STRUCT; // Äèñêðåòíûå âåëè÷èíû ïîñûëêè îò ÑÓ
|
||||||
|
|
||||||
@ -361,6 +384,67 @@ typedef struct
|
|||||||
CHAR analog68_lo;
|
CHAR analog68_lo;
|
||||||
CHAR analog68_hi;
|
CHAR analog68_hi;
|
||||||
|
|
||||||
|
CHAR analog69_lo;
|
||||||
|
CHAR analog69_hi;
|
||||||
|
CHAR analog70_lo;
|
||||||
|
CHAR analog70_hi;
|
||||||
|
CHAR analog71_lo;
|
||||||
|
CHAR analog71_hi;
|
||||||
|
CHAR analog72_lo;
|
||||||
|
CHAR analog72_hi;
|
||||||
|
CHAR analog73_lo;
|
||||||
|
CHAR analog73_hi;
|
||||||
|
CHAR analog74_lo;
|
||||||
|
CHAR analog74_hi;
|
||||||
|
CHAR analog75_lo;
|
||||||
|
CHAR analog75_hi;
|
||||||
|
CHAR analog76_lo;
|
||||||
|
CHAR analog76_hi;
|
||||||
|
CHAR analog77_lo;
|
||||||
|
CHAR analog77_hi;
|
||||||
|
CHAR analog78_lo;
|
||||||
|
CHAR analog78_hi;
|
||||||
|
CHAR analog79_lo;
|
||||||
|
CHAR analog79_hi;
|
||||||
|
CHAR analog80_lo;
|
||||||
|
CHAR analog80_hi;
|
||||||
|
|
||||||
|
CHAR analog81_lo;
|
||||||
|
CHAR analog81_hi;
|
||||||
|
CHAR analog82_lo;
|
||||||
|
CHAR analog82_hi;
|
||||||
|
CHAR analog83_lo;
|
||||||
|
CHAR analog83_hi;
|
||||||
|
CHAR analog84_lo;
|
||||||
|
CHAR analog84_hi;
|
||||||
|
|
||||||
|
CHAR analog85_lo;
|
||||||
|
CHAR analog85_hi;
|
||||||
|
CHAR analog86_lo;
|
||||||
|
CHAR analog86_hi;
|
||||||
|
CHAR analog87_lo;
|
||||||
|
CHAR analog87_hi;
|
||||||
|
CHAR analog88_lo;
|
||||||
|
CHAR analog88_hi;
|
||||||
|
CHAR analog89_lo;
|
||||||
|
CHAR analog89_hi;
|
||||||
|
|
||||||
|
CHAR analog90_lo;
|
||||||
|
CHAR analog90_hi;
|
||||||
|
CHAR analog91_lo;
|
||||||
|
CHAR analog91_hi;
|
||||||
|
CHAR analog92_lo;
|
||||||
|
CHAR analog92_hi;
|
||||||
|
CHAR analog93_lo;
|
||||||
|
CHAR analog93_hi;
|
||||||
|
CHAR analog94_lo;
|
||||||
|
CHAR analog94_hi;
|
||||||
|
|
||||||
|
CHAR analog95_lo;
|
||||||
|
CHAR analog95_hi;
|
||||||
|
CHAR analog96_lo;
|
||||||
|
CHAR analog96_hi;
|
||||||
|
|
||||||
|
|
||||||
} TMS_ANALOG_DATA_STRUCT;
|
} TMS_ANALOG_DATA_STRUCT;
|
||||||
|
|
||||||
@ -414,6 +498,17 @@ typedef struct
|
|||||||
CMD_DIGIT_BYTE_STRUCT byte23;
|
CMD_DIGIT_BYTE_STRUCT byte23;
|
||||||
CMD_DIGIT_BYTE_STRUCT byte24;
|
CMD_DIGIT_BYTE_STRUCT byte24;
|
||||||
|
|
||||||
|
CMD_DIGIT_BYTE_STRUCT byte25;
|
||||||
|
CMD_DIGIT_BYTE_STRUCT byte26;
|
||||||
|
CMD_DIGIT_BYTE_STRUCT byte27;
|
||||||
|
CMD_DIGIT_BYTE_STRUCT byte28;
|
||||||
|
CMD_DIGIT_BYTE_STRUCT byte29;
|
||||||
|
CMD_DIGIT_BYTE_STRUCT byte30;
|
||||||
|
CMD_DIGIT_BYTE_STRUCT byte31;
|
||||||
|
CMD_DIGIT_BYTE_STRUCT byte32;
|
||||||
|
CMD_DIGIT_BYTE_STRUCT byte33;
|
||||||
|
CMD_DIGIT_BYTE_STRUCT byte34;
|
||||||
|
|
||||||
} ANS_DIGIT_DATA_TO_TERMINAL_TEST_ALL_STRUCT;
|
} ANS_DIGIT_DATA_TO_TERMINAL_TEST_ALL_STRUCT;
|
||||||
|
|
||||||
typedef struct
|
typedef struct
|
||||||
|
@ -1,3 +1,5 @@
|
|||||||
|
#include "params.h"
|
||||||
|
#include "global_time.h"
|
||||||
#include "RS_Functions.h"
|
#include "RS_Functions.h"
|
||||||
|
|
||||||
#include <project.h>
|
#include <project.h>
|
||||||
@ -16,6 +18,9 @@
|
|||||||
#include "CRC_Functions.h"
|
#include "CRC_Functions.h"
|
||||||
#include "TuneUpPlane.h" //ñâåòîäèîäèê
|
#include "TuneUpPlane.h" //ñâåòîäèîäèê
|
||||||
|
|
||||||
|
#include "pwm_test_lines.h"
|
||||||
|
#include "profile_interrupt.h"
|
||||||
|
|
||||||
|
|
||||||
#define _ENABLE_INTERRUPT_RS232_LED2 0//1
|
#define _ENABLE_INTERRUPT_RS232_LED2 0//1
|
||||||
|
|
||||||
@ -24,8 +29,8 @@
|
|||||||
|
|
||||||
#define RS232_SPEED 57600//115200
|
#define RS232_SPEED 57600//115200
|
||||||
|
|
||||||
#define COM_1 1
|
#define COM_1 0 //1
|
||||||
#define COM_2 2
|
#define COM_2 1 //2
|
||||||
//#define SIZE_MODBUS_TABLE 334
|
//#define SIZE_MODBUS_TABLE 334
|
||||||
//#define ADR_MODBUS_TABLE 0x0001
|
//#define ADR_MODBUS_TABLE 0x0001
|
||||||
|
|
||||||
@ -77,8 +82,7 @@
|
|||||||
//#define SCIb_Wait4OK() while(!SCIb_OK())
|
//#define SCIb_Wait4OK() while(!SCIb_OK())
|
||||||
#define SCIb_Send(a) ScibRegs.SCITXBUF = (unsigned char)a
|
#define SCIb_Send(a) ScibRegs.SCITXBUF = (unsigned char)a
|
||||||
|
|
||||||
#define EnableReceiveRS485() GpioDataRegs.GPBDAT.bit.GPIOB14 = 1
|
|
||||||
#define EnableSendRS485() GpioDataRegs.GPBDAT.bit.GPIOB14 = 0
|
|
||||||
|
|
||||||
#define SCIa_Get() SciaRegs.SCIRXBUF.bit.RXDT
|
#define SCIa_Get() SciaRegs.SCIRXBUF.bit.RXDT
|
||||||
|
|
||||||
@ -107,10 +111,10 @@ unsigned int RS_Len[RS_LEN_CMD] = {0};
|
|||||||
char size_cmd15 = 1;
|
char size_cmd15 = 1;
|
||||||
char size_cmd16 = 1;
|
char size_cmd16 = 1;
|
||||||
|
|
||||||
unsigned int enable_profile_led1_rsa = 1;
|
//unsigned int enable_profile_led1_rsa = 1;
|
||||||
unsigned int enable_profile_led1_rsb = 1;
|
//unsigned int enable_profile_led1_rsb = 1;
|
||||||
unsigned int enable_profile_led2_rsa = 0;
|
//unsigned int enable_profile_led2_rsa = 0;
|
||||||
unsigned int enable_profile_led2_rsb = 0;
|
//unsigned int enable_profile_led2_rsb = 0;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@ -121,6 +125,8 @@ int ADDR_FOR_ALL = ADDR_FOR_ALL_DEF;
|
|||||||
float KmodTerm = 0.0, freqTerm = 0.0;
|
float KmodTerm = 0.0, freqTerm = 0.0;
|
||||||
|
|
||||||
int flag_special_mode_rs = 0;
|
int flag_special_mode_rs = 0;
|
||||||
|
int disable_flag_special_mode_rs = 0;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
void RS_Wait4OK_TXRDY(char commnumber);
|
void RS_Wait4OK_TXRDY(char commnumber);
|
||||||
@ -141,6 +147,27 @@ void RS_LineToSend(char commnumber);
|
|||||||
void RS_TX_Handler(RS_DATA_STRUCT *RS232_Arr);
|
void RS_TX_Handler(RS_DATA_STRUCT *RS232_Arr);
|
||||||
//int RS232_BSend(RS_DATA_STRUCT *RS232_Arr,unsigned int *pBuf, unsigned long len);
|
//int RS232_BSend(RS_DATA_STRUCT *RS232_Arr,unsigned int *pBuf, unsigned long len);
|
||||||
|
|
||||||
|
|
||||||
|
void EnableReceiveRS485(void)
|
||||||
|
{
|
||||||
|
#if(_ENABLE_PWM_LINES_FOR_TESTS_RS)
|
||||||
|
PWM_LINES_TK_19_ON;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
GpioDataRegs.GPBDAT.bit.GPIOB14 = 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
void EnableSendRS485(void)
|
||||||
|
{
|
||||||
|
|
||||||
|
#if(_ENABLE_PWM_LINES_FOR_TESTS_RS)
|
||||||
|
PWM_LINES_TK_19_OFF;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
GpioDataRegs.GPBDAT.bit.GPIOB14 = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
void T_Flash(RS_DATA_STRUCT *RS232_Arr)
|
void T_Flash(RS_DATA_STRUCT *RS232_Arr)
|
||||||
{
|
{
|
||||||
volatile unsigned long Address1,Address2;
|
volatile unsigned long Address1,Address2;
|
||||||
@ -311,9 +338,12 @@ void SCI_SwReset(char commnumber)
|
|||||||
//////////////////////////////////////////////////////////////
|
//////////////////////////////////////////////////////////////
|
||||||
//////////////////////////////////////////////////////////////
|
//////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
static int buf_fifo_rsa[17]={0,0,0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0};
|
//static int buf_fifo_rsa[17]={0,0,0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0};
|
||||||
static int buf_fifo_rsb[17]={0,0,0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0};
|
//static int buf_fifo_rsb[17]={0,0,0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0};
|
||||||
|
|
||||||
|
static int buf_fifo_rs_ab[2][17]={ {0,0,0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0}, {0,0,0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0} };
|
||||||
|
|
||||||
|
#pragma CODE_SECTION(my_test_rs,".fast_run2");
|
||||||
int my_test_rs(int comn)
|
int my_test_rs(int comn)
|
||||||
{
|
{
|
||||||
int cc=0;
|
int cc=0;
|
||||||
@ -323,7 +353,7 @@ int my_test_rs(int comn)
|
|||||||
{
|
{
|
||||||
while ((SciaRegs.SCIFFRX.bit.RXFIFST != 0) )
|
while ((SciaRegs.SCIFFRX.bit.RXFIFST != 0) )
|
||||||
{
|
{
|
||||||
buf_fifo_rsa[cc++] = SciaRegs.SCIRXBUF.bit.RXDT;
|
buf_fifo_rs_ab[comn][cc++] = SciaRegs.SCIRXBUF.bit.RXDT;
|
||||||
if (cc>=17) cc = 0;
|
if (cc>=17) cc = 0;
|
||||||
}
|
}
|
||||||
return cc;
|
return cc;
|
||||||
@ -332,7 +362,7 @@ int my_test_rs(int comn)
|
|||||||
{
|
{
|
||||||
while ((ScibRegs.SCIFFRX.bit.RXFIFST != 0) )
|
while ((ScibRegs.SCIFFRX.bit.RXFIFST != 0) )
|
||||||
{
|
{
|
||||||
buf_fifo_rsb[cc++] = ScibRegs.SCIRXBUF.bit.RXDT;
|
buf_fifo_rs_ab[comn][cc++] = ScibRegs.SCIRXBUF.bit.RXDT;
|
||||||
if (cc>=17) cc = 0;
|
if (cc>=17) cc = 0;
|
||||||
}
|
}
|
||||||
return cc;
|
return cc;
|
||||||
@ -341,6 +371,7 @@ int my_test_rs(int comn)
|
|||||||
}
|
}
|
||||||
|
|
||||||
///////////////
|
///////////////
|
||||||
|
//#pragma CODE_SECTION(RS_RXA_Handler_fast,".fast_run2");
|
||||||
void RS_RXA_Handler_fast(RS_DATA_STRUCT *RS232_Arr)
|
void RS_RXA_Handler_fast(RS_DATA_STRUCT *RS232_Arr)
|
||||||
{
|
{
|
||||||
char Rc;
|
char Rc;
|
||||||
@ -349,6 +380,7 @@ void RS_RXA_Handler_fast(RS_DATA_STRUCT *RS232_Arr)
|
|||||||
|
|
||||||
//i_led2_on_off(1);
|
//i_led2_on_off(1);
|
||||||
|
|
||||||
|
|
||||||
ClearTimerRS_Live(RS232_Arr);
|
ClearTimerRS_Live(RS232_Arr);
|
||||||
|
|
||||||
cn = RS232_Arr->commnumber;
|
cn = RS232_Arr->commnumber;
|
||||||
@ -361,7 +393,7 @@ void RS_RXA_Handler_fast(RS_DATA_STRUCT *RS232_Arr)
|
|||||||
if (SciaRegs.SCIRXST.bit.RXERROR)
|
if (SciaRegs.SCIRXST.bit.RXERROR)
|
||||||
{
|
{
|
||||||
// Rc = SciaRegs.SCIRXBUF.all;
|
// Rc = SciaRegs.SCIRXBUF.all;
|
||||||
RS232_Arr->count_recive_rxerror++;
|
(RS232_Arr->count_recive_rxerror)++;
|
||||||
RS232_Arr->do_resetup_rs = 1;
|
RS232_Arr->do_resetup_rs = 1;
|
||||||
}
|
}
|
||||||
if (SciaRegs.SCIRXST.bit.RXWAKE)
|
if (SciaRegs.SCIRXST.bit.RXWAKE)
|
||||||
@ -375,7 +407,7 @@ void RS_RXA_Handler_fast(RS_DATA_STRUCT *RS232_Arr)
|
|||||||
if (ScibRegs.SCIRXST.bit.RXERROR)
|
if (ScibRegs.SCIRXST.bit.RXERROR)
|
||||||
{
|
{
|
||||||
// Rc = SciaRegs.SCIRXBUF.all;
|
// Rc = SciaRegs.SCIRXBUF.all;
|
||||||
RS232_Arr->count_recive_rxerror++;
|
(RS232_Arr->count_recive_rxerror)++;
|
||||||
RS232_Arr->do_resetup_rs = 1;
|
RS232_Arr->do_resetup_rs = 1;
|
||||||
}
|
}
|
||||||
if (ScibRegs.SCIRXST.bit.RXWAKE)
|
if (ScibRegs.SCIRXST.bit.RXWAKE)
|
||||||
@ -403,12 +435,14 @@ void RS_RXA_Handler_fast(RS_DATA_STRUCT *RS232_Arr)
|
|||||||
// continue;
|
// continue;
|
||||||
// }
|
// }
|
||||||
cc1--;
|
cc1--;
|
||||||
if (cn==COM_1)
|
|
||||||
Rc = buf_fifo_rsa[cc2++];//SciaRegs.SCIRXBUF.all;// SciaRegs.SCIRXBUF.bit.RXDT;//RS_Get(RS232_Arr->commnumber); // ×èòàåì ñèìâîë â ëþáîì ñëó÷àå
|
|
||||||
else
|
|
||||||
Rc = buf_fifo_rsb[cc2++];
|
|
||||||
|
|
||||||
RS232_Arr->count_recive_bytes_all++;
|
// if (cn==COM_1)
|
||||||
|
Rc = buf_fifo_rs_ab[cn][cc2];//SciaRegs.SCIRXBUF.all;// SciaRegs.SCIRXBUF.bit.RXDT;//RS_Get(RS232_Arr->commnumber); // ×èòàåì ñèìâîë â ëþáîì ñëó÷àå
|
||||||
|
// else
|
||||||
|
// Rc = buf_fifo_rsb[cc2];
|
||||||
|
cc2++;
|
||||||
|
|
||||||
|
(RS232_Arr->count_recive_bytes_all)++;
|
||||||
//i_led2_on_off(0);
|
//i_led2_on_off(0);
|
||||||
|
|
||||||
if(RS232_Arr->RS_DataReady)
|
if(RS232_Arr->RS_DataReady)
|
||||||
@ -428,7 +462,7 @@ void RS_RXA_Handler_fast(RS_DATA_STRUCT *RS232_Arr)
|
|||||||
//i_led2_on_off(1);
|
//i_led2_on_off(1);
|
||||||
if(RS232_Arr->RS_FlagSkiping)
|
if(RS232_Arr->RS_FlagSkiping)
|
||||||
{
|
{
|
||||||
RS232_Arr->count_recive_bytes_skipped++;
|
(RS232_Arr->count_recive_bytes_skipped)++;
|
||||||
continue; // Íå íàì
|
continue; // Íå íàì
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -448,10 +482,10 @@ void RS_RXA_Handler_fast(RS_DATA_STRUCT *RS232_Arr)
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
i_led1_toggle();
|
//i_led1_toggle();
|
||||||
RS232_Arr->RS_FlagSkiping = true; // Íå íàøåìó êîíòðîëëåðó
|
RS232_Arr->RS_FlagSkiping = true; // Íå íàøåìó êîíòðîëëåðó
|
||||||
RS232_Arr->RS_FlagBegin = false; // îñòàëèñü â 9-áèò ðåæèìå
|
RS232_Arr->RS_FlagBegin = false; // îñòàëèñü â 9-áèò ðåæèìå
|
||||||
RS232_Arr->count_recive_cmd_skipped++;
|
(RS232_Arr->count_recive_cmd_skipped)++;
|
||||||
//i_led1_on_off(0);
|
//i_led1_on_off(0);
|
||||||
}
|
}
|
||||||
//i_led2_on_off(1);
|
//i_led2_on_off(1);
|
||||||
@ -490,7 +524,7 @@ i_led1_toggle();
|
|||||||
RS232_Arr->RS_FlagBegin = true;
|
RS232_Arr->RS_FlagBegin = true;
|
||||||
RS232_Arr->RS_FlagSkiping = false;
|
RS232_Arr->RS_FlagSkiping = false;
|
||||||
RS232_Arr->RS_Cmd=0;
|
RS232_Arr->RS_Cmd=0;
|
||||||
RS232_Arr->count_recive_bad++;
|
(RS232_Arr->count_recive_bad)++;
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
if(RS232_Arr->RS_Cmd == 4) {
|
if(RS232_Arr->RS_Cmd == 4) {
|
||||||
@ -510,7 +544,7 @@ i_led1_toggle();
|
|||||||
RS232_Arr->RS_FlagSkiping = true;
|
RS232_Arr->RS_FlagSkiping = true;
|
||||||
RS232_Arr->RS_DataReady = true;
|
RS232_Arr->RS_DataReady = true;
|
||||||
RS232_Arr->RS_Cmd=0;
|
RS232_Arr->RS_Cmd=0;
|
||||||
RS232_Arr->count_recive_dirty++;
|
(RS232_Arr->count_recive_dirty)++;
|
||||||
}
|
}
|
||||||
//i_led2_on_off(1);
|
//i_led2_on_off(1);
|
||||||
}
|
}
|
||||||
@ -525,14 +559,14 @@ i_led1_toggle();
|
|||||||
|
|
||||||
if(RS232_Arr->RS_PrevCmd != CMD_RS232_INITLOAD)
|
if(RS232_Arr->RS_PrevCmd != CMD_RS232_INITLOAD)
|
||||||
{
|
{
|
||||||
RS232_Arr->count_recive_bad++;
|
(RS232_Arr->count_recive_bad)++;
|
||||||
continue; // Ìû çäåñü îêàçàëèñü ïî êàêîé-òî ÷óäîâèùíîé îøèáêå
|
continue; // Ìû çäåñü îêàçàëèñü ïî êàêîé-òî ÷óäîâèùíîé îøèáêå
|
||||||
}
|
}
|
||||||
|
|
||||||
if(RS232_Arr->RS_DataReady) // Åñëè äàííûå â îñíîâíîì öèêëå íå çàáðàíû,
|
if(RS232_Arr->RS_DataReady) // Åñëè äàííûå â îñíîâíîì öèêëå íå çàáðàíû,
|
||||||
{ // òî ïðîïóñêàåì ñëåäóþùóþ ïîñûëêó
|
{ // òî ïðîïóñêàåì ñëåäóþùóþ ïîñûëêó
|
||||||
RS232_Arr->RS_FlagSkiping = true; // Èãíîðèðóåì äî ñëåäóþùåãî çàãîëîâêà
|
RS232_Arr->RS_FlagSkiping = true; // Èãíîðèðóåì äî ñëåäóþùåãî çàãîëîâêà
|
||||||
RS232_Arr->count_recive_cmd_skipped++;
|
(RS232_Arr->count_recive_cmd_skipped)++;
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -546,7 +580,7 @@ i_led1_toggle();
|
|||||||
RS_SetBitMode(RS232_Arr,9); // Ïîëó÷èëè âñå äàííûå ïåðåñòðîèëèñü â 9-áèò äëß RS485?
|
RS_SetBitMode(RS232_Arr,9); // Ïîëó÷èëè âñå äàííûå ïåðåñòðîèëèñü â 9-áèò äëß RS485?
|
||||||
RS232_Arr->RS_FlagSkiping = true; // Èãíîðèðóåì äî ñëåäóþùåãî çàãîëîâêà
|
RS232_Arr->RS_FlagSkiping = true; // Èãíîðèðóåì äî ñëåäóþùåãî çàãîëîâêà
|
||||||
RS232_Arr->RS_DataReady = true; // Ôëàã â îñíîâíîé öèêë - äàííûå ïîëó÷åíû
|
RS232_Arr->RS_DataReady = true; // Ôëàã â îñíîâíîé öèêë - äàííûå ïîëó÷åíû
|
||||||
RS232_Arr->count_recive_dirty++;
|
(RS232_Arr->count_recive_dirty)++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -569,15 +603,20 @@ int get_free_rs_fifo_tx(char commnumber)
|
|||||||
void RS_TX_Handler(RS_DATA_STRUCT *RS232_Arr)
|
void RS_TX_Handler(RS_DATA_STRUCT *RS232_Arr)
|
||||||
{
|
{
|
||||||
char RS232_BytePtr;
|
char RS232_BytePtr;
|
||||||
int final_flag=0, free_fifo;
|
unsigned int final_flag=0, free_fifo;
|
||||||
int i;
|
unsigned int i;
|
||||||
|
|
||||||
|
static unsigned int max_s_b = 1; // ïîñûëàåì ïî max_s_b øòóê
|
||||||
|
unsigned int final_free_fifo=0;
|
||||||
|
|
||||||
// if(RS232_Arr->RS_SendBlockMode == BM_CHAR32)
|
// if(RS232_Arr->RS_SendBlockMode == BM_CHAR32)
|
||||||
// {
|
// {
|
||||||
free_fifo = get_free_rs_fifo_tx(RS232_Arr->commnumber);
|
free_fifo = get_free_rs_fifo_tx(RS232_Arr->commnumber);
|
||||||
ClearTimerRS_Live(RS232_Arr);
|
ClearTimerRS_Live(RS232_Arr);
|
||||||
|
|
||||||
|
if (free_fifo>=max_s_b)
|
||||||
|
free_fifo=max_s_b; // ïîñûëàåì ïî max_s_b øòóê
|
||||||
|
|
||||||
for (i=0;i<free_fifo;i++)
|
for (i=0;i<free_fifo;i++)
|
||||||
{
|
{
|
||||||
|
|
||||||
@ -601,7 +640,7 @@ void RS_TX_Handler(RS_DATA_STRUCT *RS232_Arr)
|
|||||||
else
|
else
|
||||||
SCI_Send(RS232_Arr->commnumber,*(RS232_Arr->pRS_SendPtr_stage1++));
|
SCI_Send(RS232_Arr->commnumber,*(RS232_Arr->pRS_SendPtr_stage1++));
|
||||||
|
|
||||||
RS232_Arr->RS_SendLen++;
|
(RS232_Arr->RS_SendLen)++;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
@ -624,7 +663,7 @@ void RS_TX_Handler(RS_DATA_STRUCT *RS232_Arr)
|
|||||||
else
|
else
|
||||||
SCI_Send(RS232_Arr->commnumber,*(RS232_Arr->pRS_SendPtr_stage2++));
|
SCI_Send(RS232_Arr->commnumber,*(RS232_Arr->pRS_SendPtr_stage2++));
|
||||||
|
|
||||||
RS232_Arr->RS_SendLen++;
|
(RS232_Arr->RS_SendLen)++;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
@ -648,7 +687,7 @@ void RS_TX_Handler(RS_DATA_STRUCT *RS232_Arr)
|
|||||||
else
|
else
|
||||||
SCI_Send(RS232_Arr->commnumber,*(RS232_Arr->pRS_SendPtr++));
|
SCI_Send(RS232_Arr->commnumber,*(RS232_Arr->pRS_SendPtr++));
|
||||||
|
|
||||||
RS232_Arr->RS_SendLen++;
|
(RS232_Arr->RS_SendLen)++;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
default :
|
default :
|
||||||
@ -661,10 +700,14 @@ void RS_TX_Handler(RS_DATA_STRUCT *RS232_Arr)
|
|||||||
if (final_flag)
|
if (final_flag)
|
||||||
{
|
{
|
||||||
|
|
||||||
|
final_free_fifo = get_free_rs_fifo_tx(RS232_Arr->commnumber);
|
||||||
|
|
||||||
|
if (final_free_fifo>=15) // âñå óåõàëè? áóôåð ÷èñò?
|
||||||
|
{
|
||||||
if(RS232_Arr->RS_SendBlockMode == BM_CHAR32)
|
if(RS232_Arr->RS_SendBlockMode == BM_CHAR32)
|
||||||
{
|
{
|
||||||
// RS_Wait4OK_TXRDY(RS232_Arr->commnumber);
|
// if (max_s_b>1)
|
||||||
RS_Wait4OK(RS232_Arr->commnumber);
|
// RS_Wait4OK(RS232_Arr->commnumber);
|
||||||
|
|
||||||
RS_SetBitMode(RS232_Arr,9); /* Ïåðåäàëè âñå ïåðåñòðîèëèñü â 9-áèò äëß RS485?*/
|
RS_SetBitMode(RS232_Arr,9); /* Ïåðåäàëè âñå ïåðåñòðîèëèñü â 9-áèò äëß RS485?*/
|
||||||
RS_LineToReceive(RS232_Arr->commnumber); /* ðåæèì ïðèåìà RS485 */
|
RS_LineToReceive(RS232_Arr->commnumber); /* ðåæèì ïðèåìà RS485 */
|
||||||
@ -678,6 +721,7 @@ void RS_TX_Handler(RS_DATA_STRUCT *RS232_Arr)
|
|||||||
|
|
||||||
EnableUART_Int_RX(RS232_Arr->commnumber); /* Çàïðåùàåì ïðåðûâàíèß ïî ïåðåäà÷å */
|
EnableUART_Int_RX(RS232_Arr->commnumber); /* Çàïðåùàåì ïðåðûâàíèß ïî ïåðåäà÷å */
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
//
|
//
|
||||||
@ -687,6 +731,7 @@ void RS_TX_Handler(RS_DATA_STRUCT *RS232_Arr)
|
|||||||
///////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////
|
||||||
///////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////
|
||||||
///////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////
|
||||||
|
//#pragma CODE_SECTION(RSA_TX_Handler,".fast_run2");
|
||||||
interrupt void RSA_TX_Handler(void)
|
interrupt void RSA_TX_Handler(void)
|
||||||
{
|
{
|
||||||
// Set interrupt priority:
|
// Set interrupt priority:
|
||||||
@ -701,14 +746,16 @@ i_led2_on_off(1);
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if (_ENABLE_INTERRUPT_PROFILE_LED1)
|
#if (_ENABLE_INTERRUPT_PROFILE_LED1)
|
||||||
if (enable_profile_led1_rsa)
|
if (profile_interrupt.for_led1.bits.rsa)
|
||||||
i_led1_on_off_special(1);
|
i_led1_on_off_special(1);
|
||||||
#endif
|
#endif
|
||||||
#if (_ENABLE_INTERRUPT_PROFILE_LED2)
|
#if (_ENABLE_INTERRUPT_PROFILE_LED2)
|
||||||
if (enable_profile_led2_rsa)
|
if (profile_interrupt.for_led2.bits.rsa)
|
||||||
i_led2_on_off_special(1);
|
i_led2_on_off_special(1);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
EINT;
|
EINT;
|
||||||
|
|
||||||
|
|
||||||
@ -731,11 +778,11 @@ i_led2_on_off(1);
|
|||||||
PieCtrlRegs.PIEIER9.all = TempPIEIER;
|
PieCtrlRegs.PIEIER9.all = TempPIEIER;
|
||||||
|
|
||||||
#if (_ENABLE_INTERRUPT_PROFILE_LED1)
|
#if (_ENABLE_INTERRUPT_PROFILE_LED1)
|
||||||
if (enable_profile_led1_rsa)
|
if (profile_interrupt.for_led1.bits.rsa)
|
||||||
i_led1_on_off_special(0);
|
i_led1_on_off_special(0);
|
||||||
#endif
|
#endif
|
||||||
#if (_ENABLE_INTERRUPT_PROFILE_LED2)
|
#if (_ENABLE_INTERRUPT_PROFILE_LED2)
|
||||||
if (enable_profile_led2_rsa)
|
if (profile_interrupt.for_led2.bits.rsa)
|
||||||
i_led2_on_off_special(0);
|
i_led2_on_off_special(0);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
@ -744,13 +791,13 @@ i_led2_on_off(1);
|
|||||||
i_led2_on_off(0);
|
i_led2_on_off(0);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
///////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////
|
||||||
///////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////
|
||||||
///////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////
|
||||||
///////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////
|
||||||
|
//#pragma CODE_SECTION(RSB_TX_Handler,".fast_run2");
|
||||||
interrupt void RSB_TX_Handler(void)
|
interrupt void RSB_TX_Handler(void)
|
||||||
{
|
{
|
||||||
// Set interrupt priority:
|
// Set interrupt priority:
|
||||||
@ -760,17 +807,20 @@ interrupt void RSB_TX_Handler(void)
|
|||||||
PieCtrlRegs.PIEIER9.all &= MG94; // Set "group" priority
|
PieCtrlRegs.PIEIER9.all &= MG94; // Set "group" priority
|
||||||
PieCtrlRegs.PIEACK.all = 0xFFFF; // Enable PIE interrupts
|
PieCtrlRegs.PIEACK.all = 0xFFFF; // Enable PIE interrupts
|
||||||
|
|
||||||
|
#if(_ENABLE_PWM_LINES_FOR_TESTS_RS)
|
||||||
|
PWM_LINES_TK_16_ON;
|
||||||
|
#endif
|
||||||
|
|
||||||
#if (_ENABLE_INTERRUPT_RS232_LED2)
|
#if (_ENABLE_INTERRUPT_RS232_LED2)
|
||||||
i_led2_on_off(1);
|
i_led2_on_off(1);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if (_ENABLE_INTERRUPT_PROFILE_LED1)
|
#if (_ENABLE_INTERRUPT_PROFILE_LED1)
|
||||||
if (enable_profile_led1_rsb)
|
if (profile_interrupt.for_led1.bits.rsb)
|
||||||
i_led1_on_off_special(1);
|
i_led1_on_off_special(1);
|
||||||
#endif
|
#endif
|
||||||
#if (_ENABLE_INTERRUPT_PROFILE_LED2)
|
#if (_ENABLE_INTERRUPT_PROFILE_LED2)
|
||||||
if (enable_profile_led2_rsb)
|
if (profile_interrupt.for_led2.bits.rsb)
|
||||||
i_led2_on_off_special(1);
|
i_led2_on_off_special(1);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
@ -796,11 +846,11 @@ i_led2_on_off(1);
|
|||||||
|
|
||||||
|
|
||||||
#if (_ENABLE_INTERRUPT_PROFILE_LED1)
|
#if (_ENABLE_INTERRUPT_PROFILE_LED1)
|
||||||
if (enable_profile_led1_rsb)
|
if (profile_interrupt.for_led1.bits.rsb)
|
||||||
i_led1_on_off_special(0);
|
i_led1_on_off_special(0);
|
||||||
#endif
|
#endif
|
||||||
#if (_ENABLE_INTERRUPT_PROFILE_LED2)
|
#if (_ENABLE_INTERRUPT_PROFILE_LED2)
|
||||||
if (enable_profile_led2_rsb)
|
if (profile_interrupt.for_led2.bits.rsb)
|
||||||
i_led2_on_off_special(0);
|
i_led2_on_off_special(0);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
@ -808,11 +858,17 @@ i_led2_on_off(1);
|
|||||||
i_led2_on_off(0);
|
i_led2_on_off(0);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#if(_ENABLE_PWM_LINES_FOR_TESTS_RS)
|
||||||
|
PWM_LINES_TK_16_OFF;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
///////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////
|
||||||
///////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////
|
||||||
///////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////
|
||||||
///////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////
|
||||||
|
//#pragma CODE_SECTION(RSA_RX_Handler,".fast_run2");
|
||||||
interrupt void RSA_RX_Handler(void)
|
interrupt void RSA_RX_Handler(void)
|
||||||
{
|
{
|
||||||
// Set interrupt priority:
|
// Set interrupt priority:
|
||||||
@ -828,11 +884,11 @@ i_led2_on_off(1);
|
|||||||
|
|
||||||
|
|
||||||
#if (_ENABLE_INTERRUPT_PROFILE_LED1)
|
#if (_ENABLE_INTERRUPT_PROFILE_LED1)
|
||||||
if (enable_profile_led1_rsa)
|
if (profile_interrupt.for_led1.bits.rsa)
|
||||||
i_led1_on_off_special(1);
|
i_led1_on_off_special(1);
|
||||||
#endif
|
#endif
|
||||||
#if (_ENABLE_INTERRUPT_PROFILE_LED2)
|
#if (_ENABLE_INTERRUPT_PROFILE_LED2)
|
||||||
if (enable_profile_led2_rsa)
|
if (profile_interrupt.for_led2.bits.rsa)
|
||||||
i_led2_on_off_special(1);
|
i_led2_on_off_special(1);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
@ -864,11 +920,11 @@ i_led2_on_off(1);
|
|||||||
PieCtrlRegs.PIEIER9.all = TempPIEIER;
|
PieCtrlRegs.PIEIER9.all = TempPIEIER;
|
||||||
|
|
||||||
#if (_ENABLE_INTERRUPT_PROFILE_LED1)
|
#if (_ENABLE_INTERRUPT_PROFILE_LED1)
|
||||||
if (enable_profile_led1_rsa)
|
if (profile_interrupt.for_led1.bits.rsa)
|
||||||
i_led1_on_off_special(0);
|
i_led1_on_off_special(0);
|
||||||
#endif
|
#endif
|
||||||
#if (_ENABLE_INTERRUPT_PROFILE_LED2)
|
#if (_ENABLE_INTERRUPT_PROFILE_LED2)
|
||||||
if (enable_profile_led2_rsa)
|
if (profile_interrupt.for_led2.bits.rsa)
|
||||||
i_led2_on_off_special(0);
|
i_led2_on_off_special(0);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
@ -882,7 +938,7 @@ i_led2_on_off(0);
|
|||||||
///////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////
|
||||||
///////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////
|
||||||
///////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////
|
||||||
|
//#pragma CODE_SECTION(RSB_RX_Handler,".fast_run2");
|
||||||
interrupt void RSB_RX_Handler(void)
|
interrupt void RSB_RX_Handler(void)
|
||||||
{
|
{
|
||||||
// Set interrupt priority:
|
// Set interrupt priority:
|
||||||
@ -892,17 +948,23 @@ interrupt void RSB_RX_Handler(void)
|
|||||||
PieCtrlRegs.PIEIER9.all &= MG93; // Set "group" priority
|
PieCtrlRegs.PIEIER9.all &= MG93; // Set "group" priority
|
||||||
PieCtrlRegs.PIEACK.all = 0xFFFF; // Enable PIE interrupts
|
PieCtrlRegs.PIEACK.all = 0xFFFF; // Enable PIE interrupts
|
||||||
|
|
||||||
|
|
||||||
|
#if(_ENABLE_PWM_LINES_FOR_TESTS_RS)
|
||||||
|
PWM_LINES_TK_17_ON;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
#if (_ENABLE_INTERRUPT_RS232_LED2)
|
#if (_ENABLE_INTERRUPT_RS232_LED2)
|
||||||
i_led2_on_off(1);
|
i_led2_on_off(1);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
||||||
#if (_ENABLE_INTERRUPT_PROFILE_LED1)
|
#if (_ENABLE_INTERRUPT_PROFILE_LED1)
|
||||||
if (enable_profile_led1_rsb)
|
if (profile_interrupt.for_led1.bits.rsb)
|
||||||
i_led1_on_off_special(1);
|
i_led1_on_off_special(1);
|
||||||
#endif
|
#endif
|
||||||
#if (_ENABLE_INTERRUPT_PROFILE_LED2)
|
#if (_ENABLE_INTERRUPT_PROFILE_LED2)
|
||||||
if (enable_profile_led2_rsb)
|
if (profile_interrupt.for_led2.bits.rsb)
|
||||||
i_led2_on_off_special(1);
|
i_led2_on_off_special(1);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
@ -925,11 +987,11 @@ i_led2_on_off(1);
|
|||||||
|
|
||||||
|
|
||||||
#if (_ENABLE_INTERRUPT_PROFILE_LED1)
|
#if (_ENABLE_INTERRUPT_PROFILE_LED1)
|
||||||
if (enable_profile_led1_rsb)
|
if (profile_interrupt.for_led1.bits.rsb)
|
||||||
i_led1_on_off_special(0);
|
i_led1_on_off_special(0);
|
||||||
#endif
|
#endif
|
||||||
#if (_ENABLE_INTERRUPT_PROFILE_LED2)
|
#if (_ENABLE_INTERRUPT_PROFILE_LED2)
|
||||||
if (enable_profile_led2_rsb)
|
if (profile_interrupt.for_led2.bits.rsb)
|
||||||
i_led2_on_off_special(0);
|
i_led2_on_off_special(0);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
@ -937,6 +999,9 @@ i_led2_on_off(1);
|
|||||||
i_led2_on_off(0);
|
i_led2_on_off(0);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#if(_ENABLE_PWM_LINES_FOR_TESTS_RS)
|
||||||
|
PWM_LINES_TK_17_OFF;
|
||||||
|
#endif
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1055,6 +1120,10 @@ float SciBaud;
|
|||||||
//////////////////////////////////////////////////////
|
//////////////////////////////////////////////////////
|
||||||
void EnableUART_Int_RX(char commnumber)
|
void EnableUART_Int_RX(char commnumber)
|
||||||
{
|
{
|
||||||
|
#if(_ENABLE_PWM_LINES_FOR_TESTS_RS)
|
||||||
|
PWM_LINES_TK_18_ON;
|
||||||
|
#endif
|
||||||
|
|
||||||
switch (commnumber)
|
switch (commnumber)
|
||||||
{
|
{
|
||||||
case COM_1: //SciaRegs.SCICTL2.bit.RXBKINTENA = 0;//1; //enableUARTInt_A();
|
case COM_1: //SciaRegs.SCICTL2.bit.RXBKINTENA = 0;//1; //enableUARTInt_A();
|
||||||
@ -1085,6 +1154,10 @@ void EnableUART_Int_RX(char commnumber)
|
|||||||
void EnableUART_Int_TX(char commnumber)
|
void EnableUART_Int_TX(char commnumber)
|
||||||
{
|
{
|
||||||
|
|
||||||
|
#if(_ENABLE_PWM_LINES_FOR_TESTS_RS)
|
||||||
|
PWM_LINES_TK_18_OFF;
|
||||||
|
#endif
|
||||||
|
|
||||||
switch (commnumber)
|
switch (commnumber)
|
||||||
{
|
{
|
||||||
case COM_1: rs_a.RS_OnTransmitedData = 1;
|
case COM_1: rs_a.RS_OnTransmitedData = 1;
|
||||||
@ -1299,22 +1372,31 @@ int test_rs_live(RS_DATA_STRUCT *rs_arr)
|
|||||||
void inc_RS_timeout_cicle(void)
|
void inc_RS_timeout_cicle(void)
|
||||||
{
|
{
|
||||||
|
|
||||||
|
unsigned int i, t_refresh;
|
||||||
|
static unsigned int old_time_rs = 0;
|
||||||
|
|
||||||
|
t_refresh = get_delta_milisec(&old_time_rs, 1);
|
||||||
|
if (t_refresh>1000)
|
||||||
|
t_refresh = 1000;
|
||||||
|
if (t_refresh<1)
|
||||||
|
t_refresh = 1;
|
||||||
|
|
||||||
if (rs_a.time_wait_rs_out<RS_TIME_OUT_MAX)
|
if (rs_a.time_wait_rs_out<RS_TIME_OUT_MAX)
|
||||||
rs_a.time_wait_rs_out++;
|
rs_a.time_wait_rs_out += t_refresh;
|
||||||
|
|
||||||
if (rs_b.time_wait_rs_out<RS_TIME_OUT_MAX)
|
if (rs_b.time_wait_rs_out<RS_TIME_OUT_MAX)
|
||||||
rs_b.time_wait_rs_out++;
|
rs_b.time_wait_rs_out += t_refresh;
|
||||||
|
|
||||||
if (rs_a.time_wait_rs_out_mpu<RS_TIME_OUT_MAX)
|
if (rs_a.time_wait_rs_out_mpu<RS_TIME_OUT_MAX)
|
||||||
rs_a.time_wait_rs_out_mpu++;
|
rs_a.time_wait_rs_out_mpu += t_refresh;
|
||||||
|
|
||||||
if (rs_b.time_wait_rs_out_mpu<RS_TIME_OUT_MAX)
|
if (rs_b.time_wait_rs_out_mpu<RS_TIME_OUT_MAX)
|
||||||
rs_b.time_wait_rs_out_mpu++;
|
rs_b.time_wait_rs_out_mpu += t_refresh;
|
||||||
|
|
||||||
if ((rs_a.RS_Flag9bit==0) || rs_a.do_resetup_rs || SCIa_RX_Error())
|
if ((rs_a.RS_Flag9bit==0) || rs_a.do_resetup_rs || SCIa_RX_Error())
|
||||||
{
|
{
|
||||||
if (rs_a.time_wait_rs_lost<RS_TIME_OUT_LOST)
|
if (rs_a.time_wait_rs_lost<RS_TIME_OUT_LOST)
|
||||||
rs_a.time_wait_rs_lost++;
|
rs_a.time_wait_rs_lost += t_refresh;
|
||||||
// else
|
// else
|
||||||
// resetup_mpu_rs(&rs_a);
|
// resetup_mpu_rs(&rs_a);
|
||||||
}
|
}
|
||||||
@ -1322,7 +1404,7 @@ void inc_RS_timeout_cicle(void)
|
|||||||
if ((rs_b.RS_Flag9bit==0) || rs_b.do_resetup_rs || SCIb_RX_Error())
|
if ((rs_b.RS_Flag9bit==0) || rs_b.do_resetup_rs || SCIb_RX_Error())
|
||||||
{
|
{
|
||||||
if (rs_b.time_wait_rs_lost<RS_TIME_OUT_LOST)
|
if (rs_b.time_wait_rs_lost<RS_TIME_OUT_LOST)
|
||||||
rs_b.time_wait_rs_lost++;
|
rs_b.time_wait_rs_lost += t_refresh;
|
||||||
// else
|
// else
|
||||||
// resetup_mpu_rs(&rs_b);
|
// resetup_mpu_rs(&rs_b);
|
||||||
}
|
}
|
||||||
@ -1350,8 +1432,21 @@ void resetup_rs_on_timeout_lost(int rsp)
|
|||||||
///////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////
|
||||||
///////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
void clear_buffers_rs(RS_DATA_STRUCT *rs_arr)
|
||||||
|
{
|
||||||
|
unsigned int i;
|
||||||
|
|
||||||
|
|
||||||
|
for (i=0;i<MAX_RECEIVE_LENGTH;i++)
|
||||||
|
rs_arr->RS_Header[i] = 0;
|
||||||
|
|
||||||
|
for (i=0;i<MAX_SEND_LENGTH;i++)
|
||||||
|
rs_arr->buffer[i] = 0;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
///////////////////////////////////////////////////////////
|
||||||
|
///////////////////////////////////////////////////////////
|
||||||
|
|
||||||
#ifdef _USE_RS_FIFO
|
#ifdef _USE_RS_FIFO
|
||||||
void SetupUART(char commnumber, unsigned long speed_baud)
|
void SetupUART(char commnumber, unsigned long speed_baud)
|
||||||
@ -1440,6 +1535,7 @@ void SetupUART(char commnumber, unsigned long speed_baud)
|
|||||||
EDIS;
|
EDIS;
|
||||||
|
|
||||||
SetupArrCmdLength();
|
SetupArrCmdLength();
|
||||||
|
clear_buffers_rs(&rs_a);
|
||||||
|
|
||||||
RS_SetControllerLeading(&rs_a,false);
|
RS_SetControllerLeading(&rs_a,false);
|
||||||
|
|
||||||
@ -1453,66 +1549,7 @@ void SetupUART(char commnumber, unsigned long speed_baud)
|
|||||||
|
|
||||||
resetup_mpu_rs(&rs_a);
|
resetup_mpu_rs(&rs_a);
|
||||||
|
|
||||||
///////
|
|
||||||
|
|
||||||
//
|
|
||||||
//// enable TX, RX, internal SCICLK,
|
|
||||||
//// Disable RX ERR, SLEEP, TXWAKE
|
|
||||||
// SciaRegs.SCIFFCT.bit.ABDCLR=1;
|
|
||||||
// SciaRegs.SCIFFCT.bit.CDC=0;
|
|
||||||
//
|
|
||||||
// SciaRegs.SCICTL1.bit.RXERRINTENA=0;
|
|
||||||
// SciaRegs.SCICTL1.bit.SWRESET=0;
|
|
||||||
// SciaRegs.SCICTL1.bit.TXWAKE=0;
|
|
||||||
// SciaRegs.SCICTL1.bit.SLEEP=0;
|
|
||||||
// SciaRegs.SCICTL1.bit.TXENA=1;
|
|
||||||
// SciaRegs.SCICTL1.bit.RXENA=1;
|
|
||||||
//
|
|
||||||
////
|
|
||||||
//// SciaRegs.SCIFFTX.all=0xC028;
|
|
||||||
// SciaRegs.SCIFFRX.all=0x0000;
|
|
||||||
//
|
|
||||||
// SciaRegs.SCIFFRX.bit.RXFFIL=2; //Äëèíà íàèìåíüøåé êîìàíäû
|
|
||||||
// SciaRegs.SCIFFRX.bit.RXFFIENA = 1;//Receive FIFO interrupt enable
|
|
||||||
// SciaRegs.SCIFFRX.bit.RXFFINTCLR = 1;//Write 1 to clear RXFFINT flag in bit 7
|
|
||||||
//
|
|
||||||
// SciaRegs.SCIFFCT.all=0x00;
|
|
||||||
//
|
|
||||||
//
|
|
||||||
//
|
|
||||||
//// SciaRegs.SCICTL1.all =0x0023; // Relinquish SCI from Reset
|
|
||||||
//// SciaRegs.SCIFFTX.bit.TXFIFOXRESET=1;
|
|
||||||
//
|
|
||||||
////
|
|
||||||
//
|
|
||||||
// SciaRegs.SCIFFTX.bit.SCIFFENA=0; // TX fifo off
|
|
||||||
//
|
|
||||||
// EALLOW;
|
|
||||||
// PieVectTable.RXAINT = &RSA_RX_Handler;
|
|
||||||
// PieVectTable.TXAINT = &RSA_TX_Handler;
|
|
||||||
// PieCtrlRegs.PIEIER9.bit.INTx1=1; // PIE Group 9, INT1
|
|
||||||
// PieCtrlRegs.PIEIER9.bit.INTx2=1; // PIE Group 9, INT2
|
|
||||||
// IER |= M_INT9; // Enable CPU INT
|
|
||||||
// EDIS;
|
|
||||||
//
|
|
||||||
// SetupArrCmdLength();
|
|
||||||
// RS_SetLineSpeed(commnumber,speed_baud); /* ñêîðîñòü ëèíèè */
|
|
||||||
// RS_SetControllerLeading(&rs_a,false);
|
|
||||||
//
|
|
||||||
// RS_LineToReceive(commnumber); // ðåæèì ïðèåìà RS485
|
|
||||||
// EnableUART_Int(commnumber); // ðàçðåøåíèå ïðåðûâàíèé UART
|
|
||||||
//
|
|
||||||
// RS_SetBitMode(&rs_a,9);
|
|
||||||
// rs_a.RS_PrevCmd = 0; // íå áûëî íèêàêèõ êîìàíä
|
|
||||||
// SCI_RX_IntClear(commnumber);
|
|
||||||
//
|
|
||||||
// SciaRegs.SCICTL1.bit.SWRESET=1; // Relinquish SCI from Reset
|
|
||||||
//// SciaRegs.SCIFFTX.bit.TXFIFOXRESET=1;
|
|
||||||
//// SciaRegs.SCIFFRX.bit.RXFIFORESET=1;
|
|
||||||
//
|
|
||||||
// SciaRegs.SCIFFRX.bit.RXFIFORESET=1; // Re-enable receive FIFO operation
|
|
||||||
//
|
|
||||||
//
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1598,6 +1635,8 @@ void SetupUART(char commnumber, unsigned long speed_baud)
|
|||||||
EDIS;
|
EDIS;
|
||||||
|
|
||||||
SetupArrCmdLength();
|
SetupArrCmdLength();
|
||||||
|
clear_buffers_rs(&rs_b);
|
||||||
|
|
||||||
|
|
||||||
RS_SetControllerLeading(&rs_b,false);
|
RS_SetControllerLeading(&rs_b,false);
|
||||||
|
|
||||||
@ -1614,64 +1653,7 @@ void SetupUART(char commnumber, unsigned long speed_baud)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/*
|
|
||||||
if(commnumber==COM_2)
|
|
||||||
{
|
|
||||||
// Initialize SCI-B:
|
|
||||||
// Note: Clocks were turned on to the SCIA peripheral
|
|
||||||
// in the InitSysCtrl() function
|
|
||||||
|
|
||||||
EALLOW;
|
|
||||||
GpioMuxRegs.GPGMUX.bit.SCIRXDB_GPIOG5=1;
|
|
||||||
GpioMuxRegs.GPGMUX.bit.SCITXDB_GPIOG4=1;
|
|
||||||
GpioMuxRegs.GPBMUX.bit.C5TRIP_GPIOB14=0;
|
|
||||||
|
|
||||||
GpioMuxRegs.GPBDIR.bit.GPIOB14=1;
|
|
||||||
|
|
||||||
EDIS;
|
|
||||||
RS_SetLineMode(commnumber,8,'N',1);
|
|
||||||
|
|
||||||
// enable TX, RX, internal SCICLK,
|
|
||||||
// Disable RX ERR, SLEEP, TXWAKE
|
|
||||||
ScibRegs.SCIFFCT.bit.CDC=0;
|
|
||||||
ScibRegs.SCIFFCT.bit.ABDCLR=1;
|
|
||||||
ScibRegs.SCICTL1.bit.RXERRINTENA=0;
|
|
||||||
ScibRegs.SCICTL1.bit.SWRESET=0;
|
|
||||||
ScibRegs.SCICTL1.bit.TXWAKE=0;
|
|
||||||
ScibRegs.SCICTL1.bit.SLEEP=0;
|
|
||||||
ScibRegs.SCICTL1.bit.TXENA=1;
|
|
||||||
ScibRegs.SCICTL1.bit.RXENA=1;
|
|
||||||
|
|
||||||
ScibRegs.SCIFFTX.bit.SCIFFENA=0; // fifo off
|
|
||||||
ScibRegs.SCIFFRX.bit.RXFFIL=1; //Äëèíà íàèìåíüøåé êîìàíäû
|
|
||||||
|
|
||||||
EALLOW;
|
|
||||||
PieVectTable.RXBINT = &RSB_RX_Handler;
|
|
||||||
PieVectTable.TXBINT = &RSB_TX_Handler;
|
|
||||||
|
|
||||||
PieCtrlRegs.PIEIER9.bit.INTx3=1; // PIE Group 9, INT3
|
|
||||||
PieCtrlRegs.PIEIER9.bit.INTx4=1; // PIE Group 9, INT4
|
|
||||||
IER |= M_INT9; // Enable CPU INT
|
|
||||||
EDIS;
|
|
||||||
|
|
||||||
SetupArrCmdLength();
|
|
||||||
RS_SetLineSpeed(commnumber,speed_baud); // ñêîðîñòü ëèíèè
|
|
||||||
RS_SetControllerLeading(&rs_b,false);
|
|
||||||
|
|
||||||
RS_LineToReceive(commnumber); // ðåæèì ïðèåìà RS485
|
|
||||||
EnableUART_Int(commnumber); // ðàçðåøåíèå ïðåðûâàíèé UART
|
|
||||||
|
|
||||||
RS_SetBitMode(&rs_b,9);
|
|
||||||
rs_b.RS_PrevCmd = 0; // íå áûëî íèêàêèõ êîìàíä
|
|
||||||
SCI_RX_IntClear(commnumber);
|
|
||||||
|
|
||||||
ScibRegs.SCICTL1.bit.SWRESET=1; // Relinquish SCI from Reset
|
|
||||||
|
|
||||||
// SciaRegs.SCIFFTX.bit.TXFIFOXRESET=1;
|
|
||||||
// SciaRegs.SCIFFRX.bit.RXFIFORESET=1;
|
|
||||||
|
|
||||||
}
|
|
||||||
*/
|
|
||||||
|
|
||||||
}
|
}
|
||||||
#else
|
#else
|
||||||
@ -2018,7 +2000,7 @@ int GetCommand(RS_DATA_STRUCT *RS232_Arr)
|
|||||||
// Ïðîâåðßåì äëèíó êîìàíäû äëß ñ÷èòûâàíèß CRC
|
// Ïðîâåðßåì äëèíó êîìàíäû äëß ñ÷èòûâàíèß CRC
|
||||||
if((RS_Len[cmd]<3) || (RS_Len[cmd]>MAX_RECEIVE_LENGTH))
|
if((RS_Len[cmd]<3) || (RS_Len[cmd]>MAX_RECEIVE_LENGTH))
|
||||||
{
|
{
|
||||||
RS232_Arr->count_recive_bad++;
|
(RS232_Arr->count_recive_bad)++;
|
||||||
RS_LineToReceive(RS232_Arr->commnumber); // ðåæèì ïðèåìà RS485
|
RS_LineToReceive(RS232_Arr->commnumber); // ðåæèì ïðèåìà RS485
|
||||||
RS_SetBitMode(RS232_Arr,9);
|
RS_SetBitMode(RS232_Arr,9);
|
||||||
|
|
||||||
@ -2047,7 +2029,7 @@ int GetCommand(RS_DATA_STRUCT *RS232_Arr)
|
|||||||
|
|
||||||
if(crc == rcrc) // Ïðîâåðßåì crc
|
if(crc == rcrc) // Ïðîâåðßåì crc
|
||||||
{
|
{
|
||||||
RS232_Arr->count_recive_ok++;
|
(RS232_Arr->count_recive_ok)++;
|
||||||
|
|
||||||
RS232_Arr->RS_PrevCmd = cmd;
|
RS232_Arr->RS_PrevCmd = cmd;
|
||||||
if (RS232_Arr->RS_DataSended)
|
if (RS232_Arr->RS_DataSended)
|
||||||
@ -2059,7 +2041,7 @@ int GetCommand(RS_DATA_STRUCT *RS232_Arr)
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
RS232_Arr->count_recive_error_crc++;
|
(RS232_Arr->count_recive_error_crc)++;
|
||||||
|
|
||||||
RS_SetAdrAnswerController(RS232_Arr,0);
|
RS_SetAdrAnswerController(RS232_Arr,0);
|
||||||
RS_SetControllerLeading(RS232_Arr, false);
|
RS_SetControllerLeading(RS232_Arr, false);
|
||||||
@ -2083,7 +2065,8 @@ void ExtendBios(RS_DATA_STRUCT *RS232_Arr)
|
|||||||
|
|
||||||
unsigned long AdrOut1,AdrOut2,LengthOut;
|
unsigned long AdrOut1,AdrOut2,LengthOut;
|
||||||
unsigned int cerr, repl, count_ok, return_code, old_started;
|
unsigned int cerr, repl, count_ok, return_code, old_started;
|
||||||
volatile unsigned int go_to_reset = 0;
|
volatile unsigned int go_to_reset = 0, go_to_set_baud = 0;
|
||||||
|
unsigned long set_baud;
|
||||||
|
|
||||||
//int code_eeprom;
|
//int code_eeprom;
|
||||||
old_started = x_parallel_bus_project.flags.bit.started;
|
old_started = x_parallel_bus_project.flags.bit.started;
|
||||||
@ -2227,6 +2210,18 @@ void ExtendBios(RS_DATA_STRUCT *RS232_Arr)
|
|||||||
|
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
case 100:
|
||||||
|
go_to_set_baud = 1;
|
||||||
|
set_baud = Address1;
|
||||||
|
// SetLoad28_FromResetInternalFlash();
|
||||||
|
// SelectReset28();
|
||||||
|
//speed_baud = Address1;
|
||||||
|
|
||||||
|
|
||||||
|
break;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
default: break;
|
default: break;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -2281,6 +2276,23 @@ void ExtendBios(RS_DATA_STRUCT *RS232_Arr)
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
if (go_to_set_baud)
|
||||||
|
{
|
||||||
|
// for (i=0;i<2;i++)
|
||||||
|
DELAY_US(1000000);
|
||||||
|
|
||||||
|
// DRTM;
|
||||||
|
// DINT;
|
||||||
|
|
||||||
|
// for (i=0;i<2;i++)
|
||||||
|
// DELAY_US(1000000);
|
||||||
|
|
||||||
|
RS_SetLineSpeed(RS232_Arr->commnumber, set_baud); /* ñêîðîñòü ëèíèè */
|
||||||
|
|
||||||
|
go_to_set_baud = 0;
|
||||||
|
|
||||||
|
}
|
||||||
return;
|
return;
|
||||||
|
|
||||||
}
|
}
|
||||||
@ -2309,7 +2321,7 @@ int RS_Send(RS_DATA_STRUCT *RS232_Arr,unsigned int *pBuf,unsigned long len)
|
|||||||
|
|
||||||
if (RS232_Arr->RS_DataWillSend)
|
if (RS232_Arr->RS_DataWillSend)
|
||||||
{
|
{
|
||||||
RS232_Arr->RS_DataReadyAnswer = 0;
|
// RS232_Arr->RS_DataReadyAnswer = 0;
|
||||||
RS232_Arr->RS_DataReadyAnswer = 0;
|
RS232_Arr->RS_DataReadyAnswer = 0;
|
||||||
RS232_Arr->RS_DataSended = 0;
|
RS232_Arr->RS_DataSended = 0;
|
||||||
}
|
}
|
||||||
@ -2372,10 +2384,31 @@ void RS232_WorkingWith(unsigned int enable_rs_a, unsigned int enable_rs_b, unsig
|
|||||||
switch (GetCommand(&rs_a))
|
switch (GetCommand(&rs_a))
|
||||||
{
|
{
|
||||||
case CMD_RS232_INIT: break;
|
case CMD_RS232_INIT: break;
|
||||||
case CMD_RS232_INITLOAD: flag_special_mode_rs = 1; InitLoad(&rs_a); break;
|
|
||||||
case CMD_RS232_LOAD: flag_special_mode_rs = 1; Load(&rs_a); break;
|
case CMD_RS232_INITLOAD:
|
||||||
|
if (disable_flag_special_mode_rs)
|
||||||
|
break;
|
||||||
|
|
||||||
|
flag_special_mode_rs = 1;
|
||||||
|
InitLoad(&rs_a);
|
||||||
|
break;
|
||||||
|
|
||||||
|
case CMD_RS232_LOAD:
|
||||||
|
if (disable_flag_special_mode_rs)
|
||||||
|
break;
|
||||||
|
|
||||||
|
flag_special_mode_rs = 1;
|
||||||
|
Load(&rs_a);
|
||||||
|
break;
|
||||||
|
|
||||||
case CMD_RS232_RUN: break;
|
case CMD_RS232_RUN: break;
|
||||||
case CMD_RS232_PEEK: flag_special_mode_rs = 1; Peek(&rs_a);
|
|
||||||
|
case CMD_RS232_PEEK:
|
||||||
|
if (disable_flag_special_mode_rs)
|
||||||
|
break;
|
||||||
|
|
||||||
|
flag_special_mode_rs = 1;
|
||||||
|
Peek(&rs_a);
|
||||||
//Led1_Toggle();
|
//Led1_Toggle();
|
||||||
break;
|
break;
|
||||||
|
|
||||||
@ -2400,12 +2433,43 @@ void RS232_WorkingWith(unsigned int enable_rs_a, unsigned int enable_rs_b, unsig
|
|||||||
flag_special_mode_rs = 0;
|
flag_special_mode_rs = 0;
|
||||||
ReceiveCommand(&rs_a);
|
ReceiveCommand(&rs_a);
|
||||||
break;
|
break;
|
||||||
case CMD_RS232_TEST_ALL: flag_special_mode_rs = 1; ReceiveCommandTestAll(&rs_a); break;
|
|
||||||
|
case CMD_RS232_TEST_ALL:
|
||||||
|
if (disable_flag_special_mode_rs)
|
||||||
|
break;
|
||||||
|
|
||||||
|
flag_special_mode_rs = 1;
|
||||||
|
ReceiveCommandTestAll(&rs_a);
|
||||||
|
break;
|
||||||
#endif
|
#endif
|
||||||
case CMD_RS232_POKE: flag_special_mode_rs = 1; Poke(&rs_a); Led2_Toggle(); break;
|
case CMD_RS232_POKE:
|
||||||
case CMD_RS232_UPLOAD: flag_special_mode_rs = 1; Upload(&rs_a); break;
|
if (disable_flag_special_mode_rs)
|
||||||
case CMD_RS232_TFLASH: flag_special_mode_rs = 1; T_Flash(&rs_a); break;
|
break;
|
||||||
case CMD_RS232_EXTEND: flag_special_mode_rs = 1; ExtendBios(&rs_a); break;
|
|
||||||
|
|
||||||
|
flag_special_mode_rs = 1;
|
||||||
|
Poke(&rs_a);
|
||||||
|
Led2_Toggle();
|
||||||
|
break;
|
||||||
|
case CMD_RS232_UPLOAD:
|
||||||
|
// flag_special_mode_rs = 1;
|
||||||
|
Upload(&rs_a);
|
||||||
|
break;
|
||||||
|
case CMD_RS232_TFLASH:
|
||||||
|
if (disable_flag_special_mode_rs)
|
||||||
|
break;
|
||||||
|
|
||||||
|
|
||||||
|
flag_special_mode_rs = 1;
|
||||||
|
T_Flash(&rs_a);
|
||||||
|
break;
|
||||||
|
case CMD_RS232_EXTEND:
|
||||||
|
if (disable_flag_special_mode_rs)
|
||||||
|
break;
|
||||||
|
|
||||||
|
flag_special_mode_rs = 1;
|
||||||
|
ExtendBios(&rs_a);
|
||||||
|
break;
|
||||||
|
|
||||||
default: break;
|
default: break;
|
||||||
} // end switch
|
} // end switch
|
||||||
@ -2418,10 +2482,31 @@ void RS232_WorkingWith(unsigned int enable_rs_a, unsigned int enable_rs_b, unsig
|
|||||||
switch (GetCommand(&rs_b))
|
switch (GetCommand(&rs_b))
|
||||||
{
|
{
|
||||||
case CMD_RS232_INIT: break;
|
case CMD_RS232_INIT: break;
|
||||||
case CMD_RS232_INITLOAD: flag_special_mode_rs = 1; InitLoad(&rs_b); break;
|
|
||||||
case CMD_RS232_LOAD: flag_special_mode_rs = 1; Load(&rs_b); break;
|
case CMD_RS232_INITLOAD:
|
||||||
|
if (disable_flag_special_mode_rs)
|
||||||
|
break;
|
||||||
|
|
||||||
|
flag_special_mode_rs = 1;
|
||||||
|
InitLoad(&rs_b);
|
||||||
|
break;
|
||||||
|
|
||||||
|
case CMD_RS232_LOAD:
|
||||||
|
if (disable_flag_special_mode_rs)
|
||||||
|
break;
|
||||||
|
|
||||||
|
flag_special_mode_rs = 1;
|
||||||
|
Load(&rs_b);
|
||||||
|
break;
|
||||||
|
|
||||||
case CMD_RS232_RUN: break;
|
case CMD_RS232_RUN: break;
|
||||||
case CMD_RS232_PEEK: flag_special_mode_rs = 1; Peek(&rs_b); break;
|
case CMD_RS232_PEEK:
|
||||||
|
if (disable_flag_special_mode_rs)
|
||||||
|
break;
|
||||||
|
|
||||||
|
flag_special_mode_rs = 1;
|
||||||
|
Peek(&rs_b);
|
||||||
|
break;
|
||||||
|
|
||||||
#if USE_MODBUS_TABLE_SVU
|
#if USE_MODBUS_TABLE_SVU
|
||||||
|
|
||||||
@ -2508,13 +2593,43 @@ void RS232_WorkingWith(unsigned int enable_rs_a, unsigned int enable_rs_b, unsig
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if (USE_TEST_TERMINAL)
|
#if (USE_TEST_TERMINAL)
|
||||||
case CMD_RS232_STD: flag_special_mode_rs = 0; ReceiveCommand(&rs_b); break;
|
case CMD_RS232_STD: flag_special_mode_rs = 0;
|
||||||
case CMD_RS232_TEST_ALL: flag_special_mode_rs = 1; ReceiveCommandTestAll(&rs_b); break;
|
ReceiveCommand(&rs_b);
|
||||||
|
break;
|
||||||
|
case CMD_RS232_TEST_ALL:
|
||||||
|
if (disable_flag_special_mode_rs)
|
||||||
|
break;
|
||||||
|
|
||||||
|
flag_special_mode_rs = 1;
|
||||||
|
ReceiveCommandTestAll(&rs_b);
|
||||||
|
break;
|
||||||
#endif
|
#endif
|
||||||
case CMD_RS232_POKE: flag_special_mode_rs = 1; Poke(&rs_b); break;
|
case CMD_RS232_POKE:
|
||||||
case CMD_RS232_UPLOAD: flag_special_mode_rs = 1; Upload(&rs_b); break;
|
if (disable_flag_special_mode_rs)
|
||||||
case CMD_RS232_TFLASH: flag_special_mode_rs = 1; T_Flash(&rs_b); break;
|
break;
|
||||||
case CMD_RS232_EXTEND: flag_special_mode_rs = 1; ExtendBios(&rs_b); break;
|
|
||||||
|
flag_special_mode_rs = 1;
|
||||||
|
Poke(&rs_b);
|
||||||
|
break;
|
||||||
|
case CMD_RS232_UPLOAD:
|
||||||
|
// flag_special_mode_rs = 1;
|
||||||
|
|
||||||
|
Upload(&rs_b);
|
||||||
|
break;
|
||||||
|
case CMD_RS232_TFLASH:
|
||||||
|
if (disable_flag_special_mode_rs)
|
||||||
|
break;
|
||||||
|
|
||||||
|
flag_special_mode_rs = 1;
|
||||||
|
T_Flash(&rs_b);
|
||||||
|
break;
|
||||||
|
case CMD_RS232_EXTEND:
|
||||||
|
if (disable_flag_special_mode_rs)
|
||||||
|
break;
|
||||||
|
|
||||||
|
flag_special_mode_rs = 1;
|
||||||
|
ExtendBios(&rs_b);
|
||||||
|
break;
|
||||||
|
|
||||||
default: break;
|
default: break;
|
||||||
} // end switch
|
} // end switch
|
||||||
|
@ -94,13 +94,14 @@ typedef struct {
|
|||||||
|
|
||||||
unsigned int do_resetup_rs; // âûïîëíèòü ïåðåñáðîñ ïîðòà ïðè îøèáêàõ.
|
unsigned int do_resetup_rs; // âûïîëíèòü ïåðåñáðîñ ïîðòà ïðè îøèáêàõ.
|
||||||
|
|
||||||
|
int RS_DataWillSend2; // флаг2, что мы подготовили свой запрос и сейчас начнем его передавать и мы мастер
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
} RS_DATA_STRUCT;
|
} RS_DATA_STRUCT;
|
||||||
|
|
||||||
#define RS_DATA_STRUCT_DEFAULT {0,0,0,0,0,0,0,0,0,{0}, 0,0,0,{0},{0}, 0,0,0,0,0,0, 0,0, 0,0, 0,0,0,0, 0,0, 0,0,0, 0, 0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0, 0}
|
#define RS_DATA_STRUCT_DEFAULT {0,0,0,0,0,0,0,0,0,{0}, 0,0,0,{0},{0}, 0,0,0,0,0,0, 0,0, 0,0, 0,0,0,0, 0,0, 0,0,0, 0, 0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0, 0,0}
|
||||||
//////////////////////////////////////////////////////////
|
//////////////////////////////////////////////////////////
|
||||||
|
|
||||||
#define TMS_TO_TERMINAL_TEST_ALL_STRUCT_DEFAULT {{0}, {0}, {0}, 0, 0, 0}
|
#define TMS_TO_TERMINAL_TEST_ALL_STRUCT_DEFAULT {{0}, {0}, {0}, 0, 0, 0}
|
||||||
@ -136,6 +137,6 @@ void SetCntrlAddr (int cntrl_addr,int cntrl_addr_for_all);
|
|||||||
|
|
||||||
extern float KmodTerm, freqTerm;
|
extern float KmodTerm, freqTerm;
|
||||||
extern unsigned int RS_Len[RS_LEN_CMD];
|
extern unsigned int RS_Len[RS_LEN_CMD];
|
||||||
extern int flag_special_mode_rs;
|
extern int flag_special_mode_rs, disable_flag_special_mode_rs;
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
@ -638,6 +638,32 @@ void xseeprom_delay(void)
|
|||||||
pause_1000(10000);
|
pause_1000(10000);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void ResetNPeriphPlane(unsigned int np)
|
||||||
|
{
|
||||||
|
|
||||||
|
Controll.bit.line_P7_4_Is = np;
|
||||||
|
|
||||||
|
Controll.bit.OE_BUF_Is_ON = 1;
|
||||||
|
Controll.bit.line_Z_ER0_OUT_Is = 0;
|
||||||
|
Controll.bit.line_SET_MODE_Is = 1;
|
||||||
|
xControll_wr();
|
||||||
|
pause_1000(10000);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
Controll.bit.line_P7_4_Is = 0x0;
|
||||||
|
Controll.bit.line_Z_ER0_OUT_Is = 1;
|
||||||
|
xControll_wr();
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
// Controll.bit.RemotePlane_Is_Reset = 1;
|
||||||
|
xControll_wr();
|
||||||
|
pause_1000(10000);
|
||||||
|
// Controll.bit.RemotePlane_Is_Reset = 0;
|
||||||
|
Controll.bit.line_P7_4_Is = 0x0;
|
||||||
|
}
|
||||||
|
|
||||||
void ResetPeriphPlane()
|
void ResetPeriphPlane()
|
||||||
{
|
{
|
||||||
Controll.bit.line_P7_4_Is = 0xf;
|
Controll.bit.line_P7_4_Is = 0xf;
|
||||||
|
@ -257,5 +257,8 @@ int test_xilinx_live(void);
|
|||||||
|
|
||||||
int enable_er0_control(void);
|
int enable_er0_control(void);
|
||||||
|
|
||||||
|
void ResetNPeriphPlane(unsigned int np);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
@ -134,7 +134,7 @@ void pause_1000(unsigned long t)
|
|||||||
DSP28x_usDelay(40L);
|
DSP28x_usDelay(40L);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
//Xilinx Zone
|
||||||
void XintfZone0_Timing(void)
|
void XintfZone0_Timing(void)
|
||||||
{
|
{
|
||||||
// Zone 0------------------------------------
|
// Zone 0------------------------------------
|
||||||
@ -256,12 +256,12 @@ void XintfZone2_Timing(void)
|
|||||||
// Lead must always be 1 or greater
|
// Lead must always be 1 or greater
|
||||||
// Zone write timing
|
// Zone write timing
|
||||||
XintfRegs.XTIMING2.bit.XWRLEAD = 3;//2;
|
XintfRegs.XTIMING2.bit.XWRLEAD = 3;//2;
|
||||||
XintfRegs.XTIMING2.bit.XWRACTIVE = 7;//2;
|
XintfRegs.XTIMING2.bit.XWRACTIVE = 4;//2;
|
||||||
XintfRegs.XTIMING2.bit.XWRTRAIL = 3;//2;
|
XintfRegs.XTIMING2.bit.XWRTRAIL = 2;//2;
|
||||||
// Zone read timing
|
// Zone read timing
|
||||||
XintfRegs.XTIMING2.bit.XRDLEAD = 3;
|
XintfRegs.XTIMING2.bit.XRDLEAD = 2;
|
||||||
XintfRegs.XTIMING2.bit.XRDACTIVE = 7; //1;
|
XintfRegs.XTIMING2.bit.XRDACTIVE = 3; //1;
|
||||||
XintfRegs.XTIMING2.bit.XRDTRAIL = 3;//2;//0;
|
XintfRegs.XTIMING2.bit.XRDTRAIL = 1;//2;//0;
|
||||||
|
|
||||||
// do not double all Zone read/write lead/active/trail timing
|
// do not double all Zone read/write lead/active/trail timing
|
||||||
XintfRegs.XTIMING2.bit.X2TIMING = 0;
|
XintfRegs.XTIMING2.bit.X2TIMING = 0;
|
||||||
|
@ -9,7 +9,11 @@
|
|||||||
#include "MemoryFunctions.h"
|
#include "MemoryFunctions.h"
|
||||||
#include "Spartan2E_Adr.h"
|
#include "Spartan2E_Adr.h"
|
||||||
#include "TuneUpPlane.h"
|
#include "TuneUpPlane.h"
|
||||||
|
#include "xp_write_xpwm_time.h"
|
||||||
|
#include "params.h"
|
||||||
|
#include "pwm_test_lines.h"
|
||||||
|
#include "sync_tools.h"
|
||||||
|
#include "profile_interrupt.h"
|
||||||
|
|
||||||
//Pointers to handler functions
|
//Pointers to handler functions
|
||||||
void (*int13_handler)() = NULL;
|
void (*int13_handler)() = NULL;
|
||||||
@ -20,8 +24,8 @@ void (*int13_handler)() = NULL;
|
|||||||
//////////////////////////////////////////////////////////////////////
|
//////////////////////////////////////////////////////////////////////
|
||||||
//////////////////////////////////////////////////////////////////////
|
//////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
unsigned int enable_profile_led1_pwm = 1;
|
//unsigned int enable_profile_led1_pwm = 1;
|
||||||
unsigned int enable_profile_led2_pwm = 1;
|
//unsigned int enable_profile_led2_pwm = 1;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@ -51,21 +55,59 @@ int InitXilinxSpartan2E(void (*int_handler)())
|
|||||||
return err;
|
return err;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#pragma CODE_SECTION(XIntc_INT13_Handler,".fast_run2");
|
||||||
interrupt void XIntc_INT13_Handler(void)
|
interrupt void XIntc_INT13_Handler(void)
|
||||||
{
|
{
|
||||||
|
static int l2;
|
||||||
|
|
||||||
IER &= MINT13; // Set "global" priority
|
IER &= MINT13; // Set "global" priority
|
||||||
|
|
||||||
|
if (xpwm_time.disable_sync_out==0)
|
||||||
|
{
|
||||||
|
if (xpwm_time.do_sync_out)
|
||||||
|
{
|
||||||
|
i_sync_pin_on();
|
||||||
|
|
||||||
|
#if(_ENABLE_PWM_LINES_FOR_TESTS_SYNC)
|
||||||
|
PWM_LINES_TK_17_ON;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
i_sync_pin_off();
|
||||||
|
|
||||||
|
#if(_ENABLE_PWM_LINES_FOR_TESTS_SYNC)
|
||||||
|
PWM_LINES_TK_17_OFF;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (xpwm_time.what_next_interrupt==PWM_LOW_LEVEL_INTERRUPT)
|
||||||
|
{
|
||||||
|
l2 = 1;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
l2 = 0;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
#if (_ENABLE_INTERRUPT_PROFILE_LED1)
|
#if (_ENABLE_INTERRUPT_PROFILE_LED1)
|
||||||
if (enable_profile_led1_pwm)
|
if (profile_interrupt.for_led1.bits.pwm && l2)
|
||||||
i_led1_on_off_special(1);
|
i_led1_on_off_special(1);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if (_ENABLE_INTERRUPT_PROFILE_LED2)
|
#if (_ENABLE_INTERRUPT_PROFILE_LED2)
|
||||||
if (enable_profile_led2_pwm)
|
if (profile_interrupt.for_led2.bits.pwm && l2)
|
||||||
i_led2_on_off_special(1);
|
i_led2_on_off_special(1);
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
EINT;
|
EINT;
|
||||||
|
|
||||||
// Insert ISR Code here.......
|
// Insert ISR Code here.......
|
||||||
@ -115,11 +157,12 @@ interrupt void XIntc_INT13_Handler(void)
|
|||||||
|
|
||||||
|
|
||||||
#if (_ENABLE_INTERRUPT_PROFILE_LED1)
|
#if (_ENABLE_INTERRUPT_PROFILE_LED1)
|
||||||
if (enable_profile_led1_pwm)
|
if (profile_interrupt.for_led1.bits.pwm)
|
||||||
i_led1_on_off_special(0);
|
i_led1_on_off_special(0);
|
||||||
#endif
|
#endif
|
||||||
#if (_ENABLE_INTERRUPT_PROFILE_LED2)
|
#if (_ENABLE_INTERRUPT_PROFILE_LED2)
|
||||||
if (enable_profile_led2_pwm)
|
if (profile_interrupt.for_led2.bits.pwm)
|
||||||
|
if (l2)
|
||||||
i_led2_on_off_special(0);
|
i_led2_on_off_special(0);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
@ -116,6 +116,7 @@ extern X_PARALLEL_BUS x_parallel_bus_project;
|
|||||||
// ver 2
|
// ver 2
|
||||||
#define read_pbus_value_v2(bit,adr,res) {if (bit) { res = i_ReadMemory(adr); i_WriteMemory(adr++,0x0); } else res = 0; }
|
#define read_pbus_value_v2(bit,adr,res) {if (bit) { res = i_ReadMemory(adr); i_WriteMemory(adr++,0x0); } else res = 0; }
|
||||||
#define read_pbus_value_full_v2(bit,adr,res) {res = i_ReadMemory(adr); i_WriteMemory(adr++,0x0); }
|
#define read_pbus_value_full_v2(bit,adr,res) {res = i_ReadMemory(adr); i_WriteMemory(adr++,0x0); }
|
||||||
|
#define read_pbus_value_full_v3(bit,adr,res) {res = i_ReadMemory(adr++); }
|
||||||
|
|
||||||
#define read_pbus_adc_value_v2(bit,adr,res) {if (bit) { res = i_ReadMemory(adr) & 0xfff; i_WriteMemory(adr++,0x0);} else res = 0; }
|
#define read_pbus_adc_value_v2(bit,adr,res) {if (bit) { res = i_ReadMemory(adr) & 0xfff; i_WriteMemory(adr++,0x0);} else res = 0; }
|
||||||
#define read_pbus_adc_value_full_v2(bit,adr,res) {res = i_ReadMemory(adr) & 0xfff; i_WriteMemory(adr++,0x0); }
|
#define read_pbus_adc_value_full_v2(bit,adr,res) {res = i_ReadMemory(adr) & 0xfff; i_WriteMemory(adr++,0x0); }
|
||||||
|
@ -343,6 +343,8 @@ int cds_in_read_pbus(T_cds_in *v)
|
|||||||
read_pbus_value(v->setup_pbus.use_reg_in_pbus.bit.reg4,adr_pbus,v->read.pbus.SpeedS1_cnt90);
|
read_pbus_value(v->setup_pbus.use_reg_in_pbus.bit.reg4,adr_pbus,v->read.pbus.SpeedS1_cnt90);
|
||||||
read_pbus_value(v->setup_pbus.use_reg_in_pbus.bit.reg5,adr_pbus,v->read.pbus.SpeedS2_cnt);
|
read_pbus_value(v->setup_pbus.use_reg_in_pbus.bit.reg5,adr_pbus,v->read.pbus.SpeedS2_cnt);
|
||||||
read_pbus_value(v->setup_pbus.use_reg_in_pbus.bit.reg6,adr_pbus,v->read.pbus.SpeedS2_cnt90);
|
read_pbus_value(v->setup_pbus.use_reg_in_pbus.bit.reg6,adr_pbus,v->read.pbus.SpeedS2_cnt90);
|
||||||
|
if ((v->type_cds_xilinx == TYPE_CDS_XILINX_SP6))
|
||||||
|
{
|
||||||
read_pbus_value(v->setup_pbus.use_reg_in_pbus.bit.reg7,adr_pbus,v->read.pbus.Time_since_zero_point_S1);
|
read_pbus_value(v->setup_pbus.use_reg_in_pbus.bit.reg7,adr_pbus,v->read.pbus.Time_since_zero_point_S1);
|
||||||
read_pbus_value(v->setup_pbus.use_reg_in_pbus.bit.reg8,adr_pbus,v->read.pbus.Impulses_since_zero_point_Rising_S1);
|
read_pbus_value(v->setup_pbus.use_reg_in_pbus.bit.reg8,adr_pbus,v->read.pbus.Impulses_since_zero_point_Rising_S1);
|
||||||
read_pbus_value(v->setup_pbus.use_reg_in_pbus.bit.reg9,adr_pbus,v->read.pbus.Impulses_since_zero_point_Falling_S1);
|
read_pbus_value(v->setup_pbus.use_reg_in_pbus.bit.reg9,adr_pbus,v->read.pbus.Impulses_since_zero_point_Falling_S1);
|
||||||
@ -350,100 +352,8 @@ int cds_in_read_pbus(T_cds_in *v)
|
|||||||
read_pbus_value(v->setup_pbus.use_reg_in_pbus.bit.reg11,adr_pbus,v->read.pbus.Impulses_since_zero_point_Rising_S2);
|
read_pbus_value(v->setup_pbus.use_reg_in_pbus.bit.reg11,adr_pbus,v->read.pbus.Impulses_since_zero_point_Rising_S2);
|
||||||
read_pbus_value(v->setup_pbus.use_reg_in_pbus.bit.reg12,adr_pbus,v->read.pbus.Impulses_since_zero_point_Falling_S2);
|
read_pbus_value(v->setup_pbus.use_reg_in_pbus.bit.reg12,adr_pbus,v->read.pbus.Impulses_since_zero_point_Falling_S2);
|
||||||
read_pbus_value(v->setup_pbus.use_reg_in_pbus.bit.reg13,adr_pbus,v->read.pbus.channel_alive.all);
|
read_pbus_value(v->setup_pbus.use_reg_in_pbus.bit.reg13,adr_pbus,v->read.pbus.channel_alive.all);
|
||||||
/*
|
|
||||||
//0
|
|
||||||
if (v->setup_pbus.use_reg_in_pbus.bit.reg0)
|
|
||||||
{
|
|
||||||
x_parallel_bus_project.adr_table_read = v->adr_pbus.adr_table[0];
|
|
||||||
x_parallel_bus_project.read_one_data(&x_parallel_bus_project);
|
|
||||||
v->read.pbus.data_in.all = x_parallel_bus_project.data_table_read;
|
|
||||||
}
|
|
||||||
//1
|
|
||||||
if (v->setup_pbus.use_reg_in_pbus.bit.reg1)
|
|
||||||
{
|
|
||||||
x_parallel_bus_project.adr_table_read = v->adr_pbus.adr_table[1];
|
|
||||||
x_parallel_bus_project.read_one_data(&x_parallel_bus_project);
|
|
||||||
v->read.pbus.ready_in.all = x_parallel_bus_project.data_table_read;
|
|
||||||
}
|
|
||||||
//2
|
|
||||||
if (v->setup_pbus.use_reg_in_pbus.bit.reg2)
|
|
||||||
{
|
|
||||||
x_parallel_bus_project.adr_table_read = v->adr_pbus.adr_table[2];
|
|
||||||
x_parallel_bus_project.read_one_data(&x_parallel_bus_project);
|
|
||||||
v->read.pbus.direction_in.all = x_parallel_bus_project.data_table_read;
|
|
||||||
}
|
|
||||||
//3
|
|
||||||
if (v->setup_pbus.use_reg_in_pbus.bit.reg3)
|
|
||||||
{
|
|
||||||
x_parallel_bus_project.adr_table_read = v->adr_pbus.adr_table[3];
|
|
||||||
x_parallel_bus_project.read_one_data(&x_parallel_bus_project);
|
|
||||||
v->read.pbus.SpeedS1_cnt = x_parallel_bus_project.data_table_read;
|
|
||||||
}
|
|
||||||
//4
|
|
||||||
if (v->setup_pbus.use_reg_in_pbus.bit.reg4)
|
|
||||||
{
|
|
||||||
x_parallel_bus_project.adr_table_read = v->adr_pbus.adr_table[4];
|
|
||||||
x_parallel_bus_project.read_one_data(&x_parallel_bus_project);
|
|
||||||
v->read.pbus.SpeedS1_cnt90 = x_parallel_bus_project.data_table_read;
|
|
||||||
}
|
|
||||||
//5
|
|
||||||
if (v->setup_pbus.use_reg_in_pbus.bit.reg5)
|
|
||||||
{
|
|
||||||
x_parallel_bus_project.adr_table_read = v->adr_pbus.adr_table[5];
|
|
||||||
x_parallel_bus_project.read_one_data(&x_parallel_bus_project);
|
|
||||||
v->read.pbus.SpeedS2_cnt = x_parallel_bus_project.data_table_read;
|
|
||||||
}
|
|
||||||
//6
|
|
||||||
if (v->setup_pbus.use_reg_in_pbus.bit.reg6)
|
|
||||||
{
|
|
||||||
x_parallel_bus_project.adr_table_read = v->adr_pbus.adr_table[6];
|
|
||||||
x_parallel_bus_project.read_one_data(&x_parallel_bus_project);
|
|
||||||
v->read.pbus.SpeedS2_cnt90 = x_parallel_bus_project.data_table_read;
|
|
||||||
}
|
|
||||||
//7
|
|
||||||
if (v->setup_pbus.use_reg_in_pbus.bit.reg7)
|
|
||||||
{
|
|
||||||
x_parallel_bus_project.adr_table_read = v->adr_pbus.adr_table[7];
|
|
||||||
x_parallel_bus_project.read_one_data(&x_parallel_bus_project);
|
|
||||||
v->read.pbus.Time_since_zero_point_S1 = x_parallel_bus_project.data_table_read;
|
|
||||||
}
|
|
||||||
//8
|
|
||||||
if (v->setup_pbus.use_reg_in_pbus.bit.reg8)
|
|
||||||
{
|
|
||||||
x_parallel_bus_project.adr_table_read = v->adr_pbus.adr_table[8];
|
|
||||||
x_parallel_bus_project.read_one_data(&x_parallel_bus_project);
|
|
||||||
v->read.pbus.Time_since_zero_point_Rising_S1 = x_parallel_bus_project.data_table_read;
|
|
||||||
}
|
|
||||||
//9
|
|
||||||
if (v->setup_pbus.use_reg_in_pbus.bit.reg9)
|
|
||||||
{
|
|
||||||
x_parallel_bus_project.adr_table_read = v->adr_pbus.adr_table[9];
|
|
||||||
x_parallel_bus_project.read_one_data(&x_parallel_bus_project);
|
|
||||||
v->read.pbus.Time_since_zero_point_Falling_S1 = x_parallel_bus_project.data_table_read;
|
|
||||||
}
|
|
||||||
//10
|
|
||||||
if (v->setup_pbus.use_reg_in_pbus.bit.reg10)
|
|
||||||
{
|
|
||||||
x_parallel_bus_project.adr_table_read = v->adr_pbus.adr_table[10];
|
|
||||||
x_parallel_bus_project.read_one_data(&x_parallel_bus_project);
|
|
||||||
v->read.pbus.Time_since_zero_point_S2 = x_parallel_bus_project.data_table_read;
|
|
||||||
}
|
|
||||||
//11
|
|
||||||
if (v->setup_pbus.use_reg_in_pbus.bit.reg11)
|
|
||||||
{
|
|
||||||
x_parallel_bus_project.adr_table_read = v->adr_pbus.adr_table[11];
|
|
||||||
x_parallel_bus_project.read_one_data(&x_parallel_bus_project);
|
|
||||||
v->read.pbus.Time_since_zero_point_Rising_S2 = x_parallel_bus_project.data_table_read;
|
|
||||||
}
|
|
||||||
//12
|
|
||||||
if (v->setup_pbus.use_reg_in_pbus.bit.reg12)
|
|
||||||
{
|
|
||||||
x_parallel_bus_project.adr_table_read = v->adr_pbus.adr_table[12];
|
|
||||||
x_parallel_bus_project.read_one_data(&x_parallel_bus_project);
|
|
||||||
v->read.pbus.Time_since_zero_point_Falling_S2 = x_parallel_bus_project.data_table_read;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
*/
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -64,6 +64,12 @@ int cds_tk_write_sbus_23550(T_cds_tk_23550 *v)
|
|||||||
v->status_serial_bus.count_write_error++;
|
v->status_serial_bus.count_write_error++;
|
||||||
|
|
||||||
|
|
||||||
|
//10 time_after_err
|
||||||
|
x_serial_bus_project.reg_addr = 10; // adr memory in plate
|
||||||
|
x_serial_bus_project.write_data = v->write.sbus.time_after_err; // write data
|
||||||
|
|
||||||
|
if (x_serial_bus_project.write(&x_serial_bus_project)) // make write
|
||||||
|
v->status_serial_bus.count_write_error++;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@ -193,6 +199,25 @@ int cds_tk_read_sbus_23550(T_cds_tk_23550 *v)
|
|||||||
else
|
else
|
||||||
v->status_serial_bus.count_read_error++;
|
v->status_serial_bus.count_read_error++;
|
||||||
|
|
||||||
|
//9 id_plate
|
||||||
|
x_serial_bus_project.reg_addr = 9; // adr memory in plate
|
||||||
|
x_serial_bus_project.read(&x_serial_bus_project); // read
|
||||||
|
|
||||||
|
if (x_serial_bus_project.flags.bit.read_error == 0) // check error
|
||||||
|
v->read.sbus.id_plate.all = x_serial_bus_project.read_data;
|
||||||
|
else
|
||||||
|
v->status_serial_bus.count_read_error++;
|
||||||
|
|
||||||
|
//10 time_after_err
|
||||||
|
x_serial_bus_project.reg_addr = 10; // adr memory in plate
|
||||||
|
x_serial_bus_project.read(&x_serial_bus_project); // read
|
||||||
|
|
||||||
|
if (x_serial_bus_project.flags.bit.read_error == 0) // check error
|
||||||
|
v->read.sbus.time_after_err = x_serial_bus_project.read_data;
|
||||||
|
else
|
||||||
|
v->status_serial_bus.count_read_error++;
|
||||||
|
|
||||||
|
|
||||||
//11 time_err_tk_all
|
//11 time_err_tk_all
|
||||||
x_serial_bus_project.reg_addr = 11; // adr memory in plate
|
x_serial_bus_project.reg_addr = 11; // adr memory in plate
|
||||||
x_serial_bus_project.read(&x_serial_bus_project); // read
|
x_serial_bus_project.read(&x_serial_bus_project); // read
|
||||||
@ -241,7 +266,7 @@ int cds_tk_read_pbus_23550(T_cds_tk_23550 *v)
|
|||||||
{
|
{
|
||||||
unsigned long adr_pbus;
|
unsigned long adr_pbus;
|
||||||
|
|
||||||
if (v->useit == 0)
|
if (v->useit == 0 || v->setup_pbus.use_reg_in_pbus.all==0)
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
if (v->status & (component_Started | component_Ready | component_Error | component_ErrorSBus))
|
if (v->status & (component_Started | component_Ready | component_Error | component_ErrorSBus))
|
||||||
@ -250,12 +275,12 @@ int cds_tk_read_pbus_23550(T_cds_tk_23550 *v)
|
|||||||
if (v->type_cds_xilinx == TYPE_CDS_XILINX_SP6)
|
if (v->type_cds_xilinx == TYPE_CDS_XILINX_SP6)
|
||||||
{
|
{
|
||||||
adr_pbus = v->adr_pbus.adr_table[0] + ADR_FIRST_FREE;
|
adr_pbus = v->adr_pbus.adr_table[0] + ADR_FIRST_FREE;
|
||||||
read_pbus_value_full_v2(v->setup_pbus.use_reg_in_pbus.bit.reg0,adr_pbus,v->read.pbus.status1.all);
|
read_pbus_value_full_v3(v->setup_pbus.use_reg_in_pbus.bit.reg0,adr_pbus,v->read.pbus.status1.all);
|
||||||
read_pbus_value_full_v2(v->setup_pbus.use_reg_in_pbus.bit.reg1,adr_pbus,v->read.pbus.DataReg0.all);
|
read_pbus_value_full_v3(v->setup_pbus.use_reg_in_pbus.bit.reg1,adr_pbus,v->read.pbus.DataReg0.all);
|
||||||
read_pbus_value_full_v2(v->setup_pbus.use_reg_in_pbus.bit.reg2,adr_pbus,v->read.pbus.DataReg1.all);
|
read_pbus_value_full_v3(v->setup_pbus.use_reg_in_pbus.bit.reg2,adr_pbus,v->read.pbus.DataReg1.all);
|
||||||
read_pbus_value_full_v2(v->setup_pbus.use_reg_in_pbus.bit.reg3,adr_pbus,v->read.pbus.DataReg2.all);
|
read_pbus_value_full_v3(v->setup_pbus.use_reg_in_pbus.bit.reg3,adr_pbus,v->read.pbus.DataReg2.all);
|
||||||
read_pbus_value_full_v2(v->setup_pbus.use_reg_in_pbus.bit.reg4,adr_pbus,v->read.pbus.DataReg3.all);
|
read_pbus_value_full_v3(v->setup_pbus.use_reg_in_pbus.bit.reg4,adr_pbus,v->read.pbus.DataReg3.all);
|
||||||
read_pbus_value_full_v2(v->setup_pbus.use_reg_in_pbus.bit.reg5,adr_pbus,v->read.pbus.status2.all);
|
read_pbus_value_full_v3(v->setup_pbus.use_reg_in_pbus.bit.reg5,adr_pbus,v->read.pbus.status2.all);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@ -313,8 +338,9 @@ void cds_tk_optical_bus_check_error_read(T_cds_tk_23550 *v)
|
|||||||
|
|
||||||
if ( v->optical_data_in.status_1.bit.id_sbus == v->optical_data_in.status_2.bit.id_sbus
|
if ( v->optical_data_in.status_1.bit.id_sbus == v->optical_data_in.status_2.bit.id_sbus
|
||||||
&& v->optical_data_in.status_1.bit.id == v->optical_data_in.status_2.bit.id
|
&& v->optical_data_in.status_1.bit.id == v->optical_data_in.status_2.bit.id
|
||||||
&& (v->read.pbus.status1.bit.receiver_error==0)
|
// && (v->read.pbus.status1.bit.receiver_error==0)
|
||||||
&& (v->read.pbus.status2.bit.receiver_error==0) )
|
// && (v->read.pbus.status2.bit.receiver_error==0)
|
||||||
|
)
|
||||||
{
|
{
|
||||||
// åñëè âûñòàâèëñÿ ýòîò áèò, òî çíâ÷èò ïðèåìíèê â ïðèåìå äàííûõ, íî ò.ê. ýòè äàííûå ìû ïîëó÷àåì ïî PBUS ñ íåêîòîðûì ëàãîì
|
// åñëè âûñòàâèëñÿ ýòîò áèò, òî çíâ÷èò ïðèåìíèê â ïðèåìå äàííûõ, íî ò.ê. ýòè äàííûå ìû ïîëó÷àåì ïî PBUS ñ íåêîòîðûì ëàãîì
|
||||||
// ñìûñë ýòîãî áèòà òåðÿåò ñâîé ñìûñë, ïðîñòî êàê èíôîðìàöèÿ, äàííûå ìû ïîëó÷èì âñåãäà ïîñëåäíèå óäà÷íûå.
|
// ñìûñë ýòîãî áèòà òåðÿåò ñâîé ñìûñë, ïðîñòî êàê èíôîðìàöèÿ, äàííûå ìû ïîëó÷èì âñåãäà ïîñëåäíèå óäà÷íûå.
|
||||||
@ -326,10 +352,17 @@ void cds_tk_optical_bus_check_error_read(T_cds_tk_23550 *v)
|
|||||||
// data old
|
// data old
|
||||||
v->optical_data_in.status_read.bit.old_data = 1;
|
v->optical_data_in.status_read.bit.old_data = 1;
|
||||||
v->optical_data_in.same_id_count += 1;
|
v->optical_data_in.same_id_count += 1;
|
||||||
|
|
||||||
|
if (v->optical_data_in.same_id_count_between < v->optical_data_in.setup_count_error_between)
|
||||||
|
v->optical_data_in.same_id_count_between += 1;
|
||||||
|
else
|
||||||
|
// ÷èòàëè âñå âðåìÿ ñòàðûå äàííûå, ïåðåäàò÷èê óìåð íà òîé ñòîðîíå?
|
||||||
|
v->optical_data_in.ready = 0;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
// î÷èñòêà îøèáîê
|
// î÷èñòêà îøèáîê
|
||||||
|
v->optical_data_in.same_id_count_between = 0;
|
||||||
v->optical_data_in.local_count_error = 0;
|
v->optical_data_in.local_count_error = 0;
|
||||||
v->optical_data_in.raw_local_error = 0;
|
v->optical_data_in.raw_local_error = 0;
|
||||||
v->optical_data_in.ready = 1;
|
v->optical_data_in.ready = 1;
|
||||||
|
@ -99,7 +99,9 @@ typedef struct {
|
|||||||
UInt16 all;
|
UInt16 all;
|
||||||
struct
|
struct
|
||||||
{
|
{
|
||||||
UInt16 reserv :10;
|
UInt16 reserv :8;
|
||||||
|
UInt16 detect_soft_disconnect :1;
|
||||||
|
UInt16 enable_soft_disconnect :1;
|
||||||
UInt16 enable_line_err :1;
|
UInt16 enable_line_err :1;
|
||||||
UInt16 disable_err_mintime :1;
|
UInt16 disable_err_mintime :1;
|
||||||
UInt16 disable_err_hwp :1;
|
UInt16 disable_err_hwp :1;
|
||||||
@ -111,7 +113,8 @@ typedef struct {
|
|||||||
//7
|
//7
|
||||||
UInt16 cmd_reset_error;
|
UInt16 cmd_reset_error;
|
||||||
|
|
||||||
//
|
//10
|
||||||
|
UInt16 time_after_err; //time_after_err = 4000<-DEC * 0.02 = 80mc
|
||||||
|
|
||||||
} T_cds_tk_write_sbus_23550;
|
} T_cds_tk_write_sbus_23550;
|
||||||
|
|
||||||
@ -195,7 +198,9 @@ typedef struct {
|
|||||||
UInt16 all;
|
UInt16 all;
|
||||||
struct
|
struct
|
||||||
{
|
{
|
||||||
UInt16 reserv :10;
|
UInt16 reserv :8;
|
||||||
|
UInt16 detect_soft_disconnect :1;
|
||||||
|
UInt16 enable_soft_disconnect :1;
|
||||||
UInt16 enable_line_err :1;
|
UInt16 enable_line_err :1;
|
||||||
UInt16 disable_err_mintime :1;
|
UInt16 disable_err_mintime :1;
|
||||||
UInt16 disable_err_hwp :1;
|
UInt16 disable_err_hwp :1;
|
||||||
@ -261,7 +266,9 @@ typedef struct {
|
|||||||
UInt16 all;
|
UInt16 all;
|
||||||
struct
|
struct
|
||||||
{
|
{
|
||||||
UInt16 reserv :7;
|
UInt16 reserv :5;
|
||||||
|
UInt16 ErrorSoftShutdownForbidComb :1;
|
||||||
|
UInt16 ErrorSoftShutdownFromErr0 :1;
|
||||||
UInt16 line_err_keys_3210 :1;
|
UInt16 line_err_keys_3210 :1;
|
||||||
UInt16 line_err_keys_7654 :1;
|
UInt16 line_err_keys_7654 :1;
|
||||||
UInt16 mintime_err_keys_3210 :1;
|
UInt16 mintime_err_keys_3210 :1;
|
||||||
@ -299,6 +306,22 @@ typedef struct {
|
|||||||
} bit;
|
} bit;
|
||||||
} status_protect_current_ack;
|
} status_protect_current_ack;
|
||||||
|
|
||||||
|
//9
|
||||||
|
union
|
||||||
|
{
|
||||||
|
UInt16 all;
|
||||||
|
struct
|
||||||
|
{
|
||||||
|
UInt16 revision :5;
|
||||||
|
UInt16 version :6;
|
||||||
|
T_plate_type plate_type :5;
|
||||||
|
} bit;
|
||||||
|
} id_plate;
|
||||||
|
|
||||||
|
//10
|
||||||
|
|
||||||
|
UInt16 time_after_err;
|
||||||
|
|
||||||
|
|
||||||
//11
|
//11
|
||||||
union
|
union
|
||||||
@ -480,12 +503,14 @@ typedef union {
|
|||||||
//////////////////////////////////////////////////////////////
|
//////////////////////////////////////////////////////////////
|
||||||
typedef struct {
|
typedef struct {
|
||||||
UInt16 setup_count_error; // ñêîëüêî æäåì äî ïàäåíèÿ øèíû
|
UInt16 setup_count_error; // ñêîëüêî æäåì äî ïàäåíèÿ øèíû
|
||||||
|
UInt16 setup_count_error_between; // ñêîëüêî æäåì äî ïàäåíèÿ øèíû ïðè ÷òåíèè ñòàðûõ çíà÷åíèé
|
||||||
UInt16 full_count_error; // âñåãî îøèáîê
|
UInt16 full_count_error; // âñåãî îøèáîê
|
||||||
UInt16 local_count_error; // òåêóùèé ñ÷åò÷èê îøèáîê, èäåò äî setup_count_error è ñíèìàåòñÿ ready, ïðè óäà÷íîì ÷òåíèè îáíóëÿåòñÿ
|
UInt16 local_count_error; // òåêóùèé ñ÷åò÷èê îøèáîê, èäåò äî setup_count_error è ñíèìàåòñÿ ready, ïðè óäà÷íîì ÷òåíèè îáíóëÿåòñÿ
|
||||||
UInt16 count_ok; // ñêîëüêî óäà÷íûõ ÷òåíèé
|
UInt16 count_ok; // ñêîëüêî óäà÷íûõ ÷òåíèé
|
||||||
UInt16 count_lost; // ñêîëüêî ïîòåðü äàííûõ (ïî id_sbus)
|
UInt16 count_lost; // ñêîëüêî ïîòåðü äàííûõ (ïî id_sbus)
|
||||||
UInt16 ready; // øèíà ðàáîòàåò, îøèáêè íå ïðåâûñèëè setup_count_error
|
UInt16 ready; // øèíà ðàáîòàåò, îøèáêè íå ïðåâûñèëè setup_count_error
|
||||||
UInt16 same_id_count; // сколько повторных чтений техже данных, т.е. передатчик в др.ПЧ не прислал ничего нового
|
UInt16 same_id_count; // ñêîëüêî âñåãî ïîâòîðíûõ ÷òåíèé òåõæå äàííûõ, ò.å. ïåðåäàò÷èê â äð.Ï× íå ïðèñëàë íè÷åãî íîâîãî
|
||||||
|
UInt16 same_id_count_between; // ìåæäó óäà÷íûìè ÷òåíèÿìè, ñêîëüêî ïîâòîðíûõ ÷òåíèé òåõæå äàííûõ, ò.å. ïåðåäàò÷èê â äð.Ï× íå ïðèñëàë íè÷åãî íîâîãî
|
||||||
UInt16 error_not_ready_count; // ñêîëüêî îøèáîê íå ãîòîâíîñòè øèíû ready
|
UInt16 error_not_ready_count; // ñêîëüêî îøèáîê íå ãîòîâíîñòè øèíû ready
|
||||||
UInt16 raw_local_error; // åñòü îøèáêà ïðè ÷òåíèè, íî øèíà íå óïàëà åùå
|
UInt16 raw_local_error; // åñòü îøèáêà ïðè ÷òåíèè, íî øèíà íå óïàëà åùå
|
||||||
UInt16 buf[4]; // äàííûå
|
UInt16 buf[4]; // äàííûå
|
||||||
@ -496,7 +521,7 @@ typedef struct {
|
|||||||
STATUS_DATA_READ_OPT_BUS prev_status_read;// ñòàòóñ ïîñëå ÷òåíèÿ è àíàëèçà äàííûõ
|
STATUS_DATA_READ_OPT_BUS prev_status_read;// ñòàòóñ ïîñëå ÷òåíèÿ è àíàëèçà äàííûõ
|
||||||
} T_cds_optical_bus_data_in;
|
} T_cds_optical_bus_data_in;
|
||||||
|
|
||||||
#define T_CDS_OPTICAL_BUS_DATA_IN_DEFAULTS {15,0,0,0,0,0,0,0,0,{0,0,0,0},0,0,0,0,0}
|
#define T_CDS_OPTICAL_BUS_DATA_IN_DEFAULTS {15,50,0,0,0,0,0,0,0,0,0,{0,0,0,0},0,0,0,0,0}
|
||||||
|
|
||||||
/////////////////////////////////////////////////////////////////
|
/////////////////////////////////////////////////////////////////
|
||||||
/////////////////////////////////////////////////////////////////
|
/////////////////////////////////////////////////////////////////
|
||||||
|
@ -183,15 +183,18 @@ void hwp_init(T_hwp *v)
|
|||||||
|
|
||||||
|
|
||||||
#if (HWP_SPEED_VERSION_DEFINE==MODE_HWP_SPEED_NORMAL)
|
#if (HWP_SPEED_VERSION_DEFINE==MODE_HWP_SPEED_NORMAL)
|
||||||
v->low_setup.dac_config.bit.HWP_Speed = MODE_HWP_SPEED_NORMAL;//HWP_SPEED_VERSION_DEFINE; // new version hwp with low speed serial hwp
|
// v->low_setup.dac_config.bit.HWP_Speed = MODE_HWP_SPEED_NORMAL;//HWP_SPEED_VERSION_DEFINE; // new version hwp with low speed serial hwp
|
||||||
|
v->write.HWP_Speed = MODE_HWP_SPEED_NORMAL;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if (HWP_SPEED_VERSION_DEFINE==MODE_HWP_SPEED_SLOW)
|
#if (HWP_SPEED_VERSION_DEFINE==MODE_HWP_SPEED_SLOW)
|
||||||
v->low_setup.dac_config.bit.HWP_Speed = MODE_HWP_SPEED_SLOW;//HWP_SPEED_VERSION_DEFINE; // new version hwp with low speed serial hwp
|
// v->low_setup.dac_config.bit.HWP_Speed = MODE_HWP_SPEED_SLOW;//HWP_SPEED_VERSION_DEFINE; // new version hwp with low speed serial hwp
|
||||||
|
v->write.HWP_Speed = MODE_HWP_SPEED_SLOW;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if (HWP_SPEED_VERSION_DEFINE==MODE_HWP_SPEED_AUTO)
|
#if (HWP_SPEED_VERSION_DEFINE==MODE_HWP_SPEED_AUTO)
|
||||||
v->low_setup.dac_config.bit.HWP_Speed = MODE_HWP_SPEED_AUTO;//HWP_SPEED_VERSION_DEFINE; // new version hwp with low speed serial hwp
|
// v->low_setup.dac_config.bit.HWP_Speed = MODE_HWP_SPEED_AUTO;//HWP_SPEED_VERSION_DEFINE; // new version hwp with low speed serial hwp
|
||||||
|
v->write.HWP_Speed = MODE_HWP_SPEED_AUTO;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
}
|
}
|
||||||
@ -1267,7 +1270,7 @@ int hwp_write_all_dacs(T_hwp *v)
|
|||||||
int hwp_write_all(T_hwp *v)
|
int hwp_write_all(T_hwp *v)
|
||||||
{
|
{
|
||||||
|
|
||||||
int err = 0;
|
int err = 0, err_ready = 0;
|
||||||
|
|
||||||
if (v->useit == 0)
|
if (v->useit == 0)
|
||||||
return 0;
|
return 0;
|
||||||
@ -1312,6 +1315,8 @@ int hwp_write_all(T_hwp *v)
|
|||||||
else
|
else
|
||||||
v->status = component_Ready;
|
v->status = component_Ready;
|
||||||
|
|
||||||
|
err_ready = check_cds_ready_hwpbus( err, ITS_WRITE_BUS, &v->status_hwp_bus);
|
||||||
|
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
|
@ -23,6 +23,7 @@ static void write_command_reg(T_inc_sensor *inc_s);
|
|||||||
static void tune_sampling_time(T_inc_sensor *inc_s);
|
static void tune_sampling_time(T_inc_sensor *inc_s);
|
||||||
static void wait_for_registers_updated(T_inc_sensor *inc_s);
|
static void wait_for_registers_updated(T_inc_sensor *inc_s);
|
||||||
static void read_direction_in_plane(T_inc_sensor *inc_s);
|
static void read_direction_in_plane(T_inc_sensor *inc_s);
|
||||||
|
static void detect_break_sensor_1_2(T_inc_sensor *inc_s);
|
||||||
|
|
||||||
void sensor_set(T_inc_sensor *inc_s)
|
void sensor_set(T_inc_sensor *inc_s)
|
||||||
{
|
{
|
||||||
@ -80,6 +81,8 @@ void inc_sensor_read(T_inc_sensor *inc_s)
|
|||||||
inc_s->read_sensor2(inc_s);
|
inc_s->read_sensor2(inc_s);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
detect_break_sensor_1_2(inc_s);
|
||||||
|
|
||||||
#ifdef AUTO_CHANGE_SAMPLING_TIME
|
#ifdef AUTO_CHANGE_SAMPLING_TIME
|
||||||
tune_sampling_time(inc_s);
|
tune_sampling_time(inc_s);
|
||||||
#endif
|
#endif
|
||||||
@ -87,7 +90,8 @@ void inc_sensor_read(T_inc_sensor *inc_s)
|
|||||||
|
|
||||||
////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////
|
||||||
////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////
|
||||||
|
#define MAX_COUNT_OVERFULL_DISCRET_3 150
|
||||||
|
#pragma CODE_SECTION(inc_sensor_read1,".fast_run");
|
||||||
void inc_sensor_read1(T_inc_sensor *inc_s)
|
void inc_sensor_read1(T_inc_sensor *inc_s)
|
||||||
{
|
{
|
||||||
read_in_sensor_line1(inc_s);
|
read_in_sensor_line1(inc_s);
|
||||||
@ -107,8 +111,47 @@ void inc_sensor_read1(T_inc_sensor *inc_s)
|
|||||||
|
|
||||||
|
|
||||||
//#endif
|
//#endif
|
||||||
|
//inc_s->data.CountZero1 = inc_s->pm67regs.zero_time_line1;
|
||||||
|
|
||||||
|
if (inc_s->pm67regs.zero_time_line1==0)
|
||||||
|
{
|
||||||
|
if (inc_s->data.countCountZero1==MAX_COUNT_OVERFULL_DISCRET_3)
|
||||||
|
{
|
||||||
|
inc_s->data.prev_CountZero1 = inc_s->data.CountZero1 = 0;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
inc_s->data.CountZero1 = inc_s->data.prev_CountZero1;
|
||||||
|
inc_s->data.countCountZero1++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
inc_s->data.countCountZero1 = 0;
|
||||||
inc_s->data.CountZero1 = inc_s->pm67regs.zero_time_line1;
|
inc_s->data.CountZero1 = inc_s->pm67regs.zero_time_line1;
|
||||||
|
inc_s->data.prev_CountZero1 = inc_s->pm67regs.zero_time_line1;
|
||||||
|
}
|
||||||
|
|
||||||
|
// inc_s->data.CountOne1 = inc_s->pm67regs.one_time_line1;
|
||||||
|
if (inc_s->pm67regs.one_time_line1==0)
|
||||||
|
{
|
||||||
|
if (inc_s->data.countCountOne1==MAX_COUNT_OVERFULL_DISCRET_3)
|
||||||
|
{
|
||||||
|
inc_s->data.prev_CountOne1 = inc_s->data.CountOne1 = 0;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
inc_s->data.CountOne1 = inc_s->data.prev_CountOne1;
|
||||||
|
inc_s->data.countCountOne1++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
inc_s->data.countCountOne1 = 0;
|
||||||
inc_s->data.CountOne1 = inc_s->pm67regs.one_time_line1;
|
inc_s->data.CountOne1 = inc_s->pm67regs.one_time_line1;
|
||||||
|
inc_s->data.prev_CountOne1 = inc_s->pm67regs.one_time_line1;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
inc_s->data.counter_freq1 = inc_s->pm67regs.read_comand_reg.bit.sampling_time1;
|
inc_s->data.counter_freq1 = inc_s->pm67regs.read_comand_reg.bit.sampling_time1;
|
||||||
|
|
||||||
@ -117,7 +160,7 @@ void inc_sensor_read1(T_inc_sensor *inc_s)
|
|||||||
|
|
||||||
////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////
|
||||||
////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////
|
||||||
|
#pragma CODE_SECTION(inc_sensor_read2,".fast_run");
|
||||||
void inc_sensor_read2(T_inc_sensor *inc_s)
|
void inc_sensor_read2(T_inc_sensor *inc_s)
|
||||||
{
|
{
|
||||||
read_in_sensor_line2(inc_s);
|
read_in_sensor_line2(inc_s);
|
||||||
@ -136,8 +179,46 @@ void inc_sensor_read2(T_inc_sensor *inc_s)
|
|||||||
inc_s->data.TimeCalcFromImpulses2 = 0;
|
inc_s->data.TimeCalcFromImpulses2 = 0;
|
||||||
|
|
||||||
//#endif
|
//#endif
|
||||||
|
//inc_s->data.CountZero1 = inc_s->pm67regs.zero_time_line1;
|
||||||
|
|
||||||
|
if (inc_s->pm67regs.zero_time_line2==0)
|
||||||
|
{
|
||||||
|
if (inc_s->data.countCountZero2==MAX_COUNT_OVERFULL_DISCRET_3)
|
||||||
|
{
|
||||||
|
inc_s->data.prev_CountZero2 = inc_s->data.CountZero2 = 0;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
inc_s->data.CountZero2 = inc_s->data.prev_CountZero2;
|
||||||
|
inc_s->data.countCountZero2++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
inc_s->data.countCountZero2 = 0;
|
||||||
inc_s->data.CountZero2 = inc_s->pm67regs.zero_time_line2;
|
inc_s->data.CountZero2 = inc_s->pm67regs.zero_time_line2;
|
||||||
|
inc_s->data.prev_CountZero2 = inc_s->pm67regs.zero_time_line2;
|
||||||
|
}
|
||||||
|
|
||||||
|
// inc_s->data.CountOne1 = inc_s->pm67regs.one_time_line1;
|
||||||
|
if (inc_s->pm67regs.one_time_line2==0)
|
||||||
|
{
|
||||||
|
if (inc_s->data.countCountOne2==MAX_COUNT_OVERFULL_DISCRET_3)
|
||||||
|
{
|
||||||
|
inc_s->data.prev_CountOne2 = inc_s->data.CountOne2 = 0;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
inc_s->data.CountOne2 = inc_s->data.prev_CountOne2;
|
||||||
|
inc_s->data.countCountOne2++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
inc_s->data.countCountOne2 = 0;
|
||||||
inc_s->data.CountOne2 = inc_s->pm67regs.one_time_line2;
|
inc_s->data.CountOne2 = inc_s->pm67regs.one_time_line2;
|
||||||
|
inc_s->data.prev_CountOne2 = inc_s->pm67regs.one_time_line2;
|
||||||
|
}
|
||||||
|
|
||||||
inc_s->data.counter_freq2 = inc_s->pm67regs.read_comand_reg.bit.sampling_time2;
|
inc_s->data.counter_freq2 = inc_s->pm67regs.read_comand_reg.bit.sampling_time2;
|
||||||
|
|
||||||
@ -251,6 +332,32 @@ void wait_for_registers_updated(T_inc_sensor *inc_s)
|
|||||||
}
|
}
|
||||||
|
|
||||||
////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////
|
||||||
|
void detect_break_sensor_1_2(T_inc_sensor *inc_s)
|
||||||
|
{
|
||||||
|
unsigned int f1 = (inc_s->data.CountOne1 || inc_s->data.CountZero1);
|
||||||
|
unsigned int f2 = (inc_s->data.CountOne2 || inc_s->data.CountZero2);
|
||||||
|
|
||||||
|
|
||||||
|
if (f1 && f2==0)
|
||||||
|
{
|
||||||
|
inc_s->break_sensor1 = 0;
|
||||||
|
inc_s->break_sensor2 = 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (f1==0 && f2)
|
||||||
|
{
|
||||||
|
inc_s->break_sensor1 = 1;
|
||||||
|
inc_s->break_sensor2 = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
if ((f1==0 && f2==0) || (f1 && f2))
|
||||||
|
{
|
||||||
|
inc_s->break_sensor1 = 0;
|
||||||
|
inc_s->break_sensor2 = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
|
||||||
@ -259,16 +366,20 @@ void tune_sampling_time(T_inc_sensor *inc_s)
|
|||||||
|
|
||||||
// ñíà÷àëà ïðîâåðßåì íà ìàêñèìóì, ò.ê. åñëè äàò÷èê îòâàëèëñß, òî îí ïîêàæåò = 0.
|
// ñíà÷àëà ïðîâåðßåì íà ìàêñèìóì, ò.ê. åñëè äàò÷èê îòâàëèëñß, òî îí ïîêàæåò = 0.
|
||||||
|
|
||||||
if((inc_s->use_sensor1 && (inc_s->pm67regs.zero_time_line1 > LEVEL_SWITCH_MICROSEC))
|
if(
|
||||||
|| (inc_s->use_sensor2 && (inc_s->pm67regs.zero_time_line2 > LEVEL_SWITCH_MICROSEC)))
|
(inc_s->use_sensor1 && inc_s->break_sensor1==0 && (inc_s->data.CountOne1 > LEVEL_SWITCH_MICROSEC) && (inc_s->data.CountZero1 > LEVEL_SWITCH_MICROSEC) )
|
||||||
|
|| (inc_s->use_sensor2 && inc_s->break_sensor2==0 && (inc_s->data.CountOne2 > LEVEL_SWITCH_MICROSEC) && (inc_s->data.CountZero2 > LEVEL_SWITCH_MICROSEC) )
|
||||||
|
)
|
||||||
{
|
{
|
||||||
inc_s->pm67regs.write_comand_reg.bit.set_sampling_time = SAMPLING_TIME_MS;
|
inc_s->pm67regs.write_comand_reg.bit.set_sampling_time = SAMPLING_TIME_MS;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// ïðîâåðêà íà ìèíèìóì
|
// ïðîâåðêà íà ìèíèìóì
|
||||||
if((inc_s->use_sensor1 && (inc_s->pm67regs.zero_time_line1 < LEVEL_SWITCH_NANOSEC))
|
if(
|
||||||
|| (inc_s->use_sensor2 && (inc_s->pm67regs.zero_time_line2 < LEVEL_SWITCH_NANOSEC)))
|
(inc_s->use_sensor1 && inc_s->break_sensor1==0 && (inc_s->data.CountOne1 < LEVEL_SWITCH_NANOSEC) && (inc_s->data.CountZero1 < LEVEL_SWITCH_NANOSEC) )
|
||||||
|
|| (inc_s->use_sensor2 && inc_s->break_sensor2==0 && (inc_s->data.CountOne2 < LEVEL_SWITCH_NANOSEC) && (inc_s->data.CountZero2 < LEVEL_SWITCH_NANOSEC) )
|
||||||
|
)
|
||||||
{
|
{
|
||||||
inc_s->pm67regs.write_comand_reg.bit.set_sampling_time = SAMPLING_TIME_NS;
|
inc_s->pm67regs.write_comand_reg.bit.set_sampling_time = SAMPLING_TIME_NS;
|
||||||
}
|
}
|
||||||
|
@ -67,6 +67,10 @@ typedef struct {
|
|||||||
unsigned int error_update;
|
unsigned int error_update;
|
||||||
unsigned int use_sensor1;
|
unsigned int use_sensor1;
|
||||||
unsigned int use_sensor2;
|
unsigned int use_sensor2;
|
||||||
|
unsigned int break_sensor1;
|
||||||
|
unsigned int break_sensor2;
|
||||||
|
unsigned int break_direction;
|
||||||
|
|
||||||
|
|
||||||
struct {
|
struct {
|
||||||
|
|
||||||
@ -74,6 +78,10 @@ typedef struct {
|
|||||||
unsigned int Impulses1; // Quantity of full impulses during survey time
|
unsigned int Impulses1; // Quantity of full impulses during survey time
|
||||||
unsigned int CountZero1; // Value of the zero-half-period counter
|
unsigned int CountZero1; // Value of the zero-half-period counter
|
||||||
unsigned int CountOne1; // Value of the one-half-period counter
|
unsigned int CountOne1; // Value of the one-half-period counter
|
||||||
|
unsigned int prev_CountZero1; // Value of the prev zero-half-period counter
|
||||||
|
unsigned int prev_CountOne1; // Value of the prev one-half-period counter
|
||||||
|
unsigned int countCountZero1; // Value of the zero-half-period counter
|
||||||
|
unsigned int countCountOne1; // Value of the one-half-period counter
|
||||||
unsigned int counter_freq1; // 1 - 60MHz; 0 - 600KHz
|
unsigned int counter_freq1; // 1 - 60MHz; 0 - 600KHz
|
||||||
unsigned long TimeCalcFromImpulses1; // Ïåðåñ÷åò âðåìåíè èìïóëüñà èç êîëè÷åñòâà Impulses1 è âðåìåíè Time1
|
unsigned long TimeCalcFromImpulses1; // Ïåðåñ÷åò âðåìåíè èìïóëüñà èç êîëè÷åñòâà Impulses1 è âðåìåíè Time1
|
||||||
int direction1; // 1 - direct; 0 - reverse
|
int direction1; // 1 - direct; 0 - reverse
|
||||||
@ -82,6 +90,10 @@ typedef struct {
|
|||||||
unsigned int Impulses2; // Quantity of full impulses during survey time
|
unsigned int Impulses2; // Quantity of full impulses during survey time
|
||||||
unsigned int CountZero2; // Value of the zero-half-period counter
|
unsigned int CountZero2; // Value of the zero-half-period counter
|
||||||
unsigned int CountOne2; // Value of the one-half-period counter
|
unsigned int CountOne2; // Value of the one-half-period counter
|
||||||
|
unsigned int prev_CountZero2; // Value of the prev zero-half-period counter
|
||||||
|
unsigned int prev_CountOne2; // Value of the prev one-half-period counter
|
||||||
|
unsigned int countCountZero2; // Value of the zero-half-period counter
|
||||||
|
unsigned int countCountOne2; // Value of the one-half-period counter
|
||||||
unsigned int counter_freq2; // 1 - 60MHz; 0 - 600KHz
|
unsigned int counter_freq2; // 1 - 60MHz; 0 - 600KHz
|
||||||
unsigned long TimeCalcFromImpulses2; // Ïåðåñ÷åò âðåìåíè èìïóëüñà èç êîëè÷åñòâà Impulses1 è âðåìåíè Time1
|
unsigned long TimeCalcFromImpulses2; // Ïåðåñ÷åò âðåìåíè èìïóëüñà èç êîëè÷åñòâà Impulses1 è âðåìåíè Time1
|
||||||
int direction2; // 1 - direct; 0 - reverse
|
int direction2; // 1 - direct; 0 - reverse
|
||||||
@ -98,7 +110,14 @@ typedef struct {
|
|||||||
|
|
||||||
} T_inc_sensor;
|
} T_inc_sensor;
|
||||||
|
|
||||||
#define T_INC_SENSOR_DEFAULT {0, 0, 0, 0, {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}, T_INC_SENSOR_REGS_DEFAULTS, inc_sensor_set, update_sensors_data_s, inc_sensor_read, inc_sensor_read1, inc_sensor_read2}
|
#define T_INC_SENSOR_DEFAULT {0, 0, 0, 0, 0, 0, 0, {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,0,0,0, 0,0,0,0}, \
|
||||||
|
T_INC_SENSOR_REGS_DEFAULTS, \
|
||||||
|
inc_sensor_set,\
|
||||||
|
update_sensors_data_s, \
|
||||||
|
inc_sensor_read, \
|
||||||
|
inc_sensor_read1, \
|
||||||
|
inc_sensor_read2 \
|
||||||
|
}
|
||||||
|
|
||||||
//////////////////////////////////////////////////////////////////////////////////
|
//////////////////////////////////////////////////////////////////////////////////
|
||||||
////
|
////
|
||||||
|
@ -1229,6 +1229,8 @@ void project_autospeed_all_hwp(void)
|
|||||||
|
|
||||||
#define PAUSE_WAIT_SBUS 10000
|
#define PAUSE_WAIT_SBUS 10000
|
||||||
#define MAX_COUNT_ERR_READ_SBUS 1100 //2000 çàïàñ ïî âðåìåíè 2õ îòíîñèòåëüíî íîðìàëüíîãî ïåðèîäà çàãðóçêè âñåé êîðçèíû
|
#define MAX_COUNT_ERR_READ_SBUS 1100 //2000 çàïàñ ïî âðåìåíè 2õ îòíîñèòåëüíî íîðìàëüíîãî ïåðèîäà çàãðóçêè âñåé êîðçèíû
|
||||||
|
#define MAX_COUNT_ERR_READ_SBUS_2 600 //2000 çàïàñ ïî âðåìåíè 2õ îòíîñèòåëüíî íîðìàëüíîãî ïåðèîäà çàãðóçêè âñåé êîðçèíû
|
||||||
|
|
||||||
#define MAX_COUNT_OR_READ_SBUS 20//200
|
#define MAX_COUNT_OR_READ_SBUS 20//200
|
||||||
|
|
||||||
|
|
||||||
@ -1243,6 +1245,8 @@ unsigned int project_wait_load_all_cds(int flag_reset)
|
|||||||
unsigned int counterOk = 0, err;
|
unsigned int counterOk = 0, err;
|
||||||
unsigned int i,count_find_plat;
|
unsigned int i,count_find_plat;
|
||||||
unsigned int old_status_max_read_error = 0;
|
unsigned int old_status_max_read_error = 0;
|
||||||
|
unsigned int prev_count_one_find_plat = 0, count_one_find_plat = 0;
|
||||||
|
unsigned int max_count_err_read_sbus = MAX_COUNT_ERR_READ_SBUS;
|
||||||
// unsigned int erReg, rd;
|
// unsigned int erReg, rd;
|
||||||
/*
|
/*
|
||||||
for (i=0;i<C_adc_number;i++)
|
for (i=0;i<C_adc_number;i++)
|
||||||
@ -1277,6 +1281,7 @@ unsigned int project_wait_load_all_cds(int flag_reset)
|
|||||||
{
|
{
|
||||||
counterOk++;
|
counterOk++;
|
||||||
project.adc[i].status = component_Started;
|
project.adc[i].status = component_Started;
|
||||||
|
count_one_find_plat++;
|
||||||
}
|
}
|
||||||
|
|
||||||
project.adc[i].status_serial_bus.max_read_error = old_status_max_read_error;
|
project.adc[i].status_serial_bus.max_read_error = old_status_max_read_error;
|
||||||
@ -1307,6 +1312,7 @@ unsigned int project_wait_load_all_cds(int flag_reset)
|
|||||||
{
|
{
|
||||||
counterOk++;
|
counterOk++;
|
||||||
project.cds_tk[i].status = component_Started;
|
project.cds_tk[i].status = component_Started;
|
||||||
|
count_one_find_plat++;
|
||||||
}
|
}
|
||||||
|
|
||||||
project.cds_tk[i].status_serial_bus.max_read_error = old_status_max_read_error;
|
project.cds_tk[i].status_serial_bus.max_read_error = old_status_max_read_error;
|
||||||
@ -1337,6 +1343,7 @@ unsigned int project_wait_load_all_cds(int flag_reset)
|
|||||||
{
|
{
|
||||||
counterOk++;
|
counterOk++;
|
||||||
project.cds_in[i].status = component_Started;
|
project.cds_in[i].status = component_Started;
|
||||||
|
count_one_find_plat++;
|
||||||
}
|
}
|
||||||
|
|
||||||
project.cds_in[i].status_serial_bus.max_read_error = old_status_max_read_error;
|
project.cds_in[i].status_serial_bus.max_read_error = old_status_max_read_error;
|
||||||
@ -1367,6 +1374,8 @@ unsigned int project_wait_load_all_cds(int flag_reset)
|
|||||||
{
|
{
|
||||||
counterOk++;
|
counterOk++;
|
||||||
project.cds_out[i].status = component_Started;
|
project.cds_out[i].status = component_Started;
|
||||||
|
count_one_find_plat++;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
project.cds_out[i].status_serial_bus.max_read_error = old_status_max_read_error;
|
project.cds_out[i].status_serial_bus.max_read_error = old_status_max_read_error;
|
||||||
@ -1397,6 +1406,8 @@ unsigned int project_wait_load_all_cds(int flag_reset)
|
|||||||
{
|
{
|
||||||
counterOk++;
|
counterOk++;
|
||||||
project.cds_rs[i].status = component_Started;
|
project.cds_rs[i].status = component_Started;
|
||||||
|
count_one_find_plat++;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
project.cds_rs[i].status_serial_bus.max_read_error = old_status_max_read_error;
|
project.cds_rs[i].status_serial_bus.max_read_error = old_status_max_read_error;
|
||||||
@ -1427,6 +1438,8 @@ unsigned int project_wait_load_all_cds(int flag_reset)
|
|||||||
{
|
{
|
||||||
counterOk++;
|
counterOk++;
|
||||||
project.hwp[i].status = component_Started;
|
project.hwp[i].status = component_Started;
|
||||||
|
count_one_find_plat++;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
project.hwp[i].status_hwp_bus.max_read_error = old_status_max_read_error;
|
project.hwp[i].status_hwp_bus.max_read_error = old_status_max_read_error;
|
||||||
@ -1435,8 +1448,16 @@ unsigned int project_wait_load_all_cds(int flag_reset)
|
|||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
///////////////////////////////////////
|
///////////////////////////////////////
|
||||||
|
if (count_one_find_plat && prev_count_one_find_plat==0)
|
||||||
|
{
|
||||||
|
// ÷åòî íàøëè â ïåðâûé ðàç?
|
||||||
|
counterErr = 0;// ñáðîñèëè ñ÷åò÷èê, æäåì ïî íîâîé îñòàâøèåñÿ
|
||||||
|
max_count_err_read_sbus = MAX_COUNT_ERR_READ_SBUS_2;
|
||||||
|
}
|
||||||
|
prev_count_one_find_plat = count_one_find_plat;
|
||||||
|
|
||||||
// test error - timeout?
|
// test error - timeout?
|
||||||
if (counterErr >= MAX_COUNT_ERR_READ_SBUS)
|
if (counterErr >= max_count_err_read_sbus)
|
||||||
{
|
{
|
||||||
if (flag_reset == 0)
|
if (flag_reset == 0)
|
||||||
xerror(xserial_bus_er_ID(2), (void *)0);
|
xerror(xserial_bus_er_ID(2), (void *)0);
|
||||||
|
@ -1,267 +0,0 @@
|
|||||||
#include "xp_project.h"
|
|
||||||
#include "xp_rotation_sensor.h"
|
|
||||||
|
|
||||||
#include "xp_project.h"
|
|
||||||
|
|
||||||
|
|
||||||
T_rotation_sensor rotation_sensor = T_CDS_ROTATION_SENSOR_DEFAULTS;
|
|
||||||
|
|
||||||
//Äèñêðåòèçàöèþ, ïðè êîòîðîé ðàñ÷èòûâàåòñþ äëèòåëüíîñòü èìïóëüñîâ
|
|
||||||
#define SAMPLING_TIME_NS 1 // 16,666667ns
|
|
||||||
#define SAMPLING_TIME_MS 0 // 1,666667us
|
|
||||||
// Êîëè÷åñòâî èìïóëüñîâ, ïðè êîòîðûõ ïåðåêëþ÷àåòñó ïåðèîä äèñêðåòèçàöèè.
|
|
||||||
// Âåëè÷èíû âûáðàíû ñ "íàõë¸ñòîì" ÷òî áû íå áûëî ïîñòîþííûõ ïåðåêëþ÷åíèé
|
|
||||||
// â ðàéîíå ãðàíè÷íûõ âåëè÷èí
|
|
||||||
#define LEVEL_SWITCH_NANOSEC 327
|
|
||||||
#define LEVEL_SWITCH_MICROSEC 0xC000
|
|
||||||
|
|
||||||
|
|
||||||
static void read_in_sensor_line1(T_cds_in_rotation_sensor *rs);
|
|
||||||
static void read_in_sensor_line2(T_cds_in_rotation_sensor *rs);
|
|
||||||
static void read_command_reg(T_cds_in_rotation_sensor *rs);
|
|
||||||
static void write_command_reg(T_cds_in_rotation_sensor *rs);
|
|
||||||
static void tune_sampling_time(T_rotation_sensor *rs);
|
|
||||||
static void wait_for_registers_updated(T_cds_in_rotation_sensor *rs);
|
|
||||||
static void read_direction_in_plane(T_cds_in_rotation_sensor *rs);
|
|
||||||
|
|
||||||
void rot_sensor_set(T_rotation_sensor *rs)
|
|
||||||
{
|
|
||||||
|
|
||||||
if(rs->use_sensor1 || rs->use_sensor2)
|
|
||||||
{
|
|
||||||
rs->in_plane.set(&rs->in_plane);
|
|
||||||
}
|
|
||||||
if(rs->use_angle_plane)
|
|
||||||
{
|
|
||||||
rs->rotation_plane.set(&rs->rotation_plane);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void in_plane_set(T_cds_in_rotation_sensor* rs)
|
|
||||||
{
|
|
||||||
if(!rs->cds_in->useit)
|
|
||||||
{
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
rs->cds_in->write.sbus.enabled_channels.all = rs->write.sbus.enabled_channels.all;
|
|
||||||
rs->cds_in->write.sbus.first_sensor.all = rs->write.sbus.first_sensor_inputs.all;
|
|
||||||
rs->cds_in->write.sbus.second_sensor.all = rs->write.sbus.second_sensor_inputs.all;
|
|
||||||
// rs->cds_in->write_sbus(rs->cds_in);
|
|
||||||
write_command_reg(rs);
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
void angle_plane_set(T_cds_angle_sensor *rs)
|
|
||||||
{
|
|
||||||
if((rs->cds_rs == NULL) || (!rs->cds_rs->useit))
|
|
||||||
{
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
rs->cds_rs->write.sbus.config.all = rs->write.sbus.config.all;
|
|
||||||
rs->cds_rs->write_sbus(rs->cds_rs);
|
|
||||||
}
|
|
||||||
|
|
||||||
void sensor_read(T_rotation_sensor *rs)
|
|
||||||
{
|
|
||||||
if(rs->use_sensor1 || rs->use_sensor2 || rs->use_angle_plane)
|
|
||||||
{
|
|
||||||
wait_for_registers_updated(&rs->in_plane);
|
|
||||||
read_direction_in_plane(&rs->in_plane);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
if(rs->use_sensor1)
|
|
||||||
{
|
|
||||||
rs->in_plane.read_sensor1(&rs->in_plane);
|
|
||||||
}
|
|
||||||
if(rs->use_sensor2)
|
|
||||||
{
|
|
||||||
rs->in_plane.read_sensor2(&rs->in_plane);
|
|
||||||
}
|
|
||||||
if(rs->use_angle_plane)
|
|
||||||
{
|
|
||||||
rs->rotation_plane.read_sensor(&rs->rotation_plane);
|
|
||||||
}
|
|
||||||
#ifdef AUTO_CHANGE_SAMPLING_TIME
|
|
||||||
tune_sampling_time(rs);
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
|
|
||||||
void in_sensor_read1(T_cds_in_rotation_sensor *rs)
|
|
||||||
{
|
|
||||||
read_in_sensor_line1(rs);
|
|
||||||
#if C_PROJECT_TYPE != PROJECT_BALZAM
|
|
||||||
rs->out.Impulses1 = rs->read.regs.n_impulses_line1;
|
|
||||||
rs->out.Time1 = rs->read.regs.time_line1 / 60;
|
|
||||||
//Counter`s freq is 60ÌÃö => N/60 = time in mksec
|
|
||||||
#endif
|
|
||||||
rs->out.CountZero1 = rs->read.regs.zero_time_line1;
|
|
||||||
rs->out.CountOne1 = rs->read.regs.one_time_line1;
|
|
||||||
|
|
||||||
rs->out.counter_freq1 = rs->read.regs.comand_reg.bit.sampling_time1;
|
|
||||||
|
|
||||||
rs->out.direction1 = rs->read.pbus.direction.bit.sensor1;
|
|
||||||
}
|
|
||||||
|
|
||||||
void in_sensor_read2(T_cds_in_rotation_sensor *rs)
|
|
||||||
{
|
|
||||||
read_in_sensor_line2(rs);
|
|
||||||
#if C_PROJECT_TYPE != PROJECT_BALZAM
|
|
||||||
rs->out.Impulses2 = rs->read.regs.n_impulses_line2;
|
|
||||||
rs->out.Time2 = rs->read.regs.time_line2 / 60;
|
|
||||||
#endif
|
|
||||||
rs->out.CountZero2 = rs->read.regs.zero_time_line2;
|
|
||||||
rs->out.CountOne2 = rs->read.regs.one_time_line2;
|
|
||||||
|
|
||||||
rs->out.counter_freq2 = rs->read.regs.comand_reg.bit.sampling_time2;
|
|
||||||
|
|
||||||
rs->out.direction2 = rs->read.pbus.direction.bit.sensor2;
|
|
||||||
}
|
|
||||||
|
|
||||||
void read_in_sensor_line1(T_cds_in_rotation_sensor *rs)
|
|
||||||
{
|
|
||||||
if(!rs->read.regs.comand_reg.bit.update_registers)
|
|
||||||
{
|
|
||||||
#if C_PROJECT_TYPE != PROJECT_BALZAM
|
|
||||||
rs->read.regs.time_line1 = i_ReadMemory(ADR_SENSOR_S1_T_PERIOD);//TODO check time when turn off
|
|
||||||
rs->read.regs.n_impulses_line1 = i_ReadMemory(ADR_SENSOR_S1_COUNT_IMPULS);
|
|
||||||
#endif
|
|
||||||
rs->read.regs.zero_time_line1 = i_ReadMemory(ADR_SENSOR_S1_T_PERIOD_LOW_ONE_IMPULS);
|
|
||||||
rs->read.regs.one_time_line1 = i_ReadMemory(ADR_SENSOR_S1_T_PERIOD_HIGH_ONE_IMPULS);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void read_in_sensor_line2(T_cds_in_rotation_sensor *rs)
|
|
||||||
{
|
|
||||||
if(!rs->read.regs.comand_reg.bit.update_registers)
|
|
||||||
{
|
|
||||||
#if C_PROJECT_TYPE != PROJECT_BALZAM
|
|
||||||
rs->read.regs.time_line2 = i_ReadMemory(ADR_SENSOR_S2_T_PERIOD);
|
|
||||||
rs->read.regs.n_impulses_line2 = i_ReadMemory(ADR_SENSOR_S2_COUNT_IMPULS);
|
|
||||||
#endif
|
|
||||||
rs->read.regs.zero_time_line2 = i_ReadMemory(ADR_SENSOR_S2_T_PERIOD_LOW_ONE_IMPULS);
|
|
||||||
rs->read.regs.one_time_line2 = i_ReadMemory(ADR_SENSOR_S2_T_PERIOD_HIGH_ONE_IMPULS);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void write_command_reg(T_cds_in_rotation_sensor *rs)
|
|
||||||
{
|
|
||||||
WriteMemory(ADR_SENSOR_CMD, rs->write.regs.comand_reg.all);
|
|
||||||
}
|
|
||||||
|
|
||||||
void read_command_reg(T_cds_in_rotation_sensor *rs)
|
|
||||||
{
|
|
||||||
rs->read.regs.comand_reg.all = i_ReadMemory(ADR_SENSOR_CMD);
|
|
||||||
}
|
|
||||||
|
|
||||||
void update_sensors_data_r(T_rotation_sensor *rs)
|
|
||||||
{
|
|
||||||
rs->in_plane.write.regs.comand_reg.bit.update_registers = 1;
|
|
||||||
write_command_reg(&rs->in_plane);
|
|
||||||
// rs->in_plane.write.regs.comand_reg.bit.update_registers = 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
void read_direction_in_plane(T_cds_in_rotation_sensor *rs)
|
|
||||||
{
|
|
||||||
/*
|
|
||||||
rs->read.pbus.direction.bit.sensor1 = rs->cds_in->read.pbus.direction_in.bit.dir0 == 2 ? 1 :
|
|
||||||
rs->cds_in->read.pbus.direction_in.bit.dir0 == 1 ? -1 :
|
|
||||||
0;
|
|
||||||
rs->read.pbus.direction.bit.sensor2 = rs->cds_in->read.pbus.direction_in.bit.dir1 == 2 ? 1 :
|
|
||||||
rs->cds_in->read.pbus.direction_in.bit.dir1 == 1 ? -1 :
|
|
||||||
0;
|
|
||||||
rs->read.pbus.direction.bit.sens_err1 = rs->cds_in->read.pbus.direction_in.bit.dir0 == 3;
|
|
||||||
rs->read.pbus.direction.bit.sens_err2 = rs->cds_in->read.pbus.direction_in.bit.dir1 == 3;
|
|
||||||
*/
|
|
||||||
//Direction changes not often. May be, it`s enough to read it in main cycle.
|
|
||||||
}
|
|
||||||
|
|
||||||
void wait_for_registers_updated(T_cds_in_rotation_sensor *rs)
|
|
||||||
{
|
|
||||||
int counter_in_while = 0;
|
|
||||||
read_command_reg(rs);
|
|
||||||
while(rs->read.regs.comand_reg.bit.update_registers)
|
|
||||||
{
|
|
||||||
read_command_reg(rs);
|
|
||||||
rs->count_wait_for_update_registers++;
|
|
||||||
counter_in_while++;
|
|
||||||
if(counter_in_while > 1000)
|
|
||||||
{
|
|
||||||
rs->error_update++;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void tune_sampling_time(T_rotation_sensor *rs)
|
|
||||||
{
|
|
||||||
if((rs->use_sensor1 && (rs->in_plane.read.regs.zero_time_line1 < LEVEL_SWITCH_NANOSEC))
|
|
||||||
|| (rs->use_sensor2 && (rs->in_plane.read.regs.zero_time_line2 < LEVEL_SWITCH_NANOSEC)))
|
|
||||||
{
|
|
||||||
rs->in_plane.write.regs.comand_reg.bit.set_sampling_time = SAMPLING_TIME_NS;
|
|
||||||
}
|
|
||||||
|
|
||||||
if((rs->use_sensor1 && (rs->in_plane.read.regs.zero_time_line1 > LEVEL_SWITCH_MICROSEC))
|
|
||||||
|| (rs->use_sensor2 && (rs->in_plane.read.regs.zero_time_line2 > LEVEL_SWITCH_MICROSEC)))
|
|
||||||
{
|
|
||||||
rs->in_plane.write.regs.comand_reg.bit.set_sampling_time = SAMPLING_TIME_MS;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void angle_sensor_read(T_cds_angle_sensor *as)
|
|
||||||
{
|
|
||||||
as->cds_rs->read_pbus(as->cds_rs);
|
|
||||||
|
|
||||||
if(as->cds_rs->read.sbus.config.bit.channel1_enable)
|
|
||||||
{
|
|
||||||
// logpar.log15 = as->cds_rs->read.pbus.sensor[0].turned_angle;
|
|
||||||
// logpar.log16 = as->cds_rs->read.pbus.sensor[0].angle;
|
|
||||||
|
|
||||||
as->out.Delta_angle1 = as->cds_rs->read.pbus.sensor[0].turned_angle;
|
|
||||||
as->out.Current_angle1 = as->cds_rs->read.pbus.sensor[0].angle << 3;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
as->out.Delta_angle1 = 0;
|
|
||||||
as->out.Current_angle1 = 0;
|
|
||||||
}
|
|
||||||
if(as->cds_rs->read.sbus.config.bit.channel2_enable)
|
|
||||||
{
|
|
||||||
as->out.Delta_angle2 = as->cds_rs->read.pbus.sensor[1].turned_angle;
|
|
||||||
as->out.Current_angle2 = as->cds_rs->read.pbus.sensor[1].angle << 3;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
as->out.Delta_angle2 = 0;
|
|
||||||
as->out.Current_angle2 = 0;
|
|
||||||
}
|
|
||||||
if(as->cds_rs->read.sbus.config.bit.channel3_enable)
|
|
||||||
{
|
|
||||||
as->out.Delta_angle3 = as->cds_rs->read.pbus.sensor[2].turned_angle;
|
|
||||||
as->out.Current_angle3 = as->cds_rs->read.pbus.sensor[2].angle << 3;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
as->out.Delta_angle3 = 0;
|
|
||||||
as->out.Current_angle3 = 0;
|
|
||||||
}
|
|
||||||
if(as->cds_rs->read.sbus.config.bit.channel4_enable)
|
|
||||||
{
|
|
||||||
as->out.Delta_angle4 = as->cds_rs->read.pbus.sensor[3].turned_angle;
|
|
||||||
as->out.Current_angle4 = as->cds_rs->read.pbus.sensor[3].angle << 3;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
as->out.Delta_angle4 = 0;
|
|
||||||
as->out.Current_angle4 = 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
as->out.survey_time_mks = (as->read.sbus.config.bit.survey_time + 1) * 10;
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
@ -1,346 +0,0 @@
|
|||||||
#ifndef XP_ROT_SENS_H
|
|
||||||
#define XP_ROT_SENS_H
|
|
||||||
|
|
||||||
#include "x_basic_types.h"
|
|
||||||
#include "xp_cds_in.h"
|
|
||||||
#include "xp_cds_rs.h"
|
|
||||||
|
|
||||||
|
|
||||||
//RS speed of angle sensor
|
|
||||||
#define TS400 0
|
|
||||||
#define TS350 1
|
|
||||||
#define TS300 2
|
|
||||||
#define TS250 3
|
|
||||||
#define TS200 4
|
|
||||||
|
|
||||||
//Äèñêðåòèçàöèþ, ïðè êîòîðîé ðàñ÷èòûâàåòñþ äëèòåëüíîñòü èìïóëüñîâ
|
|
||||||
#define SAMPLING_TIME_NS 1 // 16,666667ns
|
|
||||||
#define SAMPLING_TIME_MS 0 // 1,666667us
|
|
||||||
|
|
||||||
//Àâòîìàòè÷åñêè ïåðåêëþ÷àåò ñ÷¸ò÷èê, êîãäà êîëè÷åñòâî îòñ÷¸òîâ
|
|
||||||
// íà 1 èìïóëüñ ñòàíîâèòñß ñëèøêîì áîëüøèì èëè ìàëåíüêèì.
|
|
||||||
//#define AUTO_CHANGE_SAMPLING_TIME
|
|
||||||
/*
|
|
||||||
×òî áû ïðî÷èòàòü äàííûå èç äàò÷èêà, íóæíî âûçâàòü
|
|
||||||
rotation_sensor.read_sensors(&rotation_sensor);
|
|
||||||
Ðåçóëüòàò ïëàòû IN áóäåò â
|
|
||||||
rotation_sensor.in_plane.out....
|
|
||||||
Ðåçóëüòàò ïëàòû RS áóäåò â
|
|
||||||
rotation_sensor.rotation_plane.out....
|
|
||||||
*/
|
|
||||||
|
|
||||||
/////////////////////////////////////////////////////////////
|
|
||||||
// IN plane
|
|
||||||
/////////////////////////////////////////////////////////////
|
|
||||||
|
|
||||||
// Registers with data for rotation sensor
|
|
||||||
|
|
||||||
typedef union {
|
|
||||||
unsigned int all;
|
|
||||||
struct {
|
|
||||||
unsigned int filter_sensitivity:12;
|
|
||||||
unsigned int set_sampling_time:1; //(1)-16,666667ns (0)-1,666667us
|
|
||||||
unsigned int sampling_time2:1; //(1)-16,666667ns (0)-1,666667us
|
|
||||||
unsigned int sampling_time1:1;
|
|
||||||
unsigned int update_registers:1; //0 - updated
|
|
||||||
}bit;
|
|
||||||
}T_cds_in_comand;
|
|
||||||
|
|
||||||
#define R_CDS_IN_COMAND_DEFAULT 0
|
|
||||||
|
|
||||||
typedef struct {
|
|
||||||
unsigned int time_line1;
|
|
||||||
unsigned int n_impulses_line1;
|
|
||||||
unsigned int time_line2;
|
|
||||||
unsigned int n_impulses_line2;
|
|
||||||
|
|
||||||
unsigned int zero_time_line1;
|
|
||||||
unsigned int one_time_line1;
|
|
||||||
unsigned int zero_time_line2;
|
|
||||||
unsigned int one_time_line2;
|
|
||||||
|
|
||||||
T_cds_in_comand comand_reg;
|
|
||||||
|
|
||||||
} T_cds_in_rotation_sensor_read_regs;
|
|
||||||
|
|
||||||
#define T_CDS_IN_ROTATION_SENSOR_READ_REGS_DEFAULTS {0,0,0,0, 0,0,0,0, R_CDS_IN_COMAND_DEFAULT}
|
|
||||||
|
|
||||||
typedef struct {
|
|
||||||
T_cds_in_comand comand_reg;
|
|
||||||
|
|
||||||
} T_cds_in_rotation_sensor_write_regs;
|
|
||||||
|
|
||||||
#define T_CDS_IN_ROTATION_SENSOR_WRITE_REGS_DEFAULTS {R_CDS_IN_COMAND_DEFAULT}
|
|
||||||
|
|
||||||
/////////////////////////////////////////////////////////////
|
|
||||||
//read reg parallel bus
|
|
||||||
/////////////////////////////////////////////////////////////
|
|
||||||
typedef struct {
|
|
||||||
union {
|
|
||||||
unsigned int all;
|
|
||||||
struct {
|
|
||||||
int sensor1:4;
|
|
||||||
int sensor2:4;
|
|
||||||
unsigned int sens_err1:1;
|
|
||||||
unsigned int sens_err2:1;
|
|
||||||
unsigned int reserved:6;
|
|
||||||
} bit;
|
|
||||||
} direction;
|
|
||||||
|
|
||||||
} T_cds_in_rotation_sensor_read_pbus;
|
|
||||||
|
|
||||||
#define T_CDS_IN_ROTATION_SENSOR_READ_PBUS_DEFAULTS {0}
|
|
||||||
|
|
||||||
/////////////////////////////////////////////////////////////
|
|
||||||
// write serial bus reg
|
|
||||||
/////////////////////////////////////////////////////////////
|
|
||||||
typedef struct {
|
|
||||||
//0
|
|
||||||
union
|
|
||||||
{
|
|
||||||
UInt16 all;
|
|
||||||
struct{
|
|
||||||
UInt16 discret : 8;
|
|
||||||
UInt16 reserv : 7;
|
|
||||||
UInt16 sens_2_inv_ch_90deg : 1;
|
|
||||||
UInt16 sens_2_direct_ch_90deg : 1;
|
|
||||||
UInt16 sens_2_inv_ch : 1;
|
|
||||||
UInt16 sens_2_direct_ch : 1;
|
|
||||||
UInt16 sens_1_inv_ch_90deg : 1;
|
|
||||||
UInt16 sens_1_direct_ch_90deg : 1;
|
|
||||||
UInt16 sens_1_inv_ch : 1;
|
|
||||||
UInt16 sens_1_direct_ch : 1;
|
|
||||||
}bit;
|
|
||||||
}enabled_channels;
|
|
||||||
|
|
||||||
//1
|
|
||||||
union
|
|
||||||
{
|
|
||||||
UInt16 all;
|
|
||||||
struct{
|
|
||||||
UInt16 inv_ch_90deg : 4;
|
|
||||||
UInt16 direct_ch_90deg : 4;
|
|
||||||
UInt16 inv_ch : 4;
|
|
||||||
UInt16 direct_ch : 4;
|
|
||||||
}bit;
|
|
||||||
}first_sensor_inputs;
|
|
||||||
|
|
||||||
//2
|
|
||||||
union
|
|
||||||
{
|
|
||||||
UInt16 all;
|
|
||||||
struct{
|
|
||||||
UInt16 inv_ch_90deg : 4;
|
|
||||||
UInt16 direct_ch_90deg : 4;
|
|
||||||
UInt16 inv_ch : 4;
|
|
||||||
UInt16 direct_ch : 4;
|
|
||||||
}bit;
|
|
||||||
}second_sensor_inputs;
|
|
||||||
|
|
||||||
} T_cds_in_rotation_sensor_write_sbus;
|
|
||||||
|
|
||||||
#define T_CDS_IN_ROTATION_SENSOR_WRITE_SBUS_DEFAULTS {0, 0, 0}
|
|
||||||
|
|
||||||
////////////////////////////////////////////////////////
|
|
||||||
typedef struct {
|
|
||||||
T_cds_in_rotation_sensor_read_pbus pbus;
|
|
||||||
T_cds_in_rotation_sensor_read_regs regs;
|
|
||||||
}T_cds_in_rotation_sensor_read;
|
|
||||||
|
|
||||||
#define T_CDS_IN_ROTATION_SENSOR_READ_DEFAULTS \
|
|
||||||
{T_CDS_IN_ROTATION_SENSOR_READ_PBUS_DEFAULTS, \
|
|
||||||
T_CDS_IN_ROTATION_SENSOR_READ_REGS_DEFAULTS}
|
|
||||||
|
|
||||||
typedef struct {
|
|
||||||
T_cds_in_rotation_sensor_write_sbus sbus;
|
|
||||||
T_cds_in_rotation_sensor_read_regs regs;
|
|
||||||
}T_cds_in_rotation_sensor_write;
|
|
||||||
|
|
||||||
#define T_CDS_IN_ROTATION_SENSOR_WRITE_DEFAULTS \
|
|
||||||
{T_CDS_IN_ROTATION_SENSOR_WRITE_SBUS_DEFAULTS, \
|
|
||||||
T_CDS_IN_ROTATION_SENSOR_WRITE_REGS_DEFAULTS}
|
|
||||||
|
|
||||||
|
|
||||||
////// Rotation sensor with IN plane
|
|
||||||
typedef struct {
|
|
||||||
//UInt16 plane_address;
|
|
||||||
unsigned int count_wait_for_update_registers;
|
|
||||||
unsigned int error_update;
|
|
||||||
|
|
||||||
struct {
|
|
||||||
|
|
||||||
unsigned int Time1; // Sensor's survey time in mksec
|
|
||||||
unsigned int Impulses1; // Quantity of full impulses during survey time
|
|
||||||
unsigned int CountZero1; // Value of the zero-half-period counter
|
|
||||||
unsigned int CountOne1; // Value of the one-half-period counter
|
|
||||||
unsigned int counter_freq1; // 1 - 60MHz; 0 - 600KHz
|
|
||||||
int direction1; // 1 - direct; 0 - reverse
|
|
||||||
|
|
||||||
unsigned int Time2; // Sensor's survey time in mksec
|
|
||||||
unsigned int Impulses2; // Quantity of full impulses during survey time
|
|
||||||
unsigned int CountZero2; // Value of the zero-half-period counter
|
|
||||||
unsigned int CountOne2; // Value of the one-half-period counter
|
|
||||||
unsigned int counter_freq2; // 1 - 60MHz; 0 - 600KHz
|
|
||||||
int direction2; // 1 - direct; 0 - reverse
|
|
||||||
} out;
|
|
||||||
|
|
||||||
T_cds_in *cds_in;
|
|
||||||
|
|
||||||
T_cds_in_rotation_sensor_write write;
|
|
||||||
T_cds_in_rotation_sensor_read read;
|
|
||||||
|
|
||||||
void (*set)(); // Pointer to calculation function
|
|
||||||
|
|
||||||
void (*read_sensor1)();
|
|
||||||
|
|
||||||
void (*read_sensor2)();
|
|
||||||
|
|
||||||
} T_cds_in_rotation_sensor;
|
|
||||||
|
|
||||||
#define T_CDS_IN_ROTATION_SENSOR_DEFAULT \
|
|
||||||
{0, 0, \
|
|
||||||
{0, 0, 0, 0, 0, 0, 0, 0, 0, 0}, \
|
|
||||||
NULL, \
|
|
||||||
T_CDS_IN_ROTATION_SENSOR_WRITE_DEFAULTS, \
|
|
||||||
T_CDS_IN_ROTATION_SENSOR_READ_DEFAULTS, \
|
|
||||||
in_plane_set, \
|
|
||||||
in_sensor_read1, \
|
|
||||||
in_sensor_read2}
|
|
||||||
|
|
||||||
|
|
||||||
///////////////////////////////////////////////////////////////////////////
|
|
||||||
///// Rotation Plane
|
|
||||||
///////////////////////////////////////////////////////////////////////////
|
|
||||||
typedef union {
|
|
||||||
unsigned int all;
|
|
||||||
struct {
|
|
||||||
unsigned int survey_time:8; //Ïåðèîä îïðîñà ïî 10ìêñ (0==10, 1==20,...)
|
|
||||||
unsigned int channel4_enable:1;
|
|
||||||
unsigned int channel3_enable:1;
|
|
||||||
unsigned int channel2_enable:1;
|
|
||||||
unsigned int channel1_enable:1;
|
|
||||||
unsigned int transmition_speed:3;
|
|
||||||
unsigned int plane_is_master:1;
|
|
||||||
}bit;
|
|
||||||
} T_cds_rotation_plane_config;
|
|
||||||
|
|
||||||
#define T_CDS_ROTATION_PLANE_CONFIG_DEFAULT 0xA031 //{49, 1, 0, 0, 0, 2, 1}
|
|
||||||
|
|
||||||
typedef struct {
|
|
||||||
T_cds_rotation_plane_config config;
|
|
||||||
} T_cds_rotation_plane_write_sbus;
|
|
||||||
|
|
||||||
#define T_CDS_ROTATION_PLANE_WRITE_SBUS_DEFAULT \
|
|
||||||
{T_CDS_ROTATION_PLANE_CONFIG_DEFAULT}
|
|
||||||
|
|
||||||
typedef struct {
|
|
||||||
int direction;
|
|
||||||
unsigned int turned_angle;
|
|
||||||
unsigned int angle;
|
|
||||||
} RsSensor;
|
|
||||||
|
|
||||||
#define SENSOR_DEFAULT {0, 0, 0}
|
|
||||||
|
|
||||||
typedef struct {
|
|
||||||
RsSensor sensor[4];
|
|
||||||
} T_cds_rotation_plane_read_pbus;
|
|
||||||
|
|
||||||
#define T_CDS_ROTATION_PLANE_READ_PBUS_DEFAULT { \
|
|
||||||
{SENSOR_DEFAULT, SENSOR_DEFAULT, SENSOR_DEFAULT, SENSOR_DEFAULT}}
|
|
||||||
|
|
||||||
typedef struct {
|
|
||||||
T_cds_rotation_plane_config config;
|
|
||||||
} T_cds_rotation_plane_read_sbus;
|
|
||||||
|
|
||||||
#define T_CDS_ROTATION_PLANE_READ_SBUS_DEFAULT {T_CDS_ROTATION_PLANE_CONFIG_DEFAULT}
|
|
||||||
|
|
||||||
typedef struct {
|
|
||||||
T_cds_rotation_plane_write_sbus sbus;
|
|
||||||
} T_cds_rotation_plane_write;
|
|
||||||
|
|
||||||
#define T_CDS_ROTATION_PLANE_WRITE_DEFAULT \
|
|
||||||
{T_CDS_ROTATION_PLANE_WRITE_SBUS_DEFAULT}
|
|
||||||
|
|
||||||
typedef struct {
|
|
||||||
T_cds_rotation_plane_read_pbus pbus;
|
|
||||||
T_cds_rotation_plane_read_sbus sbus;
|
|
||||||
} T_cds_rotation_plane_read;
|
|
||||||
|
|
||||||
#define T_CDS_ROTATION_PLANE_READ_DEFAULT \
|
|
||||||
{T_CDS_ROTATION_PLANE_READ_PBUS_DEFAULT, T_CDS_ROTATION_PLANE_READ_SBUS_DEFAULT}
|
|
||||||
|
|
||||||
typedef struct {
|
|
||||||
|
|
||||||
struct {
|
|
||||||
unsigned long Delta_angle1;
|
|
||||||
unsigned long Delta_angle2;
|
|
||||||
unsigned long Delta_angle3;
|
|
||||||
unsigned long Delta_angle4;
|
|
||||||
unsigned long Current_angle1;
|
|
||||||
unsigned long Current_angle2;
|
|
||||||
unsigned long Current_angle3;
|
|
||||||
unsigned long Current_angle4;
|
|
||||||
unsigned int survey_time_mks; //Âðåìß îïðîñà äàò÷èêà â ìêñ
|
|
||||||
unsigned int direction;
|
|
||||||
} out;
|
|
||||||
|
|
||||||
unsigned int error;
|
|
||||||
|
|
||||||
T_cds_rs *cds_rs;
|
|
||||||
|
|
||||||
T_cds_rotation_plane_read read;
|
|
||||||
T_cds_rotation_plane_write write;
|
|
||||||
|
|
||||||
void (*set)(); // Pointer to calculation function
|
|
||||||
|
|
||||||
void (*read_sensor)();
|
|
||||||
|
|
||||||
} T_cds_angle_sensor;
|
|
||||||
|
|
||||||
#define T_CDS_ANGLE_SENSOR_DEFAULT { \
|
|
||||||
{0, 0, 0, 0, 0, 0, 0, 0, 0, 0}, \
|
|
||||||
0, NULL, \
|
|
||||||
T_CDS_ROTATION_PLANE_READ_DEFAULT, \
|
|
||||||
T_CDS_ROTATION_PLANE_WRITE_DEFAULT, \
|
|
||||||
angle_plane_set, angle_sensor_read}
|
|
||||||
|
|
||||||
|
|
||||||
//////////////////////////////////////////////////////////////////////////////////
|
|
||||||
////
|
|
||||||
//////////////////////////////////////////////////////////////////////////////////
|
|
||||||
|
|
||||||
typedef struct {
|
|
||||||
UInt16 use_sensor1;
|
|
||||||
UInt16 use_sensor2;
|
|
||||||
UInt16 use_angle_plane;
|
|
||||||
|
|
||||||
T_cds_in_rotation_sensor in_plane;
|
|
||||||
T_cds_angle_sensor rotation_plane;
|
|
||||||
|
|
||||||
void (*set)(); // Pointer to calculation function
|
|
||||||
void (*read_sensors)();
|
|
||||||
void (*update_registers)();
|
|
||||||
|
|
||||||
} T_rotation_sensor;
|
|
||||||
|
|
||||||
#define T_CDS_ROTATION_SENSOR_DEFAULTS {0, 0, 0, \
|
|
||||||
T_CDS_IN_ROTATION_SENSOR_DEFAULT, \
|
|
||||||
T_CDS_ANGLE_SENSOR_DEFAULT, \
|
|
||||||
rot_sensor_set, \
|
|
||||||
sensor_read, \
|
|
||||||
update_sensors_data_r}
|
|
||||||
|
|
||||||
//Public functions
|
|
||||||
void rot_sensor_set(T_rotation_sensor *rs);
|
|
||||||
void sensor_read(T_rotation_sensor *rs);
|
|
||||||
void update_sensors_data_r(T_rotation_sensor *rs);
|
|
||||||
void angle_plane_set(T_cds_angle_sensor *rs);
|
|
||||||
void angle_sensor_read(T_cds_angle_sensor *as);
|
|
||||||
void in_plane_set(T_cds_in_rotation_sensor* rs);
|
|
||||||
void in_sensor_read1(T_cds_in_rotation_sensor *rs);
|
|
||||||
void in_sensor_read2(T_cds_in_rotation_sensor *rs);
|
|
||||||
|
|
||||||
|
|
||||||
extern T_rotation_sensor rotation_sensor;
|
|
||||||
|
|
||||||
#endif //XP_ROT_SENS_H
|
|
@ -123,6 +123,7 @@ typedef struct
|
|||||||
unsigned int Tclosed_high;
|
unsigned int Tclosed_high;
|
||||||
// unsigned int Tclosed_1;
|
// unsigned int Tclosed_1;
|
||||||
unsigned int pwm_tics;
|
unsigned int pwm_tics;
|
||||||
|
unsigned int half_pwm_tics;
|
||||||
unsigned int inited;
|
unsigned int inited;
|
||||||
unsigned int freq_pwm;
|
unsigned int freq_pwm;
|
||||||
unsigned int Tclosed_saw_direct_0;
|
unsigned int Tclosed_saw_direct_0;
|
||||||
@ -131,13 +132,16 @@ typedef struct
|
|||||||
unsigned int where_interrupt;
|
unsigned int where_interrupt;
|
||||||
unsigned int mode_reload;
|
unsigned int mode_reload;
|
||||||
unsigned int one_or_two_interrupts_run;
|
unsigned int one_or_two_interrupts_run;
|
||||||
|
unsigned int what_next_interrupt;
|
||||||
|
unsigned int do_sync_out;
|
||||||
|
unsigned int disable_sync_out;
|
||||||
WORD_UINT2BITS_STRUCT saw_direct;
|
WORD_UINT2BITS_STRUCT saw_direct;
|
||||||
void (*write_1_2_winding_break_times)();
|
void (*write_1_2_winding_break_times)();
|
||||||
void (*write_zero_winding_break_times)();
|
void (*write_zero_winding_break_times)();
|
||||||
void (*init)();
|
void (*init)();
|
||||||
} XPWM_TIME;
|
} XPWM_TIME;
|
||||||
|
|
||||||
#define DEFAULT_XPWM_TIME {0,0,0,0,0,0, 0,0,0,0,0,0, 0,0,0,0, 0,0,0, 0, 0, 0, 0, 0,0,0, {0}, \
|
#define DEFAULT_XPWM_TIME {0,0,0,0,0,0, 0,0,0,0,0,0,0, 0,0,0,0,0, 0,0,0, 0, 0, 0, 0, 0,0,0, 0,0, {0}, \
|
||||||
xpwm_write_1_2_winding_break_times_16_lines, \
|
xpwm_write_1_2_winding_break_times_16_lines, \
|
||||||
xpwm_write_zero_winding_break_times_16_lines, \
|
xpwm_write_zero_winding_break_times_16_lines, \
|
||||||
initXpwmTimeStructure \
|
initXpwmTimeStructure \
|
||||||
|
@ -43,6 +43,7 @@
|
|||||||
#include <f281xbmsk.h>
|
#include <f281xbmsk.h>
|
||||||
|
|
||||||
#include "TuneUpPlane.h"
|
#include "TuneUpPlane.h"
|
||||||
|
#include "profile_interrupt.h"
|
||||||
|
|
||||||
// Prototype statements for functions found within this file.
|
// Prototype statements for functions found within this file.
|
||||||
interrupt void eva_timer1_isr(void);
|
interrupt void eva_timer1_isr(void);
|
||||||
@ -57,15 +58,15 @@ Uint32 EvaTimer2InterruptCount = 0;
|
|||||||
Uint32 EvbTimer3InterruptCount = 0;
|
Uint32 EvbTimer3InterruptCount = 0;
|
||||||
Uint32 EvbTimer4InterruptCount = 0;
|
Uint32 EvbTimer4InterruptCount = 0;
|
||||||
|
|
||||||
unsigned int enable_profile_led1_Timer1 = 1;
|
//unsigned int enable_profile_led1_Timer1 = 1;
|
||||||
unsigned int enable_profile_led1_Timer2 = 1;
|
//unsigned int enable_profile_led1_Timer2 = 1;
|
||||||
unsigned int enable_profile_led1_Timer3 = 1;
|
//unsigned int enable_profile_led1_Timer3 = 1;
|
||||||
unsigned int enable_profile_led1_Timer4 = 1;
|
//unsigned int enable_profile_led1_Timer4 = 1;
|
||||||
|
//
|
||||||
unsigned int enable_profile_led2_Timer1 = 0;
|
//unsigned int enable_profile_led2_Timer1 = 0;
|
||||||
unsigned int enable_profile_led2_Timer2 = 0;
|
//unsigned int enable_profile_led2_Timer2 = 0;
|
||||||
unsigned int enable_profile_led2_Timer3 = 0;
|
//unsigned int enable_profile_led2_Timer3 = 0;
|
||||||
unsigned int enable_profile_led2_Timer4 = 0;
|
//unsigned int enable_profile_led2_Timer4 = 0;
|
||||||
|
|
||||||
//Pointers to handler functions
|
//Pointers to handler functions
|
||||||
void (*timer1_handler)() = NULL;
|
void (*timer1_handler)() = NULL;
|
||||||
@ -332,11 +333,11 @@ interrupt void eva_timer1_isr(void)
|
|||||||
PieCtrlRegs.PIEACK.all = 0xFFFF; // Enable PIE interrupts
|
PieCtrlRegs.PIEACK.all = 0xFFFF; // Enable PIE interrupts
|
||||||
|
|
||||||
#if (_ENABLE_INTERRUPT_PROFILE_LED1)
|
#if (_ENABLE_INTERRUPT_PROFILE_LED1)
|
||||||
if (enable_profile_led1_Timer1)
|
if (profile_interrupt.for_led1.bits.timer1)
|
||||||
i_led1_on_off_special(1);
|
i_led1_on_off_special(1);
|
||||||
#endif
|
#endif
|
||||||
#if (_ENABLE_INTERRUPT_PROFILE_LED2)
|
#if (_ENABLE_INTERRUPT_PROFILE_LED2)
|
||||||
if (enable_profile_led2_Timer1)
|
if (profile_interrupt.for_led2.bits.timer1)
|
||||||
i_led2_on_off_special(1);
|
i_led2_on_off_special(1);
|
||||||
#endif
|
#endif
|
||||||
EINT;
|
EINT;
|
||||||
@ -354,11 +355,11 @@ interrupt void eva_timer1_isr(void)
|
|||||||
DINT;
|
DINT;
|
||||||
PieCtrlRegs.PIEIER2.all = TempPIEIER;
|
PieCtrlRegs.PIEIER2.all = TempPIEIER;
|
||||||
#if (_ENABLE_INTERRUPT_PROFILE_LED1)
|
#if (_ENABLE_INTERRUPT_PROFILE_LED1)
|
||||||
if (enable_profile_led1_Timer1)
|
if (profile_interrupt.for_led1.bits.timer1)
|
||||||
i_led1_on_off_special(0);
|
i_led1_on_off_special(0);
|
||||||
#endif
|
#endif
|
||||||
#if (_ENABLE_INTERRUPT_PROFILE_LED2)
|
#if (_ENABLE_INTERRUPT_PROFILE_LED2)
|
||||||
if (enable_profile_led2_Timer1)
|
if (profile_interrupt.for_led2.bits.timer1)
|
||||||
i_led2_on_off_special(0);
|
i_led2_on_off_special(0);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
@ -404,11 +405,11 @@ interrupt void eva_timer2_isr(void)
|
|||||||
PieCtrlRegs.PIEACK.all = 0xFFFF; // Enable PIE interrupts
|
PieCtrlRegs.PIEACK.all = 0xFFFF; // Enable PIE interrupts
|
||||||
|
|
||||||
#if (_ENABLE_INTERRUPT_PROFILE_LED1)
|
#if (_ENABLE_INTERRUPT_PROFILE_LED1)
|
||||||
if (enable_profile_led1_Timer2)
|
if (profile_interrupt.for_led1.bits.timer2)
|
||||||
i_led1_on_off_special(1);
|
i_led1_on_off_special(1);
|
||||||
#endif
|
#endif
|
||||||
#if (_ENABLE_INTERRUPT_PROFILE_LED2)
|
#if (_ENABLE_INTERRUPT_PROFILE_LED2)
|
||||||
if (enable_profile_led2_Timer2)
|
if (profile_interrupt.for_led2.bits.timer2)
|
||||||
i_led2_on_off_special(1);
|
i_led2_on_off_special(1);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
@ -428,11 +429,11 @@ interrupt void eva_timer2_isr(void)
|
|||||||
PieCtrlRegs.PIEIER3.all = TempPIEIER;
|
PieCtrlRegs.PIEIER3.all = TempPIEIER;
|
||||||
|
|
||||||
#if (_ENABLE_INTERRUPT_PROFILE_LED1)
|
#if (_ENABLE_INTERRUPT_PROFILE_LED1)
|
||||||
if (enable_profile_led1_Timer2)
|
if (profile_interrupt.for_led1.bits.timer2)
|
||||||
i_led1_on_off_special(0);
|
i_led1_on_off_special(0);
|
||||||
#endif
|
#endif
|
||||||
#if (_ENABLE_INTERRUPT_PROFILE_LED2)
|
#if (_ENABLE_INTERRUPT_PROFILE_LED2)
|
||||||
if (enable_profile_led2_Timer2)
|
if (profile_interrupt.for_led2.bits.timer2)
|
||||||
i_led2_on_off_special(0);
|
i_led2_on_off_special(0);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
@ -484,11 +485,11 @@ interrupt void evb_timer3_isr(void)
|
|||||||
PieCtrlRegs.PIEACK.all = 0xFFFF; // Enable PIE interrupts
|
PieCtrlRegs.PIEACK.all = 0xFFFF; // Enable PIE interrupts
|
||||||
|
|
||||||
#if (_ENABLE_INTERRUPT_PROFILE_LED1)
|
#if (_ENABLE_INTERRUPT_PROFILE_LED1)
|
||||||
if (enable_profile_led1_Timer3)
|
if (profile_interrupt.for_led1.bits.timer3)
|
||||||
i_led1_on_off_special(1);
|
i_led1_on_off_special(1);
|
||||||
#endif
|
#endif
|
||||||
#if (_ENABLE_INTERRUPT_PROFILE_LED2)
|
#if (_ENABLE_INTERRUPT_PROFILE_LED2)
|
||||||
if (enable_profile_led2_Timer3)
|
if (profile_interrupt.for_led2.bits.timer3)
|
||||||
i_led2_on_off_special(1);
|
i_led2_on_off_special(1);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
@ -511,11 +512,11 @@ interrupt void evb_timer3_isr(void)
|
|||||||
PieCtrlRegs.PIEIER4.all = TempPIEIER;
|
PieCtrlRegs.PIEIER4.all = TempPIEIER;
|
||||||
|
|
||||||
#if (_ENABLE_INTERRUPT_PROFILE_LED1)
|
#if (_ENABLE_INTERRUPT_PROFILE_LED1)
|
||||||
if (enable_profile_led1_Timer3)
|
if (profile_interrupt.for_led1.bits.timer3)
|
||||||
i_led1_on_off_special(0);
|
i_led1_on_off_special(0);
|
||||||
#endif
|
#endif
|
||||||
#if (_ENABLE_INTERRUPT_PROFILE_LED2)
|
#if (_ENABLE_INTERRUPT_PROFILE_LED2)
|
||||||
if (enable_profile_led2_Timer3)
|
if (profile_interrupt.for_led2.bits.timer3)
|
||||||
i_led2_on_off_special(0);
|
i_led2_on_off_special(0);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
@ -566,11 +567,11 @@ interrupt void evb_timer4_isr(void)
|
|||||||
PieCtrlRegs.PIEACK.all = 0xFFFF; // Enable PIE interrupts
|
PieCtrlRegs.PIEACK.all = 0xFFFF; // Enable PIE interrupts
|
||||||
|
|
||||||
#if (_ENABLE_INTERRUPT_PROFILE_LED1)
|
#if (_ENABLE_INTERRUPT_PROFILE_LED1)
|
||||||
if (enable_profile_led1_Timer4)
|
if (profile_interrupt.for_led1.bits.timer4)
|
||||||
i_led1_on_off_special(1);
|
i_led1_on_off_special(1);
|
||||||
#endif
|
#endif
|
||||||
#if (_ENABLE_INTERRUPT_PROFILE_LED2)
|
#if (_ENABLE_INTERRUPT_PROFILE_LED2)
|
||||||
if (enable_profile_led2_Timer4)
|
if (profile_interrupt.for_led2.bits.timer4)
|
||||||
i_led2_on_off_special(1);
|
i_led2_on_off_special(1);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
@ -590,11 +591,11 @@ interrupt void evb_timer4_isr(void)
|
|||||||
PieCtrlRegs.PIEIER5.all = TempPIEIER;
|
PieCtrlRegs.PIEIER5.all = TempPIEIER;
|
||||||
|
|
||||||
#if (_ENABLE_INTERRUPT_PROFILE_LED1)
|
#if (_ENABLE_INTERRUPT_PROFILE_LED1)
|
||||||
if (enable_profile_led1_Timer4)
|
if (profile_interrupt.for_led1.bits.timer4)
|
||||||
i_led1_on_off_special(0);
|
i_led1_on_off_special(0);
|
||||||
#endif
|
#endif
|
||||||
#if (_ENABLE_INTERRUPT_PROFILE_LED2)
|
#if (_ENABLE_INTERRUPT_PROFILE_LED2)
|
||||||
if (enable_profile_led2_Timer4)
|
if (profile_interrupt.for_led2.bits.timer4)
|
||||||
i_led2_on_off_special(0);
|
i_led2_on_off_special(0);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
@ -8,6 +8,9 @@
|
|||||||
#ifndef SRC_MAIN_CAN_PROJECT_H_
|
#ifndef SRC_MAIN_CAN_PROJECT_H_
|
||||||
#define SRC_MAIN_CAN_PROJECT_H_
|
#define SRC_MAIN_CAN_PROJECT_H_
|
||||||
|
|
||||||
|
|
||||||
|
#include "can_protocol_ukss.h"
|
||||||
|
|
||||||
//////////////////////////////////////////////////////////////////
|
//////////////////////////////////////////////////////////////////
|
||||||
// íàñòðîéêà áàçîâûõ àäðåñîâ CAN
|
// íàñòðîéêà áàçîâûõ àäðåñîâ CAN
|
||||||
// PCH_1 èëè PCH_2 âûáèðàåòñÿ äæàìïåðîâ íà ÏÌ67
|
// PCH_1 èëè PCH_2 âûáèðàåòñÿ äæàìïåðîâ íà ÏÌ67
|
||||||
@ -28,23 +31,21 @@
|
|||||||
//#define CAN_PROTOCOL_VERSION 1
|
//#define CAN_PROTOCOL_VERSION 1
|
||||||
#define CAN_PROTOCOL_VERSION 2
|
#define CAN_PROTOCOL_VERSION 2
|
||||||
|
|
||||||
|
#define CAN_SPEED_BITS 125000
|
||||||
#define CAN_SPEED_BITS 250000
|
//#define CAN_SPEED_BITS 250000
|
||||||
//#define CAN_SPEED_BITS 500000
|
//#define CAN_SPEED_BITS 500000
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
#define ENABLE_CAN_SEND_TO_UKSS_FROM_MAIN 1
|
#define ENABLE_CAN_SEND_TO_UKSS_FROM_MAIN 1
|
||||||
#define ENABLE_CAN_SEND_TO_MPU_FROM_MAIN 1
|
#define ENABLE_CAN_SEND_TO_MPU_FROM_MAIN 1
|
||||||
#define ENABLE_CAN_SEND_TO_TERMINAL_FROM_MAIN 1
|
#define ENABLE_CAN_SEND_TO_TERMINAL_FROM_MAIN 0//1
|
||||||
#define ENABLE_CAN_SEND_TO_TERMINAL_OSCIL 0//1
|
#define ENABLE_CAN_SEND_TO_TERMINAL_OSCIL 0//1
|
||||||
#define ENABLE_CAN_SEND_TO_ANOTHER_BSU_FROM_MAIN 1
|
#define ENABLE_CAN_SEND_TO_ANOTHER_BSU_FROM_MAIN 1
|
||||||
|
|
||||||
|
|
||||||
//////////////////////////////////////////////////////
|
//////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
#ifndef ENABLE_CAN_SEND_TO_UKSS_FROM_MAIN
|
#ifndef ENABLE_CAN_SEND_TO_UKSS_FROM_MAIN
|
||||||
#define ENABLE_CAN_SEND_TO_UKSS_FROM_MAIN 0
|
#define ENABLE_CAN_SEND_TO_UKSS_FROM_MAIN 0
|
||||||
#endif
|
#endif
|
||||||
|
@ -14,9 +14,9 @@ void main()
|
|||||||
// This example function is found in the DSP281x_SysCtrl.c file.
|
// This example function is found in the DSP281x_SysCtrl.c file.
|
||||||
InitSysCtrl();
|
InitSysCtrl();
|
||||||
|
|
||||||
XintfZone0_Timing();
|
XintfZone0_Timing();//Xilinx Zone
|
||||||
XintfZone6_And7_Timing();
|
XintfZone6_And7_Timing();//Flash Zone
|
||||||
XintfZone2_Timing();
|
XintfZone2_Timing();//External RAM Zone
|
||||||
|
|
||||||
// Step 2. Initalize GPIO:
|
// Step 2. Initalize GPIO:
|
||||||
// This example function is found in the DSP281x_Gpio.c file and
|
// This example function is found in the DSP281x_Gpio.c file and
|
||||||
|
File diff suppressed because it is too large
Load Diff
@ -11,7 +11,8 @@
|
|||||||
|
|
||||||
void InitPWM(void);
|
void InitPWM(void);
|
||||||
void PWM_interrupt(void);
|
void PWM_interrupt(void);
|
||||||
void InitPWM_Variables(void);
|
void PWM_interrupt_main(void);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
void stop_wdog(void);
|
void stop_wdog(void);
|
||||||
@ -21,11 +22,20 @@ void start_wdog(void);
|
|||||||
void global_time_interrupt(void);
|
void global_time_interrupt(void);
|
||||||
void optical_bus_read_write_interrupt(void);
|
void optical_bus_read_write_interrupt(void);
|
||||||
void pwm_analog_ext_interrupt(void);
|
void pwm_analog_ext_interrupt(void);
|
||||||
|
void pwm_inc_interrupt(void);
|
||||||
|
|
||||||
void fix_pwm_freq_synchro_ain(void);
|
void fix_pwm_freq_synchro_ain(void);
|
||||||
|
void async_pwm_ext_interrupt(void);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
void calc_rotors(int flag);
|
||||||
|
|
||||||
|
void detect_work_revers(int direction, _iq fzad, _iq frot);
|
||||||
|
|
||||||
|
void calc_power_full(void);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
//////////////////////////////////////////////////
|
//////////////////////////////////////////////////
|
||||||
//////////////////////////////////////////////////
|
//////////////////////////////////////////////////
|
||||||
|
@ -132,6 +132,8 @@ ERR_ADC_PROTECT err_adc_protect[COUNT_ARR_ADC_BUF],mask_err_adc_protect[COUNT_AR
|
|||||||
|
|
||||||
|
|
||||||
_iq koef_Im_filter=0;
|
_iq koef_Im_filter=0;
|
||||||
|
_iq koef_Power_filter=0;
|
||||||
|
_iq koef_Power_filter2=0;
|
||||||
|
|
||||||
#pragma DATA_SECTION(k_norm_ADC,".slow_vars")
|
#pragma DATA_SECTION(k_norm_ADC,".slow_vars")
|
||||||
_iq19 k_norm_ADC[COUNT_ARR_ADC_BUF][16];
|
_iq19 k_norm_ADC[COUNT_ARR_ADC_BUF][16];
|
||||||
@ -165,8 +167,8 @@ _iq koef_Uin_filter=0;
|
|||||||
|
|
||||||
|
|
||||||
void fast_detect_protect_ACP();
|
void fast_detect_protect_ACP();
|
||||||
void fast_read_all_adc_one(int cc);
|
//void fast_read_all_adc_one(int cc);
|
||||||
void fast_read_all_adc_more(void);
|
//void fast_read_all_adc_more(void);
|
||||||
|
|
||||||
|
|
||||||
#if (USE_INTERNAL_ADC==1)
|
#if (USE_INTERNAL_ADC==1)
|
||||||
@ -574,7 +576,7 @@ void Init_Adc_Variables(void)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
for (i=0;i<COUNT_ARR_ADC_BUF_EXTERNAL;i++)
|
for (i=0;i<COUNT_ARR_ADC_BUF;i++)
|
||||||
{
|
{
|
||||||
if (project.adc[i].status >= component_Ready)
|
if (project.adc[i].status >= component_Ready)
|
||||||
detect_zero_analog(i);
|
detect_zero_analog(i);
|
||||||
@ -590,7 +592,7 @@ void Init_Adc_Variables(void)
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
#if (COUNT_ARR_ADC_BUF>1)
|
||||||
zero_ADC[1][1]=zero_ADC[1][15];
|
zero_ADC[1][1]=zero_ADC[1][15];
|
||||||
zero_ADC[1][2]=zero_ADC[1][15];
|
zero_ADC[1][2]=zero_ADC[1][15];
|
||||||
zero_ADC[1][3]=zero_ADC[1][15];
|
zero_ADC[1][3]=zero_ADC[1][15];
|
||||||
@ -605,12 +607,12 @@ void Init_Adc_Variables(void)
|
|||||||
zero_ADC[1][12]=zero_ADC[1][15];
|
zero_ADC[1][12]=zero_ADC[1][15];
|
||||||
zero_ADC[1][13]=zero_ADC[1][15];
|
zero_ADC[1][13]=zero_ADC[1][15];
|
||||||
zero_ADC[1][14]=zero_ADC[1][15];
|
zero_ADC[1][14]=zero_ADC[1][15];
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
for (k=0;k<16;k++)
|
for (k=0;k<16;k++)
|
||||||
{
|
{
|
||||||
for (i=0;i<COUNT_ARR_ADC_BUF_EXTERNAL;i++)
|
for (i=0;i<COUNT_ARR_ADC_BUF;i++)
|
||||||
{
|
{
|
||||||
if ((zero_ADC[i][k]>2200) || (zero_ADC[i][k]<1900))
|
if ((zero_ADC[i][k]>2200) || (zero_ADC[i][k]<1900))
|
||||||
zero_ADC[i][k] = DEFAULT_ZERO_ADC;
|
zero_ADC[i][k] = DEFAULT_ZERO_ADC;
|
||||||
@ -621,7 +623,7 @@ void Init_Adc_Variables(void)
|
|||||||
|
|
||||||
for (k=0;k<16;k++)
|
for (k=0;k<16;k++)
|
||||||
{
|
{
|
||||||
for (i=0;i<COUNT_ARR_ADC_BUF_EXTERNAL;i++)
|
for (i=0;i<COUNT_ARR_ADC_BUF;i++)
|
||||||
{
|
{
|
||||||
iq19_zero_ADC[i][k]=_IQ19(zero_ADC[i][k]);//_IQ19(1770);
|
iq19_zero_ADC[i][k]=_IQ19(zero_ADC[i][k]);//_IQ19(1770);
|
||||||
}
|
}
|
||||||
@ -636,6 +638,8 @@ void Init_Adc_Variables(void)
|
|||||||
|
|
||||||
// koef_Im_filter = _IQ(0.001/0.006);
|
// koef_Im_filter = _IQ(0.001/0.006);
|
||||||
koef_Im_filter = _IQ(0.001/0.065);
|
koef_Im_filter = _IQ(0.001/0.065);
|
||||||
|
koef_Power_filter = _IQ(0.001/0.065);
|
||||||
|
koef_Power_filter2 = _IQ(0.001/0.2);
|
||||||
|
|
||||||
// koef_Iabc_filter = _IQ(0.001/0.006);
|
// koef_Iabc_filter = _IQ(0.001/0.006);
|
||||||
|
|
||||||
@ -668,7 +672,7 @@ void Init_Adc_Variables(void)
|
|||||||
// filter.iqUin_m2 = 0;
|
// filter.iqUin_m2 = 0;
|
||||||
|
|
||||||
|
|
||||||
for (i=0;i<COUNT_ARR_ADC_BUF_EXTERNAL;i++)
|
for (i=0;i<COUNT_ARR_ADC_BUF;i++)
|
||||||
{
|
{
|
||||||
mask_err_adc_protect[i].plus.all=0;
|
mask_err_adc_protect[i].plus.all=0;
|
||||||
mask_err_adc_protect[i].minus.all=0x0;
|
mask_err_adc_protect[i].minus.all=0x0;
|
||||||
@ -755,7 +759,7 @@ void read_error_ACP()
|
|||||||
|
|
||||||
// pr = project.controller.fpga.cds_fpga_parallel_bus.pread;
|
// pr = project.controller.fpga.cds_fpga_parallel_bus.pread;
|
||||||
|
|
||||||
for (i=0;i<COUNT_ARR_ADC_BUF_EXTERNAL;i++)
|
for (i=0;i<COUNT_ARR_ADC_BUF;i++)
|
||||||
{
|
{
|
||||||
if (project.adc[i].status == component_Ready)
|
if (project.adc[i].status == component_Ready)
|
||||||
for (k=0;k<16;k++)
|
for (k=0;k<16;k++)
|
||||||
@ -847,181 +851,181 @@ _iq norma_adc_internal_sf(int l)
|
|||||||
/////////////////////////////////////////////////////////
|
/////////////////////////////////////////////////////////
|
||||||
/////////////////////////////////////////////////////////
|
/////////////////////////////////////////////////////////
|
||||||
/////////////////////////////////////////////////////////
|
/////////////////////////////////////////////////////////
|
||||||
|
//
|
||||||
|
//#pragma CODE_SECTION(fast_read_all_adc_one,".fast_run");
|
||||||
|
//void fast_read_all_adc_one(int cc)
|
||||||
|
//{
|
||||||
|
// int i,k;
|
||||||
|
// int t;
|
||||||
|
//
|
||||||
|
// i_led1_on_off(1);
|
||||||
|
//
|
||||||
|
// project.adc[0].read_pbus(&project.adc[0]);
|
||||||
|
//
|
||||||
|
// for (k=0;k<16;k++)
|
||||||
|
// {
|
||||||
|
// t = project.adc[0].read.pbus.adc_value[k];
|
||||||
|
// ADC_fast[0][k][cc] = t;
|
||||||
|
//
|
||||||
|
// // save max values
|
||||||
|
// if (t>ADC_fast[0][k][1] || cc==3)
|
||||||
|
// ADC_fast[0][k][1] = t;
|
||||||
|
// // save min values
|
||||||
|
// if (t<ADC_fast[0][k][2] || cc==3)
|
||||||
|
// ADC_fast[0][k][2] = t;
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
//
|
||||||
|
//
|
||||||
|
//
|
||||||
|
//
|
||||||
|
////i_led2_off();
|
||||||
|
// i_led1_on_off(0);
|
||||||
|
//
|
||||||
|
//}
|
||||||
|
|
||||||
#pragma CODE_SECTION(fast_read_all_adc_one,".fast_run");
|
//#pragma CODE_SECTION(fast_read_all_adc_two,".fast_run");
|
||||||
void fast_read_all_adc_one(int cc)
|
//void fast_read_all_adc_two(void)
|
||||||
{
|
//{
|
||||||
int i,k;
|
// int i,k;
|
||||||
int t;
|
// int t;
|
||||||
|
//
|
||||||
i_led1_on_off(1);
|
//// i_led2_on_off(1);
|
||||||
|
//
|
||||||
project.adc[0].read_pbus(&project.adc[0]);
|
// project.adc[1].read_pbus(&project.adc[1]);
|
||||||
|
//
|
||||||
for (k=0;k<16;k++)
|
// for (k=0;k<16;k++)
|
||||||
{
|
// {
|
||||||
t = project.adc[0].read.pbus.adc_value[k];
|
// t = project.adc[1].read.pbus.adc_value[k];
|
||||||
ADC_fast[0][k][cc] = t;
|
// ADC_fast[1][k][0] = t;
|
||||||
|
// }
|
||||||
// save max values
|
//
|
||||||
if (t>ADC_fast[0][k][1] || cc==3)
|
//// i_led2_on_off(0);
|
||||||
ADC_fast[0][k][1] = t;
|
//
|
||||||
// save min values
|
//}
|
||||||
if (t<ADC_fast[0][k][2] || cc==3)
|
|
||||||
ADC_fast[0][k][2] = t;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
//i_led2_off();
|
|
||||||
i_led1_on_off(0);
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
#pragma CODE_SECTION(fast_read_all_adc_two,".fast_run");
|
|
||||||
void fast_read_all_adc_two(void)
|
|
||||||
{
|
|
||||||
int i,k;
|
|
||||||
int t;
|
|
||||||
|
|
||||||
// i_led2_on_off(1);
|
|
||||||
|
|
||||||
project.adc[1].read_pbus(&project.adc[1]);
|
|
||||||
|
|
||||||
for (k=0;k<16;k++)
|
|
||||||
{
|
|
||||||
t = project.adc[1].read.pbus.adc_value[k];
|
|
||||||
ADC_fast[1][k][0] = t;
|
|
||||||
}
|
|
||||||
|
|
||||||
// i_led2_on_off(0);
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
/////////////////////////////////////////////////////////
|
/////////////////////////////////////////////////////////
|
||||||
|
|
||||||
#define PAUSE_BETWEEN_ADC_FAST 5
|
//#define PAUSE_BETWEEN_ADC_FAST 5
|
||||||
#pragma CODE_SECTION(fast_read_all_adc_more,".fast_run");
|
//#pragma CODE_SECTION(fast_read_all_adc_more,".fast_run");
|
||||||
void fast_read_all_adc_more(void)
|
//void fast_read_all_adc_more(void)
|
||||||
{
|
//{
|
||||||
int i,k;
|
// int i,k;
|
||||||
static int p = PAUSE_BETWEEN_ADC_FAST;
|
// static int p = PAUSE_BETWEEN_ADC_FAST;
|
||||||
|
//
|
||||||
|
// project.read_errors_controller();
|
||||||
|
//
|
||||||
|
// if (project.adc[0].status == component_Ready
|
||||||
|
// && project.controller.read.errors.bit.error_pbus == 0
|
||||||
|
// && project.controller.read.errors_buses.bit.slave_addr_error==0
|
||||||
|
// && project.x_parallel_bus->flags.bit.error==0 )
|
||||||
|
// {
|
||||||
|
//
|
||||||
|
//
|
||||||
|
//
|
||||||
|
// fast_read_all_adc_one(3);
|
||||||
|
// pause_1000(p);
|
||||||
|
// fast_read_all_adc_one(4);
|
||||||
|
// pause_1000(p);
|
||||||
|
// fast_read_all_adc_one(5);
|
||||||
|
// pause_1000(p);
|
||||||
|
// fast_read_all_adc_one(6);
|
||||||
|
// pause_1000(p);
|
||||||
|
// fast_read_all_adc_one(7);
|
||||||
|
// pause_1000(p);
|
||||||
|
// fast_read_all_adc_one(8);
|
||||||
|
//
|
||||||
|
//
|
||||||
|
//
|
||||||
|
// for (k=0;k<16;k++)
|
||||||
|
// {
|
||||||
|
// ADC_fast[0][k][0] = (-ADC_fast[0][k][1] - ADC_fast[0][k][2] + ADC_fast[0][k][3] + ADC_fast[0][k][4]
|
||||||
|
// +ADC_fast[0][k][5] + ADC_fast[0][k][6] + ADC_fast[0][k][7] + ADC_fast[0][k][8]) >> 2; // ñóììó äåëèì íà 4
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// }
|
||||||
|
// else
|
||||||
|
// {
|
||||||
|
// for (k=0;k<16;k++)
|
||||||
|
// {
|
||||||
|
// ADC_fast[0][k][0] = 5000; // error
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
//
|
||||||
|
// if (project.adc[1].status == component_Ready
|
||||||
|
// && project.controller.read.errors.bit.error_pbus == 0
|
||||||
|
// && project.controller.read.errors_buses.bit.slave_addr_error==0
|
||||||
|
// && project.x_parallel_bus->flags.bit.error==0 )
|
||||||
|
// {
|
||||||
|
//
|
||||||
|
// fast_read_all_adc_two();
|
||||||
|
// }
|
||||||
|
// else
|
||||||
|
// {
|
||||||
|
// for (k=0;k<16;k++)
|
||||||
|
// {
|
||||||
|
// ADC_fast[1][k][0] = 5000; // error
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
//}
|
||||||
|
|
||||||
project.read_errors_controller();
|
/////////////////////////////////////////////////////////
|
||||||
|
//
|
||||||
if (project.adc[0].status == component_Ready
|
//#pragma CODE_SECTION(norma_fast_adc,".fast_run");
|
||||||
&& project.controller.read.errors.bit.error_pbus == 0
|
//void norma_fast_adc(void)
|
||||||
&& project.controller.read.errors_buses.bit.slave_addr_error==0
|
//{
|
||||||
&& project.x_parallel_bus->flags.bit.error==0 )
|
// int i,k;
|
||||||
{
|
//// int bb;
|
||||||
|
//
|
||||||
|
//#ifdef LOG_ACP_TO_BUF
|
||||||
|
// static int c_log=0;
|
||||||
fast_read_all_adc_one(3);
|
// static int n_log_acp_p=0;
|
||||||
pause_1000(p);
|
// static int n_log_acp_c=2;
|
||||||
fast_read_all_adc_one(4);
|
// static int n_log_acp_p_2=0;
|
||||||
pause_1000(p);
|
// static int n_log_acp_c_2=2;
|
||||||
fast_read_all_adc_one(5);
|
//
|
||||||
pause_1000(p);
|
//#endif
|
||||||
fast_read_all_adc_one(6);
|
//
|
||||||
pause_1000(p);
|
// for (i=0;i<COUNT_ARR_ADC_BUF_EXTERNAL;i++)
|
||||||
fast_read_all_adc_one(7);
|
// {
|
||||||
pause_1000(p);
|
//
|
||||||
fast_read_all_adc_one(8);
|
// if ( project.adc[i].status == component_Ready
|
||||||
|
// && project.controller.read.errors.bit.error_pbus == 0
|
||||||
|
// && project.controller.read.errors_buses.bit.slave_addr_error==0
|
||||||
|
// && project.x_parallel_bus->flags.bit.error==0 )
|
||||||
for (k=0;k<16;k++)
|
// {
|
||||||
{
|
// for (k=0;k<16;k++)
|
||||||
ADC_fast[0][k][0] = (-ADC_fast[0][k][1] - ADC_fast[0][k][2] + ADC_fast[0][k][3] + ADC_fast[0][k][4]
|
// {
|
||||||
+ADC_fast[0][k][5] + ADC_fast[0][k][6] + ADC_fast[0][k][7] + ADC_fast[0][k][8]) >> 2; // ñóììó äåëèì íà 4
|
// iq_norm_ADC[i][k] = _IQ19toIQ(_IQ19mpy((-iq19_zero_ADC[i][k] + ((long)ADC_fast[i][k][0]<<19) ),iq19_k_norm_ADC[i][k]));
|
||||||
}
|
// }
|
||||||
|
// }
|
||||||
}
|
// else
|
||||||
else
|
// {
|
||||||
{
|
// for (k=0;k<16;k++)
|
||||||
for (k=0;k<16;k++)
|
// {
|
||||||
{
|
// iq_norm_ADC[i][k] = 0;
|
||||||
ADC_fast[0][k][0] = 5000; // error
|
// }
|
||||||
}
|
//
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
|
// }
|
||||||
if (project.adc[1].status == component_Ready
|
//
|
||||||
&& project.controller.read.errors.bit.error_pbus == 0
|
//#ifdef LOG_ACP_TO_BUF
|
||||||
&& project.controller.read.errors_buses.bit.slave_addr_error==0
|
// if (c_log>=SIZE_BUF_LOG_ACP)
|
||||||
&& project.x_parallel_bus->flags.bit.error==0 )
|
// c_log=0;
|
||||||
{
|
// BUF_ADC[c_log]=ADC_fast[n_log_acp_p][n_log_acp_c][0];
|
||||||
|
// BUF_ADC_2[c_log]=ADC_fast[n_log_acp_p_2][n_log_acp_c_2][3];
|
||||||
fast_read_all_adc_two();
|
// c_log++;
|
||||||
}
|
//#endif
|
||||||
else
|
//
|
||||||
{
|
////i_led2_off();
|
||||||
for (k=0;k<16;k++)
|
//}
|
||||||
{
|
|
||||||
ADC_fast[1][k][0] = 5000; // error
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
/////////////////////////////////////////////////////////
|
/////////////////////////////////////////////////////////
|
||||||
|
|
||||||
#pragma CODE_SECTION(norma_fast_adc,".fast_run");
|
/*
|
||||||
void norma_fast_adc(void)
|
|
||||||
{
|
|
||||||
int i,k;
|
|
||||||
// int bb;
|
|
||||||
|
|
||||||
#ifdef LOG_ACP_TO_BUF
|
|
||||||
static int c_log=0;
|
|
||||||
static int n_log_acp_p=0;
|
|
||||||
static int n_log_acp_c=2;
|
|
||||||
static int n_log_acp_p_2=0;
|
|
||||||
static int n_log_acp_c_2=2;
|
|
||||||
|
|
||||||
#endif
|
|
||||||
|
|
||||||
for (i=0;i<COUNT_ARR_ADC_BUF_EXTERNAL;i++)
|
|
||||||
{
|
|
||||||
|
|
||||||
if ( project.adc[i].status == component_Ready
|
|
||||||
&& project.controller.read.errors.bit.error_pbus == 0
|
|
||||||
&& project.controller.read.errors_buses.bit.slave_addr_error==0
|
|
||||||
&& project.x_parallel_bus->flags.bit.error==0 )
|
|
||||||
{
|
|
||||||
for (k=0;k<16;k++)
|
|
||||||
{
|
|
||||||
iq_norm_ADC[i][k] = _IQ19toIQ(_IQ19mpy((-iq19_zero_ADC[i][k] + ((long)ADC_fast[i][k][0]<<19) ),iq19_k_norm_ADC[i][k]));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
for (k=0;k<16;k++)
|
|
||||||
{
|
|
||||||
iq_norm_ADC[i][k] = 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
#ifdef LOG_ACP_TO_BUF
|
|
||||||
if (c_log>=SIZE_BUF_LOG_ACP)
|
|
||||||
c_log=0;
|
|
||||||
BUF_ADC[c_log]=ADC_fast[n_log_acp_p][n_log_acp_c][0];
|
|
||||||
BUF_ADC_2[c_log]=ADC_fast[n_log_acp_p_2][n_log_acp_c_2][3];
|
|
||||||
c_log++;
|
|
||||||
#endif
|
|
||||||
|
|
||||||
//i_led2_off();
|
|
||||||
}
|
|
||||||
|
|
||||||
/////////////////////////////////////////////////////////
|
|
||||||
|
|
||||||
|
|
||||||
#pragma CODE_SECTION(norma_all_adc,".fast_run");
|
#pragma CODE_SECTION(norma_all_adc,".fast_run");
|
||||||
void norma_all_adc(void)
|
void norma_all_adc(void)
|
||||||
{
|
{
|
||||||
@ -1036,76 +1040,7 @@ void norma_all_adc(void)
|
|||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
//i_led2_on();
|
for (i=0;i<COUNT_ARR_ADC_BUF;i++)
|
||||||
|
|
||||||
|
|
||||||
// T_cds_paralle_bus_read_all* pr;
|
|
||||||
|
|
||||||
// pr = project.controller.fpga.cds_fpga_parallel_bus.pread;
|
|
||||||
|
|
||||||
// (int)pr->data.adc[nadc].acc_short[ncan];
|
|
||||||
|
|
||||||
|
|
||||||
///
|
|
||||||
/*
|
|
||||||
|
|
||||||
iq_norm_ADC[0][0] = _IQ19toIQ(_IQ19mpy((iq19_zero_ADC[0][0] - ((long)ADC_f[0][0]<<19) ),iq19_k_norm_ADC[0][0]));
|
|
||||||
iq_norm_ADC[0][1] = _IQ19toIQ(_IQ19mpy((iq19_zero_ADC[0][1] - ((long)ADC_f[0][1]<<19) ),iq19_k_norm_ADC[0][1]));
|
|
||||||
|
|
||||||
iq_norm_ADC[0][2] = _IQ19toIQ(_IQ19mpy((iq19_zero_ADC[0][2] - ((long)ADC_f[0][2]<<19) ),iq19_k_norm_ADC[0][2]));
|
|
||||||
iq_norm_ADC[0][3] = _IQ19toIQ(_IQ19mpy((iq19_zero_ADC[0][3] - ((long)ADC_f[0][3]<<19) ),iq19_k_norm_ADC[0][3]));
|
|
||||||
iq_norm_ADC[0][4] = _IQ19toIQ(_IQ19mpy((iq19_zero_ADC[0][4] - ((long)ADC_f[0][4]<<19) ),iq19_k_norm_ADC[0][4]));
|
|
||||||
iq_norm_ADC[0][5] = _IQ19toIQ(_IQ19mpy((iq19_zero_ADC[0][5] - ((long)ADC_f[0][5]<<19) ),iq19_k_norm_ADC[0][5]));
|
|
||||||
iq_norm_ADC[0][6] = _IQ19toIQ(_IQ19mpy((iq19_zero_ADC[0][6] - ((long)ADC_f[0][6]<<19) ),iq19_k_norm_ADC[0][6]));
|
|
||||||
iq_norm_ADC[0][7] = _IQ19toIQ(_IQ19mpy((iq19_zero_ADC[0][7] - ((long)ADC_f[0][7]<<19) ),iq19_k_norm_ADC[0][7]));
|
|
||||||
|
|
||||||
|
|
||||||
//i1 second mes
|
|
||||||
// ADC_f[0][8] = (int)pr->data.adc[0].acc_short[2];
|
|
||||||
// ADC_f[0][9] = (int)pr->data.adc[0].acc_short[3];
|
|
||||||
// ADC_f[0][10] = (int)pr->data.adc[0].acc_short[4];
|
|
||||||
// ADC_f[0][11] = (int)pr->data.adc[0].acc_short[5];
|
|
||||||
// ADC_f[0][12] = (int)pr->data.adc[0].acc_short[6];
|
|
||||||
// ADC_f[0][13] = (int)pr->data.adc[0].acc_short[7];
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
iq_norm_ADC[0][8] = _IQ19toIQ(_IQ19mpy((iq19_zero_ADC[0][8] - ((long)ADC_f[0][8]<<19) ),iq19_k_norm_ADC[0][8]));
|
|
||||||
iq_norm_ADC[0][9] = _IQ19toIQ(_IQ19mpy((iq19_zero_ADC[0][9] - ((long)ADC_f[0][9]<<19) ),iq19_k_norm_ADC[0][9]));
|
|
||||||
iq_norm_ADC[0][10] = _IQ19toIQ(_IQ19mpy((iq19_zero_ADC[0][10] - ((long)ADC_f[0][10]<<19) ),iq19_k_norm_ADC[0][10]));
|
|
||||||
iq_norm_ADC[0][11] = _IQ19toIQ(_IQ19mpy((iq19_zero_ADC[0][11] - ((long)ADC_f[0][11]<<19) ),iq19_k_norm_ADC[0][11]));
|
|
||||||
iq_norm_ADC[0][12] = _IQ19toIQ(_IQ19mpy((iq19_zero_ADC[0][12] - ((long)ADC_f[0][12]<<19) ),iq19_k_norm_ADC[0][12]));
|
|
||||||
iq_norm_ADC[0][13] = _IQ19toIQ(_IQ19mpy((iq19_zero_ADC[0][13] - ((long)ADC_f[0][13]<<19) ),iq19_k_norm_ADC[0][13]));
|
|
||||||
|
|
||||||
// iq_norm_ADC[0][14] = _IQ19toIQ(_IQ19mpy((iq19_zero_ADC[0][14] - ((long)ADC_f[0][14]<<19) ),iq19_k_norm_ADC[0][14]));
|
|
||||||
// iq_norm_ADC[0][15] = _IQ19toIQ(_IQ19mpy((iq19_zero_ADC[0][15] - ((long)ADC_f[0][15]<<19) ),iq19_k_norm_ADC[0][15]));
|
|
||||||
|
|
||||||
///
|
|
||||||
// iq_norm_ADC[1][0] = _IQ19toIQ(_IQ19mpy((iq19_zero_ADC[1][0] - ((long)ADC_f[1][0]<<19) ),iq19_k_norm_ADC[1][0]));
|
|
||||||
// iq_norm_ADC[1][1] = _IQ19toIQ(_IQ19mpy((iq19_zero_ADC[1][1] - ((long)ADC_f[1][1]<<19) ),iq19_k_norm_ADC[1][1]));
|
|
||||||
|
|
||||||
iq_norm_ADC[1][2] = _IQ19toIQ(_IQ19mpy((iq19_zero_ADC[1][2] - ((long)ADC_f[1][2]<<19) ),iq19_k_norm_ADC[1][2]));
|
|
||||||
iq_norm_ADC[1][3] = _IQ19toIQ(_IQ19mpy((iq19_zero_ADC[1][3] - ((long)ADC_f[1][3]<<19) ),iq19_k_norm_ADC[1][3]));
|
|
||||||
iq_norm_ADC[1][4] = _IQ19toIQ(_IQ19mpy((iq19_zero_ADC[1][4] - ((long)ADC_f[1][4]<<19) ),iq19_k_norm_ADC[1][4]));
|
|
||||||
|
|
||||||
// iq_norm_ADC[1][5] = _IQ19toIQ(_IQ19mpy((iq19_zero_ADC[1][5] - ((long)ADC_f[1][5]<<19) ),iq19_k_norm_ADC[1][5]));
|
|
||||||
// iq_norm_ADC[1][6] = _IQ19toIQ(_IQ19mpy((iq19_zero_ADC[1][6] - ((long)ADC_f[1][6]<<19) ),iq19_k_norm_ADC[1][6]));
|
|
||||||
// iq_norm_ADC[1][7] = _IQ19toIQ(_IQ19mpy((iq19_zero_ADC[1][7] - ((long)ADC_f[1][7]<<19) ),iq19_k_norm_ADC[1][7]));
|
|
||||||
|
|
||||||
iq_norm_ADC[1][8] = _IQ19toIQ(_IQ19mpy((iq19_zero_ADC[1][8] - ((long)ADC_f[1][8]<<19) ),iq19_k_norm_ADC[1][8]));
|
|
||||||
iq_norm_ADC[1][9] = _IQ19toIQ(_IQ19mpy((iq19_zero_ADC[1][9] - ((long)ADC_f[1][9]<<19) ),iq19_k_norm_ADC[1][9]));
|
|
||||||
iq_norm_ADC[1][10] = _IQ19toIQ(_IQ19mpy((iq19_zero_ADC[1][10] - ((long)ADC_f[1][10]<<19) ),iq19_k_norm_ADC[1][10]));
|
|
||||||
iq_norm_ADC[1][11] = _IQ19toIQ(_IQ19mpy((iq19_zero_ADC[1][11] - ((long)ADC_f[1][11]<<19) ),iq19_k_norm_ADC[1][11]));
|
|
||||||
iq_norm_ADC[1][12] = _IQ19toIQ(_IQ19mpy((iq19_zero_ADC[1][12] - ((long)ADC_f[1][12]<<19) ),iq19_k_norm_ADC[1][12]));
|
|
||||||
iq_norm_ADC[1][13] = _IQ19toIQ(_IQ19mpy((iq19_zero_ADC[1][13] - ((long)ADC_f[1][13]<<19) ),iq19_k_norm_ADC[1][13]));
|
|
||||||
iq_norm_ADC[1][14] = _IQ19toIQ(_IQ19mpy((iq19_zero_ADC[1][14] - ((long)ADC_f[1][14]<<19) ),iq19_k_norm_ADC[1][14]));
|
|
||||||
iq_norm_ADC[1][15] = _IQ19toIQ(_IQ19mpy((iq19_zero_ADC[1][15] - ((long)ADC_f[1][15]<<19) ),iq19_k_norm_ADC[1][15]));
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
*/
|
|
||||||
|
|
||||||
for (i=0;i<COUNT_ARR_ADC_BUF_EXTERNAL;i++)
|
|
||||||
{
|
{
|
||||||
project.read_errors_controller();
|
project.read_errors_controller();
|
||||||
project.adc[i].read_pbus(&project.adc[i]);
|
project.adc[i].read_pbus(&project.adc[i]);
|
||||||
@ -1161,72 +1096,56 @@ void norma_all_adc(void)
|
|||||||
#endif
|
#endif
|
||||||
//i_led2_off();
|
//i_led2_off();
|
||||||
}
|
}
|
||||||
|
*/
|
||||||
////////////////////////////////////////////////////////////////////
|
|
||||||
////////////////////////////////////////////////////////////////////
|
|
||||||
////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
#pragma CODE_SECTION(calc_norm_ADC,".fast_run");
|
#pragma CODE_SECTION(norma_adc_nc,".fast_run");
|
||||||
void calc_norm_ADC(int fast)
|
void norma_adc_nc(int nc)
|
||||||
|
{
|
||||||
|
int k;
|
||||||
|
// int bb;
|
||||||
|
|
||||||
|
project.read_errors_controller();
|
||||||
|
project.adc[nc].read_pbus(&project.adc[nc]);
|
||||||
|
|
||||||
|
if ( project.adc[nc].status == component_Ready
|
||||||
|
&& project.controller.read.errors.bit.error_pbus == 0
|
||||||
|
&& project.controller.read.errors_buses.bit.slave_addr_error==0
|
||||||
|
&& project.x_parallel_bus->flags.bit.error==0 )
|
||||||
|
{
|
||||||
|
for (k=0;k<16;k++)
|
||||||
|
{
|
||||||
|
|
||||||
|
ADC_f[nc][k] = project.adc[nc].read.pbus.adc_value[k];
|
||||||
|
ADC_sf[nc][k] += (((int)(ADC_f[nc][k] - ADC_sf[nc][k]))>>SDVIG_K_FILTER_S);
|
||||||
|
iq_norm_ADC[nc][k] = _IQ19toIQ(_IQ19mpy((-iq19_zero_ADC[nc][k] + ((long)ADC_f[nc][k]<<19) ),iq19_k_norm_ADC[nc][k]));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
for (k=0;k<16;k++)
|
||||||
|
{
|
||||||
|
ADC_f[nc][k] = 5000;//DEFAULT_ZERO_ADC;
|
||||||
|
ADC_sf[nc][k] = 5000;//DEFAULT_ZERO_ADC;
|
||||||
|
iq_norm_ADC[nc][k] = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
|
||||||
|
#pragma CODE_SECTION(calc_norm_ADC_1,".fast_run");
|
||||||
|
void calc_norm_ADC_1(int run_norma)
|
||||||
{
|
{
|
||||||
_iq a1,a2,a3;
|
_iq a1,a2,a3;
|
||||||
// _iq19 t1;
|
|
||||||
// int k;
|
|
||||||
|
|
||||||
//i_led1_on_off(0);
|
#if (USE_ADC_1)
|
||||||
|
|
||||||
|
if (run_norma)
|
||||||
|
norma_adc_nc(1);
|
||||||
|
|
||||||
//i_led1_on_off(1);
|
|
||||||
// return;
|
|
||||||
//if (fast)
|
|
||||||
//{
|
|
||||||
// fast_read_all_adc_more();
|
|
||||||
// norma_fast_adc();
|
|
||||||
//}
|
|
||||||
//else
|
|
||||||
// norma_all_adc();
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
analog.iqU_1 = iq_norm_ADC[0][0] - analog_zero.iqU_1;
|
|
||||||
analog.iqU_2 = iq_norm_ADC[0][1] - analog_zero.iqU_2;
|
|
||||||
|
|
||||||
analog.iqIu_1 = iq_norm_ADC[0][2];
|
|
||||||
analog.iqIv_1 = iq_norm_ADC[0][3];
|
|
||||||
analog.iqIw_1 = iq_norm_ADC[0][4];
|
|
||||||
|
|
||||||
analog.iqIu_2 = iq_norm_ADC[0][5];
|
|
||||||
analog.iqIv_2 = iq_norm_ADC[0][6];
|
|
||||||
analog.iqIw_2 = iq_norm_ADC[0][7];
|
|
||||||
|
|
||||||
analog.iqIin_1 = -iq_norm_ADC[0][9]; // äàò÷èê ïåðåâåðíóò
|
|
||||||
analog.iqIin_2 = -iq_norm_ADC[0][9]; // äàò÷èê ïåðåâåðíóò
|
|
||||||
|
|
||||||
analog.iqUin_A1B1 = iq_norm_ADC[0][10];
|
|
||||||
|
|
||||||
// äâà âàðèàíòà ïîäêëþ÷åíèÿ äàò÷èêîâ 23550.1 áîëåå ïðàâèëüíûé - ïî ñõåìå
|
|
||||||
// 23550.1
|
|
||||||
|
|
||||||
analog.iqUin_B1C1 = iq_norm_ADC[0][11]; // 23550.1
|
|
||||||
analog.iqUin_A2B2 = iq_norm_ADC[0][12]; // 23550.1
|
|
||||||
|
|
||||||
// 23550.3 bs1 bs2
|
|
||||||
|
|
||||||
// analog.iqUin_B1C1 = iq_norm_ADC[0][12]; // 23550.3
|
|
||||||
// analog.iqUin_A2B2 = iq_norm_ADC[0][11]; // 23550.3
|
|
||||||
//
|
|
||||||
|
|
||||||
|
|
||||||
analog.iqUin_C1A1 = -(analog.iqUin_A1B1 + analog.iqUin_B1C1);
|
|
||||||
|
|
||||||
|
|
||||||
analog.iqUin_B2C2 = iq_norm_ADC[0][13];
|
|
||||||
analog.iqUin_C2A2 = -(analog.iqUin_A2B2 + analog.iqUin_B2C2);
|
|
||||||
|
|
||||||
|
|
||||||
analog.iqIbreak_1 = iq_norm_ADC[0][14];
|
|
||||||
analog.iqIbreak_2 = iq_norm_ADC[0][15];
|
|
||||||
|
|
||||||
#if (_FLOOR6==1)
|
#if (_FLOOR6==1)
|
||||||
|
|
||||||
@ -1266,10 +1185,87 @@ void calc_norm_ADC(int fast)
|
|||||||
analog.T_Air_04 = iq_norm_ADC[1][13];
|
analog.T_Air_04 = iq_norm_ADC[1][13];
|
||||||
|
|
||||||
|
|
||||||
|
#endif
|
||||||
|
#else
|
||||||
|
|
||||||
|
analog.T_U01 =
|
||||||
|
analog.T_U02 =
|
||||||
|
analog.T_U03 =
|
||||||
|
analog.T_U04 =
|
||||||
|
analog.T_U05 =
|
||||||
|
analog.T_U06 =
|
||||||
|
analog.T_U07 =
|
||||||
|
analog.T_Water_external =
|
||||||
|
analog.T_Water_internal =
|
||||||
|
|
||||||
|
analog.P_Water_internal =
|
||||||
|
|
||||||
|
analog.T_Air_01 =
|
||||||
|
analog.T_Air_02 =
|
||||||
|
analog.T_Air_03 =
|
||||||
|
analog.T_Air_04 = 0;
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
// analog.iqI_vozbud = iq_norm_ADC[1][13];
|
// analog.iqI_vozbud = iq_norm_ADC[1][13];
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
////////////////////////////////////////////////////////////////////
|
||||||
|
#pragma CODE_SECTION(calc_norm_ADC_0,".fast_run");
|
||||||
|
void calc_norm_ADC_0(int run_norma)
|
||||||
|
{
|
||||||
|
_iq a1,a2,a3;
|
||||||
|
|
||||||
|
#if (USE_ADC_0)
|
||||||
|
|
||||||
|
if (run_norma)
|
||||||
|
norma_adc_nc(0);
|
||||||
|
|
||||||
|
#if (_FLOOR6)
|
||||||
|
analog.iqU_1 = iq_norm_ADC[0][0] - analog_zero.iqU_1 + analog.iqU_1_imit;
|
||||||
|
analog.iqU_2 = iq_norm_ADC[0][1] - analog_zero.iqU_2 + analog.iqU_1_imit;
|
||||||
|
#else
|
||||||
|
analog.iqU_1 = iq_norm_ADC[0][0] - analog_zero.iqU_1;
|
||||||
|
analog.iqU_2 = iq_norm_ADC[0][1] - analog_zero.iqU_2;
|
||||||
|
#endif
|
||||||
|
analog.iqIu_1 = iq_norm_ADC[0][2];
|
||||||
|
analog.iqIv_1 = iq_norm_ADC[0][3];
|
||||||
|
analog.iqIw_1 = iq_norm_ADC[0][4];
|
||||||
|
|
||||||
|
analog.iqIu_2 = iq_norm_ADC[0][5];
|
||||||
|
analog.iqIv_2 = iq_norm_ADC[0][6];
|
||||||
|
analog.iqIw_2 = iq_norm_ADC[0][7];
|
||||||
|
|
||||||
|
analog.iqIin_1 = -iq_norm_ADC[0][9]; // äàò÷èê ïåðåâåðíóò
|
||||||
|
analog.iqIin_2 = -iq_norm_ADC[0][9]; // äàò÷èê ïåðåâåðíóò
|
||||||
|
|
||||||
|
analog.iqUin_A1B1 = iq_norm_ADC[0][10];
|
||||||
|
|
||||||
|
// äâà âàðèàíòà ïîäêëþ÷åíèÿ äàò÷èêîâ 23550.1 áîëåå ïðàâèëüíûé - ïî ñõåìå
|
||||||
|
// 23550.1
|
||||||
|
|
||||||
|
analog.iqUin_B1C1 = iq_norm_ADC[0][11]; // 23550.1
|
||||||
|
analog.iqUin_A2B2 = iq_norm_ADC[0][12]; // 23550.1
|
||||||
|
|
||||||
|
// 23550.3 bs1 bs2
|
||||||
|
|
||||||
|
// analog.iqUin_B1C1 = iq_norm_ADC[0][12]; // 23550.3
|
||||||
|
// analog.iqUin_A2B2 = iq_norm_ADC[0][11]; // 23550.3
|
||||||
|
//
|
||||||
|
analog.iqUin_B2C2 = iq_norm_ADC[0][13];
|
||||||
|
|
||||||
|
analog.iqIbreak_1 = iq_norm_ADC[0][14];
|
||||||
|
analog.iqIbreak_2 = iq_norm_ADC[0][15];
|
||||||
|
|
||||||
|
#else
|
||||||
|
analog.iqU_1 = analog.iqIu_1 = analog.iqIu_2 = analog.iqIv_1 = analog.iqIv_2 =
|
||||||
|
analog.iqIw_1 = analog.iqIw_2 = analog.iqIin_1 = analog.iqIin_2 = analog.iqUin_A1B1 =
|
||||||
|
analog.iqUin_B1C1 = analog.iqUin_A2B2 = analog.iqUin_B2C2 = analog.iqIbreak_1 = analog.iqIbreak_2
|
||||||
|
= 0;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
analog.iqUin_C1A1 = -(analog.iqUin_A1B1 + analog.iqUin_B1C1);
|
||||||
|
analog.iqUin_C2A2 = -(analog.iqUin_A2B2 + analog.iqUin_B2C2);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@ -1339,11 +1335,8 @@ void calc_norm_ADC(int fast)
|
|||||||
a3 = _IQmpy(a1,a2);
|
a3 = _IQmpy(a1,a2);
|
||||||
analog.PowerScalar = a3;
|
analog.PowerScalar = a3;
|
||||||
// filter.Power = analog.iqU_1+analog.iqU_2;
|
// filter.Power = analog.iqU_1+analog.iqU_2;
|
||||||
filter.PowerScalar = exp_regul_iq(koef_Im_filter, filter.PowerScalar, analog.PowerScalar);
|
filter.PowerScalar = exp_regul_iq(koef_Power_filter, filter.PowerScalar, analog.PowerScalar);
|
||||||
|
filter.PowerScalarFilter2 = exp_regul_iq(koef_Power_filter2, filter.PowerScalarFilter2, filter.PowerScalar);
|
||||||
//i_led1_on_off(0);
|
|
||||||
|
|
||||||
//i_led1_on_off(1);
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1374,7 +1367,10 @@ void detect_zero_analog(int nc)
|
|||||||
|
|
||||||
for (i=0; i<COUNT_DETECT_ZERO; i++)
|
for (i=0; i<COUNT_DETECT_ZERO; i++)
|
||||||
{
|
{
|
||||||
norma_all_adc();
|
// norma_all_adc();
|
||||||
|
norma_adc_nc(nc);
|
||||||
|
// norma_adc_nc(1);
|
||||||
|
|
||||||
|
|
||||||
for (k=0;k<16;k++)
|
for (k=0;k<16;k++)
|
||||||
{
|
{
|
||||||
|
@ -5,39 +5,17 @@
|
|||||||
|
|
||||||
#include "IQmathLib.h"
|
#include "IQmathLib.h"
|
||||||
#include "xp_project.h"
|
#include "xp_project.h"
|
||||||
|
#include "params_norma.h"
|
||||||
|
|
||||||
|
|
||||||
#define COUNT_DETECT_ZERO 3000
|
#define COUNT_DETECT_ZERO 3000
|
||||||
|
|
||||||
#define COUNT_ARR_ADC_BUF_FAST_POINT 10
|
#define COUNT_ARR_ADC_BUF_FAST_POINT 10
|
||||||
|
|
||||||
#define NORMA_ACP 3000.0
|
|
||||||
#define NORMA_ACP_TEMPER_MILL_AMP 100.0 //
|
|
||||||
|
|
||||||
#ifndef PROJECT_SHIP
|
|
||||||
#error Íå óñòàíîâëåí PROJECT_SHIP â predifine Name
|
|
||||||
#else
|
|
||||||
|
|
||||||
|
|
||||||
#if (PROJECT_SHIP == 1)
|
|
||||||
#define NORMA_ACP_TEMPER 100.0 // äëÿ 23550.1
|
|
||||||
#endif
|
|
||||||
|
|
||||||
|
|
||||||
#if (PROJECT_SHIP == 2)
|
|
||||||
#define NORMA_ACP_TEMPER 200.0 // äëÿ 23550.3
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#if (PROJECT_SHIP== 3)
|
|
||||||
#define NORMA_ACP_TEMPER 200.0 // äëÿ 23550.3
|
|
||||||
|
|
||||||
#endif
|
|
||||||
|
|
||||||
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#define DELTA_ACP_TEMPER 0.0 // äàò÷èêè áëîêè pt100 äàåþò ïîñòîÿííîå ñìåùåíèå 0.0 ãðàäóñîâ, òàê íàñòðîåí áëîê SG3013
|
#define DELTA_ACP_TEMPER 0.0 // äàò÷èêè áëîêè pt100 äàåþò ïîñòîÿííîå ñìåùåíèå 0.0 ãðàäóñîâ, òàê íàñòðîåí áëîê SG3013
|
||||||
|
|
||||||
#define NORMA_ACP_P 100.0
|
|
||||||
#define ADC_READ_FROM_PARALLEL_BUS 1
|
#define ADC_READ_FROM_PARALLEL_BUS 1
|
||||||
|
|
||||||
#define DEFAULT_ZERO_ADC 2048
|
#define DEFAULT_ZERO_ADC 2048
|
||||||
@ -257,7 +235,7 @@ typedef struct
|
|||||||
_iq iqUin_m2;
|
_iq iqUin_m2;
|
||||||
|
|
||||||
_iq iqIbreak_1;
|
_iq iqIbreak_1;
|
||||||
_iq iqIbreak_2;
|
_iq iqIbreak_2; //39
|
||||||
|
|
||||||
_iq T_U01;
|
_iq T_U01;
|
||||||
_iq T_U02;
|
_iq T_U02;
|
||||||
@ -275,7 +253,7 @@ typedef struct
|
|||||||
_iq T_Air_03;
|
_iq T_Air_03;
|
||||||
_iq T_Air_04;
|
_iq T_Air_04;
|
||||||
|
|
||||||
_iq P_Water_internal;
|
_iq P_Water_internal; //53
|
||||||
|
|
||||||
|
|
||||||
_iq iqI_vozbud;
|
_iq iqI_vozbud;
|
||||||
@ -291,8 +269,11 @@ typedef struct
|
|||||||
_iq iqM;
|
_iq iqM;
|
||||||
|
|
||||||
_iq PowerScalar;
|
_iq PowerScalar;
|
||||||
|
_iq PowerScalarFilter2;
|
||||||
_iq PowerFOC;
|
_iq PowerFOC;
|
||||||
|
|
||||||
|
_iq iqU_1_imit; //63
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
_iq iqUzpt_1_2; //uzpt1 bs2
|
_iq iqUzpt_1_2; //uzpt1 bs2
|
||||||
@ -360,7 +341,7 @@ typedef struct
|
|||||||
|
|
||||||
|
|
||||||
#define ANALOG_VALUE_DEFAULT {0,0,0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0,0,0,\
|
#define ANALOG_VALUE_DEFAULT {0,0,0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0,0,0,\
|
||||||
0,0,0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0,0,0, 0}
|
0,0,0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0,0,0, 0,0, 0}
|
||||||
/* Ãëîáàëüíày ñòðóêòóðà çíà÷åíèé òîêîâ è íàïðyæåíèé ÀÈÍ */
|
/* Ãëîáàëüíày ñòðóêòóðà çíà÷åíèé òîêîâ è íàïðyæåíèé ÀÈÍ */
|
||||||
|
|
||||||
|
|
||||||
@ -388,8 +369,12 @@ extern ANALOG_VALUE analog;
|
|||||||
extern ANALOG_VALUE filter;
|
extern ANALOG_VALUE filter;
|
||||||
extern ANALOG_VALUE analog_zero;
|
extern ANALOG_VALUE analog_zero;
|
||||||
|
|
||||||
void calc_norm_ADC(int fast);
|
//void calc_norm_ADC(int fast);
|
||||||
|
void calc_norm_ADC_0(int run_norma);
|
||||||
|
void calc_norm_ADC_1(int run_norma);
|
||||||
void Init_Adc_Variables(void);
|
void Init_Adc_Variables(void);
|
||||||
|
void norma_adc_nc(int nc);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
extern int ADC_f[COUNT_ARR_ADC_BUF][16];
|
extern int ADC_f[COUNT_ARR_ADC_BUF][16];
|
||||||
@ -401,8 +386,8 @@ extern unsigned int R_ADC[COUNT_ARR_ADC_BUF][16];
|
|||||||
extern unsigned int K_LEM_ADC[COUNT_ARR_ADC_BUF][16];
|
extern unsigned int K_LEM_ADC[COUNT_ARR_ADC_BUF][16];
|
||||||
extern float K_NORMA_ADC[COUNT_ARR_ADC_BUF][16];
|
extern float K_NORMA_ADC[COUNT_ARR_ADC_BUF][16];
|
||||||
|
|
||||||
void norma_all_adc(void);
|
//void norma_all_adc(void);
|
||||||
|
extern _iq koef_Uzpt_long_filter, koef_Uzpt_fast_filter, koef_Uin_filter, koef_Im_filter, koef_Power_filter, koef_Power_filter2;
|
||||||
|
|
||||||
void detect_zero_analog(int nc);
|
void detect_zero_analog(int nc);
|
||||||
|
|
||||||
|
@ -8,36 +8,39 @@
|
|||||||
|
|
||||||
#include <alg_simple_scalar.h>
|
#include <alg_simple_scalar.h>
|
||||||
#include <edrk_main.h>
|
#include <edrk_main.h>
|
||||||
#include <log_to_mem.h>
|
//#include <log_to_mem.h>
|
||||||
#include <master_slave.h>
|
#include <master_slave.h>
|
||||||
#include <math.h>
|
#include <math.h>
|
||||||
#include <params_alg.h>
|
#include <params_alg.h>
|
||||||
#include <params_norma.h>
|
#include <params_norma.h>
|
||||||
#include <project.h>
|
#include <project.h>
|
||||||
#include "log_to_mem.h"
|
//#include "log_to_mem.h"
|
||||||
#include "IQmathLib.h"
|
#include "IQmathLib.h"
|
||||||
#include "math_pi.h"
|
#include "math_pi.h"
|
||||||
#include "mathlib.h"
|
#include "mathlib.h"
|
||||||
#include "params_pwm24.h"
|
#include "params_pwm24.h"
|
||||||
|
#include "filter_v1.h"
|
||||||
|
#include "log_to_memory.h"
|
||||||
|
|
||||||
|
|
||||||
#pragma DATA_SECTION(simple_scalar1,".slow_vars");
|
#pragma DATA_SECTION(simple_scalar1,".slow_vars");
|
||||||
ALG_SIMPLE_SCALAR simple_scalar1 = ALG_SIMPLE_SCALAR_DEFAULT;
|
ALG_SIMPLE_SCALAR simple_scalar1 = ALG_SIMPLE_SCALAR_DEFAULT;
|
||||||
|
|
||||||
|
_iq koefBpsi = _IQ(0.05); //0.05
|
||||||
|
|
||||||
void init_simple_scalar(void)
|
void init_simple_scalar(void)
|
||||||
{
|
{
|
||||||
simple_scalar1.mzz_add_1 = _IQ(MZZ_ADD_1/NORMA_MZZ);
|
simple_scalar1.mzz_add_1 = _IQ(MZZ_ADD_1/NORMA_MZZ);
|
||||||
simple_scalar1.mzz_add_2 = _IQ(MZZ_ADD_2/NORMA_MZZ);
|
simple_scalar1.mzz_add_2 = _IQ(MZZ_ADD_2/NORMA_MZZ);
|
||||||
|
simple_scalar1.mzz_add_3 = _IQ(MZZ_ADD_3/NORMA_MZZ);
|
||||||
|
|
||||||
simple_scalar1.poluses = _IQ(POLUS);
|
simple_scalar1.poluses = _IQ(POLUS);
|
||||||
simple_scalar1.iq_mzz_max_for_fzad = _IQ(1000.0/NORMA_MZZ);
|
simple_scalar1.iq_mzz_max_for_fzad = _IQ(1000.0/NORMA_MZZ);
|
||||||
|
|
||||||
simple_scalar1.powerzad_add = _IQ(POWERZAD_ADD_MAX);
|
simple_scalar1.powerzad_add = _IQ(POWERZAD_ADD_MAX);
|
||||||
simple_scalar1.powerzad_dec = _IQ(POWERZAD_DEC);
|
simple_scalar1.powerzad_dec = _IQ(POWERZAD_DEC);
|
||||||
|
|
||||||
simple_scalar1.k_freq_for_pid = _IQ(1.0);
|
// simple_scalar1.k_freq_for_pid = _IQ(1.0);
|
||||||
simple_scalar1.k_freq_for_pid = _IQ(450.0/FREQ_PWM);
|
simple_scalar1.k_freq_for_pid = _IQ(450.0/FREQ_PWM);
|
||||||
|
|
||||||
simple_scalar1.iq_add_kp_df = _IQ(ADD_KP_DF);
|
simple_scalar1.iq_add_kp_df = _IQ(ADD_KP_DF);
|
||||||
@ -60,7 +63,7 @@ void init_simple_scalar(void)
|
|||||||
|
|
||||||
|
|
||||||
simple_scalar1.pidIm1.OutMax=_IQ(K_STATOR_MAX);
|
simple_scalar1.pidIm1.OutMax=_IQ(K_STATOR_MAX);
|
||||||
simple_scalar1.pidIm1.OutMin=_IQ(0);
|
simple_scalar1.pidIm1.OutMin=_IQ(K_STATOR_MIN);
|
||||||
|
|
||||||
//////////////
|
//////////////
|
||||||
|
|
||||||
@ -97,7 +100,8 @@ void init_simple_scalar(void)
|
|||||||
|
|
||||||
|
|
||||||
// ìèí. ñêîëüæåíèå
|
// ìèí. ñêîëüæåíèå
|
||||||
simple_scalar1.min_bpsi = _IQ(0.05/NORMA_FROTOR);
|
simple_scalar1.min_bpsi = _IQ(BPSI_MINIMAL/NORMA_FROTOR);
|
||||||
|
simple_scalar1.max_bpsi = _IQ(BPSI_MAXIMAL/NORMA_FROTOR);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -118,14 +122,32 @@ void init_simple_scalar(void)
|
|||||||
Èäåò ğàñ÷åò íàïğyæåíèy ÷åğåç ìîäóëü òîêà ïî îäíîé èç 3-õ ôàçíîé ñòîåê.
|
Èäåò ğàñ÷åò íàïğyæåíèy ÷åğåç ìîäóëü òîêà ïî îäíîé èç 3-õ ôàçíîé ñòîåê.
|
||||||
Çàìûêàåòñy îáğàòíày ñâyçü ïî îáîğîòàì */
|
Çàìûêàåòñy îáğàòíày ñâyçü ïî îáîğîòàì */
|
||||||
/****************************************************************/
|
/****************************************************************/
|
||||||
|
|
||||||
|
|
||||||
//#pragma CODE_SECTION(simple_scalar,".fast_run");
|
//#pragma CODE_SECTION(simple_scalar,".fast_run");
|
||||||
void simple_scalar(int n_alg, int n_wind_pump,
|
void simple_scalar(int n_alg,
|
||||||
_iq Frot_pid,_iq Frot, _iq fzad,
|
int n_wind_pump,
|
||||||
|
int direction,
|
||||||
|
_iq Frot_pid,
|
||||||
|
_iq Frot,
|
||||||
|
_iq fzad,
|
||||||
_iq iqKoefOgran,
|
_iq iqKoefOgran,
|
||||||
_iq mzz_zad, _iq bpsi_const,
|
_iq mzz_zad,
|
||||||
_iq iqIm, _iq iqUin, _iq Iin, _iq powerzad, _iq power_pid,
|
_iq bpsi_const,
|
||||||
_iq Izad_from_master, int master,
|
_iq iqIm,
|
||||||
_iq *Fz, _iq *Uz1, _iq *Uz2, _iq *Izad_out)
|
_iq iqUin,
|
||||||
|
_iq Iin,
|
||||||
|
_iq powerzad,
|
||||||
|
_iq power_pid,
|
||||||
|
_iq power_limit,
|
||||||
|
int mode_oborots_power,
|
||||||
|
_iq Izad_from_master,
|
||||||
|
int master,
|
||||||
|
int count_bs_work,
|
||||||
|
_iq *Fz,
|
||||||
|
_iq *Uz1,
|
||||||
|
_iq *Uz2,
|
||||||
|
_iq *Izad_out)
|
||||||
{
|
{
|
||||||
|
|
||||||
_iq mzz, dF, dI1, Izad, Uz_t1, Kpred_Ip, pred_Ip;//, znak_moment;
|
_iq mzz, dF, dI1, Izad, Uz_t1, Kpred_Ip, pred_Ip;//, znak_moment;
|
||||||
@ -135,6 +157,7 @@ void simple_scalar(int n_alg, int n_wind_pump,
|
|||||||
_iq Im_regul=0;
|
_iq Im_regul=0;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
static _iq bpsi=0;
|
static _iq bpsi=0;
|
||||||
// static _iq IQ_POLUS=0;
|
// static _iq IQ_POLUS=0;
|
||||||
|
|
||||||
@ -168,7 +191,7 @@ void simple_scalar(int n_alg, int n_wind_pump,
|
|||||||
static _iq fzad_add=0; //fzad_dec
|
static _iq fzad_add=0; //fzad_dec
|
||||||
_iq halfIm1, halfIm2;
|
_iq halfIm1, halfIm2;
|
||||||
|
|
||||||
static _iq powerzad_int=0, powerzad_add_max=0 ;
|
static _iq powerzad_int=0, powerzad_add_max=0, pidFOutMax = 0, pidFOutMin = 0 ;
|
||||||
//powerzad_dec powerzad_add
|
//powerzad_dec powerzad_add
|
||||||
// static _iq koef_bpsi=0;
|
// static _iq koef_bpsi=0;
|
||||||
// static _iq min_bpsi=0;
|
// static _iq min_bpsi=0;
|
||||||
@ -183,15 +206,217 @@ void simple_scalar(int n_alg, int n_wind_pump,
|
|||||||
|
|
||||||
// static _iq iq_spad_k=1;
|
// static _iq iq_spad_k=1;
|
||||||
static _iq myq_temp=0;
|
static _iq myq_temp=0;
|
||||||
|
static _iq bpsi_filter=0;
|
||||||
|
static _iq _iq_koef_im_on_tormog = _IQ(KOEF_IM_ON_TORMOG);
|
||||||
|
static _iq _iq_koef_im_on_tormog_max_temper_break = _IQ(KOEF_IM_ON_TORMOG_WITH_MAX_TEMPER_BREAK);
|
||||||
|
static _iq n_iq_koef_im_on_tormog = CONST_IQ_1, t_iq_koef_im_on_tormog = CONST_IQ_1;
|
||||||
|
|
||||||
|
static _iq _iq_koef_im_on_tormog_add =_IQ(0.0005), _iq_koef_im_on_tormog_dec = _IQ(0.01);
|
||||||
|
|
||||||
|
// static _iq F_revers_level00= _IQ(70.0/60.0/NORMA_FROTOR);
|
||||||
|
static _iq F_revers_level0 = _IQ(90.0/60.0/NORMA_FROTOR);
|
||||||
|
static _iq F_revers_level1 = _IQ(100.0/60.0/NORMA_FROTOR);
|
||||||
|
static _iq F_revers_level2 = _IQ(110.0/60.0/NORMA_FROTOR);
|
||||||
|
static _iq F_revers_level3 = _IQ(120.0/60.0/NORMA_FROTOR);
|
||||||
|
static _iq F_revers_level4 = _IQ(130.0/60.0/NORMA_FROTOR);
|
||||||
|
static _iq F_revers_level5 = _IQ(140.0/60.0/NORMA_FROTOR);
|
||||||
|
static _iq F_revers_level6 = _IQ(150.0/60.0/NORMA_FROTOR);
|
||||||
|
static _iq F_revers_level7 = _IQ(160.0/60.0/NORMA_FROTOR);
|
||||||
|
static _iq F_revers_level8 = _IQ(170.0/60.0/NORMA_FROTOR);
|
||||||
|
static _iq F_revers_level9 = _IQ(180.0/60.0/NORMA_FROTOR);
|
||||||
|
static _iq F_revers_level10 = _IQ(190.0/60.0/NORMA_FROTOR);
|
||||||
|
static _iq F_revers_level11 = _IQ(200.0/60.0/NORMA_FROTOR);
|
||||||
|
static _iq F_revers_level12 = _IQ(210.0/60.0/NORMA_FROTOR);
|
||||||
|
static _iq F_revers_level13 = _IQ(220.0/60.0/NORMA_FROTOR);
|
||||||
|
|
||||||
|
static _iq kF_revers_level00 = _IQ(0.65);
|
||||||
|
static _iq kF_revers_level0 = _IQ(0.70);
|
||||||
|
static _iq kF_revers_level1 = _IQ(0.75);
|
||||||
|
static _iq kF_revers_level2 = _IQ(0.78);
|
||||||
|
static _iq kF_revers_level3 = _IQ(0.80);
|
||||||
|
static _iq kF_revers_level4 = _IQ(0.82);
|
||||||
|
static _iq kF_revers_level5 = _IQ(0.84);
|
||||||
|
static _iq kF_revers_level6 = _IQ(0.86);
|
||||||
|
static _iq kF_revers_level7 = _IQ(0.88);
|
||||||
|
static _iq kF_revers_level8 = _IQ(0.90);
|
||||||
|
static _iq kF_revers_level9 = _IQ(0.91);
|
||||||
|
static _iq kF_revers_level10 = _IQ(0.92);
|
||||||
|
static _iq kF_revers_level11 = _IQ(0.93);
|
||||||
|
static _iq kF_revers_level12 = _IQ(0.94);
|
||||||
|
static _iq kF_revers_level13 = _IQ(0.96);
|
||||||
|
|
||||||
|
|
||||||
|
static _iq P_level0 = _IQ(70.0/60.0/NORMA_FROTOR);
|
||||||
|
static _iq P_level1 = _IQ(150.0/60.0/NORMA_FROTOR);
|
||||||
|
static _iq P_level2 = _IQ(160.0/60.0/NORMA_FROTOR);
|
||||||
|
static _iq P_level3 = _IQ(170.0/60.0/NORMA_FROTOR);
|
||||||
|
static _iq P_level4 = _IQ(180.0/60.0/NORMA_FROTOR);
|
||||||
|
static _iq P_level5 = _IQ(190.0/60.0/NORMA_FROTOR);
|
||||||
|
static _iq P_level6 = _IQ(200.0/60.0/NORMA_FROTOR);
|
||||||
|
static _iq P_level7 = _IQ(210.0/60.0/NORMA_FROTOR);
|
||||||
|
static _iq P_level8 = _IQ(220.0/60.0/NORMA_FROTOR);
|
||||||
|
static _iq P_level9 = _IQ(230.0/60.0/NORMA_FROTOR);
|
||||||
|
// static _iq P_level9 = _IQ(300.0/60.0/NORMA_FROTOR);
|
||||||
|
|
||||||
|
static _iq kP_level0 = _IQ(0.9);
|
||||||
|
static _iq kP_level1 = _IQ(0.9);
|
||||||
|
static _iq kP_level2 = _IQ(0.9);
|
||||||
|
static _iq kP_level3 = _IQ(0.85);
|
||||||
|
static _iq kP_level4 = _IQ(0.8);
|
||||||
|
static _iq kP_level5 = _IQ(0.75);
|
||||||
|
static _iq kP_level6 = _IQ(0.7);
|
||||||
|
static _iq kP_level7 = _IQ(0.65);
|
||||||
|
static _iq kP_level8 = _IQ(0.6);
|
||||||
|
static _iq kP_level9 = _IQ(0.55);
|
||||||
|
|
||||||
|
static _iq pid_kp_power = _IQ(PID_KP_POWER);
|
||||||
|
static _iq add_mzz_outmax_pidp = _IQ(100.0/NORMA_MZZ);
|
||||||
|
_iq new_pidP_OutMax = 0;
|
||||||
|
|
||||||
|
_iq k_ogr_p_koef_1 = 0;
|
||||||
|
_iq k_ogr_p_koef_2 = 0;
|
||||||
|
|
||||||
|
_iq k_ogr_n = 0;
|
||||||
|
|
||||||
|
|
||||||
|
_iq Frot_pid_abs;
|
||||||
|
|
||||||
|
_iq d_m=0;
|
||||||
|
|
||||||
|
_iq iq_decr_mzz_power;
|
||||||
|
|
||||||
|
_iq level1_power_ain_decr_mzz, level2_power_ain_decr_mzz;
|
||||||
|
_iq new_power_limit = 0;
|
||||||
|
|
||||||
|
static _iq koef_Power_filter2 = _IQ(1.0/(FREQ_PWM*EXP_FILTER_KOEF_OGRAN_POWER_LIMIT));//2.2 ñåê //30000;// 0,0012//16777;//0,001//13981;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
Frot_pid_abs = _IQabs(Frot_pid);
|
||||||
|
|
||||||
|
// ïîïûòêà ïåðåñ÷èòàòü pidPower.Kp íà ëåòó
|
||||||
|
//
|
||||||
|
// if (Frot_pid_abs>=P_level0)
|
||||||
|
// {
|
||||||
|
// k_ogr_p_koef_1 = CONST_IQ_1 - _IQdiv( (Frot_pid_abs-P_level0) , (P_level9-P_level0) );
|
||||||
|
// if (k_ogr_p_koef_1<0) k_ogr_p_koef_1 = 0;
|
||||||
|
// }
|
||||||
|
// else
|
||||||
|
// k_ogr_p_koef_1 = CONST_IQ_1;
|
||||||
|
//
|
||||||
|
// //k_ogr_p_koef_1 ìåíÿåòñÿ îò 1 äî 0 ñ
|
||||||
|
//
|
||||||
|
// k_ogr_p_koef_2 = CONST_IQ_01 + _IQmpy(CONST_IQ_09, k_ogr_p_koef_1);
|
||||||
|
|
||||||
|
// simple_scalar1.pidPower.Kp = _IQmpy (pid_kp_power, k_ogr_p_koef_2);// _IQ(PID_KP_POWER)
|
||||||
|
|
||||||
|
simple_scalar1.pidPower.Kp = pid_kp_power;//_IQmpy (pid_kp_power, k_ogr_p_koef_2);// _IQ(PID_KP_POWER)
|
||||||
|
|
||||||
|
if (mode_oborots_power == ALG_MODE_SCALAR_OBOROTS)
|
||||||
|
{
|
||||||
|
if (simple_scalar1.cmd_new_calc_p_limit)
|
||||||
|
{
|
||||||
|
simple_scalar1.flag_decr_mzz_power = 0;
|
||||||
|
simple_scalar1.iq_decr_mzz_power_filter = CONST_IQ_1;
|
||||||
|
simple_scalar1.iq_decr_mzz_power = CONST_IQ_1;
|
||||||
|
new_power_limit = power_limit;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
// ðàñ÷åò êîýô îãðàíè÷åíèÿ ìîùíîñòè ïî ïðåâûøåíèþ çàïàñà, âûøå ëèìèòà
|
||||||
|
// åñëè òåê ìîùíîñòü ïðèáëèæàåòñÿ ê ëèìèòó òî íà÷èíàåì ïðîïîðóöèîíàëüíî óìåíüøàòü òîê ÷åðåç êîýô.
|
||||||
|
// simple_scalar1.iq_decr_mzz_power_filter êîòîðûé èäåò îò 1.0 - íåò îãðàíè÷åíèÿ,
|
||||||
|
// äî 1-MAX_KOEF_OGRAN_POWER_LIMIT - ïîëíîå îãðàíè÷åíèå
|
||||||
|
new_power_limit = power_limit - simple_scalar1.sdvig_power_limit;
|
||||||
|
if (new_power_limit<MIN_DELTA_LEVEL_POWER_AIN_DECR_MZZ_DEF)
|
||||||
|
new_power_limit = MIN_DELTA_LEVEL_POWER_AIN_DECR_MZZ_DEF;
|
||||||
|
|
||||||
|
// ïåðâûé óðîâåíü
|
||||||
|
level1_power_ain_decr_mzz = new_power_limit - DELTA_LEVEL_POWER_AIN_DECR_MZZ_DEF - simple_scalar1.add_power_limit;
|
||||||
|
|
||||||
|
if (level1_power_ain_decr_mzz<0)
|
||||||
|
level1_power_ain_decr_mzz = 0;
|
||||||
|
|
||||||
|
// âòîðîé óðîâåíü
|
||||||
|
level2_power_ain_decr_mzz = level1_power_ain_decr_mzz + DELTA_LEVEL_POWER_AIN_DECR_MZZ_DEF + simple_scalar1.add_power_limit;
|
||||||
|
|
||||||
|
// ñìåñòèëè óðîâíè íà SMEWENIE_LEVEL_POWER_AIN_DECR_MZZ_DEF ââåðõ
|
||||||
|
level1_power_ain_decr_mzz = level1_power_ain_decr_mzz + SMEWENIE_LEVEL_POWER_AIN_DECR_MZZ_DEF;
|
||||||
|
level2_power_ain_decr_mzz = level2_power_ain_decr_mzz + SMEWENIE_LEVEL_POWER_AIN_DECR_MZZ_DEF;
|
||||||
|
|
||||||
|
d_m = power_pid - level1_power_ain_decr_mzz;
|
||||||
|
|
||||||
|
if (d_m<0)
|
||||||
|
d_m=0; // âñå â íîðìå
|
||||||
|
else
|
||||||
|
{
|
||||||
|
// ïîðà îãðàíè÷èâàòü ìîìåíò
|
||||||
|
if (d_m>=(level2_power_ain_decr_mzz-level1_power_ain_decr_mzz))
|
||||||
|
d_m = CONST_IQ_1;
|
||||||
|
else
|
||||||
|
d_m = _IQdiv(d_m,(level2_power_ain_decr_mzz - level1_power_ain_decr_mzz));
|
||||||
|
}
|
||||||
|
|
||||||
|
if (d_m<0)
|
||||||
|
d_m=0; // âñå â íîðìå
|
||||||
|
|
||||||
|
if (d_m>CONST_IQ_1)
|
||||||
|
d_m=CONST_IQ_1; // ïîëíîå îãðàíè÷åíèå
|
||||||
|
|
||||||
|
// ïåðåâåëè óðîâåíü îò 1.0 äî 0.0 â óðîâåíü îò MAX_KOEF_OGRAN_POWER_LIMIT äî 0.0
|
||||||
|
d_m = _IQmpy(d_m, MAX_KOEF_OGRAN_POWER_LIMIT); //
|
||||||
|
|
||||||
|
simple_scalar1.iq_decr_mzz_power = CONST_IQ_1 - d_m;// òåïåðü êîýô ìåíÿåòñÿ îò 1.0 - íåò îãðàí. äî MAX_KOEF_OGRAN_POWER_LIMIT ìàêñ. îãðàíè÷.
|
||||||
|
|
||||||
|
if (simple_scalar1.iq_decr_mzz_power<0)
|
||||||
|
simple_scalar1.iq_decr_mzz_power=0;
|
||||||
|
|
||||||
|
|
||||||
|
simple_scalar1.iq_decr_mzz_power_filter = exp_regul_iq(koef_Power_filter2,
|
||||||
|
simple_scalar1.iq_decr_mzz_power_filter,
|
||||||
|
simple_scalar1.iq_decr_mzz_power);
|
||||||
|
|
||||||
|
if (simple_scalar1.iq_decr_mzz_power_filter<0)
|
||||||
|
simple_scalar1.iq_decr_mzz_power_filter = 0;
|
||||||
|
|
||||||
|
|
||||||
|
if (d_m>0)
|
||||||
|
simple_scalar1.flag_decr_mzz_power = 1;
|
||||||
|
else
|
||||||
|
simple_scalar1.flag_decr_mzz_power=0;
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
simple_scalar1.flag_decr_mzz_power = 0;
|
||||||
|
simple_scalar1.iq_decr_mzz_power_filter = CONST_IQ_1;
|
||||||
|
simple_scalar1.iq_decr_mzz_power = CONST_IQ_1;
|
||||||
|
new_power_limit = power_limit;
|
||||||
|
}
|
||||||
|
|
||||||
|
#if (ENABLE_DECR_MZZ_POWER_IZAD)
|
||||||
|
if (simple_scalar1.disable_KoefOgranIzad==0)
|
||||||
|
simple_scalar1.iqKoefOgranIzad = _IQmpy(iqKoefOgran,simple_scalar1.iq_decr_mzz_power_filter);
|
||||||
|
else
|
||||||
|
simple_scalar1.iqKoefOgranIzad = iqKoefOgran;
|
||||||
|
#else
|
||||||
|
simple_scalar1.iqKoefOgranIzad = iqKoefOgran;
|
||||||
|
#endif
|
||||||
|
//static _iq _iq_1 = _IQ(1.0);
|
||||||
|
|
||||||
// static _iq mzz_int_level1_on_F=0;
|
// static _iq mzz_int_level1_on_F=0;
|
||||||
|
|
||||||
|
|
||||||
// mzz = _IQsat(mzz,mzz_zad_int,0);
|
// mzz = _IQsat(mzz,mzz_zad_int,0);
|
||||||
|
|
||||||
|
|
||||||
simple_scalar1.mzz_zad = mzz_zad;
|
simple_scalar1.mzz_zad_in1 = mzz_zad;
|
||||||
simple_scalar1.Izad_from_master = Izad_from_master;
|
simple_scalar1.Izad_from_master = Izad_from_master;
|
||||||
|
|
||||||
|
iqKoefOgran = _IQsat(iqKoefOgran,CONST_IQ_1,0);
|
||||||
|
|
||||||
/* óñòàíàâëèâàåì íà÷àëüíûå óñëîâèy âñåõ ğåãóëyòîğîâ */
|
/* óñòàíàâëèâàåì íà÷àëüíûå óñëîâèy âñåõ ğåãóëyòîğîâ */
|
||||||
if ( (Frot==0) && (fzad==0) )
|
if ( (Frot==0) && (fzad==0) )
|
||||||
@ -199,11 +424,16 @@ void simple_scalar(int n_alg, int n_wind_pump,
|
|||||||
mzzi = 0;
|
mzzi = 0;
|
||||||
fzad_int = 0;
|
fzad_int = 0;
|
||||||
powerzad_int = 0;
|
powerzad_int = 0;
|
||||||
|
bpsi_filter = 0;
|
||||||
|
pidFOutMax = pidFOutMin = 0;
|
||||||
|
n_iq_koef_im_on_tormog = CONST_IQ_1;//_IQ(1.0);
|
||||||
|
simple_scalar1.iq_decr_mzz_power_filter = CONST_IQ_1;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (mzz_zad==0)
|
if (mzz_zad==0)
|
||||||
{
|
{
|
||||||
|
bpsi_filter = 0;
|
||||||
mzz=0;
|
mzz=0;
|
||||||
I1_i=0;
|
I1_i=0;
|
||||||
mzzi=0;
|
mzzi=0;
|
||||||
@ -275,6 +505,88 @@ void simple_scalar(int n_alg, int n_wind_pump,
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// îãðàíè÷åíèå ïðè ðåêóïåðàöèè
|
||||||
|
if (direction==0)
|
||||||
|
{
|
||||||
|
// ñòîèì
|
||||||
|
n_iq_koef_im_on_tormog = CONST_IQ_1;//_IQ(1.0);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
if (direction==-1 && fzad <= 0)
|
||||||
|
{
|
||||||
|
// åäåì íàçàä, çàäàíèå ñîâïàäàåò ñ íàïðàâëåíèåì âðàùåíèÿ
|
||||||
|
if (Frot_pid<-F_revers_level13)
|
||||||
|
n_iq_koef_im_on_tormog = kF_revers_level13;
|
||||||
|
else
|
||||||
|
if (Frot_pid<-F_revers_level12)
|
||||||
|
n_iq_koef_im_on_tormog = kF_revers_level12;
|
||||||
|
else
|
||||||
|
if (Frot_pid<-F_revers_level11)
|
||||||
|
n_iq_koef_im_on_tormog = kF_revers_level11;
|
||||||
|
else
|
||||||
|
if (Frot_pid<-F_revers_level10)
|
||||||
|
n_iq_koef_im_on_tormog = kF_revers_level10;
|
||||||
|
else
|
||||||
|
if (Frot_pid<-F_revers_level9)
|
||||||
|
n_iq_koef_im_on_tormog = kF_revers_level9;
|
||||||
|
else
|
||||||
|
if (Frot_pid<-F_revers_level8)
|
||||||
|
n_iq_koef_im_on_tormog = kF_revers_level8;
|
||||||
|
else
|
||||||
|
if (Frot_pid<-F_revers_level7)
|
||||||
|
n_iq_koef_im_on_tormog = kF_revers_level7;
|
||||||
|
else
|
||||||
|
if (Frot_pid<-F_revers_level6)
|
||||||
|
n_iq_koef_im_on_tormog = kF_revers_level6;
|
||||||
|
else
|
||||||
|
if (Frot_pid<-F_revers_level5)
|
||||||
|
n_iq_koef_im_on_tormog = kF_revers_level5;
|
||||||
|
else
|
||||||
|
if (Frot_pid<-F_revers_level4)
|
||||||
|
n_iq_koef_im_on_tormog = kF_revers_level4;
|
||||||
|
else
|
||||||
|
if (Frot_pid<-F_revers_level3)
|
||||||
|
n_iq_koef_im_on_tormog = kF_revers_level3;
|
||||||
|
else
|
||||||
|
if (Frot_pid<-F_revers_level2)
|
||||||
|
n_iq_koef_im_on_tormog = kF_revers_level2;
|
||||||
|
else
|
||||||
|
if (Frot_pid<-F_revers_level1)
|
||||||
|
n_iq_koef_im_on_tormog = kF_revers_level1;
|
||||||
|
if (Frot_pid<-F_revers_level0)
|
||||||
|
n_iq_koef_im_on_tormog = kF_revers_level0;
|
||||||
|
else
|
||||||
|
n_iq_koef_im_on_tormog = kF_revers_level00;
|
||||||
|
|
||||||
|
}
|
||||||
|
else
|
||||||
|
if (direction==1 && fzad>=0)
|
||||||
|
{
|
||||||
|
// åäåì âïåðåä, çàäàíèå ñîâïàäàåò ñ íàïðàâëåíèåì âðàùåíèÿ
|
||||||
|
n_iq_koef_im_on_tormog = CONST_IQ_1;//_IQ(1.0);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
// åñëè ðåêóïåðàöèÿ òî óìåíüøèì òîê â _iq_koef_im_on_tormog ðàç ìåíüøå îò çàäàííîãî
|
||||||
|
// mzz_zad = _IQmpy(mzz_zad, _iq_koef_im_on_tormog);
|
||||||
|
|
||||||
|
if (edrk.warnings.e9.bits.BREAK_TEMPER_ALARM == 1)
|
||||||
|
// åñòü ïåðåãðåâ àâàðèéíûé, ñíèæàåì ìîùíîñòü
|
||||||
|
n_iq_koef_im_on_tormog = _iq_koef_im_on_tormog_max_temper_break;
|
||||||
|
else
|
||||||
|
n_iq_koef_im_on_tormog = _iq_koef_im_on_tormog;
|
||||||
|
}
|
||||||
|
|
||||||
|
t_iq_koef_im_on_tormog = zad_intensiv_q(_iq_koef_im_on_tormog_add,
|
||||||
|
_iq_koef_im_on_tormog_dec,
|
||||||
|
t_iq_koef_im_on_tormog,
|
||||||
|
n_iq_koef_im_on_tormog);
|
||||||
|
|
||||||
|
|
||||||
|
mzz_zad = _IQmpy(mzz_zad, t_iq_koef_im_on_tormog);
|
||||||
|
|
||||||
|
simple_scalar1.mzz_zad_in2 = mzz_zad;
|
||||||
|
|
||||||
/* çàäàò÷èê èíòåíñèâíîñòè ìîìåíòà */
|
/* çàäàò÷èê èíòåíñèâíîñòè ìîìåíòà */
|
||||||
if (n_alg==1)
|
if (n_alg==1)
|
||||||
{
|
{
|
||||||
@ -292,14 +604,14 @@ void simple_scalar(int n_alg, int n_wind_pump,
|
|||||||
if (n_alg==2)
|
if (n_alg==2)
|
||||||
mzz_zad_int = zad_intensiv_q(simple_scalar1.mzz_add_2, simple_scalar1.mzz_add_2, mzz_zad_int, mzz_zad);
|
mzz_zad_int = zad_intensiv_q(simple_scalar1.mzz_add_2, simple_scalar1.mzz_add_2, mzz_zad_int, mzz_zad);
|
||||||
|
|
||||||
myq_temp = _IQdiv(mzz_zad, simple_scalar1.iq_mzz_max_for_fzad);
|
// myq_temp = _IQdiv(mzz_zad, simple_scalar1.iq_mzz_max_for_fzad);
|
||||||
|
// myq_temp = _IQmpy( myq_temp, fzad_add_max);
|
||||||
|
// fzad_add = myq_temp;
|
||||||
|
|
||||||
|
fzad_int = zad_intensiv_q(fzad_add, fzad_add, fzad_int, fzad );
|
||||||
|
|
||||||
myq_temp = _IQsat( myq_temp, simple_scalar1.fzad_add_max, 0);
|
|
||||||
|
|
||||||
fzad_add = myq_temp;
|
|
||||||
|
|
||||||
|
|
||||||
fzad_int = zad_intensiv_q(fzad_add, fzad_add, fzad_int, fzad);
|
|
||||||
|
|
||||||
powerzad_int = zad_intensiv_q(simple_scalar1.powerzad_add, simple_scalar1.powerzad_add, powerzad_int, powerzad);
|
powerzad_int = zad_intensiv_q(simple_scalar1.powerzad_add, simple_scalar1.powerzad_add, powerzad_int, powerzad);
|
||||||
|
|
||||||
@ -308,11 +620,31 @@ void simple_scalar(int n_alg, int n_wind_pump,
|
|||||||
/* ğåãóëyòîğ ñêîğîñòè */
|
/* ğåãóëyòîğ ñêîğîñòè */
|
||||||
if (mzz_zad_int>=0)
|
if (mzz_zad_int>=0)
|
||||||
{
|
{
|
||||||
dF = fzad_int - Frot_pid;
|
dF = fzad_int - Frot_pid;//*direction;
|
||||||
|
|
||||||
////////// Power PI //////////////
|
////////// Power PI //////////////
|
||||||
|
|
||||||
simple_scalar1.pidPower.OutMax=mzz_zad;
|
|
||||||
|
//if (_IQabs(simple_scalar1.pidF.Out))
|
||||||
|
|
||||||
|
k_ogr_n = (_IQabs(power_pid) - _IQabs(powerzad_int));
|
||||||
|
// if (k_ogr_n<0) k_ogr_n = 0;
|
||||||
|
|
||||||
|
k_ogr_n = CONST_IQ_1 - _IQdiv(k_ogr_n, _IQabs(powerzad_int));
|
||||||
|
|
||||||
|
simple_scalar1.k_ogr_n = _IQsat(k_ogr_n,CONST_IQ_1,-CONST_IQ_1);
|
||||||
|
|
||||||
|
|
||||||
|
// íîâîå îãðàíè÷åíèÿ äëÿ pidP OutMax
|
||||||
|
new_pidP_OutMax = _IQabs(simple_scalar1.pidF.Out)+add_mzz_outmax_pidp;
|
||||||
|
new_pidP_OutMax = _IQsat(new_pidP_OutMax, mzz_zad_int, add_mzz_outmax_pidp ); // îò 100 äî ðåçóëüòàòà âûõîäà ðåãóëÿòîðà simple_scalar1.pidF.Out
|
||||||
|
|
||||||
|
// ñòàðûé âàðèàíò îãðàíè÷åíèÿ
|
||||||
|
// new_pidP_OutMax = mzz_zad_int;
|
||||||
|
|
||||||
|
simple_scalar1.pidPower.OutMax = new_pidP_OutMax;
|
||||||
|
simple_scalar1.pidPower.OutMin = 0;
|
||||||
|
|
||||||
|
|
||||||
// pidPower.Kp = _IQmpy( _IQdiv(iq_add_kp_dpower, _IQsat(mzz_zad,mzz_zad,MIN_MZZ_FOR_DPOWER)), pidPower_Kp);
|
// pidPower.Kp = _IQmpy( _IQdiv(iq_add_kp_dpower, _IQsat(mzz_zad,mzz_zad,MIN_MZZ_FOR_DPOWER)), pidPower_Kp);
|
||||||
// pidPower.Ki = _IQmpy( _IQdiv(iq_add_ki_dpower, _IQsat(mzz_zad,mzz_zad,MIN_MZZ_FOR_DPOWER)), pidPower_Ki);
|
// pidPower.Ki = _IQmpy( _IQdiv(iq_add_ki_dpower, _IQsat(mzz_zad,mzz_zad,MIN_MZZ_FOR_DPOWER)), pidPower_Ki);
|
||||||
@ -320,9 +652,9 @@ void simple_scalar(int n_alg, int n_wind_pump,
|
|||||||
// simple_scalar1.pidPower.Ki = _IQmpy(simple_scalar1.pidPower.Ki, simple_scalar1.k_freq_for_pid);
|
// simple_scalar1.pidPower.Ki = _IQmpy(simple_scalar1.pidPower.Ki, simple_scalar1.k_freq_for_pid);
|
||||||
|
|
||||||
|
|
||||||
simple_scalar1.pidPower.Ref = powerzad_int;
|
simple_scalar1.pidPower.Ref = _IQabs(powerzad_int); // òóò òîëüêî ïîëîæèòåëüíàÿ ìîùíîñòü
|
||||||
|
|
||||||
simple_scalar1.pidPower.Fdb = power_pid;
|
simple_scalar1.pidPower.Fdb = _IQabs(power_pid);
|
||||||
simple_scalar1.pidPower.calc(&simple_scalar1.pidPower);
|
simple_scalar1.pidPower.calc(&simple_scalar1.pidPower);
|
||||||
|
|
||||||
|
|
||||||
@ -342,12 +674,56 @@ void simple_scalar(int n_alg, int n_wind_pump,
|
|||||||
// pidF.OutMax=mzz_zad_int;
|
// pidF.OutMax=mzz_zad_int;
|
||||||
// èëè òàê
|
// èëè òàê
|
||||||
|
|
||||||
simple_scalar1.pidF.OutMax = simple_scalar1.pidPower.Out;
|
pidFOutMax = zad_intensiv_q(simple_scalar1.mzz_add_3, simple_scalar1.mzz_add_1, pidFOutMax, simple_scalar1.pidPower.Out);
|
||||||
|
pidFOutMin = zad_intensiv_q(simple_scalar1.mzz_add_3, simple_scalar1.mzz_add_1, pidFOutMin, simple_scalar1.pidPower.Out);
|
||||||
|
|
||||||
|
|
||||||
|
// fzad
|
||||||
|
if (direction==-1 && fzad <= 0)
|
||||||
|
{
|
||||||
|
pidFOutMax = 0;
|
||||||
|
simple_scalar1.pidF.OutMax = 0;//simple_scalar1.pidPower.Out;
|
||||||
|
simple_scalar1.pidF.OutMin = -pidFOutMin;//-simple_scalar1.pidPower.Out;
|
||||||
|
|
||||||
|
}
|
||||||
|
else
|
||||||
|
if (direction==1 && fzad>=0)
|
||||||
|
{
|
||||||
|
pidFOutMin = 0;
|
||||||
|
simple_scalar1.pidF.OutMax = pidFOutMax;//simple_scalar1.pidPower.Out;
|
||||||
|
simple_scalar1.pidF.OutMin = 0;//-simple_scalar1.pidPower.Out;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
simple_scalar1.pidF.OutMax = pidFOutMax;//simple_scalar1.pidPower.Out;
|
||||||
|
simple_scalar1.pidF.OutMin = -pidFOutMin;//-simple_scalar1.pidPower.Out;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
// pzad
|
||||||
|
if (direction==-1 && powerzad <= 0)
|
||||||
|
{
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
else
|
||||||
|
if (direction==1 && powerzad>=0)
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
*/
|
||||||
|
|
||||||
// pidF.OutMax = mzz_zad;
|
// pidF.OutMax = mzz_zad;
|
||||||
|
if (count_bs_work==2)
|
||||||
|
simple_scalar1.pidF.Kp = simple_scalar1.pidF_Kp;//_IQmpy( _IQdiv(simple_scalar1.iq_add_kp_df, _IQsat(mzz_zad,mzz_zad,simple_scalar1.min_mzz_for_df)), simple_scalar1.pidF_Kp);
|
||||||
|
else
|
||||||
|
simple_scalar1.pidF.Kp = _IQmpy2(simple_scalar1.pidF_Kp);
|
||||||
|
|
||||||
simple_scalar1.pidF.Kp = _IQmpy( _IQdiv(simple_scalar1.iq_add_kp_df, _IQsat(mzz_zad,mzz_zad,simple_scalar1.min_mzz_for_df)), simple_scalar1.pidF_Kp);
|
simple_scalar1.pidF.Ki = simple_scalar1.pidF_Ki;//_IQmpy( _IQdiv(simple_scalar1.iq_add_ki_df, _IQsat(mzz_zad,mzz_zad,simple_scalar1.min_mzz_for_df)), simple_scalar1.pidF_Ki);
|
||||||
simple_scalar1.pidF.Ki = _IQmpy( _IQdiv(simple_scalar1.iq_add_ki_df, _IQsat(mzz_zad,mzz_zad,simple_scalar1.min_mzz_for_df)), simple_scalar1.pidF_Ki);
|
|
||||||
|
|
||||||
simple_scalar1.pidF.Ki = _IQmpy(simple_scalar1.pidF.Ki,simple_scalar1.k_freq_for_pid);
|
simple_scalar1.pidF.Ki = _IQmpy(simple_scalar1.pidF.Ki,simple_scalar1.k_freq_for_pid);
|
||||||
|
|
||||||
@ -366,9 +742,10 @@ void simple_scalar(int n_alg, int n_wind_pump,
|
|||||||
//////////////////////////////////
|
//////////////////////////////////
|
||||||
|
|
||||||
// áåç êîğğåêöèé dF
|
// áåç êîğğåêöèé dF
|
||||||
simple_scalar1.pidF.Ref = fzad_int;
|
//fzad_int =
|
||||||
|
simple_scalar1.pidF.Ref = _IQmpy(fzad_int, iqKoefOgran);
|
||||||
|
|
||||||
simple_scalar1.pidF.Fdb = Frot_pid;
|
simple_scalar1.pidF.Fdb = Frot_pid;//*direction;
|
||||||
simple_scalar1.pidF.calc(&simple_scalar1.pidF);
|
simple_scalar1.pidF.calc(&simple_scalar1.pidF);
|
||||||
|
|
||||||
|
|
||||||
@ -380,7 +757,7 @@ void simple_scalar(int n_alg, int n_wind_pump,
|
|||||||
simple_scalar1.pidF.Ui = simple_scalar1.pidF.OutMin;
|
simple_scalar1.pidF.Ui = simple_scalar1.pidF.OutMin;
|
||||||
/////////////////////////////////////
|
/////////////////////////////////////
|
||||||
|
|
||||||
mzz = simple_scalar1.pidF.Out;
|
mzz = _IQabs(simple_scalar1.pidF.Out); // òóò ìîäóëü!!!
|
||||||
|
|
||||||
///////////////////////////////////////
|
///////////////////////////////////////
|
||||||
|
|
||||||
@ -441,8 +818,8 @@ void simple_scalar(int n_alg, int n_wind_pump,
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
iqKoefOgran = _IQsat(iqKoefOgran,CONST_IQ_1,0);
|
|
||||||
Izad = _IQmpy(mzz, iqKoefOgran);
|
Izad = _IQmpy(mzz, simple_scalar1.iqKoefOgranIzad);
|
||||||
|
|
||||||
// if ((n_alg==1) || (n_alg==2))
|
// if ((n_alg==1) || (n_alg==2))
|
||||||
// {
|
// {
|
||||||
@ -524,7 +901,7 @@ void simple_scalar(int n_alg, int n_wind_pump,
|
|||||||
Uze_t1 = Uz_t1;
|
Uze_t1 = Uz_t1;
|
||||||
}
|
}
|
||||||
|
|
||||||
Uze_t1 = _IQsat(Uze_t1,simple_scalar1.pidIm1.OutMax,0);
|
Uze_t1 = _IQsat(Uze_t1,simple_scalar1.pidIm1.OutMax, simple_scalar1.pidIm1.OutMin);
|
||||||
|
|
||||||
// }
|
// }
|
||||||
|
|
||||||
@ -534,15 +911,13 @@ void simple_scalar(int n_alg, int n_wind_pump,
|
|||||||
*Uz2 = Uze_t1;
|
*Uz2 = Uze_t1;
|
||||||
|
|
||||||
|
|
||||||
|
bpsi = bpsi_const + simple_scalar1.add_bpsi;
|
||||||
|
|
||||||
|
|
||||||
bpsi = bpsi_const;
|
|
||||||
|
|
||||||
// ñêîëüæ. ~ ìîìåíòó
|
// ñêîëüæ. ~ ìîìåíòó
|
||||||
// bpsi = _IQmpy(koef_bpsi,mzz);
|
// bpsi = _IQmpy(koef_bpsi,mzz);
|
||||||
|
|
||||||
bpsi = _IQsat(bpsi,bpsi_const, simple_scalar1.min_bpsi);
|
|
||||||
|
bpsi = _IQsat(bpsi,simple_scalar1.max_bpsi, simple_scalar1.min_bpsi);
|
||||||
|
|
||||||
#ifdef BAN_ROTOR_REVERS_DIRECT
|
#ifdef BAN_ROTOR_REVERS_DIRECT
|
||||||
// èñïîëüçóåì çàùèòó îò íåïğàâèëüíîãî âğàùåíèß
|
// èñïîëüçóåì çàùèòó îò íåïğàâèëüíîãî âğàùåíèß
|
||||||
@ -555,12 +930,35 @@ void simple_scalar(int n_alg, int n_wind_pump,
|
|||||||
|
|
||||||
#else
|
#else
|
||||||
|
|
||||||
*Fz = _IQmpy(Frot,simple_scalar1.poluses) + bpsi; /* bpsi - ñêîëüæåíèå, áåðåì ïîêà
|
if (simple_scalar1.pidF.Out < 0)
|
||||||
êîíñòàíòîé õîòy òîæå äîëæåí ðåãóëèðîâàòüñy */
|
{
|
||||||
|
bpsi_filter = exp_regul_iq(koefBpsi, bpsi_filter, -bpsi);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
if (simple_scalar1.pidF.Out > 0)
|
||||||
|
{
|
||||||
|
bpsi_filter = exp_regul_iq(koefBpsi, bpsi_filter, bpsi);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
bpsi_filter = exp_regul_iq(koefBpsi, bpsi_filter, 0);
|
||||||
|
|
||||||
|
|
||||||
|
// *Fz = _IQmpy(Frot*direction,simple_scalar1.poluses) + bpsi_filter;
|
||||||
|
*Fz = _IQmpy(Frot, simple_scalar1.poluses) + bpsi_filter;
|
||||||
|
|
||||||
|
|
||||||
|
simple_scalar1.bpsi_curent = bpsi_filter;
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
simple_scalar1.mzz_zad_int = mzz_zad_int;
|
||||||
|
simple_scalar1.Uze_t1 = Uze_t1;
|
||||||
|
simple_scalar1.iqKoefOgran = iqKoefOgran;
|
||||||
|
simple_scalar1.Fz = *Fz;
|
||||||
|
simple_scalar1.direction = direction;
|
||||||
|
simple_scalar1.fzad_int = fzad_int;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// if (n_alg==2)
|
// if (n_alg==2)
|
||||||
@ -572,20 +970,6 @@ void simple_scalar(int n_alg, int n_wind_pump,
|
|||||||
// }
|
// }
|
||||||
|
|
||||||
|
|
||||||
// logpar.log1 = (int16)(_IQtoIQ15(Izad));
|
|
||||||
// logpar.log2 = (int16)(_IQtoIQ15(mzz_zad));//(int16)(_IQtoIQ15(Uze_t1));
|
|
||||||
// logpar.log3 = (int16)(_IQtoIQ15(fzad_int));
|
|
||||||
// logpar.log4 = (int16)(_IQtoIQ15(simple_scalar1.pidF.Ui));
|
|
||||||
// logpar.log5 = (int16)(_IQtoIQ14(simple_scalar1.pidF.Up));
|
|
||||||
// logpar.log6 = (int16)(_IQtoIQ14(simple_scalar1.pidF.SatErr));
|
|
||||||
// logpar.log7 = (int16)(_IQtoIQ15(mzz_zad_int));
|
|
||||||
// logpar.log8 = (int16)(_IQtoIQ15(simple_scalar1.pidIm1.Ref));
|
|
||||||
// logpar.log9 = (int16)(_IQtoIQ15(simple_scalar1.pidIm1.Fdb));
|
|
||||||
// logpar.log10 = (int16)(_IQtoIQ15(simple_scalar1.pidIm1.Ui));
|
|
||||||
// logpar.log11 = (int16)(_IQtoIQ15(simple_scalar1.pidIm1.Up));
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -39,11 +39,38 @@ typedef struct { PIDREG3 pidIm1;
|
|||||||
int UpravIm2;
|
int UpravIm2;
|
||||||
_iq pidIm_Ki;
|
_iq pidIm_Ki;
|
||||||
|
|
||||||
_iq mzz_zad;
|
_iq mzz_zad_in1;
|
||||||
|
_iq mzz_zad_in2;
|
||||||
|
|
||||||
_iq mzz_zad_int;
|
_iq mzz_zad_int;
|
||||||
_iq Im_regul;
|
_iq Im_regul;
|
||||||
_iq Izad;
|
_iq Izad;
|
||||||
_iq Izad_from_master;
|
_iq Izad_from_master;
|
||||||
|
_iq bpsi_curent;
|
||||||
|
_iq Uze_t1;
|
||||||
|
|
||||||
|
_iq iqKoefOgran;
|
||||||
|
_iq Fz;
|
||||||
|
int direction;
|
||||||
|
_iq fzad_int;
|
||||||
|
|
||||||
|
_iq add_bpsi;
|
||||||
|
_iq max_bpsi;
|
||||||
|
|
||||||
|
_iq mzz_add_3;
|
||||||
|
|
||||||
|
_iq k_ogr_n;
|
||||||
|
_iq iq_decr_mzz_power;
|
||||||
|
_iq iq_decr_mzz_power_filter;
|
||||||
|
int flag_decr_mzz_power;
|
||||||
|
|
||||||
|
_iq iqKoefOgranIzad;
|
||||||
|
int disable_KoefOgranIzad;
|
||||||
|
_iq add_power_limit;
|
||||||
|
_iq sdvig_power_limit;
|
||||||
|
|
||||||
|
int cmd_new_calc_p_limit;
|
||||||
|
|
||||||
|
|
||||||
} ALG_SIMPLE_SCALAR;
|
} ALG_SIMPLE_SCALAR;
|
||||||
|
|
||||||
@ -52,7 +79,8 @@ typedef struct { PIDREG3 pidIm1;
|
|||||||
0,0,0,0,0,\
|
0,0,0,0,0,\
|
||||||
0,0,0,0,0,\
|
0,0,0,0,0,\
|
||||||
0,0,0,0,0,\
|
0,0,0,0,0,\
|
||||||
0,0,0,0,0 \
|
0,0,0,0,0,0,0, \
|
||||||
|
0,0, 0,0,0, 0,0, 0, 0, 0,0,0,0,0,0, 0,0 \
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -60,10 +88,12 @@ extern ALG_SIMPLE_SCALAR simple_scalar1;
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
void simple_scalar(int n_alg, int n_wind_pump, _iq Frot_pid, _iq Frot,_iq fzad,_iq mzz_zad, _iq bpsi_const,
|
void simple_scalar(int n_alg, int n_wind_pump, int direction,
|
||||||
|
_iq Frot_pid, _iq Frot,_iq fzad,_iq mzz_zad, _iq bpsi_const,
|
||||||
_iq iqKoefOgran,
|
_iq iqKoefOgran,
|
||||||
_iq iqIm, _iq iqUin, _iq Iin, _iq powerzad, _iq power_pid,
|
_iq iqIm, _iq iqUin, _iq Iin, _iq powerzad, _iq power_pid,
|
||||||
_iq Izad_from_master, int master,
|
_iq power_limit, int mode_oborots_power,
|
||||||
|
_iq Izad_from_master, int master, int count_bs_work,
|
||||||
_iq *Fz, _iq *Uz1, _iq *Uz2, _iq *Izad);
|
_iq *Fz, _iq *Uz1, _iq *Uz2, _iq *Izad);
|
||||||
|
|
||||||
void init_simple_scalar(void);
|
void init_simple_scalar(void);
|
||||||
|
@ -64,25 +64,34 @@ void break_resistor_managment_calc()
|
|||||||
{
|
{
|
||||||
static unsigned int break_counter = 0;//MAX_BREAK_IMPULSE + 1;
|
static unsigned int break_counter = 0;//MAX_BREAK_IMPULSE + 1;
|
||||||
|
|
||||||
if(edrk.Discharge && edrk.from_shema.bits.QTV_ON_OFF==0 && edrk.from_shema.bits.UMP_ON_OFF==0)
|
if(edrk.Discharge && edrk.from_shema_filter.bits.QTV_ON_OFF==0
|
||||||
|
&& edrk.from_shema_filter.bits.UMP_ON_OFF==0)// && edrk.to_shema.bits.QTV_ON == 0)
|
||||||
{
|
{
|
||||||
if (break_counter < MAX_BREAK_IMPULSE)
|
if (break_counter < MAX_BREAK_IMPULSE)
|
||||||
{
|
{
|
||||||
break_counter++;
|
break_counter++;
|
||||||
|
|
||||||
|
|
||||||
if ((filter.iqU_1_fast > BREAK_INSENSITIVE_LEVEL_MIN) || edrk.ManualDischarge || edrk.NoDetectUZeroDischarge)
|
if ((filter.iqU_1_fast > BREAK_INSENSITIVE_LEVEL_MIN)
|
||||||
|
|| edrk.ManualDischarge || edrk.NoDetectUZeroDischarge)
|
||||||
{
|
{
|
||||||
|
if (edrk.Obmotka1 == 0)
|
||||||
break_result_1 = 300;
|
break_result_1 = 300;
|
||||||
|
else
|
||||||
|
break_result_1 = 0;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
break_result_1 = 0;
|
break_result_1 = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((filter.iqU_2_fast > BREAK_INSENSITIVE_LEVEL_MIN) || edrk.ManualDischarge || edrk.NoDetectUZeroDischarge )
|
if ((filter.iqU_2_fast > BREAK_INSENSITIVE_LEVEL_MIN)
|
||||||
|
|| edrk.ManualDischarge || edrk.NoDetectUZeroDischarge )
|
||||||
{
|
{
|
||||||
|
if (edrk.Obmotka2 == 0)
|
||||||
break_result_2 = 300;
|
break_result_2 = 300;
|
||||||
|
else
|
||||||
|
break_result_2 = 0;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@ -149,7 +158,8 @@ void break_resistor_recup_calc(_iq Uzpt_nominal)
|
|||||||
{
|
{
|
||||||
_iq Uzpt_start_recup = Uzpt_nominal + IQ_DELTA_U_START_RECUP;
|
_iq Uzpt_start_recup = Uzpt_nominal + IQ_DELTA_U_START_RECUP;
|
||||||
_iq Uzpt_max_open_break_keys = Uzpt_nominal + IQ_DELTA_U_MAX_OPEN_BREAK_KEYS;
|
_iq Uzpt_max_open_break_keys = Uzpt_nominal + IQ_DELTA_U_MAX_OPEN_BREAK_KEYS;
|
||||||
if (edrk.Go && edrk.SborFinishOk)
|
|
||||||
|
if (/*edrk.Go &&*/ (edrk.SborFinishOk || edrk.Status_Ready.bits.ImitationReady2) )
|
||||||
{
|
{
|
||||||
break_result_1 = calc_recup(filter.iqU_1_fast, Uzpt_start_recup, Uzpt_max_open_break_keys);
|
break_result_1 = calc_recup(filter.iqU_1_fast, Uzpt_start_recup, Uzpt_max_open_break_keys);
|
||||||
break_result_2 = calc_recup(filter.iqU_2_fast, Uzpt_start_recup, Uzpt_max_open_break_keys);
|
break_result_2 = calc_recup(filter.iqU_2_fast, Uzpt_start_recup, Uzpt_max_open_break_keys);
|
||||||
|
@ -19,6 +19,8 @@ int calc_max_temper_acdrive_winding(void);
|
|||||||
int calc_max_temper_edrk_u(void);
|
int calc_max_temper_edrk_u(void);
|
||||||
int calc_max_temper_edrk_water(void);
|
int calc_max_temper_edrk_water(void);
|
||||||
int calc_max_temper_edrk_air(void);
|
int calc_max_temper_edrk_air(void);
|
||||||
|
int calc_min_temper_edrk_air(void);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@ -94,6 +96,19 @@ int calc_max_temper_edrk_air(void)
|
|||||||
|
|
||||||
return max_t;
|
return max_t;
|
||||||
|
|
||||||
|
}
|
||||||
|
//////////////////////////////////////////////////////////
|
||||||
|
//////////////////////////////////////////////////////////
|
||||||
|
int calc_min_temper_edrk_air(void)
|
||||||
|
{
|
||||||
|
int i, min_t=1000;
|
||||||
|
|
||||||
|
for (i=0;i<4;i++)
|
||||||
|
if (edrk.temper_edrk.real_int_temper_air[i]<min_t)
|
||||||
|
min_t = edrk.temper_edrk.real_int_temper_air[i];
|
||||||
|
|
||||||
|
return min_t;
|
||||||
|
|
||||||
}
|
}
|
||||||
//////////////////////////////////////////////////////////
|
//////////////////////////////////////////////////////////
|
||||||
//////////////////////////////////////////////////////////
|
//////////////////////////////////////////////////////////
|
||||||
@ -257,6 +272,8 @@ void calc_temper_edrk(void)
|
|||||||
edrk.temper_edrk.real_int_temper_air[i] = edrk.temper_edrk.real_temper_air[i]*K_TEMPER_TO_SVU;
|
edrk.temper_edrk.real_int_temper_air[i] = edrk.temper_edrk.real_temper_air[i]*K_TEMPER_TO_SVU;
|
||||||
|
|
||||||
edrk.temper_edrk.max_real_int_temper_air = calc_max_temper_edrk_air();
|
edrk.temper_edrk.max_real_int_temper_air = calc_max_temper_edrk_air();
|
||||||
|
edrk.temper_edrk.min_real_int_temper_air = calc_min_temper_edrk_air();
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -20,6 +20,7 @@
|
|||||||
#include "DSP281x_SWPrioritizedIsrLevels.h" // DSP281x Examples Include File
|
#include "DSP281x_SWPrioritizedIsrLevels.h" // DSP281x Examples Include File
|
||||||
#include "DSP281x_Device.h"
|
#include "DSP281x_Device.h"
|
||||||
#include "xp_project.h"
|
#include "xp_project.h"
|
||||||
|
#include "another_bs.h"
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@ -27,10 +28,11 @@
|
|||||||
|
|
||||||
|
|
||||||
#pragma DATA_SECTION(Unites2SecondBS, ".slow_vars")
|
#pragma DATA_SECTION(Unites2SecondBS, ".slow_vars")
|
||||||
int Unites2SecondBS[SIZE_ARR_CAN_UNITES_BS2BS]={0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,\
|
int Unites2SecondBS[SIZE_ARR_CAN_UNITES_BS2BS]={0,0,0,0,0,0,0,0,0,0,\
|
||||||
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,\
|
0,0,0,0,0,0,0,0,0,0,\
|
||||||
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,\
|
0,0,0,0,0,0,0,0,0,0,\
|
||||||
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0\
|
0,0,0,0,0,0,0,0,0,0,\
|
||||||
|
0,0,0,0,0,0,0,0,0,0\
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
@ -8,7 +8,7 @@
|
|||||||
#ifndef SRC_MAIN_CAN_BS2BS_H_
|
#ifndef SRC_MAIN_CAN_BS2BS_H_
|
||||||
#define SRC_MAIN_CAN_BS2BS_H_
|
#define SRC_MAIN_CAN_BS2BS_H_
|
||||||
|
|
||||||
#define SIZE_ARR_CAN_UNITES_BS2BS 100
|
#define SIZE_ARR_CAN_UNITES_BS2BS 50 //100
|
||||||
|
|
||||||
|
|
||||||
extern int Unites2SecondBS[SIZE_ARR_CAN_UNITES_BS2BS];
|
extern int Unites2SecondBS[SIZE_ARR_CAN_UNITES_BS2BS];
|
||||||
|
File diff suppressed because it is too large
Load Diff
@ -76,13 +76,14 @@ enum
|
|||||||
CONTROL_STATION_CMD_DISABLE_ON_QTV,
|
CONTROL_STATION_CMD_DISABLE_ON_QTV,
|
||||||
CONTROL_STATION_CMD_MANUAL_DISCHARGE,
|
CONTROL_STATION_CMD_MANUAL_DISCHARGE,
|
||||||
CONTROL_STATION_CMD_DISABLE_ON_UMP,
|
CONTROL_STATION_CMD_DISABLE_ON_UMP,
|
||||||
CONTROL_STATION_CMD_CROSS_STEND_AUTOMATS,
|
CONTROL_STATION_CMD_WDOG_OFF,
|
||||||
CONTROL_STATION_CMD_SET_LIMIT_POWER,// çàïàñ ìîùíîñòü îò ïîñòà
|
CONTROL_STATION_CMD_SET_LIMIT_POWER,// çàïàñ ìîùíîñòü îò ïîñòà
|
||||||
CONTROL_STATION_CMD_BLOCK_BS, // áëîêèðîâêà ñ âåðõíåãî óðîâíÿ
|
CONTROL_STATION_CMD_BLOCK_BS, // áëîêèðîâêà ñ âåðõíåãî óðîâíÿ
|
||||||
CONTROL_STATION_CMD_DISABLE_INTERRUPT_SYNC,
|
CONTROL_STATION_CMD_DISABLE_INTERRUPT_SYNC,
|
||||||
CONTROL_STATION_CMD_DISABLE_INTERRUPT_TIMER2,
|
CONTROL_STATION_CMD_DISABLE_INTERRUPT_TIMER2,
|
||||||
CONTROL_STATION_CMD_DISABLE_RASCEPITEL, // íå óïðàâëÿòü ðàñöåïèòåëåì, åñëè îí ñâåäåí è íå ðàáîòàåò ìîòîð ðàñöåïèòåëÿ
|
CONTROL_STATION_CMD_DISABLE_RASCEPITEL, // íå óïðàâëÿòü ðàñöåïèòåëåì, åñëè îí ñâåäåí è íå ðàáîòàåò ìîòîð ðàñöåïèòåëÿ
|
||||||
CONTROL_STATION_CMD_PWM_TEST_LINES, // øèì ëèíèè íà 96ïèí øèíå êàê òåñòîâûå, òîëüêî äëÿ òåñòà!!!
|
CONTROL_STATION_CMD_PWM_TEST_LINES, // øèì ëèíèè íà 96ïèí øèíå êàê òåñòîâûå, òîëüêî äëÿ òåñòà!!!
|
||||||
|
CONTROL_STATION_CMD_STOP_LOGS, // ñòîï ëîãîâ
|
||||||
CONTROL_STATION_CMD_LAST // ïîñëåäíèé êîä â ñïèñêå, âñåãäà äîëæåí áûòü, íå óäàëÿòü åãî, èñïîëüçóåì äëÿ ðàçìåðíîñòè ìàññèâà.
|
CONTROL_STATION_CMD_LAST // ïîñëåäíèé êîä â ñïèñêå, âñåãäà äîëæåí áûòü, íå óäàëÿòü åãî, èñïîëüçóåì äëÿ ðàçìåðíîñòè ìàññèâà.
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -162,6 +162,6 @@ int detect_system_asymmetry_rms(DETECT_PROTECT_3_PHASE *v) {
|
|||||||
_iq d3 = _IQabs(v->iqVal_U - v->iqVal_W);
|
_iq d3 = _IQabs(v->iqVal_U - v->iqVal_W);
|
||||||
return d1 > v->setup.levels.iqAsymmetry_delta ||
|
return d1 > v->setup.levels.iqAsymmetry_delta ||
|
||||||
d2 > v->setup.levels.iqAsymmetry_delta ||
|
d2 > v->setup.levels.iqAsymmetry_delta ||
|
||||||
d2 > v->setup.levels.iqAsymmetry_delta ? 1 : 0;
|
d3 > v->setup.levels.iqAsymmetry_delta ? 1 : 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -118,7 +118,7 @@ typedef struct {
|
|||||||
//Setup
|
//Setup
|
||||||
SETUP_3_PHASE_PROTECT setup;
|
SETUP_3_PHASE_PROTECT setup;
|
||||||
|
|
||||||
int (*calc)();
|
int (*calc_detect_error_3_phase)();
|
||||||
|
|
||||||
} DETECT_PROTECT_3_PHASE;
|
} DETECT_PROTECT_3_PHASE;
|
||||||
|
|
||||||
|
@ -15,9 +15,14 @@
|
|||||||
#include <protect_levels.h>
|
#include <protect_levels.h>
|
||||||
#include <sync_tools.h>
|
#include <sync_tools.h>
|
||||||
#include <vector.h>
|
#include <vector.h>
|
||||||
|
#include "v_rotor.h"
|
||||||
|
|
||||||
|
|
||||||
#include "control_station.h"
|
#include "control_station.h"
|
||||||
#include "DSP281x_Device.h"
|
#include "DSP281x_Device.h"
|
||||||
|
#include "master_slave.h"
|
||||||
|
#include "another_bs.h"
|
||||||
|
#include "digital_filters.h"
|
||||||
|
|
||||||
|
|
||||||
void detect_error_from_knopka_avaria(void);
|
void detect_error_from_knopka_avaria(void);
|
||||||
@ -59,10 +64,17 @@ void detect_error_acdrive_winding(void);
|
|||||||
|
|
||||||
int get_common_state_warning(void);
|
int get_common_state_warning(void);
|
||||||
int get_common_state_overheat(void);
|
int get_common_state_overheat(void);
|
||||||
|
void detect_error_sensor_rotor(void);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
#pragma DATA_SECTION(protect_levels,".slow_vars");
|
#pragma DATA_SECTION(protect_levels,".slow_vars");
|
||||||
PROTECT_LEVELS protect_levels = PROTECT_LEVELS_DEFAULTS;
|
PROTECT_LEVELS protect_levels = PROTECT_LEVELS_DEFAULTS;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
///////////////////////////////////////////////
|
///////////////////////////////////////////////
|
||||||
int get_status_temper_acdrive_winding(int nc)
|
int get_status_temper_acdrive_winding(int nc)
|
||||||
{
|
{
|
||||||
@ -200,6 +212,54 @@ int get_status_p_water_min(int pump_on_off)
|
|||||||
}
|
}
|
||||||
///////////////////////////////////////////////
|
///////////////////////////////////////////////
|
||||||
///////////////////////////////////////////////
|
///////////////////////////////////////////////
|
||||||
|
void detect_error_sensor_rotor(void)
|
||||||
|
{
|
||||||
|
static unsigned int count_err1 = 0, count_err2 = 0, count_err3 = 0, count_err4 = 0;
|
||||||
|
|
||||||
|
|
||||||
|
if (edrk.Go)
|
||||||
|
{
|
||||||
|
// ñòîèì íà ìåñòå?
|
||||||
|
if (edrk.iq_f_rotor_hz==0)
|
||||||
|
{
|
||||||
|
// äîëãî ñòîèì!
|
||||||
|
if (pause_detect_error(&count_err3,TIME_WAIT_SENSOR_ROTOR_BREAK_ALL,1))
|
||||||
|
{
|
||||||
|
edrk.warnings.e9.bits.SENSOR_ROTOR_1_BREAK = 1;
|
||||||
|
edrk.warnings.e9.bits.SENSOR_ROTOR_2_BREAK = 1;
|
||||||
|
//edrk.errors.e9.bits.SENSOR_ROTOR_1_2_BREAK |= 1; // ïîêà óáåðåì!
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
// edrk.warnings.e9.bits.SENSOR_ROTOR_1_BREAK = 0;
|
||||||
|
// edrk.warnings.e9.bits.SENSOR_ROTOR_2_BREAK = 0;
|
||||||
|
edrk.warnings.e9.bits.SENSOR_ROTOR_1_BREAK = pause_detect_error(&count_err1,TIME_WAIT_SENSOR_ROTOR_BREAK_ONE_SENSOR,
|
||||||
|
inc_sensor.break_sensor1);
|
||||||
|
edrk.warnings.e9.bits.SENSOR_ROTOR_2_BREAK = pause_detect_error(&count_err2,TIME_WAIT_SENSOR_ROTOR_BREAK_ONE_SENSOR,
|
||||||
|
inc_sensor.break_sensor2);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
count_err3 = 0;
|
||||||
|
// edrk.warnings.e9.bits.SENSOR_ROTOR_1_BREAK = 0;
|
||||||
|
// edrk.warnings.e9.bits.SENSOR_ROTOR_2_BREAK = 0;
|
||||||
|
edrk.warnings.e9.bits.SENSOR_ROTOR_1_BREAK |= pause_detect_error(&count_err1,TIME_WAIT_ERROR,inc_sensor.break_sensor1);
|
||||||
|
edrk.warnings.e9.bits.SENSOR_ROTOR_2_BREAK |= pause_detect_error(&count_err2,TIME_WAIT_ERROR,inc_sensor.break_sensor2);
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
|
||||||
|
count_err1 = count_err2 = 0;
|
||||||
|
count_err3 = 0;
|
||||||
|
|
||||||
|
edrk.warnings.e9.bits.SENSOR_ROTOR_1_BREAK = 0;
|
||||||
|
edrk.warnings.e9.bits.SENSOR_ROTOR_2_BREAK = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
///////////////////////////////////////////////
|
///////////////////////////////////////////////
|
||||||
#define TIME_WAIT_T_WATER 30
|
#define TIME_WAIT_T_WATER 30
|
||||||
void detect_error_t_water(void)
|
void detect_error_t_water(void)
|
||||||
@ -453,7 +513,7 @@ void detect_error_acdrive_bear(void)
|
|||||||
static unsigned int count_run = 0, count_run_static = 0;
|
static unsigned int count_run = 0, count_run_static = 0;
|
||||||
int status,i;
|
int status,i;
|
||||||
|
|
||||||
status = 0;
|
// status = 0;
|
||||||
|
|
||||||
status = get_status_temper_acdrive_bear_with_limits(0, protect_levels.alarm_temper_acdrive_bear_DNE,
|
status = get_status_temper_acdrive_bear_with_limits(0, protect_levels.alarm_temper_acdrive_bear_DNE,
|
||||||
protect_levels.abnormal_temper_acdrive_bear_DNE);
|
protect_levels.abnormal_temper_acdrive_bear_DNE);
|
||||||
@ -556,7 +616,7 @@ void detect_error_ground(void)
|
|||||||
}
|
}
|
||||||
|
|
||||||
if ((edrk.from_ing1.bits.ZAZEML_OFF == 1) && (edrk.from_ing1.bits.ZAZEML_ON == 0))
|
if ((edrk.from_ing1.bits.ZAZEML_OFF == 1) && (edrk.from_ing1.bits.ZAZEML_ON == 0))
|
||||||
pause_detect_error(&count_err,TIME_WAIT_ERROR,0);
|
count_err = 0;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -572,7 +632,7 @@ void detect_error_nagrev(void)
|
|||||||
edrk.errors.e5.bits.ERROR_HEAT |= 1;
|
edrk.errors.e5.bits.ERROR_HEAT |= 1;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
pause_detect_error(&count_err,TIME_WAIT_ERROR,0);
|
count_err = 0;
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
@ -615,10 +675,11 @@ void detect_error_block_izol(void)
|
|||||||
|
|
||||||
if (edrk.from_ing1.bits.BLOCK_IZOL_AVARIA == 0 && edrk.from_ing1.bits.BLOCK_IZOL_NORMA == 1 )
|
if (edrk.from_ing1.bits.BLOCK_IZOL_AVARIA == 0 && edrk.from_ing1.bits.BLOCK_IZOL_NORMA == 1 )
|
||||||
{
|
{
|
||||||
pause_detect_error(&count_err,TIME_WAIT_ERROR_IZOL,0);
|
count_err = 0;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (edrk.cmd_imit_low_isolation)
|
||||||
|
edrk.errors.e5.bits.ERROR_ISOLATE |= 1;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -639,7 +700,7 @@ void detect_error_pre_charge(void)
|
|||||||
|
|
||||||
|
|
||||||
if (edrk.from_ing1.bits.ZARYAD_ON == 0 && edrk.to_ing.bits.ZARYAD_ON == 0)
|
if (edrk.from_ing1.bits.ZARYAD_ON == 0 && edrk.to_ing.bits.ZARYAD_ON == 0)
|
||||||
pause_detect_error(&count_err,TIME_WAIT_ERROR_CHARGE_ANSWER,0);
|
count_err = 0;
|
||||||
|
|
||||||
|
|
||||||
// edrk.errors.e6.bits.ERROR_PRE_CHARGE_ANSWER |= 1;
|
// edrk.errors.e6.bits.ERROR_PRE_CHARGE_ANSWER |= 1;
|
||||||
@ -654,7 +715,7 @@ void detect_error_qtv(void)
|
|||||||
|
|
||||||
|
|
||||||
// íåò êîìàíäû íà âûêë, íî ñóõîé êîíòàêò ïðèøåë
|
// íåò êîìàíäû íà âûêë, íî ñóõîé êîíòàêò ïðèøåë
|
||||||
if (edrk.from_shema.bits.QTV_ON_OFF == 1 && edrk.cmd_to_qtv == 0)
|
if (edrk.from_shema_filter.bits.QTV_ON_OFF == 1 && edrk.cmd_to_qtv == 0)
|
||||||
{
|
{
|
||||||
if (pause_detect_error(&count_err_off,TIME_WAIT_ERROR_QTV,1))
|
if (pause_detect_error(&count_err_off,TIME_WAIT_ERROR_QTV,1))
|
||||||
edrk.errors.e6.bits.QTV_ERROR_NOT_ANSWER |= 1;
|
edrk.errors.e6.bits.QTV_ERROR_NOT_ANSWER |= 1;
|
||||||
@ -665,7 +726,7 @@ void detect_error_qtv(void)
|
|||||||
}
|
}
|
||||||
|
|
||||||
// áûëà êîìàíäà íà âêë, íî ñóõîé êîíòàêò íå ïðèøåë
|
// áûëà êîìàíäà íà âêë, íî ñóõîé êîíòàêò íå ïðèøåë
|
||||||
if (edrk.from_shema.bits.QTV_ON_OFF == 0 && edrk.cmd_to_qtv == 1)
|
if (edrk.from_shema_filter.bits.QTV_ON_OFF == 0 && edrk.cmd_to_qtv == 1)
|
||||||
{
|
{
|
||||||
if (pause_detect_error(&count_err_on,TIME_WAIT_ERROR_QTV,1))
|
if (pause_detect_error(&count_err_on,TIME_WAIT_ERROR_QTV,1))
|
||||||
edrk.errors.e6.bits.QTV_ERROR_NOT_ANSWER |= 1;
|
edrk.errors.e6.bits.QTV_ERROR_NOT_ANSWER |= 1;
|
||||||
@ -696,20 +757,77 @@ void detect_error_predohr_vipr(void)
|
|||||||
edrk.errors.e5.bits.ERROR_PRED_VIPR |= 1;
|
edrk.errors.e5.bits.ERROR_PRED_VIPR |= 1;
|
||||||
|
|
||||||
if (edrk.from_ing1.bits.VIPR_PREDOHR_NORMA == 1)
|
if (edrk.from_ing1.bits.VIPR_PREDOHR_NORMA == 1)
|
||||||
pause_detect_error(&count_err,TIME_WAIT_ERROR,0);
|
count_err = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
///////////////////////////////////////////////
|
///////////////////////////////////////////////
|
||||||
|
#define TIME_WAIT_ERROR_UMP_READY 1200 //120 ñåê //750 // æäåì 75 ñåê ò.ê. âîçìîæíî óìð çàíÿò íà ñáîð âòîðîãî áñ
|
||||||
|
#define TIME_WAIT_WARNING_UMP_READY 10
|
||||||
void detect_error_ump(void)
|
void detect_error_ump(void)
|
||||||
{
|
{
|
||||||
static unsigned int count_err = 0;
|
static unsigned int count_err = 0;
|
||||||
|
static unsigned int count_err2 = 0;
|
||||||
|
|
||||||
if (edrk.from_shema.bits.READY_UMP == 0)
|
static unsigned int prev_SumSbor = 0;
|
||||||
if (pause_detect_error(&count_err,TIME_WAIT_ERROR,1))
|
static unsigned int StageUMP = 0;
|
||||||
|
static unsigned int count_UMP_NOT_READY = 0;
|
||||||
|
int local_warning_ump = 0;
|
||||||
|
|
||||||
|
if (edrk.SumSbor==1)
|
||||||
|
{
|
||||||
|
switch (StageUMP) {
|
||||||
|
case 0: if (edrk.from_shema_filter.bits.UMP_ON_OFF == 1)
|
||||||
|
StageUMP++;
|
||||||
|
break;
|
||||||
|
case 1: if (edrk.from_shema_filter.bits.UMP_ON_OFF == 0)
|
||||||
|
StageUMP++;
|
||||||
|
break;
|
||||||
|
case 2:
|
||||||
|
break;
|
||||||
|
case 3:
|
||||||
|
break;
|
||||||
|
|
||||||
|
|
||||||
|
default: break;
|
||||||
|
}
|
||||||
|
|
||||||
|
if ((edrk.from_shema_filter.bits.READY_UMP == 0) && (StageUMP==0) && control_station.active_array_cmd[CONTROL_STATION_CMD_DISABLE_ON_UMP]==0)
|
||||||
|
{
|
||||||
|
|
||||||
|
if (pause_detect_error(&count_err,TIME_WAIT_ERROR_UMP_READY,1))
|
||||||
edrk.errors.e7.bits.UMP_NOT_READY |= 1;
|
edrk.errors.e7.bits.UMP_NOT_READY |= 1;
|
||||||
|
}
|
||||||
|
if (edrk.from_shema_filter.bits.READY_UMP == 1)
|
||||||
|
count_err = 0;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
count_err= 0;
|
||||||
|
|
||||||
if (edrk.from_ing1.bits.VIPR_PREDOHR_NORMA == 1)
|
// ÓÌÏ âêëþ÷åí, à íå äîëæåí!
|
||||||
pause_detect_error(&count_err,TIME_WAIT_ERROR,0);
|
if (edrk.from_shema_filter.bits.UMP_ON_OFF==1)
|
||||||
|
if (pause_detect_error(&count_err2,TIME_WAIT_ERROR,1))
|
||||||
|
edrk.errors.e11.bits.ERROR_UMP_NOT_OFF |= 1;
|
||||||
|
|
||||||
|
if (edrk.from_shema_filter.bits.UMP_ON_OFF == 0)
|
||||||
|
count_err2 = 0;
|
||||||
|
|
||||||
|
// íåò ãîòîâíîñòè
|
||||||
|
if (edrk.ump_cmd_another_bs==0) // äðóãîé ÁÑ íå çàíÿë ÓÌÏ
|
||||||
|
local_warning_ump = !edrk.from_shema_filter.bits.READY_UMP;
|
||||||
|
// edrk.warnings.e7.bits.UMP_NOT_READY = !edrk.from_shema_filter.bits.READY_UMP;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
StageUMP = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
edrk.warnings.e7.bits.UMP_NOT_READY = filter_digital_input( edrk.warnings.e7.bits.UMP_NOT_READY,
|
||||||
|
&count_UMP_NOT_READY,
|
||||||
|
TIME_WAIT_WARNING_UMP_READY,
|
||||||
|
local_warning_ump);
|
||||||
|
|
||||||
|
prev_SumSbor = edrk.SumSbor;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -721,8 +839,14 @@ void detect_error_block_qtv_from_svu(void)
|
|||||||
|
|
||||||
|
|
||||||
if (edrk.from_shema.bits.SVU_BLOCK_QTV == 1 || control_station.active_array_cmd[CONTROL_STATION_CMD_BLOCK_BS])
|
if (edrk.from_shema.bits.SVU_BLOCK_QTV == 1 || control_station.active_array_cmd[CONTROL_STATION_CMD_BLOCK_BS])
|
||||||
|
{
|
||||||
if (pause_detect_error(&count_err,TIME_WAIT_BLOCK_QTV_FROM_SVU,1))
|
if (pause_detect_error(&count_err,TIME_WAIT_BLOCK_QTV_FROM_SVU,1))
|
||||||
edrk.errors.e7.bits.SVU_BLOCK_ON_QTV |= 1;
|
edrk.errors.e7.bits.SVU_BLOCK_ON_QTV |= 1;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
count_err = 0;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -740,7 +864,7 @@ void detect_error_fan(void)
|
|||||||
edrk.errors.e5.bits.FAN |= 1;
|
edrk.errors.e5.bits.FAN |= 1;
|
||||||
|
|
||||||
if (edrk.from_ing1.bits.VENTIL_ON == 0 && (edrk.to_ing.bits.NASOS_1_ON == 0 && edrk.to_ing.bits.NASOS_2_ON == 0))
|
if (edrk.from_ing1.bits.VENTIL_ON == 0 && (edrk.to_ing.bits.NASOS_1_ON == 0 && edrk.to_ing.bits.NASOS_2_ON == 0))
|
||||||
pause_detect_error(&count_err,TIME_WAIT_ERROR_FAN,0);
|
count_err = 0;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -760,7 +884,7 @@ void detect_error_pre_ready_pump(void)
|
|||||||
|
|
||||||
if (edrk.from_ing1.bits.NASOS_NORMA == 1)
|
if (edrk.from_ing1.bits.NASOS_NORMA == 1)
|
||||||
{
|
{
|
||||||
pause_detect_error(&count_err,TIME_WAIT_ERROR,0);
|
count_err = 0;
|
||||||
edrk.warnings.e5.bits.PRE_READY_PUMP = 0;
|
edrk.warnings.e5.bits.PRE_READY_PUMP = 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -789,13 +913,13 @@ void detect_error_pump_1(void)
|
|||||||
if (edrk.from_ing1.bits.NASOS_ON == 0 && edrk.to_ing.bits.NASOS_1_ON==0 && edrk.SelectPump1_2==1)
|
if (edrk.from_ing1.bits.NASOS_ON == 0 && edrk.to_ing.bits.NASOS_1_ON==0 && edrk.SelectPump1_2==1)
|
||||||
{
|
{
|
||||||
// òóò âñå îê
|
// òóò âñå îê
|
||||||
pause_detect_error(&count_err,TIME_WAIT_ERROR_PUMP,0);
|
count_err = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (edrk.from_ing1.bits.NASOS_ON == 1 && edrk.to_ing.bits.NASOS_1_ON==1 && edrk.SelectPump1_2==1)
|
if (edrk.from_ing1.bits.NASOS_ON == 1 && edrk.to_ing.bits.NASOS_1_ON==1 && edrk.SelectPump1_2==1)
|
||||||
{
|
{
|
||||||
// òóò âñå îê
|
// òóò âñå îê
|
||||||
pause_detect_error(&count_err,TIME_WAIT_ERROR_PUMP,0);
|
count_err = 0;
|
||||||
edrk.warnings.e5.bits.PUMP_1 = 0;
|
edrk.warnings.e5.bits.PUMP_1 = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -824,13 +948,13 @@ void detect_error_pump_2(void)
|
|||||||
if (edrk.from_ing1.bits.NASOS_ON == 0 && edrk.to_ing.bits.NASOS_2_ON==0 && edrk.SelectPump1_2==2)
|
if (edrk.from_ing1.bits.NASOS_ON == 0 && edrk.to_ing.bits.NASOS_2_ON==0 && edrk.SelectPump1_2==2)
|
||||||
{
|
{
|
||||||
// òóò âñå îê
|
// òóò âñå îê
|
||||||
pause_detect_error(&count_err,TIME_WAIT_ERROR_PUMP,0);
|
count_err = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (edrk.from_ing1.bits.NASOS_ON == 1 && edrk.to_ing.bits.NASOS_2_ON==1 && edrk.SelectPump1_2==2)
|
if (edrk.from_ing1.bits.NASOS_ON == 1 && edrk.to_ing.bits.NASOS_2_ON==1 && edrk.SelectPump1_2==2)
|
||||||
{
|
{
|
||||||
// òóò âñå îê
|
// òóò âñå îê
|
||||||
pause_detect_error(&count_err,TIME_WAIT_ERROR_PUMP,0);
|
count_err = 0;
|
||||||
edrk.warnings.e5.bits.PUMP_2 = 0;
|
edrk.warnings.e5.bits.PUMP_2 = 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -846,7 +970,7 @@ void detect_error_op_pit(void)
|
|||||||
edrk.errors.e5.bits.OP_PIT |= 1;
|
edrk.errors.e5.bits.OP_PIT |= 1;
|
||||||
|
|
||||||
if (edrk.from_ing1.bits.OP_PIT_NORMA == 1 )
|
if (edrk.from_ing1.bits.OP_PIT_NORMA == 1 )
|
||||||
pause_detect_error(&count_err,TIME_WAIT_ERROR,0);
|
count_err = 0;
|
||||||
}
|
}
|
||||||
///////////////////////////////////////////////
|
///////////////////////////////////////////////
|
||||||
void detect_error_power_upc(void)
|
void detect_error_power_upc(void)
|
||||||
@ -858,7 +982,7 @@ void detect_error_power_upc(void)
|
|||||||
edrk.errors.e5.bits.POWER_UPC |= 1;
|
edrk.errors.e5.bits.POWER_UPC |= 1;
|
||||||
|
|
||||||
if (edrk.from_ing1.bits.UPC_24V_NORMA == 1 )
|
if (edrk.from_ing1.bits.UPC_24V_NORMA == 1 )
|
||||||
pause_detect_error(&count_err,TIME_WAIT_ERROR,0);
|
count_err = 0;
|
||||||
}
|
}
|
||||||
///////////////////////////////////////////////
|
///////////////////////////////////////////////
|
||||||
void detect_error_t_vipr(void)
|
void detect_error_t_vipr(void)
|
||||||
@ -883,7 +1007,7 @@ void detect_error_ute4ka_water(void)
|
|||||||
|
|
||||||
|
|
||||||
if (edrk.from_ing1.bits.OHLAD_UTE4KA_WATER == 0 )
|
if (edrk.from_ing1.bits.OHLAD_UTE4KA_WATER == 0 )
|
||||||
pause_detect_error(&count_err,TIME_WAIT_ERROR,0);
|
count_err = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
///////////////////////////////////////////////
|
///////////////////////////////////////////////
|
||||||
@ -931,14 +1055,55 @@ void detect_error_sync_bus(void)
|
|||||||
// ó ýòîãî ÁÑ ñèíõðîñèãíàëà íåò, è ó âòîðîãî òîæå íåò, òîãäà àâàðèÿ
|
// ó ýòîãî ÁÑ ñèíõðîñèãíàëà íåò, è ó âòîðîãî òîæå íåò, òîãäà àâàðèÿ
|
||||||
if (sync_data.timeout_sync_signal && optical_read_data.data.cmd.bit.sync_line_detect==0
|
if (sync_data.timeout_sync_signal && optical_read_data.data.cmd.bit.sync_line_detect==0
|
||||||
&& edrk.ms.another_bs_maybe_on && optical_read_data.status==1)
|
&& edrk.ms.another_bs_maybe_on && optical_read_data.status==1)
|
||||||
|
{
|
||||||
if (pause_detect_error(&count_err,TIME_WAIT_SYNC_SIGNAL,1))
|
if (pause_detect_error(&count_err,TIME_WAIT_SYNC_SIGNAL,1))
|
||||||
edrk.errors.e1.bits.NO_INPUT_SYNC_SIGNAL |= 1;
|
edrk.errors.e1.bits.NO_INPUT_SYNC_SIGNAL |= 1;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
count_err = 0;
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
///////////////////////////////////////////////
|
///////////////////////////////////////////////
|
||||||
|
#pragma CODE_SECTION(detect_error_u_zpt_fast,".fast_run");
|
||||||
|
int detect_error_u_zpt_fast(void)
|
||||||
|
{
|
||||||
|
int err;
|
||||||
|
|
||||||
|
err = 0;
|
||||||
|
|
||||||
|
|
||||||
|
if (analog.iqU_1>=edrk.iqMAX_U_ZPT_Global)
|
||||||
|
edrk.errors.e0.bits.U_1_MAX |= 1;
|
||||||
|
|
||||||
|
if (analog.iqU_2>=edrk.iqMAX_U_ZPT_Global)
|
||||||
|
edrk.errors.e0.bits.U_2_MAX |= 1;
|
||||||
|
|
||||||
|
|
||||||
|
if (analog.iqU_1>=edrk.iqMAX_U_ZPT)
|
||||||
|
edrk.errors.e0.bits.U_1_MAX |= 1;
|
||||||
|
|
||||||
|
|
||||||
|
if (analog.iqU_2>=edrk.iqMAX_U_ZPT)
|
||||||
|
edrk.errors.e0.bits.U_2_MAX |= 1;
|
||||||
|
|
||||||
|
|
||||||
|
if (edrk.from_shema_filter.bits.QTV_ON_OFF == 1
|
||||||
|
// && edrk.to_shema.bits.QTV_ON
|
||||||
|
)
|
||||||
|
{
|
||||||
|
if (analog.iqU_1<=edrk.iqMIN_U_ZPT)
|
||||||
|
edrk.errors.e0.bits.U_1_MIN |= 1;
|
||||||
|
|
||||||
|
if (analog.iqU_2<=edrk.iqMIN_U_ZPT)
|
||||||
|
edrk.errors.e0.bits.U_2_MIN |= 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
err = (edrk.errors.e0.bits.U_1_MAX || edrk.errors.e0.bits.U_2_MAX || edrk.errors.e0.bits.U_1_MIN || edrk.errors.e0.bits.U_2_MIN);
|
||||||
|
return err;
|
||||||
|
|
||||||
|
}
|
||||||
|
///////////////////////////////////////////////
|
||||||
///////////////////////////////////////////////
|
///////////////////////////////////////////////
|
||||||
int detect_error_u_zpt(void)
|
int detect_error_u_zpt(void)
|
||||||
{
|
{
|
||||||
@ -956,7 +1121,9 @@ int detect_error_u_zpt(void)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
if (edrk.iqMAX_U_ZPT>MINIMAL_LEVEL_ZAD_U && edrk.from_shema.bits.QTV_ON_OFF == 1)
|
if (edrk.iqMAX_U_ZPT>MINIMAL_LEVEL_ZAD_U && edrk.from_shema_filter.bits.QTV_ON_OFF == 1
|
||||||
|
// && edrk.to_shema.bits.QTV_ON
|
||||||
|
)
|
||||||
{
|
{
|
||||||
if (analog.iqU_1>=edrk.iqMAX_U_ZPT)
|
if (analog.iqU_1>=edrk.iqMAX_U_ZPT)
|
||||||
edrk.errors.e0.bits.U_1_MAX |= 1;
|
edrk.errors.e0.bits.U_1_MAX |= 1;
|
||||||
@ -966,7 +1133,9 @@ int detect_error_u_zpt(void)
|
|||||||
edrk.errors.e0.bits.U_2_MAX |= 1;
|
edrk.errors.e0.bits.U_2_MAX |= 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (edrk.from_shema.bits.QTV_ON_OFF == 1)
|
if (edrk.from_shema_filter.bits.QTV_ON_OFF == 1
|
||||||
|
//&& edrk.to_shema.bits.QTV_ON
|
||||||
|
)
|
||||||
{
|
{
|
||||||
if (analog.iqU_1<=edrk.iqMIN_U_ZPT)
|
if (analog.iqU_1<=edrk.iqMIN_U_ZPT)
|
||||||
edrk.errors.e0.bits.U_1_MIN |= 1;
|
edrk.errors.e0.bits.U_1_MIN |= 1;
|
||||||
@ -1003,6 +1172,7 @@ int detect_error_u_zpt_on_predzaryad(void)
|
|||||||
}
|
}
|
||||||
|
|
||||||
///////////////////////////////////////////////
|
///////////////////////////////////////////////
|
||||||
|
#pragma CODE_SECTION(detect_error_u_in,".fast_run");
|
||||||
int detect_error_u_in(void)
|
int detect_error_u_in(void)
|
||||||
{
|
{
|
||||||
int err;
|
int err;
|
||||||
@ -1020,7 +1190,9 @@ int detect_error_u_in(void)
|
|||||||
edrk.errors.e0.bits.U_IN_MAX |= 1;
|
edrk.errors.e0.bits.U_IN_MAX |= 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (edrk.from_shema.bits.QTV_ON_OFF == 1 && edrk.SumSbor)
|
if (edrk.from_shema_filter.bits.QTV_ON_OFF == 1 && edrk.SumSbor
|
||||||
|
// && edrk.to_shema.bits.QTV_ON
|
||||||
|
)
|
||||||
{
|
{
|
||||||
if (control_station.active_array_cmd[CONTROL_STATION_CMD_DISABLE_ON_QTV]==1)
|
if (control_station.active_array_cmd[CONTROL_STATION_CMD_DISABLE_ON_QTV]==1)
|
||||||
{
|
{
|
||||||
@ -1061,7 +1233,7 @@ int detect_error_u_in(void)
|
|||||||
|
|
||||||
}
|
}
|
||||||
///////////////////////////////////////////////
|
///////////////////////////////////////////////
|
||||||
#define MAX_WAIT_AFTER_KVITIR 50
|
#define MAX_WAIT_AFTER_KVITIR 100//50
|
||||||
void detect_error_all(void)
|
void detect_error_all(void)
|
||||||
{
|
{
|
||||||
unsigned int pause_after_kvitir=0;
|
unsigned int pause_after_kvitir=0;
|
||||||
@ -1100,9 +1272,13 @@ void detect_error_all(void)
|
|||||||
detect_error_ground();
|
detect_error_ground();
|
||||||
detect_error_ump();
|
detect_error_ump();
|
||||||
|
|
||||||
|
|
||||||
// äëÿ àâàðèè â äðóãîé Ï× èñêëþ÷àåì àâàðèþ èç ýòîãîæå Ï×, èíà÷å ïîëó÷àåì êîëüöî. Àâàðèè çàìûêàþòñÿ!
|
// äëÿ àâàðèè â äðóãîé Ï× èñêëþ÷àåì àâàðèþ èç ýòîãîæå Ï×, èíà÷å ïîëó÷àåì êîëüöî. Àâàðèè çàìûêàþòñÿ!
|
||||||
if (pause_after_kvitir)
|
if (pause_after_kvitir)
|
||||||
|
{
|
||||||
detect_error_from_knopka_avaria();
|
detect_error_from_knopka_avaria();
|
||||||
|
detect_error_from_another_bs();
|
||||||
|
}
|
||||||
|
|
||||||
#if (_FLOOR6==1)
|
#if (_FLOOR6==1)
|
||||||
|
|
||||||
@ -1129,6 +1305,7 @@ void detect_error_all(void)
|
|||||||
edrk.warnings.e10.bits.WARNING_I_OUT_OVER_1_6_NOMINAL = out_I_over_1_6.overload_detected;
|
edrk.warnings.e10.bits.WARNING_I_OUT_OVER_1_6_NOMINAL = out_I_over_1_6.overload_detected;
|
||||||
|
|
||||||
// edrk.errors.e7.bits.ANOTHER_BS_ALARM |= optical_read_data.data.cmd.bit.alarm;
|
// edrk.errors.e7.bits.ANOTHER_BS_ALARM |= optical_read_data.data.cmd.bit.alarm;
|
||||||
|
detect_error_sensor_rotor();
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
@ -1189,7 +1366,7 @@ void read_plane_errors(void)
|
|||||||
if (project.controller.read.errors.bit.pwm_wdog)
|
if (project.controller.read.errors.bit.pwm_wdog)
|
||||||
edrk.errors.e9.bits.ERR_PWM_WDOG |= 1;
|
edrk.errors.e9.bits.ERR_PWM_WDOG |= 1;
|
||||||
|
|
||||||
#ifdef USE_TK_0
|
#if USE_TK_0
|
||||||
//af1
|
//af1
|
||||||
if (project.cds_tk[0].read.sbus.status_protect_current_ack.bit.tk0_ack ||
|
if (project.cds_tk[0].read.sbus.status_protect_current_ack.bit.tk0_ack ||
|
||||||
project.cds_tk[0].read.sbus.status_protect_current_ack.bit.tk0_current ||
|
project.cds_tk[0].read.sbus.status_protect_current_ack.bit.tk0_current ||
|
||||||
@ -1216,7 +1393,7 @@ void read_plane_errors(void)
|
|||||||
edrk.errors.e6.bits.UO3_KEYS |= 1;
|
edrk.errors.e6.bits.UO3_KEYS |= 1;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef USE_TK_1
|
#if USE_TK_1
|
||||||
//af3
|
//af3
|
||||||
if (project.cds_tk[1].read.sbus.status_protect_current_ack.bit.tk0_ack ||
|
if (project.cds_tk[1].read.sbus.status_protect_current_ack.bit.tk0_ack ||
|
||||||
project.cds_tk[1].read.sbus.status_protect_current_ack.bit.tk0_current ||
|
project.cds_tk[1].read.sbus.status_protect_current_ack.bit.tk0_current ||
|
||||||
@ -1243,7 +1420,7 @@ void read_plane_errors(void)
|
|||||||
edrk.errors.e6.bits.UO5_KEYS |= 1;
|
edrk.errors.e6.bits.UO5_KEYS |= 1;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef USE_TK_2
|
#if USE_TK_2
|
||||||
//af5
|
//af5
|
||||||
if (project.cds_tk[2].read.sbus.status_protect_current_ack.bit.tk0_ack ||
|
if (project.cds_tk[2].read.sbus.status_protect_current_ack.bit.tk0_ack ||
|
||||||
project.cds_tk[2].read.sbus.status_protect_current_ack.bit.tk0_current ||
|
project.cds_tk[2].read.sbus.status_protect_current_ack.bit.tk0_current ||
|
||||||
@ -1272,7 +1449,7 @@ void read_plane_errors(void)
|
|||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef USE_TK_3
|
#if USE_TK_3
|
||||||
|
|
||||||
if (project.cds_tk[3].read.sbus.status_protect_current_ack.bit.tk0_ack ||
|
if (project.cds_tk[3].read.sbus.status_protect_current_ack.bit.tk0_ack ||
|
||||||
project.cds_tk[3].read.sbus.status_protect_current_ack.bit.tk0_current ||
|
project.cds_tk[3].read.sbus.status_protect_current_ack.bit.tk0_current ||
|
||||||
@ -1389,7 +1566,7 @@ void read_plane_errors(void)
|
|||||||
if (project.all_status_plates.in0 != component_Ready)
|
if (project.all_status_plates.in0 != component_Ready)
|
||||||
edrk.errors.e3.bits.NOT_READY_IN_0 |= 1;
|
edrk.errors.e3.bits.NOT_READY_IN_0 |= 1;
|
||||||
#endif
|
#endif
|
||||||
#if USE_IN_0
|
#if USE_IN_1
|
||||||
if (project.all_status_plates.in1 != component_Ready)
|
if (project.all_status_plates.in1 != component_Ready)
|
||||||
edrk.errors.e3.bits.NOT_READY_IN_1 |= 1;
|
edrk.errors.e3.bits.NOT_READY_IN_1 |= 1;
|
||||||
#endif
|
#endif
|
||||||
@ -1426,3 +1603,4 @@ int get_common_state_overheat() {
|
|||||||
edrk.errors.e2.bits.T_UO7_MAX | edrk.errors.e2.bits.T_WATER_EXT_MAX |
|
edrk.errors.e2.bits.T_UO7_MAX | edrk.errors.e2.bits.T_WATER_EXT_MAX |
|
||||||
edrk.errors.e2.bits.T_WATER_INT_MAX;
|
edrk.errors.e2.bits.T_WATER_INT_MAX;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -13,9 +13,14 @@
|
|||||||
#define TIME_WAIT_ERROR 20 // 2 sec
|
#define TIME_WAIT_ERROR 20 // 2 sec
|
||||||
#define TIME_WAIT_ERROR_QTV 100 // 10 sec
|
#define TIME_WAIT_ERROR_QTV 100 // 10 sec
|
||||||
#define TIME_WAIT_ERROR_CHARGE_ANSWER 60 // 6 sec
|
#define TIME_WAIT_ERROR_CHARGE_ANSWER 60 // 6 sec
|
||||||
#define TIME_WAIT_ERROR_IZOL 200 // 20 sec
|
#define TIME_WAIT_ERROR_IZOL 50 //5 sec //200 // 20 sec
|
||||||
#define TIME_WAIT_ERROR_PUMP 100 // 10 sec
|
#define TIME_WAIT_ERROR_PUMP 100 // 10 sec
|
||||||
#define TIME_WAIT_ERROR_FAN 300 // 30 sec
|
#define TIME_WAIT_ERROR_FAN 300 // 30 sec
|
||||||
|
#define TIME_WAIT_SENSOR_ROTOR_BREAK_ALL 200 // 20 sec
|
||||||
|
#define TIME_WAIT_SENSOR_ROTOR_BREAK_DIRECTION 10 // 1 sec
|
||||||
|
#define TIME_WAIT_SENSOR_ROTOR_BREAK_ONE_SENSOR 20 // 2 sec
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
#define MINIMAL_LEVEL_ZAD_U 27962 // 10 V
|
#define MINIMAL_LEVEL_ZAD_U 27962 // 10 V
|
||||||
@ -26,5 +31,50 @@ void detect_error_all(void);
|
|||||||
void read_plane_errors(void);
|
void read_plane_errors(void);
|
||||||
int detect_error_u_zpt_on_predzaryad(void);
|
int detect_error_u_zpt_on_predzaryad(void);
|
||||||
int detect_error_u_in(void);
|
int detect_error_u_in(void);
|
||||||
|
int detect_error_u_zpt_fast(void);
|
||||||
|
|
||||||
|
|
||||||
|
void detect_error_from_knopka_avaria(void);
|
||||||
|
void detect_error_ute4ka_water(void);
|
||||||
|
void detect_error_t_vipr(void);
|
||||||
|
void detect_error_power_upc(void);
|
||||||
|
void detect_error_op_pit(void);
|
||||||
|
void detect_error_p_water(void);
|
||||||
|
void detect_error_pump_2(void);
|
||||||
|
void detect_error_pump_1(void);
|
||||||
|
void detect_error_pre_ready_pump(void);
|
||||||
|
void detect_error_fan(void);
|
||||||
|
void detect_error_block_qtv_from_svu(void);
|
||||||
|
|
||||||
|
void detect_error_predohr_vipr(void);
|
||||||
|
void detect_error_qtv(void);
|
||||||
|
void detect_error_pre_charge(void);
|
||||||
|
void detect_error_block_izol(void);
|
||||||
|
void detect_error_nagrev(void);
|
||||||
|
void detect_error_ground(void);
|
||||||
|
void detect_error_block_door(void);
|
||||||
|
void detect_error_optical_bus(void);
|
||||||
|
void detect_error_sync_bus(void);
|
||||||
|
int get_status_temper_acdrive_winding(int nc);
|
||||||
|
int get_status_temper_acdrive_winding_with_limits(int nc, int alarm, int abnormal);
|
||||||
|
int get_status_temper_acdrive_bear(int nc);
|
||||||
|
int get_status_temper_acdrive_bear_with_limits(int nc, int alarm, int abnormal);
|
||||||
|
int get_status_temper_air(int nc);
|
||||||
|
int get_status_temper_air_with_limits(int nc, int alarm, int abnormal);
|
||||||
|
int get_status_temper_u(int nc);
|
||||||
|
int get_status_temper_u_with_limits(int nc, int alarm, int abnormal);
|
||||||
|
int get_status_temper_water(int nc);
|
||||||
|
int get_status_p_water_max(void);
|
||||||
|
int get_status_p_water_min(int pump_on_off);
|
||||||
|
void detect_error_t_water(void);
|
||||||
|
void detect_error_t_air(void);
|
||||||
|
void detect_error_t_u(void);
|
||||||
|
void detect_error_acdrive_winding(void);
|
||||||
|
|
||||||
|
int get_common_state_warning(void);
|
||||||
|
int get_common_state_overheat(void);
|
||||||
|
void detect_error_sensor_rotor(void);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
#endif /* SRC_MYLIBS_DETECT_ERRORS_H_ */
|
#endif /* SRC_MYLIBS_DETECT_ERRORS_H_ */
|
||||||
|
@ -11,18 +11,22 @@
|
|||||||
#include <edrk_main.h>
|
#include <edrk_main.h>
|
||||||
#include <params_protect_adc.h>
|
#include <params_protect_adc.h>
|
||||||
#include <protect_levels.h>
|
#include <protect_levels.h>
|
||||||
|
#include "digital_filters.h"
|
||||||
|
|
||||||
#include "IQmathLib.h"
|
#include "IQmathLib.h"
|
||||||
|
|
||||||
//ANALOG_PROTECT_LEVELS analog_protect_levels = ANALOG_PROTECT_LEVELS_DEFAULTS;
|
//ANALOG_PROTECT_LEVELS analog_protect_levels = ANALOG_PROTECT_LEVELS_DEFAULTS;
|
||||||
|
|
||||||
#pragma DATA_SECTION(analog_protect,".fast_vars");
|
//#pragma DATA_SECTION(analog_protect,".fast_vars");
|
||||||
|
#pragma DATA_SECTION(analog_protect,".slow_vars");
|
||||||
ANALOG_ADC_PROTECT analog_protect = ANALOG_ADC_PROTECT_DEFAULTS;
|
ANALOG_ADC_PROTECT analog_protect = ANALOG_ADC_PROTECT_DEFAULTS;
|
||||||
|
|
||||||
#pragma DATA_SECTION(break_Iout_1_state,".fast_vars");
|
//#pragma DATA_SECTION(break_Iout_1_state,".fast_vars");
|
||||||
|
#pragma DATA_SECTION(break_Iout_1_state,".slow_vars");
|
||||||
BREAK_PHASE_I break_Iout_1_state = BREAK_PHASE_I_DEFAULTS;
|
BREAK_PHASE_I break_Iout_1_state = BREAK_PHASE_I_DEFAULTS;
|
||||||
|
|
||||||
#pragma DATA_SECTION(break_Iout_2_state,".fast_vars");
|
//#pragma DATA_SECTION(break_Iout_2_state,".fast_vars");
|
||||||
|
#pragma DATA_SECTION(break_Iout_2_state,".slow_vars");
|
||||||
BREAK_PHASE_I break_Iout_2_state = BREAK_PHASE_I_DEFAULTS;
|
BREAK_PHASE_I break_Iout_2_state = BREAK_PHASE_I_DEFAULTS;
|
||||||
|
|
||||||
int detect_error_Izpt();
|
int detect_error_Izpt();
|
||||||
@ -34,7 +38,9 @@ void init_analog_protect_levels(void) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
#define AMPL_TO_RMS 0.709
|
#define AMPL_TO_RMS 0.709
|
||||||
#define LEVEL_I_1_2_DIBALANCE 1118481
|
|
||||||
|
//#define LEVEL_I_1_2_DIBALANCE 1118481 // 200 A
|
||||||
|
#define LEVEL_I_1_2_DIBALANCE 1677721 // 300 A
|
||||||
|
|
||||||
void init_protect_3_phase(void) {
|
void init_protect_3_phase(void) {
|
||||||
analog_protect.in_voltage[0].setup.levels.iqVal_module_max = edrk.iqMAX_U_IN;
|
analog_protect.in_voltage[0].setup.levels.iqVal_module_max = edrk.iqMAX_U_IN;
|
||||||
@ -196,13 +202,14 @@ void detect_protect_adc(_iq teta_ch1, _iq teta_ch2) {
|
|||||||
edrk.errors.e0.bits.U_B2C2_MAX |= analog_protect.in_voltage[1].errors.bits.phase_V_max;
|
edrk.errors.e0.bits.U_B2C2_MAX |= analog_protect.in_voltage[1].errors.bits.phase_V_max;
|
||||||
edrk.errors.e0.bits.U_IN_MAX |= analog_protect.in_voltage[1].errors.bits.module_max;
|
edrk.errors.e0.bits.U_IN_MAX |= analog_protect.in_voltage[1].errors.bits.module_max;
|
||||||
|
|
||||||
edrk.warnings.e8.bits.U_IN_20_PROCENTS_HIGH = analog_protect.in_voltage[0].over_limit.bits.module_20_percent_hi;
|
edrk.warnings.e8.bits.U_IN_20_PROCENTS_HIGH = analog_protect.in_voltage[0].over_limit.bits.module_20_percent_hi || analog_protect.in_voltage[1].over_limit.bits.module_20_percent_hi;
|
||||||
edrk.errors.e8.bits.U_IN_20_PROCENTS_HIGH |= analog_protect.in_voltage[0].errors.bits.module_20_percent_hi;
|
edrk.errors.e8.bits.U_IN_20_PROCENTS_HIGH |= analog_protect.in_voltage[0].errors.bits.module_20_percent_hi;
|
||||||
|
|
||||||
edrk.warnings.e8.bits.U_IN_20_PROCENTS_HIGH = analog_protect.in_voltage[1].over_limit.bits.module_20_percent_hi;
|
|
||||||
edrk.errors.e8.bits.U_IN_20_PROCENTS_HIGH |= analog_protect.in_voltage[1].errors.bits.module_20_percent_hi;
|
edrk.errors.e8.bits.U_IN_20_PROCENTS_HIGH |= analog_protect.in_voltage[1].errors.bits.module_20_percent_hi;
|
||||||
|
|
||||||
if (edrk.from_shema.bits.QTV_ON_OFF == 1) {
|
if (edrk.from_shema_filter.bits.QTV_ON_OFF == 1
|
||||||
|
// && edrk.to_shema.bits.QTV_ON
|
||||||
|
)
|
||||||
|
{
|
||||||
|
|
||||||
// êîíòðîëü íàïðÿæåíèé òîëüêî ïðè âêëþ÷åííîì ñèëîâîì àâòîìàòå
|
// êîíòðîëü íàïðÿæåíèé òîëüêî ïðè âêëþ÷åííîì ñèëîâîì àâòîìàòå
|
||||||
edrk.errors.e8.bits.U_IN_10_PROCENTS_LOW |= analog_protect.in_voltage[0].errors.bits.module_10_percent_low;
|
edrk.errors.e8.bits.U_IN_10_PROCENTS_LOW |= analog_protect.in_voltage[0].errors.bits.module_10_percent_low;
|
||||||
@ -211,11 +218,21 @@ void detect_protect_adc(_iq teta_ch1, _iq teta_ch2) {
|
|||||||
edrk.errors.e8.bits.U_IN_10_PROCENTS_LOW |= analog_protect.in_voltage[1].errors.bits.module_10_percent_low;
|
edrk.errors.e8.bits.U_IN_10_PROCENTS_LOW |= analog_protect.in_voltage[1].errors.bits.module_10_percent_low;
|
||||||
edrk.errors.e8.bits.U_IN_20_PROCENTS_LOW |= analog_protect.in_voltage[1].errors.bits.module_20_percent_low;
|
edrk.errors.e8.bits.U_IN_20_PROCENTS_LOW |= analog_protect.in_voltage[1].errors.bits.module_20_percent_low;
|
||||||
|
|
||||||
edrk.warnings.e8.bits.U_IN_10_PROCENTS_LOW = pause_detect_error(&counter_in1_minus10, TIME_DETECT_WARNING_U_PREDELS, analog_protect.in_voltage[0].over_limit.bits.module_10_percent_low);
|
edrk.warnings.e8.bits.U_IN_10_PROCENTS_LOW = pause_detect_error(&counter_in1_minus10,
|
||||||
edrk.warnings.e8.bits.U_IN_10_PROCENTS_LOW |= pause_detect_error(&counter_in2_minus10, TIME_DETECT_WARNING_U_PREDELS, analog_protect.in_voltage[1].over_limit.bits.module_10_percent_low);
|
TIME_DETECT_WARNING_U_PREDELS,
|
||||||
|
analog_protect.in_voltage[0].over_limit.bits.module_10_percent_low);
|
||||||
|
|
||||||
edrk.warnings.e8.bits.U_IN_20_PROCENTS_LOW = pause_detect_error(&counter_in1_minus20, TIME_DETECT_WARNING_U_PREDELS, analog_protect.in_voltage[0].over_limit.bits.module_20_percent_low);
|
edrk.warnings.e8.bits.U_IN_10_PROCENTS_LOW = pause_detect_error(&counter_in2_minus10,
|
||||||
edrk.warnings.e8.bits.U_IN_20_PROCENTS_LOW |= pause_detect_error(&counter_in2_minus20, TIME_DETECT_WARNING_U_PREDELS, analog_protect.in_voltage[1].over_limit.bits.module_20_percent_low);
|
TIME_DETECT_WARNING_U_PREDELS,
|
||||||
|
analog_protect.in_voltage[1].over_limit.bits.module_10_percent_low);
|
||||||
|
|
||||||
|
edrk.warnings.e8.bits.U_IN_20_PROCENTS_LOW = pause_detect_error(&counter_in1_minus20,
|
||||||
|
TIME_DETECT_WARNING_U_PREDELS,
|
||||||
|
analog_protect.in_voltage[0].over_limit.bits.module_20_percent_low);
|
||||||
|
|
||||||
|
edrk.warnings.e8.bits.U_IN_20_PROCENTS_LOW = pause_detect_error(&counter_in2_minus20,
|
||||||
|
TIME_DETECT_WARNING_U_PREDELS,
|
||||||
|
analog_protect.in_voltage[1].over_limit.bits.module_20_percent_low);
|
||||||
|
|
||||||
edrk.errors.e9.bits.DISBALANCE_Uin_1 |= analog_protect.in_voltage[0].errors.bits.system_asymmetry;
|
edrk.errors.e9.bits.DISBALANCE_Uin_1 |= analog_protect.in_voltage[0].errors.bits.system_asymmetry;
|
||||||
edrk.errors.e9.bits.DISBALANCE_Uin_2 |= analog_protect.in_voltage[1].errors.bits.system_asymmetry;
|
edrk.errors.e9.bits.DISBALANCE_Uin_2 |= analog_protect.in_voltage[1].errors.bits.system_asymmetry;
|
||||||
|
@ -33,7 +33,8 @@ typedef struct {
|
|||||||
|
|
||||||
#define ANALOG_ADC_PROTECT_DEFAULTS { \
|
#define ANALOG_ADC_PROTECT_DEFAULTS { \
|
||||||
{DETECT_PROTECT_3_PHASE_DEFAULTS,DETECT_PROTECT_3_PHASE_DEFAULTS},\
|
{DETECT_PROTECT_3_PHASE_DEFAULTS,DETECT_PROTECT_3_PHASE_DEFAULTS},\
|
||||||
{DETECT_PROTECT_3_PHASE_DEFAULTS,DETECT_PROTECT_3_PHASE_DEFAULTS}}
|
{DETECT_PROTECT_3_PHASE_DEFAULTS,DETECT_PROTECT_3_PHASE_DEFAULTS},\
|
||||||
|
0,0 }
|
||||||
|
|
||||||
void init_analog_protect_levels(void);
|
void init_analog_protect_levels(void);
|
||||||
void detect_protect_adc (_iq teta_ch1, _iq teta_ch2);
|
void detect_protect_adc (_iq teta_ch1, _iq teta_ch2);
|
||||||
|
@ -9,6 +9,7 @@
|
|||||||
#include <edrk_main.h>
|
#include <edrk_main.h>
|
||||||
#include <params_motor.h>
|
#include <params_motor.h>
|
||||||
#include <params_pwm24.h>
|
#include <params_pwm24.h>
|
||||||
|
#include "alg_simple_scalar.h"
|
||||||
|
|
||||||
#include "IQmathLib.h"
|
#include "IQmathLib.h"
|
||||||
|
|
||||||
@ -43,32 +44,49 @@ int calc_detect_overload(DETECT_OVERLOAD *v) {
|
|||||||
return v->overload_detected;
|
return v->overload_detected;
|
||||||
}
|
}
|
||||||
|
|
||||||
#define LIMIT_DETECT_LEVEL 15938355 //95%
|
#define LIMIT_DETECT_LEVEL 16273899 // 0.97 //15938355 //95%
|
||||||
|
|
||||||
void check_all_power_limits() {
|
void check_all_power_limits() {
|
||||||
_iq level_I_nominal = 0;
|
_iq level_I_nominal = 0;
|
||||||
|
|
||||||
edrk.power_limit.bits.limit_by_temper = edrk.temper_limit_koeffs.code_status;
|
//edrk.power_limit.bits.limit_by_temper = edrk.temper_limit_koeffs.code_status;
|
||||||
|
|
||||||
|
if (edrk.Go)
|
||||||
|
{
|
||||||
|
|
||||||
level_I_nominal = _IQmpy(LIMIT_DETECT_LEVEL, edrk.zadanie.iq_Izad_rmp);
|
level_I_nominal = _IQmpy(LIMIT_DETECT_LEVEL, edrk.zadanie.iq_Izad_rmp);
|
||||||
if ((filter.iqIm_1 > level_I_nominal) || (filter.iqIm_1 > level_I_nominal) ||
|
|
||||||
out_I_over_1_6.overload_detected) {
|
if ((filter.iqIm > level_I_nominal) ||
|
||||||
|
out_I_over_1_6.overload_detected)
|
||||||
|
{
|
||||||
edrk.power_limit.bits.limit_Iout = 1;
|
edrk.power_limit.bits.limit_Iout = 1;
|
||||||
} else {
|
} else
|
||||||
|
{
|
||||||
edrk.power_limit.bits.limit_Iout = 0;
|
edrk.power_limit.bits.limit_Iout = 0;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
edrk.power_limit.bits.limit_Iout = 0;
|
||||||
|
|
||||||
// edrk.power_limit.bits.limit_UOM =
|
// if (edrk.from_uom.code>1)
|
||||||
|
// edrk.power_limit.bits.limit_UOM = 1;
|
||||||
|
// else
|
||||||
|
// edrk.power_limit.bits.limit_UOM = 0;
|
||||||
|
|
||||||
if ((filter.PowerScalar + edrk.iq_power_kw_another_bs) >
|
//filter.PowerScalar + edrk.iq_power_kw_another_bs
|
||||||
_IQmpy(LIMIT_DETECT_LEVEL, edrk.zadanie.iq_limit_power_zad_rmp)
|
if ( (edrk.iq_power_kw_full_filter_abs > _IQmpy(LIMIT_DETECT_LEVEL, edrk.zadanie.iq_limit_power_zad_rmp))
|
||||||
|
|| simple_scalar1.flag_decr_mzz_power
|
||||||
// Äàííûé ñïîñîá äëÿ ñêàëÿðíîãî óïðàâëåíèÿ, äëÿ FOC, âîçìîæíî, íóæíà âåêòîðíàÿ ìîùíîñòü.
|
// Äàííûé ñïîñîá äëÿ ñêàëÿðíîãî óïðàâëåíèÿ, äëÿ FOC, âîçìîæíî, íóæíà âåêòîðíàÿ ìîùíîñòü.
|
||||||
) {
|
)
|
||||||
|
{
|
||||||
edrk.power_limit.bits.limit_from_SVU = 1;
|
edrk.power_limit.bits.limit_from_SVU = 1;
|
||||||
} else {
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
edrk.power_limit.bits.limit_from_SVU = 0;
|
edrk.power_limit.bits.limit_from_SVU = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
File diff suppressed because it is too large
Load Diff
@ -5,16 +5,25 @@
|
|||||||
|
|
||||||
#include "IQmathLib.h"
|
#include "IQmathLib.h"
|
||||||
#include "rmp_cntl_v1.h"
|
#include "rmp_cntl_v1.h"
|
||||||
|
#include "rmp_cntl_v2.h"
|
||||||
|
|
||||||
#include "alg_pll.h"
|
#include "alg_pll.h"
|
||||||
|
|
||||||
|
|
||||||
#define TIME_PAUSE_MODBUS_CAN_BS2BS 500
|
#define TIME_PAUSE_MODBUS_CAN_BS2BS 500 //900 //500
|
||||||
#define TIME_PAUSE_MODBUS_CAN_ZADATCHIK_VPU 100
|
#define TIME_PAUSE_MODBUS_CAN_ZADATCHIK_VPU 250 //100//100
|
||||||
#define TIME_PAUSE_MODBUS_CAN_UKSS_SETUP 5000
|
#define TIME_PAUSE_MODBUS_CAN_UKSS_SETUP 2500 //
|
||||||
#define TIME_PAUSE_MODBUS_CAN_MPU 500
|
#define TIME_PAUSE_MODBUS_CAN_MPU 1100 //500
|
||||||
#define TIME_PAUSE_MODBUS_CAN_TERMINALS 1000
|
#define TIME_PAUSE_MODBUS_CAN_TERMINALS 2000 //1000
|
||||||
#define TIME_PAUSE_MODBUS_CAN_OSCIL 5000
|
#define TIME_PAUSE_MODBUS_CAN_OSCIL 5000
|
||||||
|
|
||||||
|
//#define TIME_PAUSE_MODBUS_CAN_BS2BS 100//20//500
|
||||||
|
//#define TIME_PAUSE_MODBUS_CAN_ZADATCHIK_VPU 250//20//100
|
||||||
|
//#define TIME_PAUSE_MODBUS_CAN_UKSS_SETUP 5000
|
||||||
|
//#define TIME_PAUSE_MODBUS_CAN_MPU 500//20//500
|
||||||
|
//#define TIME_PAUSE_MODBUS_CAN_TERMINALS 1000
|
||||||
|
//#define TIME_PAUSE_MODBUS_CAN_OSCIL 5000
|
||||||
|
|
||||||
|
|
||||||
//#define TIME_PAUSE_MODBUS_CAN_TMS2TMS_VIPR 75 //500
|
//#define TIME_PAUSE_MODBUS_CAN_TMS2TMS_VIPR 75 //500
|
||||||
|
|
||||||
@ -134,6 +143,22 @@ enum
|
|||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
enum
|
||||||
|
{
|
||||||
|
STAGE_SBOR_STATUS_NO_STATUS = 0,
|
||||||
|
STAGE_SBOR_STATUS_FIRST,
|
||||||
|
STAGE_SBOR_STATUS_PUMP,
|
||||||
|
STAGE_SBOR_STATUS_ZARYAD,
|
||||||
|
STAGE_SBOR_STATUS_UMP_ON,
|
||||||
|
STAGE_SBOR_STATUS_QTV,
|
||||||
|
STAGE_SBOR_STATUS_UMP_OFF,
|
||||||
|
STAGE_SBOR_STATUS_RASCEPITEL_1,
|
||||||
|
STAGE_SBOR_STATUS_RASCEPITEL_2,
|
||||||
|
STAGE_SBOR_STATUS_RASCEPITEL_3,
|
||||||
|
STAGE_SBOR_STATUS_RASCEPITEL_4,
|
||||||
|
STAGE_SBOR_STATUS_WAIT_READY_ANOTHER,
|
||||||
|
STAGE_SBOR_STATUS_FINISH
|
||||||
|
};
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
|
||||||
@ -188,6 +213,7 @@ typedef struct
|
|||||||
float real_temper_air[4];
|
float real_temper_air[4];
|
||||||
int real_int_temper_air[4];
|
int real_int_temper_air[4];
|
||||||
int max_real_int_temper_air;
|
int max_real_int_temper_air;
|
||||||
|
int min_real_int_temper_air;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@ -195,7 +221,7 @@ typedef struct
|
|||||||
} TEMPER_EDRK;
|
} TEMPER_EDRK;
|
||||||
#define TEMPER_EDRK_DEFAULT {{0,0,0,0,0,0,0},{0,0,0,0,0,0,0},{0,0,0,0,0,0,0},0,\
|
#define TEMPER_EDRK_DEFAULT {{0,0,0,0,0,0,0},{0,0,0,0,0,0,0},{0,0,0,0,0,0,0},0,\
|
||||||
{0,0},{0,0},{0,0},0,\
|
{0,0},{0,0},{0,0},0,\
|
||||||
{0,0,0,0},{0,0,0,0},{0,0,0,0},0\
|
{0,0,0,0},{0,0,0,0},{0,0,0,0},0,0\
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -514,8 +540,15 @@ typedef struct
|
|||||||
unsigned int ERR_PWM_WDOG :1;
|
unsigned int ERR_PWM_WDOG :1;
|
||||||
|
|
||||||
unsigned int ERR_INT_PWM_VERY_LONG : 1;
|
unsigned int ERR_INT_PWM_VERY_LONG : 1;
|
||||||
|
unsigned int SENSOR_ROTOR_1_BREAK : 1;
|
||||||
|
unsigned int SENSOR_ROTOR_2_BREAK : 1;
|
||||||
|
unsigned int SENSOR_ROTOR_1_2_BREAK : 1;
|
||||||
|
|
||||||
unsigned int res: 7;
|
unsigned int SENSOR_ROTOR_BREAK_DIRECTION : 1;
|
||||||
|
|
||||||
|
unsigned int BREAK_TEMPER_WARNING : 1;
|
||||||
|
unsigned int BREAK_TEMPER_ALARM : 1;
|
||||||
|
unsigned int BREAKER_GED_ON : 1;
|
||||||
|
|
||||||
} bits;
|
} bits;
|
||||||
} e9;
|
} e9;
|
||||||
@ -685,8 +718,8 @@ typedef union {
|
|||||||
|
|
||||||
|
|
||||||
} bits;
|
} bits;
|
||||||
} AUTO_MASTER_SLAVE_DATA;
|
|
||||||
|
|
||||||
|
} AUTO_MASTER_SLAVE_DATA;
|
||||||
////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////
|
||||||
typedef union {
|
typedef union {
|
||||||
unsigned int all;
|
unsigned int all;
|
||||||
@ -704,11 +737,10 @@ typedef union {
|
|||||||
|
|
||||||
unsigned int Batt: 1;
|
unsigned int Batt: 1;
|
||||||
unsigned int ImitationReady2: 1;
|
unsigned int ImitationReady2: 1;
|
||||||
|
|
||||||
unsigned int MasterSlaveActive: 1; // âûñòàâèì åñëè åñòü master èëè slave
|
unsigned int MasterSlaveActive: 1; // âûñòàâèì åñëè åñòü master èëè slave
|
||||||
|
unsigned int preImitationReady2: 1;
|
||||||
|
|
||||||
|
unsigned int res:4;
|
||||||
// unsigned int res:6;
|
|
||||||
} bits;
|
} bits;
|
||||||
} STATUS_READY;
|
} STATUS_READY;
|
||||||
////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////
|
||||||
@ -833,8 +865,14 @@ typedef union {
|
|||||||
unsigned int PLUS: 1;
|
unsigned int PLUS: 1;
|
||||||
unsigned int MINUS : 1;
|
unsigned int MINUS : 1;
|
||||||
unsigned int PROVOROT :1 ;
|
unsigned int PROVOROT :1 ;
|
||||||
unsigned int ACTIVE : 1;
|
|
||||||
unsigned int res:11;
|
unsigned int UOM_READY_ACTIVE : 1;
|
||||||
|
unsigned int UOM_LIMIT_3 : 1;
|
||||||
|
unsigned int UOM_LIMIT_2 : 1;
|
||||||
|
unsigned int UOM_LIMIT_1 : 1;
|
||||||
|
|
||||||
|
|
||||||
|
unsigned int res:8;
|
||||||
} bits;
|
} bits;
|
||||||
} FROM_ZADAT4IK;
|
} FROM_ZADAT4IK;
|
||||||
////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////
|
||||||
@ -875,14 +913,14 @@ typedef union {
|
|||||||
union {
|
union {
|
||||||
unsigned int all;
|
unsigned int all;
|
||||||
struct {
|
struct {
|
||||||
unsigned int GOTOV1: 1;
|
unsigned int GOTOV1 : 1;
|
||||||
unsigned int GOTOV2: 1;
|
unsigned int GOTOV2 : 1;
|
||||||
// unsigned int EMKOST : 1; //For 23550.3 and AVARIA moved up
|
unsigned int EMKOST : 1; //For 23550.3 and AVARIA moved up
|
||||||
unsigned int AVARIA:1;
|
unsigned int NEISPRAVNOST : 1;
|
||||||
unsigned int NEISPRAVNOST :1 ;
|
|
||||||
unsigned int PEREGREV : 1;
|
unsigned int PEREGREV : 1;
|
||||||
unsigned int OGRAN_POWER : 1;
|
unsigned int OGRAN_POWER : 1;
|
||||||
unsigned int res:10;
|
unsigned int AVARIA : 1;
|
||||||
|
unsigned int res:9;
|
||||||
} bits;
|
} bits;
|
||||||
} BIG_LAMS;
|
} BIG_LAMS;
|
||||||
|
|
||||||
@ -923,6 +961,10 @@ typedef union {
|
|||||||
} APL_LAMS_PCH;
|
} APL_LAMS_PCH;
|
||||||
|
|
||||||
} TO_ZADAT4IK;
|
} TO_ZADAT4IK;
|
||||||
|
|
||||||
|
#define TO_ZADAT4IK_DEFAULT {0,0,0,0,0}
|
||||||
|
|
||||||
|
|
||||||
////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////
|
||||||
typedef struct {
|
typedef struct {
|
||||||
|
|
||||||
@ -947,12 +989,18 @@ typedef union {
|
|||||||
} BIG_LAMS;
|
} BIG_LAMS;
|
||||||
|
|
||||||
} TO_VPU;
|
} TO_VPU;
|
||||||
|
|
||||||
|
#define TO_VPU_DEFAULT {0,0,0}
|
||||||
|
|
||||||
////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////
|
||||||
typedef struct {
|
typedef struct {
|
||||||
|
|
||||||
unsigned int level_value;
|
unsigned int level_value;
|
||||||
unsigned int ready;
|
unsigned int ready;
|
||||||
unsigned int error;
|
unsigned int error;
|
||||||
|
unsigned int code;
|
||||||
|
_iq iq_level_value;
|
||||||
|
_iq iq_level_value_kwt;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@ -1020,12 +1068,17 @@ typedef struct {
|
|||||||
RMP_V1 rmp_k_u_disbalance;
|
RMP_V1 rmp_k_u_disbalance;
|
||||||
RMP_V1 rmp_kplus_u_disbalance;
|
RMP_V1 rmp_kplus_u_disbalance;
|
||||||
RMP_V1 rmp_Izad;
|
RMP_V1 rmp_Izad;
|
||||||
RMP_V1 rmp_powers_zad;
|
|
||||||
RMP_V1 rmp_limit_powers_zad;
|
RMP_V2 rmp_powers_zad;
|
||||||
|
|
||||||
|
RMP_V2 rmp_limit_powers_zad;
|
||||||
RMP_V1 rmp_kzad;
|
RMP_V1 rmp_kzad;
|
||||||
RMP_V1 rmp_oborots_zad_hz;
|
|
||||||
|
|
||||||
|
RMP_V2 rmp_oborots_zad_hz;
|
||||||
|
|
||||||
|
RMP_V1 rmp_oborots_imitation;
|
||||||
|
|
||||||
|
_iq rmp_oborots_imitation_rmp;
|
||||||
|
|
||||||
|
|
||||||
float ZadanieU_Charge;
|
float ZadanieU_Charge;
|
||||||
@ -1033,6 +1086,7 @@ typedef struct {
|
|||||||
_iq iq_ZadanieU_Charge_rmp;
|
_iq iq_ZadanieU_Charge_rmp;
|
||||||
|
|
||||||
float oborots_zad;
|
float oborots_zad;
|
||||||
|
|
||||||
float oborots_zad_hz;
|
float oborots_zad_hz;
|
||||||
_iq iq_oborots_zad_hz;
|
_iq iq_oborots_zad_hz;
|
||||||
_iq iq_oborots_zad_hz_rmp;
|
_iq iq_oborots_zad_hz_rmp;
|
||||||
@ -1065,37 +1119,154 @@ typedef struct {
|
|||||||
_iq iq_limit_power_zad;
|
_iq iq_limit_power_zad;
|
||||||
_iq iq_limit_power_zad_rmp;
|
_iq iq_limit_power_zad_rmp;
|
||||||
|
|
||||||
|
_iq iq_set_break_level;
|
||||||
|
|
||||||
|
float oborots_zad_no_dead_zone;
|
||||||
|
|
||||||
} ZADANIE;
|
} ZADANIE;
|
||||||
|
|
||||||
#define ZADANIE_DEFAULT { RMP_V1_DEFAULTS, RMP_V1_DEFAULTS,RMP_V1_DEFAULTS,\
|
#define ZADANIE_DEFAULT { RMP_V1_DEFAULTS, RMP_V1_DEFAULTS,RMP_V1_DEFAULTS,\
|
||||||
RMP_V1_DEFAULTS,RMP_V1_DEFAULTS,RMP_V1_DEFAULTS,RMP_V1_DEFAULTS,RMP_V1_DEFAULTS,RMP_V1_DEFAULTS,\
|
RMP_V1_DEFAULTS,RMP_V1_DEFAULTS,\
|
||||||
0,0,0,0,0, 0,0,0,0,0, 0,0,0,0,0, 0,0,0,0,0,0,0,0,0,0 , 0,0,0}
|
RMP_V2_DEFAULTS,\
|
||||||
|
RMP_V2_DEFAULTS,RMP_V1_DEFAULTS,\
|
||||||
|
RMP_V2_DEFAULTS,\
|
||||||
|
RMP_V1_DEFAULTS,\
|
||||||
|
0, 0,0,0,0,0, 0,0,0,0,0, 0,0,0,0,0, 0,0,0,0,0,0,0,0,0,0 , 0,0,0, 0,0}
|
||||||
|
|
||||||
typedef union {
|
typedef union {
|
||||||
struct {
|
struct {
|
||||||
unsigned int limit_by_temper;
|
unsigned int limit_by_temper:1;
|
||||||
unsigned int limit_Iout;
|
unsigned int limit_Iout:1;
|
||||||
unsigned int limit_UOM; //Óñòðîéñòâî îãðàíè÷åíèÿ ìîùíîñòè
|
unsigned int limit_UOM:1; //Óñòðîéñòâî îãðàíè÷åíèÿ ìîùíîñòè
|
||||||
unsigned int limit_from_SVU;
|
unsigned int limit_from_SVU:1;
|
||||||
|
unsigned int limit_from_freq:1;
|
||||||
|
unsigned int limit_from_uom_fast:1;
|
||||||
|
unsigned int limit_moment:1;
|
||||||
|
|
||||||
|
unsigned int res:9;
|
||||||
} bits;
|
} bits;
|
||||||
unsigned int all;
|
unsigned int all;
|
||||||
} POWER_LIMIT;
|
} POWER_LIMIT;
|
||||||
|
|
||||||
#define POWER_LIMIT_DEFAULTS {0,0,0,0}
|
#define POWER_LIMIT_DEFAULTS {0}
|
||||||
|
|
||||||
|
|
||||||
|
typedef struct {
|
||||||
|
|
||||||
|
_iq temper_limit;
|
||||||
|
_iq power_limit;
|
||||||
|
_iq moment_limit;
|
||||||
|
_iq uin_freq_limit;
|
||||||
|
_iq uom_limit;
|
||||||
|
|
||||||
|
_iq local_temper_limit;
|
||||||
|
_iq local_power_limit;
|
||||||
|
_iq local_moment_limit;
|
||||||
|
_iq local_uin_freq_limit;
|
||||||
|
_iq local_uom_limit;
|
||||||
|
|
||||||
|
_iq sum_limit;
|
||||||
|
_iq local_sum_limit;
|
||||||
|
int code_status;
|
||||||
|
|
||||||
|
} ALL_LIMIT_KOEFFS;
|
||||||
|
|
||||||
|
#define ALL_LIMIT_KOEFFS_DEFAULTS {0,0,0,0,0, 0,0,0,0,0, 0,0,0}
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
_iq power_units;
|
_iq power_units;
|
||||||
_iq area;
|
_iq area;
|
||||||
_iq water_int;
|
_iq water_int;
|
||||||
_iq water_ext;
|
_iq water_ext;
|
||||||
_iq acdrive_windings;
|
_iq acdrive_windings;
|
||||||
|
|
||||||
_iq acdrive_bears;
|
_iq acdrive_bears;
|
||||||
_iq sum_limit;
|
_iq sum_limit;
|
||||||
int code_status;
|
int code_status;
|
||||||
} TEMPERATURE_LIMIT_KOEFFS;
|
} TEMPERATURE_LIMIT_KOEFFS;
|
||||||
|
|
||||||
#define TEMPERATURE_LIMIT_KOEFFS_DEFAULTS {0,0,0,0,0,0,0}
|
#define TEMPERATURE_LIMIT_KOEFFS_DEFAULTS {0,0,0,0,0, 0,CONST_IQ_1,0}
|
||||||
|
|
||||||
|
#define COUNT_MOTO_PULT 18
|
||||||
|
|
||||||
|
typedef struct
|
||||||
|
{
|
||||||
|
|
||||||
|
int nPCH;
|
||||||
|
int TimeToChangePump;
|
||||||
|
|
||||||
|
int count_revers; // êîë-âî ðåâåðñîâ
|
||||||
|
int count_build; // êîë-âî ñáîðîê ñõåì
|
||||||
|
|
||||||
|
int LastWorkPump; // êàêîé áûë ïîñëåäíèé çàïóùåííûé íàñîñ
|
||||||
|
|
||||||
|
int moto[COUNT_MOTO_PULT];
|
||||||
|
|
||||||
|
} t_params_pult_ing_one;
|
||||||
|
|
||||||
|
#define PARAMS_PULT_ING_ONE_DEFAULTS {-1,-1, -1,-1, 0, \
|
||||||
|
{-1,-1,-1,-1,-1, -1,-1,-1,-1,-1, -1,-1,-1,-1,-1, -1,-1,-1 } }
|
||||||
|
|
||||||
|
#define PARAMS_PULT_ING_TWO_DEFAULTS {0,0, 0,0, 0, \
|
||||||
|
{0,0,0,0,0, 0,0,0,0,0, 0,0,0,0,0, 0,0,0 } }
|
||||||
|
|
||||||
|
typedef struct
|
||||||
|
{
|
||||||
|
int flagSaveDataPCH;
|
||||||
|
int flagSaveDataMoto;
|
||||||
|
int flagSaveSlowLogs;
|
||||||
|
int flagSaveParamLogs;
|
||||||
|
|
||||||
|
int logger_params[28];
|
||||||
|
|
||||||
|
t_params_pult_ing_one data;
|
||||||
|
t_params_pult_ing_one data_from_pult;
|
||||||
|
t_params_pult_ing_one data_to_pult;
|
||||||
|
|
||||||
|
// int nPCH_from_pult;
|
||||||
|
// int nPCH_to_pult;
|
||||||
|
// int nPCH;
|
||||||
|
//
|
||||||
|
// int TimeToChangePump_from_pult;
|
||||||
|
// int TimeToChangePump_to_pult;
|
||||||
|
// int TimeToChangePump;
|
||||||
|
//
|
||||||
|
// int moto_from_pult[COUNT_MOTO_PULT];
|
||||||
|
// int mot_to_pult[COUNT_MOTO_PULT];
|
||||||
|
// int moto[COUNT_MOTO_PULT];
|
||||||
|
//
|
||||||
|
// int count_revers_from_pult;
|
||||||
|
// int count_revers_to_pult;
|
||||||
|
|
||||||
|
} t_params_pult_ing;
|
||||||
|
|
||||||
|
#define PARAMS_PULT_ING_DEFAULTS {0,0,0,0, \
|
||||||
|
{0,0,0,0,0, 0,0,0,0,0, 0,0,0,0,0, 0,0,0,0,0, 0,0,0,0,0, 0,0,0}, \
|
||||||
|
PARAMS_PULT_ING_TWO_DEFAULTS, \
|
||||||
|
PARAMS_PULT_ING_ONE_DEFAULTS, \
|
||||||
|
PARAMS_PULT_ING_ONE_DEFAULTS \
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
typedef struct
|
||||||
|
{
|
||||||
|
int log_what_memory; // Çíà÷åíèå 0 - íåò íè ôëåøêè, íè êàðòû;
|
||||||
|
//Çíà÷åíèå 1 - íåò ôëåøêè, åñòü êàðòà;
|
||||||
|
//Çíà÷åíèå 2 - åñòü ôëåøêà, íåò êàðòû;
|
||||||
|
//Çíà÷åíèå 3 - åñòü è ôëåøêà è êàðòà;
|
||||||
|
int kvitir; //
|
||||||
|
int sbor;
|
||||||
|
int send_log;
|
||||||
|
int pump_mode;
|
||||||
|
int sdusb;// 0 - sd, 1 usb
|
||||||
|
|
||||||
|
} t_pult_cmd_ing;
|
||||||
|
|
||||||
|
#define PULT_CMD_ING_DEFAULTS 0,0,0,0,0,0
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////
|
||||||
typedef struct
|
typedef struct
|
||||||
@ -1110,6 +1281,7 @@ typedef struct
|
|||||||
|
|
||||||
POWER_LIMIT power_limit;
|
POWER_LIMIT power_limit;
|
||||||
TEMPERATURE_LIMIT_KOEFFS temper_limit_koeffs;
|
TEMPERATURE_LIMIT_KOEFFS temper_limit_koeffs;
|
||||||
|
ALL_LIMIT_KOEFFS all_limit_koeffs;
|
||||||
|
|
||||||
MASTER_SLAVE_COM ms;
|
MASTER_SLAVE_COM ms;
|
||||||
|
|
||||||
@ -1142,6 +1314,7 @@ typedef struct
|
|||||||
TO_SHEMA to_shema;//1
|
TO_SHEMA to_shema;//1
|
||||||
|
|
||||||
FROM_SHEMA from_shema;//1
|
FROM_SHEMA from_shema;//1
|
||||||
|
FROM_SHEMA from_shema_filter;//1
|
||||||
|
|
||||||
FROM_ZADAT4IK from_zadat4ik;//1
|
FROM_ZADAT4IK from_zadat4ik;//1
|
||||||
|
|
||||||
@ -1163,7 +1336,7 @@ typedef struct
|
|||||||
|
|
||||||
TO_VPU to_vpu;//3
|
TO_VPU to_vpu;//3
|
||||||
|
|
||||||
FROM_UOM from_uom;//4
|
FROM_UOM from_uom;//7
|
||||||
///////////////////////////////////////////////
|
///////////////////////////////////////////////
|
||||||
|
|
||||||
unsigned int Discharge;
|
unsigned int Discharge;
|
||||||
@ -1186,6 +1359,7 @@ typedef struct
|
|||||||
|
|
||||||
unsigned int prevGo;
|
unsigned int prevGo;
|
||||||
unsigned int Go;
|
unsigned int Go;
|
||||||
|
unsigned int GoBreak;
|
||||||
|
|
||||||
unsigned int GoWait;
|
unsigned int GoWait;
|
||||||
|
|
||||||
@ -1193,6 +1367,8 @@ typedef struct
|
|||||||
int flag_block_zadanie;
|
int flag_block_zadanie;
|
||||||
int StartGEDfromControl;
|
int StartGEDfromControl;
|
||||||
int StartGEDfromZadanie;
|
int StartGEDfromZadanie;
|
||||||
|
int prevStartGEDfromZadanie;
|
||||||
|
|
||||||
int StartGED;
|
int StartGED;
|
||||||
int test_mode;
|
int test_mode;
|
||||||
int cmd_to_qtv;//20
|
int cmd_to_qtv;//20
|
||||||
@ -1267,7 +1443,8 @@ typedef struct
|
|||||||
_iq iq_f_rotor_hz;
|
_iq iq_f_rotor_hz;
|
||||||
float f_rotor_hz;
|
float f_rotor_hz;
|
||||||
int oborots;
|
int oborots;
|
||||||
float power_kw;
|
int rotor_direction;
|
||||||
|
int power_kw;
|
||||||
// _iq iq_oborots;
|
// _iq iq_oborots;
|
||||||
|
|
||||||
_iq Izad_out;
|
_iq Izad_out;
|
||||||
@ -1299,7 +1476,7 @@ typedef struct
|
|||||||
int warning;
|
int warning;
|
||||||
int overheat;
|
int overheat;
|
||||||
|
|
||||||
unsigned MasterSlave;
|
unsigned int MasterSlave;
|
||||||
|
|
||||||
_iq master_theta;
|
_iq master_theta;
|
||||||
_iq master_Uzad;
|
_iq master_Uzad;
|
||||||
@ -1331,10 +1508,14 @@ typedef struct
|
|||||||
int Ready1_another_bs;
|
int Ready1_another_bs;
|
||||||
int Ready2_another_bs;
|
int Ready2_another_bs;
|
||||||
|
|
||||||
|
int ump_cmd_another_bs;
|
||||||
|
int qtv_cmd_another_bs;
|
||||||
|
|
||||||
int active_post_upravl;
|
int active_post_upravl;
|
||||||
int active_post_upravl_another_bs;
|
int active_post_upravl_another_bs;
|
||||||
int MasterSlave_another_bs;
|
int MasterSlave_another_bs;
|
||||||
int freq_50hz;
|
int freq_50hz_1;
|
||||||
|
int freq_50hz_2;
|
||||||
|
|
||||||
_iq test_rms_Iu;
|
_iq test_rms_Iu;
|
||||||
_iq test_rms_Ua;
|
_iq test_rms_Ua;
|
||||||
@ -1356,8 +1537,97 @@ typedef struct
|
|||||||
int disable_rascepitel_work;
|
int disable_rascepitel_work;
|
||||||
|
|
||||||
int enable_pwm_test_lines;
|
int enable_pwm_test_lines;
|
||||||
|
int count_bs_work;
|
||||||
|
|
||||||
|
unsigned int run_to_pwm_async;
|
||||||
|
|
||||||
|
int power_kw_full;
|
||||||
|
|
||||||
|
int stop_logs_rs232;
|
||||||
|
int sbor_wait_ump1;
|
||||||
|
int sbor_wait_ump2;
|
||||||
|
int flag_enable_on_ump;
|
||||||
|
|
||||||
|
int local_ump_on_off;
|
||||||
|
int local_ump_on_off_count;
|
||||||
|
int local_ready_ump;
|
||||||
|
int local_ready_ump_count;
|
||||||
|
|
||||||
|
t_params_pult_ing pult_data;
|
||||||
|
|
||||||
|
int logs_rotor;
|
||||||
|
|
||||||
|
int stop_slow_log;
|
||||||
|
int t_slow_log;
|
||||||
|
int disable_limit_power_from_svu;
|
||||||
|
int disable_uom;
|
||||||
|
int disable_break_work;
|
||||||
|
|
||||||
|
int flag_another_bs_first_ready12;
|
||||||
|
int flag_this_bs_first_ready12;
|
||||||
|
int enter_to_pump_stage;
|
||||||
|
|
||||||
|
int buildYear;
|
||||||
|
int buildMonth;
|
||||||
|
int buildDay;
|
||||||
|
|
||||||
|
int errors_another_bs_from_can;
|
||||||
|
|
||||||
|
unsigned int count_sbor;
|
||||||
|
unsigned int count_revers;
|
||||||
|
unsigned int count_run;
|
||||||
|
|
||||||
|
int flag_slow_in_main;
|
||||||
|
|
||||||
|
t_pult_cmd_ing pult_cmd;
|
||||||
|
|
||||||
|
int get_new_data_from_hmi2;
|
||||||
|
|
||||||
|
_iq iq_freq_50hz;
|
||||||
|
|
||||||
|
int imit_limit_freq;
|
||||||
|
int imit_limit_uom;
|
||||||
|
int set_limit_uom_50;
|
||||||
|
|
||||||
|
_iq iq_power_kw_full_znak;
|
||||||
|
_iq iq_power_kw_one_znak;
|
||||||
|
|
||||||
|
_iq iq_power_kw_full_filter_znak;
|
||||||
|
_iq iq_power_kw_one_filter_znak;
|
||||||
|
|
||||||
|
_iq iq_power_kw_full_abs;
|
||||||
|
_iq iq_power_kw_one_abs;
|
||||||
|
|
||||||
|
_iq iq_power_kw_full_filter_abs;
|
||||||
|
_iq iq_power_kw_one_filter_abs;
|
||||||
|
|
||||||
|
unsigned int sum_count_err_read_opt_bus;
|
||||||
|
|
||||||
|
int imit_save_slow_logs;
|
||||||
|
|
||||||
|
int imit_send_alarm_log_pult;
|
||||||
|
|
||||||
|
int current_active_control;
|
||||||
|
|
||||||
|
// int data_to_message2[100];
|
||||||
//101
|
//101
|
||||||
|
unsigned long canes_reg;
|
||||||
|
unsigned long cantec_reg; // Transmit Error Counter
|
||||||
|
unsigned long canrec_reg; // Receive Error Counter
|
||||||
|
|
||||||
|
int cmd_clear_can_error;
|
||||||
|
|
||||||
|
int cmd_very_slow_start;
|
||||||
|
|
||||||
|
int cmd_imit_low_isolation;
|
||||||
|
|
||||||
|
|
||||||
|
int breaker_on;
|
||||||
|
int break_tempers[4];
|
||||||
|
|
||||||
|
int cmd_disable_calc_km_on_slave;
|
||||||
|
|
||||||
|
|
||||||
} EDRK;
|
} EDRK;
|
||||||
|
|
||||||
|
|
||||||
@ -1365,53 +1635,70 @@ typedef struct
|
|||||||
#define EDRK_DEFAULT { \
|
#define EDRK_DEFAULT { \
|
||||||
ZADANIE_DEFAULT,\
|
ZADANIE_DEFAULT,\
|
||||||
ZADANIE_FROM_ANOTHER_BS_DEFAULT,\
|
ZADANIE_FROM_ANOTHER_BS_DEFAULT,\
|
||||||
TEMPER_EDRK_DEFAULT, P_WATER_EDRK_DEFAULT, \
|
TEMPER_EDRK_DEFAULT, \
|
||||||
ERRORS_EDRK_DEFAULT, ERRORS_EDRK_DEFAULT,\
|
P_WATER_EDRK_DEFAULT, \
|
||||||
TEMPER_ACDRIVE_DEFAULT,\
|
ERRORS_EDRK_DEFAULT, \
|
||||||
POWER_LIMIT_DEFAULTS,\
|
ERRORS_EDRK_DEFAULT, \
|
||||||
TEMPERATURE_LIMIT_KOEFFS_DEFAULTS,\
|
TEMPER_ACDRIVE_DEFAULT, \
|
||||||
MASTER_SLAVE_COM_DEFAULT,\
|
POWER_LIMIT_DEFAULTS, \
|
||||||
0,0,0,0,0,0,\
|
TEMPERATURE_LIMIT_KOEFFS_DEFAULTS, \
|
||||||
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,\
|
ALL_LIMIT_KOEFFS_DEFAULTS, \
|
||||||
0,0,0,0,0,\
|
MASTER_SLAVE_COM_DEFAULT, \
|
||||||
0,0,0,0,\
|
0,0,0,0,0,0, \
|
||||||
0,0,0,\
|
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, \
|
||||||
0,0,0,0,\
|
0,0,0,0,0, \
|
||||||
|
0,0,0,0, \
|
||||||
|
0,0,0, \
|
||||||
|
0,0,0,0,0,0,0, \
|
||||||
\
|
\
|
||||||
0,0,0,0,0,0,0,0,0,0,\
|
0,0,0,0,0,0,0,0,0,0, \
|
||||||
0,0,0,0,0,0,0,0,0,0,\
|
0,0,0,0,0,0,0,0,0,0, \
|
||||||
0,0,0,0,0,0,0,0,0,0,\
|
0,0,0,0,0,0,0,0,0,0, \
|
||||||
0,0,0,0,0,0,0,0,0,0,\
|
0,0,0,0,0,0,0,0,0,0, \
|
||||||
0,0,0,0,0,0,0,0,0,0,\
|
0,0,0,0,0,0,0,0,0,0, \
|
||||||
0,0,0,0,0,0,0,0,0,0,\
|
0,0,0,0,0,0,0,0,0,0, \
|
||||||
0,0,0,0,0,0,0,0,0,0,\
|
0,0,0,0,0,0,0,0,0,0, \
|
||||||
0,0,0,0,0,0,0,0,0,0,\
|
0,0,0,0,0,0,0,0,0,0, \
|
||||||
0,0,0,0,0,0,0,0,0,0,\
|
0,0,0,0,0,0,0,0,0,0, \
|
||||||
0,0,0,0,0,0,0,0,0,0,0,0,\
|
0,0,0,0,0,0,0,0,0,0,0,0, \
|
||||||
0,0,0,0,0,0,0,0,0,0, 0,0,\
|
0,0,0,0,0,0,0,0,0,0, 0,0, \
|
||||||
0,0,0,0,0,0,0,0,0,0,0,0 \
|
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, \
|
||||||
|
0,0,0,0, \
|
||||||
|
PARAMS_PULT_ING_DEFAULTS, \
|
||||||
|
0,0,0,0,0,0,0,0, \
|
||||||
|
0,0,0,\
|
||||||
|
0, 0,0,0, 0, \
|
||||||
|
PULT_CMD_ING_DEFAULTS, 0,0, 0,0,0, 0,0,0,0, 0,0,0,0, \
|
||||||
|
0, 0,0, 0, 0, \
|
||||||
|
0,0,0, 0, 0, 0, \
|
||||||
|
0, {0,0,0,0}, \
|
||||||
|
0 \
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
extern EDRK edrk;
|
extern EDRK edrk;
|
||||||
|
extern PLL_REC pll1;
|
||||||
|
|
||||||
float get_sensor_ing(void);
|
//float get_sensor_ing(void);
|
||||||
float get_i_vozbud(void);
|
//float get_i_vozbud(void);
|
||||||
float get_zad_vozbud(void);
|
//float get_zad_vozbud(void);
|
||||||
|
|
||||||
unsigned int convert_w_to_mA(float inp);
|
//unsigned int convert_w_to_mA(float inp);
|
||||||
|
|
||||||
void edrk_init(void);
|
void edrk_init(void);
|
||||||
|
|
||||||
|
|
||||||
void update_input_edrk(void);
|
void update_input_edrk(void);
|
||||||
void update_output_edrk(void);
|
void update_output_edrk(void);
|
||||||
|
|
||||||
float get_amper_vozbud(void);
|
|
||||||
|
|
||||||
void set_amper_vozbud(float set_curr, float cur_curr);
|
//float get_amper_vozbud(void);
|
||||||
|
|
||||||
|
//void set_amper_vozbud(float set_curr, float cur_curr);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
void write_dac(int ndac, int Value);
|
//void write_dac(int ndac, int Value);
|
||||||
|
|
||||||
void run_edrk(void);
|
void run_edrk(void);
|
||||||
|
|
||||||
@ -1420,63 +1707,52 @@ void run_edrk(void);
|
|||||||
void set_oborots_from_zadat4ik(void);
|
void set_oborots_from_zadat4ik(void);
|
||||||
void get_where_oborots(void);
|
void get_where_oborots(void);
|
||||||
|
|
||||||
void update_errors(void);
|
//void update_errors(void);
|
||||||
|
|
||||||
|
|
||||||
void calc_p_water_edrk(void);
|
|
||||||
|
|
||||||
|
|
||||||
unsigned int pause_detect_error(unsigned int *c_err, unsigned int max_wait,unsigned int flag);
|
|
||||||
|
|
||||||
void nagrev_auto_on_off(void);
|
|
||||||
unsigned int zaryad_on_off(unsigned int flag);
|
//unsigned int zaryad_on_off(unsigned int flag);
|
||||||
|
|
||||||
|
|
||||||
void update_lamp_alarm(void);
|
void update_lamp_alarm(void);
|
||||||
void auto_block_key_on_off(void);
|
|
||||||
void nagrev_auto_on_off(void);
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
int get_status_temper_acdrive_winding(int nc);
|
|
||||||
int get_status_temper_acdrive_bear(int nc);
|
|
||||||
int get_status_temper_air(int nc);
|
//int get_status_temper_acdrive_winding(int nc);
|
||||||
int get_status_temper_u(int nc);
|
//int get_status_temper_acdrive_bear(int nc);
|
||||||
int get_status_temper_water(int nc);
|
//int get_status_temper_air(int nc);
|
||||||
int get_status_p_water_max(void);
|
//int get_status_temper_u(int nc);
|
||||||
int get_status_p_water_min(int pump_on_off);
|
//int get_status_temper_water(int nc);
|
||||||
|
//int get_status_p_water_max(void);
|
||||||
|
//int get_status_p_water_min(int pump_on_off);
|
||||||
|
|
||||||
void detect_kvitir_from_all(void);
|
void detect_kvitir_from_all(void);
|
||||||
void set_status_pump_fan(void);
|
//void set_status_pump_fan(void);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
int qtv_on_off(unsigned int flag);
|
int qtv_on_off(unsigned int flag);
|
||||||
|
|
||||||
int detect_error_u_zpt(void);
|
///int detect_error_u_zpt(void);
|
||||||
int detect_error_u_zpt_on_predzaryad(void);
|
//int detect_error_u_zpt_on_predzaryad(void);
|
||||||
|
|
||||||
void set_zadanie_u_charge(void);
|
void set_zadanie_u_charge(void);
|
||||||
|
|
||||||
void update_ukss_can(unsigned int pause);
|
|
||||||
void update_ukss_setup(unsigned int pause);
|
|
||||||
void update_bsu_can(unsigned int pause);
|
|
||||||
void init_can_box_between_bs1_bs2(void);
|
|
||||||
|
|
||||||
unsigned int filter_err_count(unsigned int *counter, unsigned int max_errors, unsigned int err, unsigned int cmd);
|
|
||||||
|
|
||||||
void detect_alive_another_bs(void);
|
|
||||||
|
|
||||||
void auto_select_master_slave(void);
|
|
||||||
|
|
||||||
void clear_errors_master_slave(void);
|
|
||||||
|
|
||||||
void who_select_sync_signal(void);
|
|
||||||
|
|
||||||
void clear_wait_synhro_optical_bus(void);
|
|
||||||
|
|
||||||
unsigned int wait_synhro_optical_bus(void);
|
|
||||||
|
|
||||||
|
|
||||||
void edrk_init_variables(void);
|
void edrk_init_variables(void);
|
||||||
|
|
||||||
@ -1486,41 +1762,53 @@ void edrk_go_main(void);
|
|||||||
|
|
||||||
int get_start_ged_from_zadanie(void);
|
int get_start_ged_from_zadanie(void);
|
||||||
|
|
||||||
void ramp_all_zadanie(int flag_set_zero);
|
|
||||||
void init_ramp_all_zadanie(void);
|
|
||||||
|
|
||||||
void UpdateTableSecondBS(void);
|
//void UpdateTableSecondBS(void);
|
||||||
|
|
||||||
unsigned int get_ready_1(void);
|
unsigned int get_ready_1(void);
|
||||||
|
|
||||||
int detect_zaryad_ump(void);
|
//int detect_zaryad_ump(void);
|
||||||
|
|
||||||
void cross_stend_automats(void);
|
void cross_stend_automats(void);
|
||||||
|
|
||||||
|
|
||||||
void update_zadat4ik(void);
|
|
||||||
|
|
||||||
void get_sumsbor_command(void);
|
void get_sumsbor_command(void);
|
||||||
|
|
||||||
|
|
||||||
unsigned int read_cmd_sbor_from_bs(void);
|
//unsigned int read_cmd_sbor_from_bs(void);
|
||||||
|
|
||||||
void read_data_from_bs(void);
|
//void read_data_from_bs(void);
|
||||||
|
|
||||||
|
|
||||||
void check_change_post_upravl(void);
|
void check_change_post_upravl(void);
|
||||||
int get_code_active_post_upravl(void);
|
int get_code_active_post_upravl(void);
|
||||||
|
|
||||||
|
|
||||||
void get_freq_50hz(void);
|
|
||||||
void calc_pll_50hz(void);
|
|
||||||
void init_50hz_input_net50hz(void);
|
|
||||||
void auto_detect_zero_u_zpt(void);
|
void auto_detect_zero_u_zpt(void);
|
||||||
|
|
||||||
_iq calc_rms(_iq input, _iq input_prev, _iq freq_signal);
|
void run_can_from_mpu(void);
|
||||||
|
void set_new_level_i_protect(int n_af, int level);
|
||||||
|
void update_maz_level_i_af(int n_af, unsigned int new_maz_level);
|
||||||
|
void calc_count_build_revers(void);
|
||||||
|
int calc_auto_moto_pump(void);
|
||||||
|
void prepare_logger_pult(void);
|
||||||
|
void read_can_error(void);
|
||||||
|
void clear_can_error(void);
|
||||||
|
void cmd_clear_can_error(void);
|
||||||
|
void check_temper_break(void);
|
||||||
|
void check_breaker_ged(void);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
//extern int ccc[40];
|
||||||
|
|
||||||
|
void reinit_before_sbor(void);
|
||||||
|
unsigned int toggle_status_lamp(unsigned int bb1, unsigned int flag);
|
||||||
|
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
@ -17,5 +17,18 @@ MODE_SLAVE
|
|||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
//////////////////////////////////////////////////////////
|
||||||
|
#define MAX_COUNT_TRY_MASTER_BS1 200//40 //15 //5
|
||||||
|
#define MAX_COUNT_TRY_MASTER_BS2 100//40 //15 //40 //20
|
||||||
|
#define MAX_COUNT_WAIT_ANSWER_CONFIRM_MODE 20
|
||||||
|
|
||||||
|
#define MAX_COUNT_WAIT_SLAVE_TRY_MASTER 100
|
||||||
|
|
||||||
|
|
||||||
|
#define SIZE_LOG_MASTER_SLAVE_STATUS 50
|
||||||
|
|
||||||
|
void auto_select_master_slave(void);
|
||||||
|
void clear_errors_master_slave(void);
|
||||||
|
|
||||||
|
|
||||||
#endif /* SRC_MASTER_SLAVE_H_ */
|
#endif /* SRC_MASTER_SLAVE_H_ */
|
||||||
|
@ -22,7 +22,13 @@
|
|||||||
#include "xp_hwp.h"
|
#include "xp_hwp.h"
|
||||||
#include "xp_project.h"
|
#include "xp_project.h"
|
||||||
#include "modbus_table_v2.h"
|
#include "modbus_table_v2.h"
|
||||||
|
#include "filter_v1.h"
|
||||||
|
#include "v_rotor_22220.h"
|
||||||
|
#include "log_params.h"
|
||||||
|
#include "break_regul.h"
|
||||||
|
#include "logs_hmi.h"
|
||||||
|
#include "CAN_Setup.h"
|
||||||
|
#include "params_temper_p.h"
|
||||||
|
|
||||||
|
|
||||||
void func_unpack_answer_from_TMS_RS232(CMD_TO_TMS_STRUCT *pcommand)
|
void func_unpack_answer_from_TMS_RS232(CMD_TO_TMS_STRUCT *pcommand)
|
||||||
@ -101,8 +107,8 @@ void func_pack_answer_to_TMS(TMS_TO_TERMINAL_STRUCT *reply_a)
|
|||||||
/* const óêàçàòåëü íà ñòðóêòóðó ñòàíäàðòíîé êîìàíäû
|
/* const óêàçàòåëü íà ñòðóêòóðó ñòàíäàðòíîé êîìàíäû
|
||||||
íàñòðîèëè íà áóôåð ïðèåìà */
|
íàñòðîèëè íà áóôåð ïðèåìà */
|
||||||
|
|
||||||
|
// edrk.data_to_message2[1] = _IQtoF(filter.iqU_1_long)*NORMA_ACP;
|
||||||
|
// edrk.data_to_message2[2] = _IQtoF(filter.iqU_2_long)*NORMA_ACP;
|
||||||
|
|
||||||
|
|
||||||
//For instance
|
//For instance
|
||||||
@ -147,7 +153,6 @@ void func_pack_answer_to_TMS(TMS_TO_TERMINAL_STRUCT *reply_a)
|
|||||||
reply_a->analog_data.analog7_hi = HIBYTE(Data);
|
reply_a->analog_data.analog7_hi = HIBYTE(Data);
|
||||||
|
|
||||||
Data = _IQtoF(filter.iqIm_2)*NORMA_ACP;//project.adc[0].read.pbus.adc_value[3];
|
Data = _IQtoF(filter.iqIm_2)*NORMA_ACP;//project.adc[0].read.pbus.adc_value[3];
|
||||||
|
|
||||||
reply_a->analog_data.analog8_lo = LOBYTE(Data);
|
reply_a->analog_data.analog8_lo = LOBYTE(Data);
|
||||||
reply_a->analog_data.analog8_hi = HIBYTE(Data);
|
reply_a->analog_data.analog8_hi = HIBYTE(Data);
|
||||||
|
|
||||||
@ -163,31 +168,31 @@ void func_pack_answer_to_TMS(TMS_TO_TERMINAL_STRUCT *reply_a)
|
|||||||
reply_a->analog_data.analog11_lo = LOBYTE(Data);
|
reply_a->analog_data.analog11_lo = LOBYTE(Data);
|
||||||
reply_a->analog_data.analog11_hi = HIBYTE(Data);
|
reply_a->analog_data.analog11_hi = HIBYTE(Data);
|
||||||
|
|
||||||
Data = (int) (edrk.temper_edrk.max_real_int_temper_air);//_IQtoF(edrk.f_stator)*F_STATOR_MAX;//
|
Data = (int) (edrk.temper_edrk.max_real_int_temper_air);//_IQtoF(edrk.f_stator)*F_STATOR_MAX;//
|
||||||
reply_a->analog_data.analog12_lo = LOBYTE(Data);
|
reply_a->analog_data.analog12_lo = LOBYTE(Data);
|
||||||
reply_a->analog_data.analog12_hi = HIBYTE(Data);
|
reply_a->analog_data.analog12_hi = HIBYTE(Data);
|
||||||
|
|
||||||
Data = fast_round(_IQtoF(edrk.zadanie.iq_ZadanieU_Charge_rmp)*NORMA_ACP);//edrk.I_zad_vozbud;//
|
Data = fast_round(_IQtoF(edrk.zadanie.iq_ZadanieU_Charge_rmp)*NORMA_ACP);//edrk.I_zad_vozbud;//
|
||||||
reply_a->analog_data.analog13_lo = LOBYTE(Data);
|
reply_a->analog_data.analog13_lo = LOBYTE(Data);
|
||||||
reply_a->analog_data.analog13_hi = HIBYTE(Data);
|
reply_a->analog_data.analog13_hi = HIBYTE(Data);
|
||||||
|
|
||||||
Data = edrk.zadanie.oborots_zad;//edrk.I_zad_vozbud_exp;//
|
Data = edrk.zadanie.oborots_zad;//edrk.I_zad_vozbud_exp;//
|
||||||
reply_a->analog_data.analog14_lo = LOBYTE(Data);
|
reply_a->analog_data.analog14_lo = LOBYTE(Data);
|
||||||
reply_a->analog_data.analog14_hi = HIBYTE(Data);
|
reply_a->analog_data.analog14_hi = HIBYTE(Data);
|
||||||
|
|
||||||
Data = edrk.zadanie.power_zad;//edrk.I_cur_vozbud;//
|
Data = edrk.zadanie.power_zad;//edrk.I_cur_vozbud;//
|
||||||
reply_a->analog_data.analog15_lo = LOBYTE(Data);
|
reply_a->analog_data.analog15_lo = LOBYTE(Data);
|
||||||
reply_a->analog_data.analog15_hi = HIBYTE(Data);
|
reply_a->analog_data.analog15_hi = HIBYTE(Data);
|
||||||
|
|
||||||
Data = edrk.zadanie.Izad;//edrk.I_cur_vozbud_exp;//
|
Data = edrk.zadanie.Izad;//edrk.I_cur_vozbud_exp;//
|
||||||
reply_a->analog_data.analog16_lo = LOBYTE(Data);
|
reply_a->analog_data.analog16_lo = LOBYTE(Data);
|
||||||
reply_a->analog_data.analog16_hi = HIBYTE(Data);
|
reply_a->analog_data.analog16_hi = HIBYTE(Data);
|
||||||
|
|
||||||
Data = fast_round(_IQtoF(edrk.Kplus)*1000.0);//edrk.W_zad_mA;//
|
Data = fast_round(_IQtoF(edrk.Kplus)*1000.0);//edrk.W_zad_mA;//
|
||||||
reply_a->analog_data.analog17_lo = LOBYTE(Data);
|
reply_a->analog_data.analog17_lo = LOBYTE(Data);
|
||||||
reply_a->analog_data.analog17_hi = HIBYTE(Data);
|
reply_a->analog_data.analog17_hi = HIBYTE(Data);
|
||||||
|
|
||||||
Data = fast_round(edrk.freq_50hz/10.0);//edrk.Zadanie2VozbudING;//
|
Data = fast_round(edrk.freq_50hz_1/10.0);//edrk.Zadanie2VozbudING;//
|
||||||
reply_a->analog_data.analog18_lo = LOBYTE(Data);
|
reply_a->analog_data.analog18_lo = LOBYTE(Data);
|
||||||
reply_a->analog_data.analog18_hi = HIBYTE(Data);
|
reply_a->analog_data.analog18_hi = HIBYTE(Data);
|
||||||
|
|
||||||
@ -199,15 +204,16 @@ Data = fast_round(_IQtoF(edrk.k_stator1)*10000.0);// edrk.W_from_all;
|
|||||||
reply_a->analog_data.analog20_lo = LOBYTE(Data);
|
reply_a->analog_data.analog20_lo = LOBYTE(Data);
|
||||||
reply_a->analog_data.analog20_hi = HIBYTE(Data);
|
reply_a->analog_data.analog20_hi = HIBYTE(Data);
|
||||||
|
|
||||||
Data =_IQtoF(edrk.test_rms_Iu)*NORMA_ACP; //fast_round(_IQtoF(WRotor.iqWRotorImpulses1)*NORMA_FROTOR*1000.0);// edrk.W_from_DISPLAY;
|
Data = _IQtoF(vect_control.iqId1)*NORMA_ACP;//0;//_IQtoF(edrk.test_rms_Iu)*NORMA_ACP; //fast_round(_IQtoF(WRotor.iqWRotorImpulses1)*NORMA_FROTOR*1000.0);// edrk.W_from_DISPLAY;
|
||||||
reply_a->analog_data.analog21_lo = LOBYTE(Data);
|
reply_a->analog_data.analog21_lo = LOBYTE(Data);
|
||||||
reply_a->analog_data.analog21_hi = HIBYTE(Data);
|
reply_a->analog_data.analog21_hi = HIBYTE(Data);
|
||||||
|
|
||||||
Data =_IQtoF(edrk.test_rms_Ua)*NORMA_ACP;// fast_round(_IQtoF(WRotor.iqWRotorImpulses2)*NORMA_FROTOR*1000.0);//600.0*1000000000.0/WRotor.iqWRotorImpulses1;//edrk.W_from_SVU;
|
Data = _IQtoF(vect_control.iqIq1)*NORMA_ACP;// 0;//_IQtoF(edrk.test_rms_Ua)*NORMA_ACP;// fast_round(_IQtoF(WRotor.iqWRotorImpulses2)*NORMA_FROTOR*1000.0);//600.0*1000000000.0/WRotor.iqWRotorImpulses1;//edrk.W_from_SVU;
|
||||||
reply_a->analog_data.analog22_lo = LOBYTE(Data);
|
reply_a->analog_data.analog22_lo = LOBYTE(Data);
|
||||||
reply_a->analog_data.analog22_hi = HIBYTE(Data);
|
reply_a->analog_data.analog22_hi = HIBYTE(Data);
|
||||||
|
|
||||||
Data = edrk.oborots;//fast_round(_IQtoF(WRotorPBus.iqAngle1F)*360.0);//600.0*1000000000.0/WRotor.iqWRotorImpulses2;//edrk.W_from_ZADAT4IK;
|
//Data = fast_round(_IQtoF(WRotor.iqWRotorSumFilter3)*NORMA_FROTOR*100.0*60.0);//edrk.oborots;//fast_round(_IQtoF(WRotorPBus.iqAngle1F)*360.0);//600.0*1000000000.0/WRotor.iqWRotorImpulses2;//edrk.W_from_ZADAT4IK;
|
||||||
|
Data = _IQtoF(WRotor.iqWRotorSumFilter) * NORMA_FROTOR*600.0;//edrk.oborots;
|
||||||
reply_a->analog_data.analog23_lo = LOBYTE(Data);
|
reply_a->analog_data.analog23_lo = LOBYTE(Data);
|
||||||
reply_a->analog_data.analog23_hi = HIBYTE(Data);
|
reply_a->analog_data.analog23_hi = HIBYTE(Data);
|
||||||
|
|
||||||
@ -216,11 +222,12 @@ Data = fast_round(edrk.f_rotor_hz*100.0);//fast_round(_IQtoF(WRotorPBus.iqAngle2
|
|||||||
reply_a->analog_data.analog24_hi = HIBYTE(Data);
|
reply_a->analog_data.analog24_hi = HIBYTE(Data);
|
||||||
|
|
||||||
//Data = _IQtoF(edrk.k_stator1)*10000;//;
|
//Data = _IQtoF(edrk.k_stator1)*10000;//;
|
||||||
Data = fast_round(_IQtoF(WRotor.iqWRotorCalcBeforeRegul1)*NORMA_FROTOR*1000.0);
|
Data = edrk.period_calc_pwm_int2;//fast_round(_IQtoF(rotor_22220.iqFdirty)*NORMA_FROTOR*1000.0);
|
||||||
reply_a->analog_data.analog25_lo = LOBYTE(Data);
|
reply_a->analog_data.analog25_lo = LOBYTE(Data);
|
||||||
reply_a->analog_data.analog25_hi = HIBYTE(Data);
|
reply_a->analog_data.analog25_hi = HIBYTE(Data);
|
||||||
|
|
||||||
Data = fast_round(_IQtoF(WRotor.iqWRotorCalcBeforeRegul2)*NORMA_FROTOR*1000.0);
|
Data = edrk.power_kw_full; //Ìîùíîñòü äâèãàòåëÿ òåêóùàÿ êÂò
|
||||||
|
//fast_round(_IQtoF(WRotor.iqWRotorCalcBeforeRegul2)*NORMA_FROTOR*1000.0);
|
||||||
reply_a->analog_data.analog26_lo = LOBYTE(Data);
|
reply_a->analog_data.analog26_lo = LOBYTE(Data);
|
||||||
reply_a->analog_data.analog26_hi = HIBYTE(Data);
|
reply_a->analog_data.analog26_hi = HIBYTE(Data);
|
||||||
|
|
||||||
@ -240,56 +247,59 @@ Data = edrk.period_calc_pwm_int1;
|
|||||||
reply_a->analog_data.analog30_lo = LOBYTE(Data);
|
reply_a->analog_data.analog30_lo = LOBYTE(Data);
|
||||||
reply_a->analog_data.analog30_hi = HIBYTE(Data);
|
reply_a->analog_data.analog30_hi = HIBYTE(Data);
|
||||||
|
|
||||||
|
Data = (int)edrk.temper_acdrive.winding.max_real_int_temper;
|
||||||
Data = (int)(edrk.temper_edrk.real_int_temper_u[0]);
|
|
||||||
reply_a->analog_data.analog31_lo = LOBYTE(Data);
|
reply_a->analog_data.analog31_lo = LOBYTE(Data);
|
||||||
reply_a->analog_data.analog31_hi = HIBYTE(Data);
|
reply_a->analog_data.analog31_hi = HIBYTE(Data);
|
||||||
|
Data = (int)edrk.temper_acdrive.bear.max_real_int_temper;
|
||||||
Data = (int)(edrk.temper_edrk.real_int_temper_u[1]);
|
|
||||||
reply_a->analog_data.analog32_lo = LOBYTE(Data);
|
reply_a->analog_data.analog32_lo = LOBYTE(Data);
|
||||||
reply_a->analog_data.analog32_hi = HIBYTE(Data);
|
reply_a->analog_data.analog32_hi = HIBYTE(Data);
|
||||||
Data = (int)(edrk.temper_edrk.real_int_temper_u[2]);
|
|
||||||
|
|
||||||
|
|
||||||
|
Data = (int)(edrk.temper_edrk.real_int_temper_u[0]);
|
||||||
reply_a->analog_data.analog33_lo = LOBYTE(Data);
|
reply_a->analog_data.analog33_lo = LOBYTE(Data);
|
||||||
reply_a->analog_data.analog33_hi = HIBYTE(Data);
|
reply_a->analog_data.analog33_hi = HIBYTE(Data);
|
||||||
Data = (int)(edrk.temper_edrk.real_int_temper_u[3]);
|
|
||||||
|
Data = (int)(edrk.temper_edrk.real_int_temper_u[1]);
|
||||||
reply_a->analog_data.analog34_lo = LOBYTE(Data);
|
reply_a->analog_data.analog34_lo = LOBYTE(Data);
|
||||||
reply_a->analog_data.analog34_hi = HIBYTE(Data);
|
reply_a->analog_data.analog34_hi = HIBYTE(Data);
|
||||||
Data = (int)(edrk.temper_edrk.real_int_temper_u[4]);
|
Data = (int)(edrk.temper_edrk.real_int_temper_u[2]);
|
||||||
reply_a->analog_data.analog35_lo = LOBYTE(Data);
|
reply_a->analog_data.analog35_lo = LOBYTE(Data);
|
||||||
reply_a->analog_data.analog35_hi = HIBYTE(Data);
|
reply_a->analog_data.analog35_hi = HIBYTE(Data);
|
||||||
Data = (int)(edrk.temper_edrk.real_int_temper_u[5]);
|
Data = (int)(edrk.temper_edrk.real_int_temper_u[3]);
|
||||||
reply_a->analog_data.analog36_lo = LOBYTE(Data);
|
reply_a->analog_data.analog36_lo = LOBYTE(Data);
|
||||||
reply_a->analog_data.analog36_hi = HIBYTE(Data);
|
reply_a->analog_data.analog36_hi = HIBYTE(Data);
|
||||||
Data = (int)(edrk.temper_edrk.real_int_temper_u[6]);
|
Data = (int)(edrk.temper_edrk.real_int_temper_u[4]);
|
||||||
reply_a->analog_data.analog37_lo = LOBYTE(Data);
|
reply_a->analog_data.analog37_lo = LOBYTE(Data);
|
||||||
reply_a->analog_data.analog37_hi = HIBYTE(Data);
|
reply_a->analog_data.analog37_hi = HIBYTE(Data);
|
||||||
Data = (int)(edrk.temper_edrk.real_int_temper_air[0]);
|
Data = (int)(edrk.temper_edrk.real_int_temper_u[5]);
|
||||||
reply_a->analog_data.analog38_lo = LOBYTE(Data);
|
reply_a->analog_data.analog38_lo = LOBYTE(Data);
|
||||||
reply_a->analog_data.analog38_hi = HIBYTE(Data);
|
reply_a->analog_data.analog38_hi = HIBYTE(Data);
|
||||||
Data = (int)(edrk.temper_edrk.real_int_temper_air[1]);
|
Data = (int)(edrk.temper_edrk.real_int_temper_u[6]);
|
||||||
reply_a->analog_data.analog39_lo = LOBYTE(Data);
|
reply_a->analog_data.analog39_lo = LOBYTE(Data);
|
||||||
reply_a->analog_data.analog39_hi = HIBYTE(Data);
|
reply_a->analog_data.analog39_hi = HIBYTE(Data);
|
||||||
Data = (int)(edrk.temper_edrk.real_int_temper_air[2]);
|
Data = (int)(edrk.temper_edrk.real_int_temper_air[0]);
|
||||||
reply_a->analog_data.analog40_lo = LOBYTE(Data);
|
reply_a->analog_data.analog40_lo = LOBYTE(Data);
|
||||||
reply_a->analog_data.analog40_hi = HIBYTE(Data);
|
reply_a->analog_data.analog40_hi = HIBYTE(Data);
|
||||||
|
Data = (int)(edrk.temper_edrk.real_int_temper_air[1]);
|
||||||
Data = (int)(edrk.temper_edrk.real_int_temper_air[3]);
|
|
||||||
reply_a->analog_data.analog41_lo = LOBYTE(Data);
|
reply_a->analog_data.analog41_lo = LOBYTE(Data);
|
||||||
reply_a->analog_data.analog41_hi = HIBYTE(Data);
|
reply_a->analog_data.analog41_hi = HIBYTE(Data);
|
||||||
Data = (int)(edrk.temper_edrk.real_int_temper_water[0]); // external
|
Data = (int)(edrk.temper_edrk.real_int_temper_air[2]);
|
||||||
reply_a->analog_data.analog42_lo = LOBYTE(Data);
|
reply_a->analog_data.analog42_lo = LOBYTE(Data);
|
||||||
reply_a->analog_data.analog42_hi = HIBYTE(Data);
|
reply_a->analog_data.analog42_hi = HIBYTE(Data);
|
||||||
Data = (int)(edrk.temper_edrk.real_int_temper_water[1]); // internal
|
|
||||||
|
Data = (int)(edrk.temper_edrk.real_int_temper_air[3]);
|
||||||
reply_a->analog_data.analog43_lo = LOBYTE(Data);
|
reply_a->analog_data.analog43_lo = LOBYTE(Data);
|
||||||
reply_a->analog_data.analog43_hi = HIBYTE(Data);
|
reply_a->analog_data.analog43_hi = HIBYTE(Data);
|
||||||
Data = (int)edrk.temper_acdrive.winding.max_real_int_temper;
|
Data = (int)(edrk.temper_edrk.real_int_temper_water[0]); // external
|
||||||
reply_a->analog_data.analog44_lo = LOBYTE(Data);
|
reply_a->analog_data.analog44_lo = LOBYTE(Data);
|
||||||
reply_a->analog_data.analog44_hi = HIBYTE(Data);
|
reply_a->analog_data.analog44_hi = HIBYTE(Data);
|
||||||
Data = (int)edrk.temper_acdrive.bear.max_real_int_temper;
|
Data = (int)(edrk.temper_edrk.real_int_temper_water[1]); // internal
|
||||||
reply_a->analog_data.analog45_lo = LOBYTE(Data);
|
reply_a->analog_data.analog45_lo = LOBYTE(Data);
|
||||||
reply_a->analog_data.analog45_hi = HIBYTE(Data);
|
reply_a->analog_data.analog45_hi = HIBYTE(Data);
|
||||||
|
|
||||||
Data = edrk.auto_master_slave.prev_status;//fast_round(_IQtoF(edrk.zadanie.iq_ZadanieU_Charge_rmp)*NORMA_ACP);
|
|
||||||
|
Data = fast_round(_IQtoF(simple_scalar1.pidF.OutMax)*NORMA_ACP);//edrk.auto_master_slave.prev_status;//fast_round(_IQtoF(edrk.zadanie.iq_ZadanieU_Charge_rmp)*NORMA_ACP);
|
||||||
reply_a->analog_data.analog46_lo = LOBYTE(Data);
|
reply_a->analog_data.analog46_lo = LOBYTE(Data);
|
||||||
reply_a->analog_data.analog46_hi = HIBYTE(Data);
|
reply_a->analog_data.analog46_hi = HIBYTE(Data);
|
||||||
|
|
||||||
@ -311,15 +321,14 @@ Data = edrk.period_calc_pwm_int1;
|
|||||||
reply_a->analog_data.analog51_lo = LOBYTE(Data);
|
reply_a->analog_data.analog51_lo = LOBYTE(Data);
|
||||||
reply_a->analog_data.analog51_hi = HIBYTE(Data);
|
reply_a->analog_data.analog51_hi = HIBYTE(Data);
|
||||||
|
|
||||||
Data = fast_round( _IQtoF(edrk.zadanie.iq_k_u_disbalance_rmp)*100.0);
|
Data = _IQtoF(vect_control.iqId2)*NORMA_ACP;//0;//fast_round( _IQtoF(edrk.zadanie.iq_k_u_disbalance_rmp)*100.0);
|
||||||
reply_a->analog_data.analog52_lo = LOBYTE(Data);
|
reply_a->analog_data.analog52_lo = LOBYTE(Data);
|
||||||
reply_a->analog_data.analog52_hi = HIBYTE(Data);
|
reply_a->analog_data.analog52_hi = HIBYTE(Data);
|
||||||
|
|
||||||
Data = edrk.auto_master_slave.status;//fast_round(_IQtoF(edrk.zadanie.iq_kplus_u_disbalance_rmp)*1000.0);
|
Data = fast_round(_IQtoF(edrk.zadanie.iq_limit_power_zad_rmp)*NORMA_ACP*NORMA_ACP/1000.0);
|
||||||
reply_a->analog_data.analog53_lo = LOBYTE(Data);
|
reply_a->analog_data.analog53_lo = LOBYTE(Data);
|
||||||
reply_a->analog_data.analog53_hi = HIBYTE(Data);
|
reply_a->analog_data.analog53_hi = HIBYTE(Data);
|
||||||
|
|
||||||
|
|
||||||
if (edrk.Mode_ScalarVectorUFConst == ALG_MODE_FOC_OBOROTS || edrk.Mode_ScalarVectorUFConst == ALG_MODE_FOC_POWER) {
|
if (edrk.Mode_ScalarVectorUFConst == ALG_MODE_FOC_OBOROTS || edrk.Mode_ScalarVectorUFConst == ALG_MODE_FOC_POWER) {
|
||||||
Data = fast_round(_IQtoF(turns.pidFvect.Out)*NORMA_ACP);
|
Data = fast_round(_IQtoF(turns.pidFvect.Out)*NORMA_ACP);
|
||||||
reply_a->analog_data.analog54_lo = LOBYTE(Data);
|
reply_a->analog_data.analog54_lo = LOBYTE(Data);
|
||||||
@ -335,7 +344,7 @@ Data = edrk.period_calc_pwm_int1;
|
|||||||
Data = fast_round(_IQtoF(simple_scalar1.pidF.Out)*NORMA_ACP);
|
Data = fast_round(_IQtoF(simple_scalar1.pidF.Out)*NORMA_ACP);
|
||||||
reply_a->analog_data.analog54_lo = LOBYTE(Data);
|
reply_a->analog_data.analog54_lo = LOBYTE(Data);
|
||||||
reply_a->analog_data.analog54_hi = HIBYTE(Data);
|
reply_a->analog_data.analog54_hi = HIBYTE(Data);
|
||||||
Data = fast_round(_IQtoF(simple_scalar1.pidF.OutMax)*NORMA_ACP);
|
Data = fast_round(_IQtoF(simple_scalar1.pidF.OutMin)*NORMA_ACP);
|
||||||
reply_a->analog_data.analog55_lo = LOBYTE(Data);
|
reply_a->analog_data.analog55_lo = LOBYTE(Data);
|
||||||
reply_a->analog_data.analog55_hi = HIBYTE(Data);
|
reply_a->analog_data.analog55_hi = HIBYTE(Data);
|
||||||
Data =fast_round(_IQtoF(simple_scalar1.pidPower.Out)*NORMA_ACP);
|
Data =fast_round(_IQtoF(simple_scalar1.pidPower.Out)*NORMA_ACP);
|
||||||
@ -346,13 +355,18 @@ Data = edrk.period_calc_pwm_int1;
|
|||||||
|
|
||||||
reply_a->analog_data.analog57_lo = LOBYTE(Data);
|
reply_a->analog_data.analog57_lo = LOBYTE(Data);
|
||||||
reply_a->analog_data.analog57_hi = HIBYTE(Data);
|
reply_a->analog_data.analog57_hi = HIBYTE(Data);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
Data = fast_round(_IQtoF(simple_scalar1.Izad)*NORMA_ACP);
|
Data = fast_round(_IQtoF(simple_scalar1.Izad)*NORMA_ACP);
|
||||||
reply_a->analog_data.analog58_lo = LOBYTE(Data);
|
reply_a->analog_data.analog58_lo = LOBYTE(Data);
|
||||||
reply_a->analog_data.analog58_hi = HIBYTE(Data);
|
reply_a->analog_data.analog58_hi = HIBYTE(Data);
|
||||||
|
|
||||||
Data = fast_round(_IQtoF(edrk.master_Iq)*NORMA_ACP);
|
Data = fast_round(_IQtoF(edrk.master_Iq)*NORMA_ACP);
|
||||||
reply_a->analog_data.analog59_lo = LOBYTE(Data);
|
reply_a->analog_data.analog59_lo = LOBYTE(Data);
|
||||||
reply_a->analog_data.analog59_hi = HIBYTE(Data);
|
reply_a->analog_data.analog59_hi = HIBYTE(Data);
|
||||||
Data = fast_round(_IQtoF(simple_scalar1.mzz_zad)*NORMA_ACP);//count_transmited++;
|
|
||||||
|
Data = fast_round(_IQtoF(simple_scalar1.mzz_zad_in2)*NORMA_ACP);//count_transmited++;
|
||||||
reply_a->analog_data.analog60_lo = LOBYTE(Data);
|
reply_a->analog_data.analog60_lo = LOBYTE(Data);
|
||||||
reply_a->analog_data.analog60_hi = HIBYTE(Data);
|
reply_a->analog_data.analog60_hi = HIBYTE(Data);
|
||||||
//
|
//
|
||||||
@ -372,25 +386,153 @@ Data = edrk.period_calc_pwm_int1;
|
|||||||
reply_a->analog_data.analog64_lo = LOBYTE(Data);
|
reply_a->analog_data.analog64_lo = LOBYTE(Data);
|
||||||
reply_a->analog_data.analog64_hi = HIBYTE(Data);
|
reply_a->analog_data.analog64_hi = HIBYTE(Data);
|
||||||
|
|
||||||
Data = project.cds_tk[3].optical_data_in.local_count_error;
|
Data = fast_round(_IQtoF(simple_scalar1.pidPower.SatErr)*NORMA_ACP);//project.cds_tk[3].optical_data_in.local_count_error;
|
||||||
reply_a->analog_data.analog65_lo = LOBYTE(Data);
|
reply_a->analog_data.analog65_lo = LOBYTE(Data);
|
||||||
reply_a->analog_data.analog65_hi = HIBYTE(Data);
|
reply_a->analog_data.analog65_hi = HIBYTE(Data);
|
||||||
|
|
||||||
Data = project.cds_tk[3].optical_data_out.local_count_error;
|
Data = fast_round(_IQtoF(simple_scalar1.pidPower.Fdb)*NORMA_ACP*NORMA_ACP/1000.0);//project.cds_tk[3].optical_data_out.local_count_error;
|
||||||
reply_a->analog_data.analog66_lo = LOBYTE(Data);
|
reply_a->analog_data.analog66_lo = LOBYTE(Data);
|
||||||
reply_a->analog_data.analog66_hi = HIBYTE(Data);
|
reply_a->analog_data.analog66_hi = HIBYTE(Data);
|
||||||
|
|
||||||
Data = optical_read_data.count_error_wdog;
|
Data = fast_round(_IQtoF(simple_scalar1.pidPower.Ref)*NORMA_ACP*NORMA_ACP/1000.0);//////optical_read_data.count_error_wdog;
|
||||||
reply_a->analog_data.analog67_lo = LOBYTE(Data);
|
reply_a->analog_data.analog67_lo = LOBYTE(Data);
|
||||||
reply_a->analog_data.analog67_hi = HIBYTE(Data);
|
reply_a->analog_data.analog67_hi = HIBYTE(Data);
|
||||||
|
|
||||||
Data = edrk.period_calc_pwm_int2;
|
|
||||||
|
Data = fast_round(_IQtoF(simple_scalar1.pidPower.Up)*NORMA_ACP);//edrk.auto_master_slave.status;//fast_round(_IQtoF(edrk.zadanie.iq_kplus_u_disbalance_rmp)*1000.0);
|
||||||
reply_a->analog_data.analog68_lo = LOBYTE(Data);
|
reply_a->analog_data.analog68_lo = LOBYTE(Data);
|
||||||
reply_a->analog_data.analog68_hi = HIBYTE(Data);
|
reply_a->analog_data.analog68_hi = HIBYTE(Data);
|
||||||
|
|
||||||
|
Data = fast_round(_IQtoF(pll1.vars.pll_Uq)*NORMA_ACP);
|
||||||
|
reply_a->analog_data.analog69_lo = LOBYTE(Data);
|
||||||
|
reply_a->analog_data.analog69_hi = HIBYTE(Data);
|
||||||
|
|
||||||
|
Data = fast_round(_IQtoF(pll1.vars.pll_Ud)*NORMA_ACP);
|
||||||
|
reply_a->analog_data.analog70_lo = LOBYTE(Data);
|
||||||
|
reply_a->analog_data.analog70_hi = HIBYTE(Data);
|
||||||
|
|
||||||
|
Data = fast_round(_IQtoF(simple_scalar1.bpsi_curent)*NORMA_FROTOR*1000.0);
|
||||||
|
reply_a->analog_data.analog71_lo = LOBYTE(Data);
|
||||||
|
reply_a->analog_data.analog71_hi = HIBYTE(Data);
|
||||||
|
|
||||||
|
Data = fast_round(_IQtoF(WRotor.iqWRotorSumFilter2)*NORMA_FROTOR*1000.0); //iqFlong
|
||||||
|
reply_a->analog_data.analog72_lo = LOBYTE(Data);
|
||||||
|
reply_a->analog_data.analog72_hi = HIBYTE(Data);
|
||||||
|
|
||||||
|
//Data = fast_round(_IQtoF(WRotor.iqWRotorCalc1)*NORMA_FROTOR*1000.0);
|
||||||
|
Data = fast_round(_IQtoF(edrk.from_uom.iq_level_value_kwt)*NORMA_ACP*NORMA_ACP/1000.0);// ;//edrk.from_uom.level_value;//fast_round(_IQtoF(rotor_22220.iqFdirty)*NORMA_FROTOR*1000.0);
|
||||||
|
reply_a->analog_data.analog73_lo = LOBYTE(Data);
|
||||||
|
reply_a->analog_data.analog73_hi = HIBYTE(Data);
|
||||||
|
|
||||||
|
//Data = fast_round(_IQtoF(WRotor.iqWRotorCalc2)*NORMA_FROTOR*1000.0);
|
||||||
|
Data = _IQtoF(vect_control.iqIq2)*NORMA_ACP;//0;//fast_round(_IQtoF(rotor_22220.iqF)*NORMA_FROTOR*1000.0);
|
||||||
|
reply_a->analog_data.analog74_lo = LOBYTE(Data);
|
||||||
|
reply_a->analog_data.analog74_hi = HIBYTE(Data);
|
||||||
|
|
||||||
|
//Data = fast_round(_IQtoF(WRotor.iqWRotorImpulsesBeforeRegul1)*NORMA_FROTOR*1000.0);// edrk.W_from_DISPLAY;
|
||||||
|
Data = fast_round(_IQtoF(WRotor.iqWRotorSumFilter)*NORMA_FROTOR*1000.0);
|
||||||
|
reply_a->analog_data.analog75_lo = LOBYTE(Data);
|
||||||
|
reply_a->analog_data.analog75_hi = HIBYTE(Data);
|
||||||
|
|
||||||
|
//Data = fast_round(_IQtoF(WRotor.iqWRotorImpulsesBeforeRegul2)*NORMA_FROTOR*1000.0);//600.0*1000000000.0/WRotor.iqWRotorImpulses1;//edrk.W_from_SVU;
|
||||||
|
Data = fast_round(_IQtoF(simple_scalar1.mzz_zad_int)*NORMA_ACP);//;//0;//fast_round(_IQtoF(rotor_22220.iqFlong)*NORMA_FROTOR*1000.0);
|
||||||
|
reply_a->analog_data.analog76_lo = LOBYTE(Data);
|
||||||
|
reply_a->analog_data.analog76_hi = HIBYTE(Data);
|
||||||
|
|
||||||
|
//Data = fast_round(_IQtoF(WRotor.iqWRotorImpulses1)*NORMA_FROTOR*1000.0);// edrk.W_from_DISPLAY;
|
||||||
|
Data = _IQtoF(simple_scalar1.Izad)*NORMA_ACP_RMS;// 0;//fast_round(_IQtoF(WRotor.iqWRotorSumRamp)*NORMA_FROTOR*1000.0);
|
||||||
|
reply_a->analog_data.analog77_lo = LOBYTE(Data);
|
||||||
|
reply_a->analog_data.analog77_hi = HIBYTE(Data);
|
||||||
|
|
||||||
|
//Data = fast_round(_IQtoF(WRotor.iqWRotorImpulses2)*NORMA_FROTOR*1000.0);//600.0*1000000000.0/WRotor.iqWRotorImpulses1;//edrk.W_from_SVU;
|
||||||
|
Data = WRotor.RotorDirectionSlow;
|
||||||
|
reply_a->analog_data.analog78_lo = LOBYTE(Data);
|
||||||
|
reply_a->analog_data.analog78_hi = HIBYTE(Data);
|
||||||
|
|
||||||
|
Data = fast_round(_IQtoF(simple_scalar1.iqKoefOgran)*1000.0);//0;//fast_round(_IQtoF(WRotor.iqWRotorSum)*NORMA_FROTOR*1000.0);// edrk.W_from_DISPLAY;
|
||||||
|
reply_a->analog_data.analog79_lo = LOBYTE(Data);
|
||||||
|
reply_a->analog_data.analog79_hi = HIBYTE(Data);
|
||||||
|
|
||||||
|
Data = fast_round(_IQtoF(simple_scalar1.iqKoefOgranIzad)*1000.0);//0;//fast_round(_IQtoF(WRotor.iqWRotorSumFilter)*NORMA_FROTOR*1000.0);//600.0*1000000000.0/WRotor.iqWRotorImpulses1;//edrk.W_from_SVU;
|
||||||
|
reply_a->analog_data.analog80_lo = LOBYTE(Data);
|
||||||
|
reply_a->analog_data.analog80_hi = HIBYTE(Data);
|
||||||
|
|
||||||
|
Data = log_params.cur_volume_of_slow_log;//edrk.power_kw_full; //Ìîùíîñòü äâèãàòåëÿ òåêóùàÿ êÂò
|
||||||
|
// Data = (_IQtoF((analog.Power) * 9000.0)); //Ìîùíîñòü äâèãàòåëÿ òåêóùàÿ êÂò
|
||||||
|
//_IQtoF(analog.iqIin_1)*NORMA_ACP;//project.adc[0].read.pbus.adc_value[0];
|
||||||
|
reply_a->analog_data.analog81_lo = LOBYTE(Data);
|
||||||
|
reply_a->analog_data.analog81_hi = HIBYTE(Data);
|
||||||
|
|
||||||
|
Data = fast_round(_IQtoF(edrk.zadanie.iq_limit_power_zad)*NORMA_ACP*NORMA_ACP/1000.0);
|
||||||
|
reply_a->analog_data.analog82_lo = LOBYTE(Data);
|
||||||
|
reply_a->analog_data.analog82_hi = HIBYTE(Data);
|
||||||
|
|
||||||
|
Data = break_result_1;//fast_round(_IQtoF(WRotor.iqWRotorSumFilter3)*NORMA_FROTOR*1000.0);
|
||||||
|
reply_a->analog_data.analog83_lo = LOBYTE(Data);
|
||||||
|
reply_a->analog_data.analog83_hi = HIBYTE(Data);
|
||||||
|
|
||||||
|
Data = break_result_2;//WRotorPBus.RotorDirectionInstant;
|
||||||
|
reply_a->analog_data.analog84_lo = LOBYTE(Data);
|
||||||
|
reply_a->analog_data.analog84_hi = HIBYTE(Data);
|
||||||
|
|
||||||
|
Data = fast_round(_IQtoF(edrk.all_limit_koeffs.sum_limit)*1000.0);//WRotorPBus.RotorDirectionCount;
|
||||||
|
reply_a->analog_data.analog85_lo = LOBYTE(Data);
|
||||||
|
reply_a->analog_data.analog85_hi = HIBYTE(Data);
|
||||||
|
|
||||||
|
|
||||||
|
Data = fast_round(_IQtoF(edrk.all_limit_koeffs.uom_limit)*1000.0);//WRotorPBus.RotorDirectionSlow2;
|
||||||
|
reply_a->analog_data.analog86_lo = LOBYTE(Data);
|
||||||
|
reply_a->analog_data.analog86_hi = HIBYTE(Data);
|
||||||
|
|
||||||
|
Data = fast_round(_IQtoF(edrk.all_limit_koeffs.uin_freq_limit)*1000.0);//fast_round(_IQtoF(WRotor.iqWRotorSumRamp)*NORMA_FROTOR*1000.0);
|
||||||
|
reply_a->analog_data.analog87_lo = LOBYTE(Data);
|
||||||
|
reply_a->analog_data.analog87_hi = HIBYTE(Data);
|
||||||
|
|
||||||
|
Data = _IQtoF(simple_scalar1.Im_regul)*NORMA_ACP_RMS;//(edrk.cantec_reg & 0xff);//edrk.pult_data.TimeToChangePump_from_pult;//0;//fast_round(_IQtoF(WRotor.iqWRotorCalc1Ramp)*NORMA_FROTOR*1000.0);;//WRotor.iqWRotorCalc1Ramp
|
||||||
|
reply_a->analog_data.analog88_lo = LOBYTE(Data);
|
||||||
|
reply_a->analog_data.analog88_hi = HIBYTE(Data);
|
||||||
|
|
||||||
|
Data = fast_round(_IQtoF(simple_scalar1.pidPower.Ui)*NORMA_ACP);//(edrk.canrec_reg & 0xff);;//edrk.pult_data.nPCH_from_pult;//0;//fast_round(_IQtoF(WRotor.iqWRotorCalc2Ramp)*NORMA_FROTOR*1000.0);;
|
||||||
|
reply_a->analog_data.analog89_lo = LOBYTE(Data);
|
||||||
|
reply_a->analog_data.analog89_hi = HIBYTE(Data);
|
||||||
|
|
||||||
|
Data = fast_round(_IQtoF(simple_scalar1.pidF.Fdb)*NORMA_FROTOR*1000.0);//(((unsigned long)edrk.canes_reg>>16) & 0x01ff);
|
||||||
|
reply_a->analog_data.analog90_lo = LOBYTE(Data);
|
||||||
|
reply_a->analog_data.analog90_hi = HIBYTE(Data);
|
||||||
|
|
||||||
|
Data = fast_round(_IQtoF(simple_scalar1.pidF.Ref)*NORMA_FROTOR*1000.0);//(((unsigned long)edrk.canes_reg) & 0x3f);
|
||||||
|
reply_a->analog_data.analog91_lo = LOBYTE(Data);
|
||||||
|
reply_a->analog_data.analog91_hi = HIBYTE(Data);
|
||||||
|
|
||||||
|
|
||||||
|
Data = fast_round(_IQtoF(simple_scalar1.pidF.SatErr)*NORMA_ACP);//CanBusOffError;//0;
|
||||||
|
reply_a->analog_data.analog92_lo = LOBYTE(Data);
|
||||||
|
reply_a->analog_data.analog92_hi = HIBYTE(Data);
|
||||||
|
|
||||||
|
Data = fast_round(_IQtoF(simple_scalar1.pidF.Ui)*NORMA_ACP);//CanTimeOutErrorTR;//0;
|
||||||
|
reply_a->analog_data.analog93_lo = LOBYTE(Data);
|
||||||
|
reply_a->analog_data.analog93_hi = HIBYTE(Data);
|
||||||
|
|
||||||
|
Data = fast_round(_IQtoF(simple_scalar1.pidF.Up)*NORMA_ACP);//0;
|
||||||
|
reply_a->analog_data.analog94_lo = LOBYTE(Data);
|
||||||
|
reply_a->analog_data.analog94_hi = HIBYTE(Data);
|
||||||
|
|
||||||
|
Data = fast_round(_IQtoF(simple_scalar1.iq_decr_mzz_power)*1000.0);//0;//simple_scalar1.k_ogr_n
|
||||||
|
reply_a->analog_data.analog95_lo = LOBYTE(Data);
|
||||||
|
reply_a->analog_data.analog95_hi = HIBYTE(Data);
|
||||||
|
|
||||||
|
Data = fast_round(_IQtoF(simple_scalar1.iq_decr_mzz_power_filter)*1000.0);//fast_round(_IQtoF(edrk.zadanie.rmp_oborots_zad_hz.PosRampPlus1)*NORMA_FROTOR*60.0*450.0*1000.0);
|
||||||
|
reply_a->analog_data.analog96_lo = LOBYTE(Data);
|
||||||
|
reply_a->analog_data.analog96_hi = HIBYTE(Data);
|
||||||
|
|
||||||
|
// Data = 0;
|
||||||
|
// reply_a->analog_data.analog97_lo = LOBYTE(Data);
|
||||||
|
// reply_a->analog_data.analog97_hi = HIBYTE(Data);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
pByte = &reply_a->digit_data.byte01.byte_data;
|
pByte = &reply_a->digit_data.byte01.byte_data;
|
||||||
for (i = 0; i < 44; i++) //zero all dig data
|
for (i = 0; i < 59; i++) //zero all dig data
|
||||||
{
|
{
|
||||||
*(pByte + i) = 0;
|
*(pByte + i) = 0;
|
||||||
}
|
}
|
||||||
@ -431,6 +573,11 @@ Data = edrk.period_calc_pwm_int1;
|
|||||||
reply_a->digit_data.byte13.bit_data.bit2 = edrk.from_second_pch.bits.MASTER;
|
reply_a->digit_data.byte13.bit_data.bit2 = edrk.from_second_pch.bits.MASTER;
|
||||||
reply_a->digit_data.byte13.bit_data.bit3 = edrk.from_second_pch.bits.RASCEPITEL;
|
reply_a->digit_data.byte13.bit_data.bit3 = edrk.from_second_pch.bits.RASCEPITEL;
|
||||||
|
|
||||||
|
reply_a->digit_data.byte13.bit_data.bit4 = edrk.warning;
|
||||||
|
reply_a->digit_data.byte13.bit_data.bit5 = edrk.overheat;
|
||||||
|
reply_a->digit_data.byte13.bit_data.bit6 = edrk.summ_errors;
|
||||||
|
reply_a->digit_data.byte13.bit_data.bit7 = edrk.Status_Ready.bits.ready_final;
|
||||||
|
|
||||||
|
|
||||||
// reply_a->digit_data.byte13.byte_data = edrk.errors.e6.all & 0xff;
|
// reply_a->digit_data.byte13.byte_data = edrk.errors.e6.all & 0xff;
|
||||||
// reply->digit_data.byte14.byte_data = (edrk.errors.e6.all >> 8) & 0xff;
|
// reply->digit_data.byte14.byte_data = (edrk.errors.e6.all >> 8) & 0xff;
|
||||||
@ -570,8 +717,12 @@ Data = edrk.period_calc_pwm_int1;
|
|||||||
reply_a->digit_data.byte36.bit_data.bit1 = edrk.ms.ready1;
|
reply_a->digit_data.byte36.bit_data.bit1 = edrk.ms.ready1;
|
||||||
reply_a->digit_data.byte36.bit_data.bit2 = edrk.ms.ready2;
|
reply_a->digit_data.byte36.bit_data.bit2 = edrk.ms.ready2;
|
||||||
reply_a->digit_data.byte36.bit_data.bit3 = edrk.flag_wait_both_ready2;
|
reply_a->digit_data.byte36.bit_data.bit3 = edrk.flag_wait_both_ready2;
|
||||||
reply_a->digit_data.byte36.bit_data.bit3 = edrk.flag_wait_both_ready2;
|
reply_a->digit_data.byte36.bit_data.bit4 = edrk.Ready1_another_bs;
|
||||||
reply_a->digit_data.byte36.bit_data.bit3 = edrk.flag_wait_both_ready2;
|
reply_a->digit_data.byte36.bit_data.bit5 = edrk.Ready2_another_bs;
|
||||||
|
reply_a->digit_data.byte36.bit_data.bit6 = edrk.flag_another_bs_first_ready12;
|
||||||
|
reply_a->digit_data.byte36.bit_data.bit7 = edrk.flag_this_bs_first_ready12;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
reply_a->digit_data.byte37.byte_data = edrk.errors.e8.all & 0xff;
|
reply_a->digit_data.byte37.byte_data = edrk.errors.e8.all & 0xff;
|
||||||
@ -591,6 +742,11 @@ Data = edrk.period_calc_pwm_int1;
|
|||||||
reply_a->digit_data.byte40.bit_data.bit2 = edrk.StartGED;
|
reply_a->digit_data.byte40.bit_data.bit2 = edrk.StartGED;
|
||||||
reply_a->digit_data.byte40.bit_data.bit3 = edrk.GoWait;
|
reply_a->digit_data.byte40.bit_data.bit3 = edrk.GoWait;
|
||||||
|
|
||||||
|
reply_a->digit_data.byte40.bit_data.bit4 = edrk.stop_logs_rs232;
|
||||||
|
reply_a->digit_data.byte40.bit_data.bit5 = edrk.stop_slow_log;
|
||||||
|
|
||||||
|
reply_a->digit_data.byte40.bit_data.bit6 = edrk.disable_limit_power_from_svu;
|
||||||
|
reply_a->digit_data.byte40.bit_data.bit7 = edrk.disable_uom;
|
||||||
|
|
||||||
reply_a->digit_data.byte41.byte_data = edrk.errors.e9.all & 0xff;
|
reply_a->digit_data.byte41.byte_data = edrk.errors.e9.all & 0xff;
|
||||||
reply_a->digit_data.byte42.byte_data = (edrk.errors.e9.all >> 8) & 0xff;
|
reply_a->digit_data.byte42.byte_data = (edrk.errors.e9.all >> 8) & 0xff;
|
||||||
@ -636,27 +792,111 @@ Data = edrk.period_calc_pwm_int1;
|
|||||||
// edrk.from_ing1.bits.RASCEPITEL_ON = FROM_ING_RASCEPITEL_ON_OFF;
|
// edrk.from_ing1.bits.RASCEPITEL_ON = FROM_ING_RASCEPITEL_ON_OFF;
|
||||||
|
|
||||||
reply_a->digit_data.byte49.bit_data.bit6 = edrk.from_ing2.bits.SOST_ZAMKA;
|
reply_a->digit_data.byte49.bit_data.bit6 = edrk.from_ing2.bits.SOST_ZAMKA;
|
||||||
reply_a->digit_data.byte49.bit_data.bit7 = edrk.from_shema.bits.RAZBOR_SHEMA;
|
reply_a->digit_data.byte49.bit_data.bit7 = edrk.from_shema_filter.bits.RAZBOR_SHEMA;
|
||||||
//
|
//
|
||||||
reply_a->digit_data.byte50.bit_data.bit0 = edrk.from_shema.bits.SBOR_SHEMA;
|
reply_a->digit_data.byte50.bit_data.bit0 = edrk.from_shema_filter.bits.SBOR_SHEMA;
|
||||||
|
|
||||||
reply_a->digit_data.byte50.bit_data.bit1 = edrk.from_shema.bits.ZADA_DISPLAY;
|
reply_a->digit_data.byte50.bit_data.bit1 = edrk.from_shema_filter.bits.ZADA_DISPLAY;
|
||||||
reply_a->digit_data.byte50.bit_data.bit2 = edrk.from_shema.bits.SVU;
|
reply_a->digit_data.byte50.bit_data.bit2 = edrk.from_shema_filter.bits.SVU;
|
||||||
// edrk.from_shema.bits.KNOPKA_AVARIA = FROM_ALL_KNOPKA_AVARIA;
|
// edrk.from_shema.bits.KNOPKA_AVARIA = FROM_ALL_KNOPKA_AVARIA;
|
||||||
reply_a->digit_data.byte50.bit_data.bit3 = edrk.from_shema.bits.QTV_ON_OFF;
|
reply_a->digit_data.byte50.bit_data.bit3 = edrk.from_shema.bits.QTV_ON_OFF;
|
||||||
reply_a->digit_data.byte50.bit_data.bit4 = edrk.from_shema.bits.UMP_ON_OFF;
|
reply_a->digit_data.byte50.bit_data.bit4 = edrk.from_shema_filter.bits.UMP_ON_OFF;
|
||||||
reply_a->digit_data.byte50.bit_data.bit5 = edrk.from_shema.bits.READY_UMP;
|
reply_a->digit_data.byte50.bit_data.bit5 = edrk.from_shema_filter.bits.READY_UMP;
|
||||||
reply_a->digit_data.byte50.bit_data.bit6 = edrk.from_shema.bits.SVU_BLOCK_QTV;
|
reply_a->digit_data.byte50.bit_data.bit6 = edrk.from_shema.bits.SVU_BLOCK_QTV;
|
||||||
|
reply_a->digit_data.byte50.bit_data.bit7 = edrk.errors_another_bs_from_can;
|
||||||
|
|
||||||
|
|
||||||
// reply_a->digit_data.byte44.byte_data = 0;
|
// reply_a->digit_data.byte44.byte_data = 0;
|
||||||
|
|
||||||
|
|
||||||
|
reply_a->digit_data.byte51.bit_data.bit0 = inc_sensor.break_sensor1;
|
||||||
|
reply_a->digit_data.byte51.bit_data.bit1 = inc_sensor.break_sensor2;
|
||||||
|
reply_a->digit_data.byte51.bit_data.bit2 = pll1.output.flag_find_pll;
|
||||||
|
reply_a->digit_data.byte51.bit_data.bit3 = log_params.stop_log_slow;
|
||||||
|
reply_a->digit_data.byte51.bit_data.bit4 = log_params.stop_log_level_1;
|
||||||
|
reply_a->digit_data.byte51.bit_data.bit5 = log_params.stop_log_level_2;
|
||||||
|
reply_a->digit_data.byte51.bit_data.bit6 = log_params.stop_log_slow_level_1;
|
||||||
|
reply_a->digit_data.byte51.bit_data.bit7 = log_params.stop_log_slow_level_2;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
reply_a->digit_data.byte52.bit_data.bit0 = edrk.from_zadat4ik.bits.KVITIR;
|
||||||
|
reply_a->digit_data.byte52.bit_data.bit1 = edrk.from_zadat4ik.bits.PLUS;
|
||||||
|
reply_a->digit_data.byte52.bit_data.bit2 = edrk.from_zadat4ik.bits.MINUS;
|
||||||
|
reply_a->digit_data.byte52.bit_data.bit3 = edrk.from_zadat4ik.bits.PROVOROT;
|
||||||
|
reply_a->digit_data.byte52.bit_data.bit4 = edrk.from_zadat4ik.bits.UOM_READY_ACTIVE;
|
||||||
|
reply_a->digit_data.byte52.bit_data.bit5 = edrk.from_zadat4ik.bits.UOM_LIMIT_3;
|
||||||
|
reply_a->digit_data.byte52.bit_data.bit6 = edrk.from_zadat4ik.bits.UOM_LIMIT_2;
|
||||||
|
reply_a->digit_data.byte52.bit_data.bit7 = edrk.from_zadat4ik.bits.UOM_LIMIT_1;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
reply_a->digit_data.byte53.bit_data.bit0 = edrk.Run_UMP;
|
||||||
|
reply_a->digit_data.byte53.bit_data.bit1 = edrk.Status_UMP_Ok;
|
||||||
|
reply_a->digit_data.byte53.bit_data.bit2 = edrk.Zaryad_UMP_Ok;
|
||||||
|
reply_a->digit_data.byte53.bit_data.bit3 = edrk.cmd_to_ump;
|
||||||
|
reply_a->digit_data.byte53.bit_data.bit4 = edrk.sbor_wait_ump1;
|
||||||
|
reply_a->digit_data.byte53.bit_data.bit5 = edrk.sbor_wait_ump2;
|
||||||
|
reply_a->digit_data.byte53.bit_data.bit6 = edrk.flag_enable_on_ump;
|
||||||
|
|
||||||
|
reply_a->digit_data.byte53.bit_data.bit7 = edrk.local_ump_on_off;
|
||||||
|
reply_a->digit_data.byte54.bit_data.bit0 = edrk.local_ready_ump;
|
||||||
|
|
||||||
|
///
|
||||||
|
reply_a->digit_data.byte54.bit_data.bit1 = (modbus_table_can_in[128].all) ? 1 : 0; //cmd_local_charge PCH 0
|
||||||
|
reply_a->digit_data.byte54.bit_data.bit2 = (modbus_table_can_in[131].all) ? 1 : 0; //cmd_local_uncharge PCH 0
|
||||||
|
|
||||||
|
reply_a->digit_data.byte54.bit_data.bit3 = (modbus_table_can_in[129].all) ? 1 : 0; //cmd_local_charge PCH 1
|
||||||
|
reply_a->digit_data.byte54.bit_data.bit4 = (modbus_table_can_in[132].all) ? 1 : 0; //cmd_local_uncharge PCH 1
|
||||||
|
|
||||||
|
reply_a->digit_data.byte54.bit_data.bit5 = edrk.from_shema_filter.bits.UMP_ON_OFF;
|
||||||
|
reply_a->digit_data.byte54.bit_data.bit6 = edrk.SumSbor;
|
||||||
|
|
||||||
|
reply_a->digit_data.byte55.bit_data.bit0 = edrk.power_limit.bits.limit_Iout;
|
||||||
|
reply_a->digit_data.byte55.bit_data.bit1 = edrk.power_limit.bits.limit_UOM;
|
||||||
|
reply_a->digit_data.byte55.bit_data.bit2 = edrk.power_limit.bits.limit_by_temper;
|
||||||
|
reply_a->digit_data.byte55.bit_data.bit3 = edrk.power_limit.bits.limit_from_SVU;
|
||||||
|
reply_a->digit_data.byte55.bit_data.bit4 = edrk.power_limit.bits.limit_from_uom_fast;
|
||||||
|
reply_a->digit_data.byte55.bit_data.bit5 = edrk.power_limit.bits.limit_from_freq;
|
||||||
|
reply_a->digit_data.byte55.bit_data.bit6 = edrk.power_limit.bits.limit_moment;
|
||||||
|
reply_a->digit_data.byte55.bit_data.bit7 = simple_scalar1.flag_decr_mzz_power;
|
||||||
|
|
||||||
|
|
||||||
|
reply_a->digit_data.byte56.bit_data.bit0 = (edrk.pult_cmd.log_what_memory & 0x1) ? 1 : 0;
|
||||||
|
reply_a->digit_data.byte56.bit_data.bit1 = (edrk.pult_cmd.log_what_memory & 0x2) ? 1 : 0;
|
||||||
|
|
||||||
|
reply_a->digit_data.byte56.bit_data.bit2 = edrk.pult_data.flagSaveDataMoto ? 1 : 0;
|
||||||
|
|
||||||
|
reply_a->digit_data.byte56.bit_data.bit3 = (edrk.pult_data.flagSaveSlowLogs) ? 1 : 0;
|
||||||
|
reply_a->digit_data.byte56.bit_data.bit4 = edrk.pult_cmd.send_log ? 1 : 0;
|
||||||
|
|
||||||
|
reply_a->digit_data.byte56.bit_data.bit5 = (log_to_HMI.send_log==1) ? 1 : 0;
|
||||||
|
reply_a->digit_data.byte56.bit_data.bit6 = (log_to_HMI.send_log==2) ? 1 : 0;
|
||||||
|
reply_a->digit_data.byte56.bit_data.bit7 = (log_to_HMI.send_log==3) ? 1 : 0;
|
||||||
|
|
||||||
|
//
|
||||||
|
reply_a->digit_data.byte57.bit_data.bit0 = (edrk.break_tempers[0] > ABNORMAL_TEMPER_BREAK_INT) ? 1 : 0;
|
||||||
|
reply_a->digit_data.byte57.bit_data.bit1 = (edrk.break_tempers[1] > ABNORMAL_TEMPER_BREAK_INT) ? 1 : 0;
|
||||||
|
reply_a->digit_data.byte57.bit_data.bit2 = (edrk.break_tempers[2] > ABNORMAL_TEMPER_BREAK_INT) ? 1 : 0;
|
||||||
|
reply_a->digit_data.byte57.bit_data.bit3 = (edrk.break_tempers[3] > ABNORMAL_TEMPER_BREAK_INT) ? 1 : 0;
|
||||||
|
|
||||||
|
reply_a->digit_data.byte57.bit_data.bit4 = (edrk.break_tempers[0] > ALARM_TEMPER_BREAK_INT) ? 1 : 0;
|
||||||
|
reply_a->digit_data.byte57.bit_data.bit5 = (edrk.break_tempers[1] > ALARM_TEMPER_BREAK_INT) ? 1 : 0;
|
||||||
|
reply_a->digit_data.byte57.bit_data.bit6 = (edrk.break_tempers[2] > ALARM_TEMPER_BREAK_INT) ? 1 : 0;
|
||||||
|
reply_a->digit_data.byte57.bit_data.bit7 = (edrk.break_tempers[3] > ALARM_TEMPER_BREAK_INT) ? 1 : 0;
|
||||||
|
|
||||||
|
reply_a->digit_data.byte58.bit_data.bit0 = (edrk.breaker_on==1) ? 1 : 0;
|
||||||
|
|
||||||
|
reply_a->digit_data.byte58.bit_data.bit1 = edrk.warnings.e9.bits.BREAK_TEMPER_WARNING;
|
||||||
|
reply_a->digit_data.byte58.bit_data.bit2 = edrk.warnings.e9.bits.BREAK_TEMPER_ALARM;
|
||||||
|
reply_a->digit_data.byte58.bit_data.bit3 = edrk.warnings.e9.bits.BREAKER_GED_ON;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
// reply_a->digit_data.byte57.byte_data = 0;//(((unsigned long)edrk.canes_reg>>16) & 0x0ff);
|
||||||
|
// reply_a->digit_data.byte58.byte_data = 0;//(((unsigned long)edrk.canes_reg) & 0x3f);
|
||||||
|
reply_a->digit_data.byte59.byte_data = 0;//(((unsigned long)edrk.canes_reg>>24) & 0x1);
|
||||||
|
reply_a->digit_data.byte60.byte_data = 0;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@ -13,6 +13,8 @@
|
|||||||
#include "xp_project.h"
|
#include "xp_project.h"
|
||||||
|
|
||||||
#include "x_wdog.h"
|
#include "x_wdog.h"
|
||||||
|
#include "params_hwp.h"
|
||||||
|
#include "detect_errors.h"
|
||||||
|
|
||||||
|
|
||||||
//XilinxV2
|
//XilinxV2
|
||||||
@ -22,7 +24,7 @@ void func_fill_answer_to_TMS_test(TMS_TO_TERMINAL_TEST_ALL_STRUCT* reply_ans, CM
|
|||||||
{
|
{
|
||||||
// îíòðîëüíày ñóììà
|
// îíòðîëüíày ñóììà
|
||||||
unsigned int crc, DataOut, sinusImpulse, doubleImpulse,adc_plate;
|
unsigned int crc, DataOut, sinusImpulse, doubleImpulse,adc_plate;
|
||||||
int Data,Data1,Data2/*,bitt, DataAnalog1, DataAnalog2*/, tk0,tk1,tk2,tk3,period1,period2;
|
int Data,Data1,Data2/*,bitt, DataAnalog1, DataAnalog2*/, tk0,tk1,tk2,tk3,period1,period2, period3;
|
||||||
|
|
||||||
//static int vs11,vs12,vs1;
|
//static int vs11,vs12,vs1;
|
||||||
static int prev_Go = 0;
|
static int prev_Go = 0;
|
||||||
@ -31,6 +33,12 @@ void func_fill_answer_to_TMS_test(TMS_TO_TERMINAL_TEST_ALL_STRUCT* reply_ans, CM
|
|||||||
static int flag_prev_turn_on = 0;
|
static int flag_prev_turn_on = 0;
|
||||||
static int flag_prev_turn_off = 0;
|
static int flag_prev_turn_off = 0;
|
||||||
static int flag_prev_lamp_on_off = 0;
|
static int flag_prev_lamp_on_off = 0;
|
||||||
|
static int soft_off_enable = 0, soft_on_enable = 0;
|
||||||
|
static float tk_time_soft_off = 0;
|
||||||
|
static unsigned long tk_time_soft_off_d = 0;
|
||||||
|
static unsigned int i_af_protect_a = 0, i_af_protect_d = 0;
|
||||||
|
int enable_line_err = 0, disable_tk_soft_off, disable_protect_tk_soft_off;
|
||||||
|
|
||||||
|
|
||||||
stop_wdog();
|
stop_wdog();
|
||||||
|
|
||||||
@ -46,7 +54,16 @@ void func_fill_answer_to_TMS_test(TMS_TO_TERMINAL_TEST_ALL_STRUCT* reply_ans, CM
|
|||||||
// f.RScount = SECOND*3;
|
// f.RScount = SECOND*3;
|
||||||
|
|
||||||
f.terminal_prepare = pcommand->digit_data.byte05.bit_data.bit1;
|
f.terminal_prepare = pcommand->digit_data.byte05.bit_data.bit1;
|
||||||
// "àïèñàëè âñå âûõîäû
|
soft_off_enable = pcommand->digit_data.byte06.bit_data.bit0;
|
||||||
|
soft_on_enable = pcommand->digit_data.byte06.bit_data.bit1;
|
||||||
|
// edrk.direct_write_out = pcommand->digit_data.byte06.bit_data.bit2;
|
||||||
|
|
||||||
|
disable_tk_soft_off = pcommand->digit_data.byte06.bit_data.bit3;
|
||||||
|
disable_protect_tk_soft_off = pcommand->digit_data.byte06.bit_data.bit4;
|
||||||
|
|
||||||
|
enable_line_err = pcommand->digit_data.byte06.bit_data.bit5;
|
||||||
|
|
||||||
|
// Çàïèñàëè âñå âûõîäû
|
||||||
|
|
||||||
#if (CHECK_IN_OUT_TERMINAL==1)
|
#if (CHECK_IN_OUT_TERMINAL==1)
|
||||||
|
|
||||||
@ -72,7 +89,9 @@ void func_fill_answer_to_TMS_test(TMS_TO_TERMINAL_TEST_ALL_STRUCT* reply_ans, CM
|
|||||||
|
|
||||||
// write_dig_out();
|
// write_dig_out();
|
||||||
|
|
||||||
calc_norm_ADC(0);
|
//calc_norm_ADC(0);
|
||||||
|
calc_norm_ADC_0(1);
|
||||||
|
calc_norm_ADC_1(1);
|
||||||
|
|
||||||
// ïðîâåðêà êëþ÷åé
|
// ïðîâåðêà êëþ÷åé
|
||||||
tk0 = (pcommand->digit_data.byte01.byte_data);
|
tk0 = (pcommand->digit_data.byte01.byte_data);
|
||||||
@ -90,6 +109,39 @@ void func_fill_answer_to_TMS_test(TMS_TO_TERMINAL_TEST_ALL_STRUCT* reply_ans, CM
|
|||||||
Data = (Data2 + Data1*256);
|
Data = (Data2 + Data1*256);
|
||||||
period2 = Data;
|
period2 = Data;
|
||||||
|
|
||||||
|
Data1 = pcommand->analog_data.analog3_hi;
|
||||||
|
Data2 = pcommand->analog_data.analog3_lo;
|
||||||
|
Data = (Data2 + Data1*256);
|
||||||
|
period3 = Data;
|
||||||
|
|
||||||
|
Data1 = pcommand->analog_data.analog4_hi;
|
||||||
|
Data2 = pcommand->analog_data.analog4_lo;
|
||||||
|
Data = (Data2 + Data1*256);
|
||||||
|
// Data = 200;
|
||||||
|
tk_time_soft_off = Data*100.0; // mks*10->ns
|
||||||
|
if (tk_time_soft_off>1300000.0)
|
||||||
|
tk_time_soft_off = 1300000.0;
|
||||||
|
tk_time_soft_off_d = (unsigned long)(tk_time_soft_off / DIV_TIME_TK_SOFT_OFF);
|
||||||
|
|
||||||
|
if (tk_time_soft_off_d>65535)
|
||||||
|
tk_time_soft_off_d = 65535;
|
||||||
|
|
||||||
|
|
||||||
|
Data1 = pcommand->analog_data.analog5_hi;
|
||||||
|
Data2 = pcommand->analog_data.analog5_lo;
|
||||||
|
Data = (Data2 + Data1*256);
|
||||||
|
i_af_protect_a = Data;
|
||||||
|
|
||||||
|
if (i_af_protect_a>LEVEL_HWP_I_AF) i_af_protect_a = LEVEL_HWP_I_AF;
|
||||||
|
if (i_af_protect_a<10) i_af_protect_a = 10;
|
||||||
|
i_af_protect_d = convert_real_to_mv_hwp(4,i_af_protect_a);
|
||||||
|
if (i_af_protect_d>1500) i_af_protect_d = 1500; // max 1500 mV
|
||||||
|
|
||||||
|
update_maz_level_i_af(0, i_af_protect_d);
|
||||||
|
project.read_all_hwp();
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
if(pcommand->digit_data.byte05.bit_data.bit3 == 1)
|
if(pcommand->digit_data.byte05.bit_data.bit3 == 1)
|
||||||
doubleImpulse = 1;
|
doubleImpulse = 1;
|
||||||
else
|
else
|
||||||
@ -102,8 +154,43 @@ void func_fill_answer_to_TMS_test(TMS_TO_TERMINAL_TEST_ALL_STRUCT* reply_ans, CM
|
|||||||
|
|
||||||
if ((pcommand->digit_data.byte05.bit_data.bit0 == 1) && (prev_Go == 0))
|
if ((pcommand->digit_data.byte05.bit_data.bit0 == 1) && (prev_Go == 0))
|
||||||
{
|
{
|
||||||
|
if (pcommand->digit_data.byte05.bit_data.bit2 == 1) // ïðè öèêë èìïóëüñå ïðåäâàðèòåëüíî äàåì êâèòèðîâàíèå
|
||||||
|
{
|
||||||
|
update_maz_level_i_af(0, 1500);
|
||||||
|
project.write_all_hwp();
|
||||||
|
clear_errors();
|
||||||
|
project.clear_errors_all_plates();
|
||||||
|
update_maz_level_i_af(0, i_af_protect_d);
|
||||||
|
project.write_all_hwp();
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
// test_tk_ak_one_impulse( tk0, tk1, tk2, tk3, period1, period2);
|
// test_tk_ak_one_impulse( tk0, tk1, tk2, tk3, period1, period2);
|
||||||
test_tk_ak_one_impulse( tk0, tk1, tk2, tk3, period1, period2, doubleImpulse, sinusImpulse);
|
#if (USE_TK_0)
|
||||||
|
project.cds_tk[0].write.sbus.protect_error.bit.enable_soft_disconnect = !disable_tk_soft_off;
|
||||||
|
project.cds_tk[0].write.sbus.protect_error.bit.detect_soft_disconnect = !disable_protect_tk_soft_off;
|
||||||
|
project.cds_tk[0].write.sbus.protect_error.bit.enable_line_err = enable_line_err;
|
||||||
|
project.cds_tk[0].write.sbus.time_after_err = tk_time_soft_off_d;//(int)(tk_time_soft_off / DIV_TIME_TK_SOFT_OFF);
|
||||||
|
#endif
|
||||||
|
#if (USE_TK_1)
|
||||||
|
project.cds_tk[1].write.sbus.protect_error.bit.enable_soft_disconnect = !disable_tk_soft_off;
|
||||||
|
project.cds_tk[1].write.sbus.protect_error.bit.detect_soft_disconnect = !disable_protect_tk_soft_off;
|
||||||
|
project.cds_tk[1].write.sbus.protect_error.bit.enable_line_err = enable_line_err;
|
||||||
|
project.cds_tk[1].write.sbus.time_after_err = tk_time_soft_off_d;//(int)(tk_time_soft_off / DIV_TIME_TK_SOFT_OFF);
|
||||||
|
#endif
|
||||||
|
#if (USE_TK_3)
|
||||||
|
project.cds_tk[3].write.sbus.protect_error.bit.enable_soft_disconnect = !disable_tk_soft_off;
|
||||||
|
project.cds_tk[3].write.sbus.protect_error.bit.detect_soft_disconnect = !disable_protect_tk_soft_off;
|
||||||
|
project.cds_tk[3].write.sbus.protect_error.bit.enable_line_err = enable_line_err;
|
||||||
|
project.cds_tk[3].write.sbus.time_after_err = tk_time_soft_off_d;//(int)(tk_time_soft_off / DIV_TIME_TK_SOFT_OFF);
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
project.write_all_sbus();
|
||||||
|
project.write_all_hwp();
|
||||||
|
|
||||||
|
test_tk_ak_one_impulse( tk0, tk1, tk2, tk3, period1, period2, period3, doubleImpulse, sinusImpulse, soft_off_enable, soft_on_enable);
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((pcommand->digit_data.byte05.bit_data.bit0 == 1) &&
|
if ((pcommand->digit_data.byte05.bit_data.bit0 == 1) &&
|
||||||
@ -119,14 +206,19 @@ void func_fill_answer_to_TMS_test(TMS_TO_TERMINAL_TEST_ALL_STRUCT* reply_ans, CM
|
|||||||
if (pcommand->digit_data.byte05.bit_data.bit1==1)
|
if (pcommand->digit_data.byte05.bit_data.bit1==1)
|
||||||
{
|
{
|
||||||
stop_wdog();
|
stop_wdog();
|
||||||
|
update_maz_level_i_af(0, 1500);
|
||||||
|
project.write_all_hwp();
|
||||||
|
clear_errors();
|
||||||
project.clear_errors_all_plates();
|
project.clear_errors_all_plates();
|
||||||
|
update_maz_level_i_af(0, i_af_protect_d);
|
||||||
|
project.write_all_hwp();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
prev_Prepare = pcommand->digit_data.byte05.bit_data.bit1;
|
prev_Prepare = pcommand->digit_data.byte05.bit_data.bit1;
|
||||||
|
|
||||||
if (pcommand->digit_data.byte05.bit_data.bit2 == 1)
|
if (pcommand->digit_data.byte05.bit_data.bit2 == 1)
|
||||||
{
|
{
|
||||||
|
|
||||||
prev_Go = 0; // çàöèêëèëè Go
|
prev_Go = 0; // çàöèêëèëè Go
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -280,17 +372,46 @@ void func_fill_answer_to_TMS_test(TMS_TO_TERMINAL_TEST_ALL_STRUCT* reply_ans, CM
|
|||||||
reply_test_all.analog_data.analog16_lo=LOBYTE(Data);
|
reply_test_all.analog_data.analog16_lo=LOBYTE(Data);
|
||||||
reply_test_all.analog_data.analog16_hi=HIBYTE(Data);
|
reply_test_all.analog_data.analog16_hi=HIBYTE(Data);
|
||||||
|
|
||||||
/*
|
|
||||||
Data = _IQtoF(analog.iqU_3) * NORMA_ACP;
|
Data = _IQtoF(analog.iqU_1) * NORMA_ACP;
|
||||||
|
reply_ans->analog_data.analog17_lo=LOBYTE(Data);
|
||||||
|
reply_ans->analog_data.analog17_hi=HIBYTE(Data);
|
||||||
|
|
||||||
|
Data = _IQtoF(analog.iqU_2) * NORMA_ACP;
|
||||||
|
reply_ans->analog_data.analog18_lo=LOBYTE(Data);
|
||||||
|
reply_ans->analog_data.analog18_hi=HIBYTE(Data);
|
||||||
|
|
||||||
|
Data = project.cds_tk[0].read.sbus.time_err_tk_all.bit.tk_3210;
|
||||||
reply_ans->analog_data.analog19_lo=LOBYTE(Data);
|
reply_ans->analog_data.analog19_lo=LOBYTE(Data);
|
||||||
reply_ans->analog_data.analog19_hi=HIBYTE(Data);
|
reply_ans->analog_data.analog19_hi=HIBYTE(Data);
|
||||||
|
|
||||||
Data = _IQtoF(analog.iqU_4) * NORMA_ACP;
|
Data = project.cds_tk[0].read.sbus.time_err_tk_all.bit.tk_7654;
|
||||||
reply_ans->analog_data.analog20_lo=LOBYTE(Data);
|
reply_ans->analog_data.analog20_lo=LOBYTE(Data);
|
||||||
reply_ans->analog_data.analog20_hi=HIBYTE(Data);
|
reply_ans->analog_data.analog20_hi=HIBYTE(Data);
|
||||||
|
|
||||||
*/
|
Data = project.cds_tk[1].read.sbus.time_err_tk_all.bit.tk_3210;
|
||||||
|
reply_ans->analog_data.analog21_lo=LOBYTE(Data);
|
||||||
|
reply_ans->analog_data.analog21_hi=HIBYTE(Data);
|
||||||
|
|
||||||
|
Data = project.cds_tk[1].read.sbus.time_err_tk_all.bit.tk_7654;
|
||||||
|
reply_ans->analog_data.analog22_lo=LOBYTE(Data);
|
||||||
|
reply_ans->analog_data.analog22_hi=HIBYTE(Data);
|
||||||
|
|
||||||
|
Data = project.cds_tk[2].read.sbus.time_err_tk_all.bit.tk_3210;
|
||||||
|
reply_ans->analog_data.analog23_lo=LOBYTE(Data);
|
||||||
|
reply_ans->analog_data.analog23_hi=HIBYTE(Data);
|
||||||
|
|
||||||
|
Data = project.cds_tk[2].read.sbus.time_err_tk_all.bit.tk_7654;
|
||||||
|
reply_ans->analog_data.analog24_lo=LOBYTE(Data);
|
||||||
|
reply_ans->analog_data.analog24_hi=HIBYTE(Data);
|
||||||
|
|
||||||
|
// Data = project.cds_tk[3].read.sbus.time_err_tk_all.bit.tk_3210;
|
||||||
|
// reply_ans->analog_data.analog25_lo=LOBYTE(Data);
|
||||||
|
// reply_ans->analog_data.analog25_hi=HIBYTE(Data);
|
||||||
|
//
|
||||||
|
// Data = project.cds_tk[3].read.sbus.time_err_tk_all.bit.tk_7654;
|
||||||
|
// reply_ans->analog_data.analog26_lo=LOBYTE(Data);
|
||||||
|
// reply_ans->analog_data.analog26_hi=HIBYTE(Data);
|
||||||
|
|
||||||
reply_ans->digit_data.byte01.byte_data = 0;
|
reply_ans->digit_data.byte01.byte_data = 0;
|
||||||
reply_ans->digit_data.byte02.byte_data = 0;
|
reply_ans->digit_data.byte02.byte_data = 0;
|
||||||
@ -393,8 +514,16 @@ reply_ans->digit_data.byte24.byte_data = 0;
|
|||||||
reply_ans->digit_data.byte19.bit_data.bit6 = CAN_timeout[get_real_in_mbox(UNITS_TYPE_BOX,UMU_CAN_DEVICE)];
|
reply_ans->digit_data.byte19.bit_data.bit6 = CAN_timeout[get_real_in_mbox(UNITS_TYPE_BOX,UMU_CAN_DEVICE)];
|
||||||
//reply.digit_data.byte21.bit_data.bit7 = CAN_timeout[VPU1_CAN_DEVICE];
|
//reply.digit_data.byte21.bit_data.bit7 = CAN_timeout[VPU1_CAN_DEVICE];
|
||||||
|
|
||||||
reply_ans->digit_data.byte20.bit_data.bit0 = CAN_timeout[get_real_in_mbox(UNITS_TYPE_BOX,VPU_CAN)];
|
reply_ans->digit_data.byte20.bit_data.bit0 = project.controller.read.errors.bit.er0_out;
|
||||||
reply_ans->digit_data.byte20.bit_data.bit1 = CAN_timeout[get_real_in_mbox(MPU_TYPE_BOX,0)];
|
reply_ans->digit_data.byte20.bit_data.bit1 = project.controller.read.errors.bit.er0_trig;
|
||||||
|
reply_ans->digit_data.byte20.bit_data.bit2 = project.controller.read.errors.bit.errHWP;
|
||||||
|
reply_ans->digit_data.byte20.bit_data.bit3 = project.controller.read.errors.bit.errHWP_trig;
|
||||||
|
reply_ans->digit_data.byte20.bit_data.bit4 = project.controller.read.errors.bit.error_pbus;
|
||||||
|
reply_ans->digit_data.byte20.bit_data.bit5 = project.controller.read.errors.bit.pwm_wdog;
|
||||||
|
reply_ans->digit_data.byte20.bit_data.bit6 = project.controller.read.errors.bit.status_er0;
|
||||||
|
// reply_ans->digit_data.byte20.bit_data.bit0 = project.controller.read.errors.bit.er0_out;
|
||||||
|
// reply_ans->digit_data.byte20.bit_data.bit0 = CAN_timeout[get_real_in_mbox(UNITS_TYPE_BOX,VPU_CAN)];
|
||||||
|
// reply_ans->digit_data.byte20.bit_data.bit1 = CAN_timeout[get_real_in_mbox(MPU_TYPE_BOX,0)];
|
||||||
reply_ans->digit_data.byte20.bit_data.bit2 = 0;//READY_UKSS_6;
|
reply_ans->digit_data.byte20.bit_data.bit2 = 0;//READY_UKSS_6;
|
||||||
reply_ans->digit_data.byte20.bit_data.bit3 = 0;//READY_UKSS_7;
|
reply_ans->digit_data.byte20.bit_data.bit3 = 0;//READY_UKSS_7;
|
||||||
reply_ans->digit_data.byte20.bit_data.bit4 = 0;//READY_UKSS_8;
|
reply_ans->digit_data.byte20.bit_data.bit4 = 0;//READY_UKSS_8;
|
||||||
@ -436,8 +565,82 @@ reply_ans->digit_data.byte24.byte_data = 0;
|
|||||||
reply_ans->digit_data.byte23.byte_data=project.hwp[0].read.comp_s.minus.all & 0x00ff;
|
reply_ans->digit_data.byte23.byte_data=project.hwp[0].read.comp_s.minus.all & 0x00ff;
|
||||||
reply_ans->digit_data.byte24.byte_data=((project.hwp[0].read.comp_s.minus.all >> 8) & 0x00ff);
|
reply_ans->digit_data.byte24.byte_data=((project.hwp[0].read.comp_s.minus.all >> 8) & 0x00ff);
|
||||||
|
|
||||||
reply_ans->digit_data.byte23.byte_data|=project.hwp[0].read.comp_s.minus.all & 0x00ff;
|
reply_ans->digit_data.byte23.byte_data|=project.hwp[0].read.comp_s.plus.all & 0x00ff;
|
||||||
reply_ans->digit_data.byte24.byte_data|=((project.hwp[0].read.comp_s.minus.all >> 8) & 0x00ff);
|
reply_ans->digit_data.byte24.byte_data|=((project.hwp[0].read.comp_s.plus.all >> 8) & 0x00ff);
|
||||||
|
|
||||||
|
#if (USE_TK_0)
|
||||||
|
if (project.cds_tk[0].useit)
|
||||||
|
{
|
||||||
|
// reply_ans->digit_data.byte22.bit_data.bit0 = project.cds_tk[0].read.sbus.lock_status_error.bit.err0_in;
|
||||||
|
reply_ans->digit_data.byte25.bit_data.bit0 = project.cds_tk[0].read.sbus.lock_status_error.bit.err_hwp;
|
||||||
|
reply_ans->digit_data.byte25.bit_data.bit1 = project.cds_tk[0].read.sbus.lock_status_error.bit.err0_local;
|
||||||
|
reply_ans->digit_data.byte25.bit_data.bit2 = project.cds_tk[0].read.sbus.lock_status_error.bit.mintime_err_keys_7654;
|
||||||
|
reply_ans->digit_data.byte25.bit_data.bit3 = project.cds_tk[0].read.sbus.lock_status_error.bit.mintime_err_keys_3210;
|
||||||
|
reply_ans->digit_data.byte25.bit_data.bit4 = project.cds_tk[0].read.sbus.lock_status_error.bit.line_err_keys_7654;
|
||||||
|
reply_ans->digit_data.byte25.bit_data.bit5 = project.cds_tk[0].read.sbus.lock_status_error.bit.line_err_keys_3210;
|
||||||
|
reply_ans->digit_data.byte25.bit_data.bit6 = project.cds_tk[0].read.sbus.lock_status_error.bit.ErrorSoftShutdownFromErr0;
|
||||||
|
reply_ans->digit_data.byte25.bit_data.bit7 = project.cds_tk[0].read.sbus.lock_status_error.bit.ErrorSoftShutdownForbidComb;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
reply_ans->digit_data.byte25.byte_data = 0;
|
||||||
|
|
||||||
|
#else
|
||||||
|
reply_ans->digit_data.byte25.byte_data = 0;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if (USE_TK_1)
|
||||||
|
if (project.cds_tk[1].useit)
|
||||||
|
{
|
||||||
|
reply_ans->digit_data.byte26.bit_data.bit0 = project.cds_tk[1].read.sbus.lock_status_error.bit.err_hwp;
|
||||||
|
reply_ans->digit_data.byte26.bit_data.bit1 = project.cds_tk[1].read.sbus.lock_status_error.bit.err0_local;
|
||||||
|
reply_ans->digit_data.byte26.bit_data.bit2 = project.cds_tk[1].read.sbus.lock_status_error.bit.mintime_err_keys_7654;
|
||||||
|
reply_ans->digit_data.byte26.bit_data.bit3 = project.cds_tk[1].read.sbus.lock_status_error.bit.mintime_err_keys_3210;
|
||||||
|
reply_ans->digit_data.byte26.bit_data.bit4 = project.cds_tk[1].read.sbus.lock_status_error.bit.line_err_keys_7654;
|
||||||
|
reply_ans->digit_data.byte26.bit_data.bit5 = project.cds_tk[1].read.sbus.lock_status_error.bit.line_err_keys_3210;
|
||||||
|
reply_ans->digit_data.byte26.bit_data.bit6 = project.cds_tk[1].read.sbus.lock_status_error.bit.ErrorSoftShutdownFromErr0;
|
||||||
|
reply_ans->digit_data.byte26.bit_data.bit7 = project.cds_tk[1].read.sbus.lock_status_error.bit.ErrorSoftShutdownForbidComb;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
reply_ans->digit_data.byte26.byte_data = 0;
|
||||||
|
#else
|
||||||
|
reply_ans->digit_data.byte26.byte_data = 0;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if (USE_TK_2)
|
||||||
|
if (project.cds_tk[2].useit)
|
||||||
|
{
|
||||||
|
reply_ans->digit_data.byte27.bit_data.bit0 = project.cds_tk[2].read.sbus.lock_status_error.bit.err_hwp;
|
||||||
|
reply_ans->digit_data.byte27.bit_data.bit1 = project.cds_tk[2].read.sbus.lock_status_error.bit.err0_local;
|
||||||
|
reply_ans->digit_data.byte27.bit_data.bit2 = project.cds_tk[2].read.sbus.lock_status_error.bit.mintime_err_keys_7654;
|
||||||
|
reply_ans->digit_data.byte27.bit_data.bit3 = project.cds_tk[2].read.sbus.lock_status_error.bit.mintime_err_keys_3210;
|
||||||
|
reply_ans->digit_data.byte27.bit_data.bit4 = project.cds_tk[2].read.sbus.lock_status_error.bit.line_err_keys_7654;
|
||||||
|
reply_ans->digit_data.byte27.bit_data.bit5 = project.cds_tk[2].read.sbus.lock_status_error.bit.line_err_keys_3210;
|
||||||
|
reply_ans->digit_data.byte27.bit_data.bit6 = project.cds_tk[2].read.sbus.lock_status_error.bit.ErrorSoftShutdownFromErr0;
|
||||||
|
reply_ans->digit_data.byte27.bit_data.bit7 = project.cds_tk[2].read.sbus.lock_status_error.bit.ErrorSoftShutdownForbidComb;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
reply_ans->digit_data.byte27.byte_data = 0;
|
||||||
|
#else
|
||||||
|
reply_ans->digit_data.byte27.byte_data = 0;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if (USE_TK_3)
|
||||||
|
if (project.cds_tk[3].useit)
|
||||||
|
{
|
||||||
|
reply_ans->digit_data.byte28.bit_data.bit0 = project.cds_tk[3].read.sbus.lock_status_error.bit.err_hwp;
|
||||||
|
reply_ans->digit_data.byte28.bit_data.bit1 = project.cds_tk[3].read.sbus.lock_status_error.bit.err0_local;
|
||||||
|
reply_ans->digit_data.byte28.bit_data.bit2 = project.cds_tk[3].read.sbus.lock_status_error.bit.mintime_err_keys_7654;
|
||||||
|
reply_ans->digit_data.byte28.bit_data.bit3 = project.cds_tk[3].read.sbus.lock_status_error.bit.mintime_err_keys_3210;
|
||||||
|
reply_ans->digit_data.byte28.bit_data.bit4 = project.cds_tk[3].read.sbus.lock_status_error.bit.line_err_keys_7654;
|
||||||
|
reply_ans->digit_data.byte28.bit_data.bit5 = project.cds_tk[3].read.sbus.lock_status_error.bit.line_err_keys_3210;
|
||||||
|
reply_ans->digit_data.byte28.bit_data.bit6 = project.cds_tk[3].read.sbus.lock_status_error.bit.ErrorSoftShutdownFromErr0;
|
||||||
|
reply_ans->digit_data.byte28.bit_data.bit7 = project.cds_tk[3].read.sbus.lock_status_error.bit.ErrorSoftShutdownForbidComb;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
reply_ans->digit_data.byte28.byte_data = 0;
|
||||||
|
#else
|
||||||
|
reply_ans->digit_data.byte28.byte_data = 0;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -22,6 +22,10 @@
|
|||||||
#include <message2can.h>
|
#include <message2can.h>
|
||||||
#include <edrk_main.h>
|
#include <edrk_main.h>
|
||||||
|
|
||||||
|
#include "pwm_test_lines.h"
|
||||||
|
#include "params.h"
|
||||||
|
#include "logs_hmi.h"
|
||||||
|
|
||||||
|
|
||||||
//#include "can_setup_21300.h"
|
//#include "can_setup_21300.h"
|
||||||
//#include "modbus_can.h"
|
//#include "modbus_can.h"
|
||||||
@ -164,6 +168,7 @@ void write_all_data_to_mpu_can(int run_force, unsigned int pause)
|
|||||||
|
|
||||||
static int cur_position_buf_modbus16_can = 0, prev_send_to_can = 0;
|
static int cur_position_buf_modbus16_can = 0, prev_send_to_can = 0;
|
||||||
int real_mbox;
|
int real_mbox;
|
||||||
|
unsigned int i;
|
||||||
|
|
||||||
real_mbox = get_real_out_mbox(MPU_TYPE_BOX, edrk.flag_second_PCH);
|
real_mbox = get_real_out_mbox(MPU_TYPE_BOX, edrk.flag_second_PCH);
|
||||||
|
|
||||||
@ -235,6 +240,13 @@ void write_all_data_to_mpu_can(int run_force, unsigned int pause)
|
|||||||
// modbus_table_can_out[ADR_CAN_TEST_PLUS_ONE].all++;
|
// modbus_table_can_out[ADR_CAN_TEST_PLUS_ONE].all++;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// ñîõðàíÿåì âî âðåìåííîé ïàìÿòè ïåðåä íà÷àëîì ïåðåäà÷è âñåãî ìàññèâà ÷òîáû äàííûå íå ìåíÿëèñü âî âðåìÿ ïåðåäà÷è
|
||||||
|
if (cur_position_buf_modbus16_can == 0)
|
||||||
|
{
|
||||||
|
for (i=0;i<SIZE_MODBUS_TABLE;i++)
|
||||||
|
modbus_table_can_out_temp[i] = modbus_table_can_out[i];
|
||||||
|
}
|
||||||
|
|
||||||
if ((cur_position_buf_modbus16_can + SIZE_BUF_WRITE_TO_MODBUS16_CAN) >= SIZE_MODBUS_TABLE)
|
if ((cur_position_buf_modbus16_can + SIZE_BUF_WRITE_TO_MODBUS16_CAN) >= SIZE_MODBUS_TABLE)
|
||||||
count_write_to_modbus_can = SIZE_MODBUS_TABLE - cur_position_buf_modbus16_can;
|
count_write_to_modbus_can = SIZE_MODBUS_TABLE - cur_position_buf_modbus16_can;
|
||||||
else
|
else
|
||||||
@ -249,7 +261,8 @@ void write_all_data_to_mpu_can(int run_force, unsigned int pause)
|
|||||||
MPU_TYPE_BOX,
|
MPU_TYPE_BOX,
|
||||||
edrk.flag_second_PCH,
|
edrk.flag_second_PCH,
|
||||||
cur_position_buf_modbus16_can + 1,
|
cur_position_buf_modbus16_can + 1,
|
||||||
&modbus_table_can_out[cur_position_buf_modbus16_can].all,
|
// &modbus_table_can_out[cur_position_buf_modbus16_can].all,
|
||||||
|
&modbus_table_can_out_temp[cur_position_buf_modbus16_can].all,
|
||||||
count_write_to_modbus_can, CAN_BOX_STANDART_ADR, CAN_BOX_PRIORITY_NORMAL);
|
count_write_to_modbus_can, CAN_BOX_STANDART_ADR, CAN_BOX_PRIORITY_NORMAL);
|
||||||
|
|
||||||
cur_position_buf_modbus16_can = cur_position_buf_modbus16_can + SIZE_BUF_WRITE_TO_MODBUS16_CAN;
|
cur_position_buf_modbus16_can = cur_position_buf_modbus16_can + SIZE_BUF_WRITE_TO_MODBUS16_CAN;
|
||||||
@ -399,6 +412,9 @@ void test_alive_pult_485(void)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
#define MAX_COUNT_WORK_IN_LOG 150
|
||||||
|
|
||||||
|
|
||||||
int modbusNetworkSharing(int flag_update_only_hmi)
|
int modbusNetworkSharing(int flag_update_only_hmi)
|
||||||
{
|
{
|
||||||
static unsigned int old_time = 0 , old_time_refresh = 0, time_pause = TIME_PAUSE_MODBUS_REMOUTE;
|
static unsigned int old_time = 0 , old_time_refresh = 0, time_pause = TIME_PAUSE_MODBUS_REMOUTE;
|
||||||
@ -410,8 +426,13 @@ int modbusNetworkSharing(int flag_update_only_hmi)
|
|||||||
static int run_pause = 1, flag_next = 0, prev_flag_next = 0;
|
static int run_pause = 1, flag_next = 0, prev_flag_next = 0;
|
||||||
static int last_ok_cmd=0;
|
static int last_ok_cmd=0;
|
||||||
static int flag_only_one_cmd=0;
|
static int flag_only_one_cmd=0;
|
||||||
|
static int status_ok = 1, status_err = 0, flag_work_rs_send_log = 0, count_free = 0, count_work_in_log = 0;
|
||||||
|
|
||||||
|
|
||||||
|
#if(_ENABLE_PWM_LINES_FOR_TESTS_RS)
|
||||||
|
PWM_LINES_TK_20_ON;
|
||||||
|
#endif
|
||||||
|
|
||||||
RS232_WorkingWith(0,1,0);
|
RS232_WorkingWith(0,1,0);
|
||||||
|
|
||||||
// âêë òèï çàïðîñ-îòâåò äëÿ ñèñòåìû òàéìèíãà
|
// âêë òèï çàïðîñ-îòâåò äëÿ ñèñòåìû òàéìèíãà
|
||||||
@ -435,21 +456,123 @@ int modbusNetworkSharing(int flag_update_only_hmi)
|
|||||||
|
|
||||||
final_code = 0;
|
final_code = 0;
|
||||||
|
|
||||||
|
|
||||||
|
switch(status)
|
||||||
|
{
|
||||||
|
case 0:
|
||||||
|
|
||||||
|
old_time = global_time.miliseconds;
|
||||||
|
status = 1;
|
||||||
|
if (time_pause==0)
|
||||||
|
status = 2;
|
||||||
|
|
||||||
|
break;
|
||||||
|
case 1:
|
||||||
|
// if (numberInT==0)
|
||||||
|
// {
|
||||||
|
if (detect_pause_milisec(time_pause,&old_time))
|
||||||
|
status = 2;
|
||||||
|
// }
|
||||||
|
// else
|
||||||
|
// status = 2;
|
||||||
|
|
||||||
|
break;
|
||||||
|
case 2:
|
||||||
|
enable_send_cmd = 1;
|
||||||
|
control_station.time_detect_answer_485[CONTROL_STATION_INGETEAM_PULT_RS485] = 0;
|
||||||
|
status = 3;
|
||||||
|
old_time_status_3 = global_time.miliseconds;
|
||||||
|
|
||||||
|
break;
|
||||||
|
case 3:
|
||||||
|
// // åñëè ìû â ïåðåäà÷å ëîãîâ è òàì ïóñòàÿ êîìàíäà áåç îáìåíà ïî rs485
|
||||||
|
// if (flag_work_rs_send_log)
|
||||||
|
// {
|
||||||
|
// status = 0;
|
||||||
|
// status_ok++;
|
||||||
|
// if (status_ok<0) status_ok=1;
|
||||||
|
// }
|
||||||
|
|
||||||
|
// íå áûëî ïåðåäà÷ ïî rs485 çíà÷èò è ëîâèòü òóò íå÷åãî!
|
||||||
|
if (rs_b.RS_DataWillSend2 == 0 && enable_send_cmd == 0)
|
||||||
|
{
|
||||||
|
status = 0;
|
||||||
|
status_ok++;
|
||||||
|
count_free++;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
if (rs_b.RS_DataReadyAnswerAnalyze)
|
||||||
|
{
|
||||||
|
// i_led2_on_off(0);
|
||||||
|
|
||||||
|
control_station.time_detect_answer_485[CONTROL_STATION_INGETEAM_PULT_RS485] = 0;
|
||||||
|
control_station.count_ok_modbus[CONTROL_STATION_INGETEAM_PULT_RS485]++;
|
||||||
|
rs_b.RS_DataReadyAnswerAnalyze = 0;
|
||||||
|
rs_b.RS_DataWillSend2 = 0;
|
||||||
|
status = 0;
|
||||||
|
|
||||||
|
if (last_ok_cmd==4) // ïðîøëà readAnalogDataFromRemote() ñì íèæå
|
||||||
|
{
|
||||||
|
edrk.get_new_data_from_hmi = 1;// ìîæíî çàáðàòü äàííûå?
|
||||||
|
edrk.get_new_data_from_hmi2 = 1;// ìîæíî çàáðàòü äàííûå?
|
||||||
|
}
|
||||||
|
final_code = last_ok_cmd;//numberInT+1;
|
||||||
|
|
||||||
|
//status_err = 0;
|
||||||
|
status_ok++;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
if ( (control_station.time_detect_answer_485[CONTROL_STATION_INGETEAM_PULT_RS485]>control_station.setup_time_detect_active_resend_485[CONTROL_STATION_INGETEAM_PULT_RS485])
|
||||||
|
|| (detect_pause_milisec(time_pause_status_3,&old_time_status_3)) )
|
||||||
|
{
|
||||||
|
resetup_mpu_rs(&rs_b);
|
||||||
|
control_station.time_detect_answer_485[CONTROL_STATION_INGETEAM_PULT_RS485] = 0;
|
||||||
|
rs_b.RS_DataWillSend2 = 0;
|
||||||
|
status = 0;
|
||||||
|
control_station.count_error_modbus[CONTROL_STATION_INGETEAM_PULT_RS485]++;
|
||||||
|
status_err++;// = 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
if (status_ok<0) status_ok=1;
|
||||||
|
|
||||||
|
break;
|
||||||
|
case 4:
|
||||||
|
|
||||||
|
break;
|
||||||
|
case 5:
|
||||||
|
|
||||||
|
break;
|
||||||
|
case 6:
|
||||||
|
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
break;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
if (status==0)
|
if (status==0)
|
||||||
{
|
{
|
||||||
old_time = global_time.miliseconds;
|
old_time = global_time.miliseconds;
|
||||||
status = 1;
|
status = 1;
|
||||||
|
if (time_pause==0)
|
||||||
|
status = 2;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (status==1)
|
if (status==1)
|
||||||
{
|
{
|
||||||
if (numberInT==0)
|
// if (numberInT==0)
|
||||||
{
|
// {
|
||||||
if (detect_pause_milisec(time_pause,&old_time))
|
if (detect_pause_milisec(time_pause,&old_time))
|
||||||
status = 2;
|
status = 2;
|
||||||
}
|
// }
|
||||||
else
|
// else
|
||||||
status = 2;
|
// status = 2;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (status==2)
|
if (status==2)
|
||||||
@ -462,6 +585,21 @@ int modbusNetworkSharing(int flag_update_only_hmi)
|
|||||||
|
|
||||||
if (status==3)
|
if (status==3)
|
||||||
{
|
{
|
||||||
|
if (rs_b.RS_DataWillSend2 == 0)
|
||||||
|
{
|
||||||
|
|
||||||
|
count_free++;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
// åñëè ìû â ïåðåäà÷å ëîãîâ è òàì ïóñòàÿ êîìàíäà áåç îáìåíà ïî rs485
|
||||||
|
if (flag_work_rs_send_log)
|
||||||
|
{
|
||||||
|
status = 0;
|
||||||
|
status_ok++;
|
||||||
|
if (status_ok<0) status_ok=1;
|
||||||
|
}
|
||||||
|
|
||||||
if (rs_b.RS_DataReadyAnswerAnalyze)
|
if (rs_b.RS_DataReadyAnswerAnalyze)
|
||||||
{
|
{
|
||||||
// i_led2_on_off(0);
|
// i_led2_on_off(0);
|
||||||
@ -469,11 +607,16 @@ int modbusNetworkSharing(int flag_update_only_hmi)
|
|||||||
control_station.time_detect_answer_485[CONTROL_STATION_INGETEAM_PULT_RS485] = 0;
|
control_station.time_detect_answer_485[CONTROL_STATION_INGETEAM_PULT_RS485] = 0;
|
||||||
control_station.count_ok_modbus[CONTROL_STATION_INGETEAM_PULT_RS485]++;
|
control_station.count_ok_modbus[CONTROL_STATION_INGETEAM_PULT_RS485]++;
|
||||||
rs_b.RS_DataReadyAnswerAnalyze = 0;
|
rs_b.RS_DataReadyAnswerAnalyze = 0;
|
||||||
|
rs_b.RS_DataWillSend2 = 0;
|
||||||
status = 0;
|
status = 0;
|
||||||
|
|
||||||
if (last_ok_cmd==4) // ïðîøëà readAnalogDataFromRemote() ñì íèæå
|
if (last_ok_cmd==4) // ïðîøëà readAnalogDataFromRemote() ñì íèæå
|
||||||
edrk.get_new_data_from_hmi = 1;// ìîæíî çàáðàòü äàííûå?
|
edrk.get_new_data_from_hmi = 1;// ìîæíî çàáðàòü äàííûå?
|
||||||
final_code = last_ok_cmd;//numberInT+1;
|
final_code = last_ok_cmd;//numberInT+1;
|
||||||
|
|
||||||
|
//status_err = 0;
|
||||||
|
status_ok++;
|
||||||
|
if (status_ok<0) status_ok=1;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@ -482,14 +625,16 @@ int modbusNetworkSharing(int flag_update_only_hmi)
|
|||||||
{
|
{
|
||||||
resetup_mpu_rs(&rs_b);
|
resetup_mpu_rs(&rs_b);
|
||||||
control_station.time_detect_answer_485[CONTROL_STATION_INGETEAM_PULT_RS485] = 0;
|
control_station.time_detect_answer_485[CONTROL_STATION_INGETEAM_PULT_RS485] = 0;
|
||||||
|
rs_b.RS_DataWillSend2 = 0;
|
||||||
status = 0;
|
status = 0;
|
||||||
control_station.count_error_modbus[CONTROL_STATION_INGETEAM_PULT_RS485]++;
|
control_station.count_error_modbus[CONTROL_STATION_INGETEAM_PULT_RS485]++;
|
||||||
|
status_err++;// = 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
*/
|
||||||
// switch (status)
|
// switch (status)
|
||||||
// {
|
// {
|
||||||
// case 0 : status = 1;
|
// case 0 : status = 1;
|
||||||
@ -586,7 +731,9 @@ int modbusNetworkSharing(int flag_update_only_hmi)
|
|||||||
//
|
//
|
||||||
|
|
||||||
|
|
||||||
if (enable_send_cmd && (log_to_HMI.send_log == 0))
|
if (enable_send_cmd
|
||||||
|
// && (log_to_HMI.send_log == 0)
|
||||||
|
)
|
||||||
{
|
{
|
||||||
//i_led2_on_off(1);
|
//i_led2_on_off(1);
|
||||||
last_ok_cmd = numberInT;
|
last_ok_cmd = numberInT;
|
||||||
@ -602,11 +749,13 @@ int modbusNetworkSharing(int flag_update_only_hmi)
|
|||||||
edrk.test++;
|
edrk.test++;
|
||||||
|
|
||||||
numberInT++;
|
numberInT++;
|
||||||
|
enable_send_cmd = 0;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 1:
|
case 1:
|
||||||
|
|
||||||
if ((flag_update_only_hmi==0) && (edrk.flag_enable_update_hmi))
|
if ((flag_update_only_hmi==0) && (edrk.flag_enable_update_hmi))
|
||||||
|
// if (edrk.flag_enable_update_hmi)
|
||||||
update_tables_HMI_analog();
|
update_tables_HMI_analog();
|
||||||
|
|
||||||
writeAnalogDataToRemote(); // 1 ÷àñòü àíàëîãà
|
writeAnalogDataToRemote(); // 1 ÷àñòü àíàëîãà
|
||||||
@ -617,6 +766,7 @@ int modbusNetworkSharing(int flag_update_only_hmi)
|
|||||||
// else
|
// else
|
||||||
numberInT++;
|
numberInT++;
|
||||||
|
|
||||||
|
enable_send_cmd = 0;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 2:
|
case 2:
|
||||||
@ -632,39 +782,79 @@ int modbusNetworkSharing(int flag_update_only_hmi)
|
|||||||
// else
|
// else
|
||||||
numberInT++;
|
numberInT++;
|
||||||
|
|
||||||
|
enable_send_cmd = 0;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
|
||||||
case 3:
|
case 3:
|
||||||
readAnalogDataFromRemote(); // 1 ÷àñòü
|
readAnalogDataFromRemote(); // 1 ÷àñòü
|
||||||
numberInT++;
|
numberInT++;
|
||||||
|
enable_send_cmd = 0;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 4:
|
case 4:
|
||||||
readAnalogDataFromRemote(); // 2 ÷àñòü
|
readAnalogDataFromRemote(); // 2 ÷àñòü
|
||||||
|
|
||||||
if (log_to_HMI.send_log == 1)
|
if (log_to_HMI.send_log)
|
||||||
|
{
|
||||||
numberInT++;
|
numberInT++;
|
||||||
|
}
|
||||||
else
|
else
|
||||||
// ïðîïóñêàåì ñëåä êîìàíäó
|
// ïðîïóñêàåì ñëåä êîìàíäó
|
||||||
numberInT = 0;
|
numberInT = 0;
|
||||||
|
|
||||||
|
enable_send_cmd = 0;
|
||||||
|
count_work_in_log = 0; // ïîäãîòîâêà äëÿ ëîãîâ
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 5:
|
case 5:
|
||||||
sendLogToHMI();
|
if (log_to_HMI.send_log)
|
||||||
|
{
|
||||||
|
time_pause = 2;
|
||||||
|
// ccc[0] = 1;
|
||||||
|
flag_work_rs_send_log = !sendLogToHMI(status_ok);
|
||||||
|
edrk.flag_slow_in_main = 1;
|
||||||
|
enable_send_cmd = 0;
|
||||||
|
|
||||||
|
if (count_work_in_log>MAX_COUNT_WORK_IN_LOG)
|
||||||
|
{
|
||||||
|
count_work_in_log = 0;
|
||||||
|
numberInT = 0; // çàïóñêàåì ïîëíûé öèêë
|
||||||
|
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
count_work_in_log++;
|
||||||
|
// îñòàåìñÿ â ýòîì öèêëå ëîãîâ
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
time_pause = TIME_PAUSE_MODBUS_REMOUTE;
|
||||||
|
// ccc[0] = 0;
|
||||||
numberInT = 0;
|
numberInT = 0;
|
||||||
|
enable_send_cmd = 0;
|
||||||
|
edrk.flag_slow_in_main = 0;
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
|
||||||
default:
|
default:
|
||||||
|
enable_send_cmd = 0;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
enable_send_cmd = 0;
|
|
||||||
//i_led2_on_off(0);
|
//i_led2_on_off(0);
|
||||||
|
|
||||||
}
|
}
|
||||||
sendLogToHMI();
|
//sendLogToHMI();
|
||||||
|
|
||||||
|
|
||||||
|
#if(_ENABLE_PWM_LINES_FOR_TESTS_RS)
|
||||||
|
PWM_LINES_TK_20_OFF;
|
||||||
|
#endif
|
||||||
|
|
||||||
if (flag_update_only_hmi)
|
if (flag_update_only_hmi)
|
||||||
return final_code;
|
return final_code;
|
||||||
@ -680,17 +870,19 @@ int modbusNetworkSharingCAN(void)
|
|||||||
// static unsigned int old_time1 = 0 , time_pause1 = TIME_PAUSE_NETWORK_CAN1;
|
// static unsigned int old_time1 = 0 , time_pause1 = TIME_PAUSE_NETWORK_CAN1;
|
||||||
// static unsigned int old_time2 = 0 , time_pause2 = TIME_PAUSE_NETWORK_CAN2;
|
// static unsigned int old_time2 = 0 , time_pause2 = TIME_PAUSE_NETWORK_CAN2;
|
||||||
// static unsigned int old_time3 = 0 , time_pause3 = TIME_PAUSE_NETWORK_CAN3;
|
// static unsigned int old_time3 = 0 , time_pause3 = TIME_PAUSE_NETWORK_CAN3;
|
||||||
|
static unsigned int time_pause_modbus_can_terminals = TIME_PAUSE_MODBUS_CAN_TERMINALS;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
#if (ENABLE_CAN_SEND_TO_MPU_FROM_MAIN)
|
#if (ENABLE_CAN_SEND_TO_MPU_FROM_MAIN)
|
||||||
// if (detect_pause_milisec(time_pause1,&old_time1))
|
// if (detect_pause_milisec(time_pause1,&old_time1))
|
||||||
write_all_data_to_mpu_can(1, TIME_PAUSE_MODBUS_CAN_MPU);
|
static unsigned int time_pause_modbus_can_mpu = TIME_PAUSE_MODBUS_CAN_MPU;
|
||||||
|
write_all_data_to_mpu_can(1, time_pause_modbus_can_mpu);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if (ENABLE_CAN_SEND_TO_TERMINAL_FROM_MAIN)
|
#if (ENABLE_CAN_SEND_TO_TERMINAL_FROM_MAIN)
|
||||||
// if (detect_pause_milisec(time_pause2,&old_time2))
|
// if (detect_pause_milisec(time_pause2,&old_time2))
|
||||||
write_all_data_to_terminals_can(1, TIME_PAUSE_MODBUS_CAN_TERMINALS);
|
write_all_data_to_terminals_can(1, time_pause_modbus_can_terminals);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
@ -15,7 +15,7 @@
|
|||||||
// void ReceiveAnswerCommandModbus3(RS_DATA *rs_arr);
|
// void ReceiveAnswerCommandModbus3(RS_DATA *rs_arr);
|
||||||
|
|
||||||
#define TIME_PAUSE_MODBUS_MPU 250 //100//500
|
#define TIME_PAUSE_MODBUS_MPU 250 //100//500
|
||||||
#define TIME_PAUSE_MODBUS_REMOUTE 100 //500
|
#define TIME_PAUSE_MODBUS_REMOUTE 20 //100 //500
|
||||||
|
|
||||||
#define TIME_PAUSE_NETWORK_CAN1 444 //500
|
#define TIME_PAUSE_NETWORK_CAN1 444 //500
|
||||||
#define TIME_PAUSE_NETWORK_CAN2 990 //500
|
#define TIME_PAUSE_NETWORK_CAN2 990 //500
|
||||||
@ -30,11 +30,11 @@
|
|||||||
|
|
||||||
#define SIZE_BUF_WRITE_TO_MODBUS16_VPU 100 //
|
#define SIZE_BUF_WRITE_TO_MODBUS16_VPU 100 //
|
||||||
|
|
||||||
#define SIZE_BUF_WRITE_TO_MODBUS16_REMOUTE 100 //100 // ïåðåäà÷à, ðàçìåð â îäíîé ïîñûëêå àíàëîã.÷àñòè ïóëüòà ÁÑÓ, íå áîëüøå SIZE_ANALOG_DATA_REMOUTE
|
#define SIZE_BUF_WRITE_TO_MODBUS16_REMOUTE 120 //100 // ïåðåäà÷à, ðàçìåð â îäíîé ïîñûëêå àíàëîã.÷àñòè ïóëüòà ÁÑÓ, íå áîëüøå SIZE_ANALOG_DATA_REMOUTE
|
||||||
#define SIZE_ANALOG_DATA_REMOUTE 200 //165 // ïåðåäà÷à, ðàçìåð äàííûõ ïî àíàëîãîâîé ÷àñòè ïóëüòà ÁÑÓ
|
#define SIZE_ANALOG_DATA_REMOUTE 240 //165 // ïåðåäà÷à, ðàçìåð äàííûõ ïî àíàëîãîâîé ÷àñòè ïóëüòà ÁÑÓ
|
||||||
|
|
||||||
|
|
||||||
#define SIZE_BUF_READ_FROM_MODBUS16_REMOUTE 100 //20//36 // ïðèåì, ðàçìåð â îäíîé ïîñûëêå àíàëîã.÷àñòè ïóëüòà ÁÑÓ, íå áîëüøå SIZE_ANALOG_DATA_FROM_MODBUS16_REMOUTE
|
#define SIZE_BUF_READ_FROM_MODBUS16_REMOUTE 120 //20//36 // ïðèåì, ðàçìåð â îäíîé ïîñûëêå àíàëîã.÷àñòè ïóëüòà ÁÑÓ, íå áîëüøå SIZE_ANALOG_DATA_FROM_MODBUS16_REMOUTE
|
||||||
#define SIZE_ANALOG_DATA_FROM_MODBUS16_REMOUTE SIZE_ANALOG_DATA_REMOUTE //20//36 // ïðèåì, ðàçìåð äàííûõ ïî àíàëîãîâîé ÷àñòè ïóëüòà ÁÑÓ
|
#define SIZE_ANALOG_DATA_FROM_MODBUS16_REMOUTE SIZE_ANALOG_DATA_REMOUTE //20//36 // ïðèåì, ðàçìåð äàííûõ ïî àíàëîãîâîé ÷àñòè ïóëüòà ÁÑÓ
|
||||||
|
|
||||||
|
|
||||||
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue
Block a user