113 lines
3.4 KiB
C
113 lines
3.4 KiB
C
|
|
#include "../main/SystemInclude.h"
|
|||
|
|
|
|||
|
|
|
|||
|
|
//##############################################################################
|
|||
|
|
#ifndef ENABLE_4_20MA_OUTPUT
|
|||
|
|
#pragma message("[undefined] ENABLE_4_20MA_OUTPUT")
|
|||
|
|
#elif(ENABLE_4_20MA_OUTPUT)
|
|||
|
|
//##############################################################################
|
|||
|
|
|
|||
|
|
//******************************************************************************
|
|||
|
|
void CurrentLoopInit(void)
|
|||
|
|
{
|
|||
|
|
#ifndef ENABLE_4_20MA_ALL
|
|||
|
|
#pragma message("[undefined] ENABLE_4_20MA_ALL")
|
|||
|
|
#elif(ENABLE_4_20MA_ALL)
|
|||
|
|
SysLoopChip = ReadShortParameterFromEEPROM(SYS_LOOP_CHIP, SYS_LOOP_CHIP_WIDTH, SYS_LOOP_CHIP_DEFAULT);
|
|||
|
|
if(SysLoopChip == DAC8760)
|
|||
|
|
{
|
|||
|
|
DAC8760Init(FR_20MA);
|
|||
|
|
#ifndef ENABLE_PRESSURE
|
|||
|
|
#pragma message("[undefined] ENABLE_PRESSURE")
|
|||
|
|
#elif(ENABLE_PRESSURE)
|
|||
|
|
DAC8760Init(PRESS_20MA);
|
|||
|
|
#endif
|
|||
|
|
}
|
|||
|
|
else if(SysLoopChip == AD5420)
|
|||
|
|
{
|
|||
|
|
AD5420Init(FR_20MA);
|
|||
|
|
#ifndef ENABLE_PRESSURE
|
|||
|
|
#pragma message("[undefined] ENABLE_PRESSURE")
|
|||
|
|
#elif(ENABLE_PRESSURE)
|
|||
|
|
AD5420Init(PRESS_20MA);
|
|||
|
|
#endif
|
|||
|
|
}
|
|||
|
|
#else
|
|||
|
|
|
|||
|
|
#ifndef ENABLE_USE_DAC8760
|
|||
|
|
#pragma message("[undefined] ENABLE_USE_DAC8760")
|
|||
|
|
#elif(ENABLE_USE_DAC8760)
|
|||
|
|
DAC8760Init(FR_20MA);
|
|||
|
|
#endif
|
|||
|
|
|
|||
|
|
#ifndef ENABLE_USE_AD5420
|
|||
|
|
#pragma message("[undefined] ENABLE_USE_AD5420")
|
|||
|
|
#elif(ENABLE_USE_AD5420)
|
|||
|
|
AD5420Init(FR_20MA);
|
|||
|
|
#endif
|
|||
|
|
|
|||
|
|
#endif
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
//******************************************************************************
|
|||
|
|
void CurrentLoopLopwerMode(void)
|
|||
|
|
{
|
|||
|
|
DisableDACSPI();
|
|||
|
|
|
|||
|
|
#ifndef ENABLE_USE_DACSOMI
|
|||
|
|
#pragma message("[undefined] ENABLE_USE_DACSOMI")
|
|||
|
|
#elif(ENABLE_USE_DACSOMI)
|
|||
|
|
DISABLE_DACSOMI();
|
|||
|
|
ENABLE_DACSOMI_OUTPUT();
|
|||
|
|
#endif
|
|||
|
|
|
|||
|
|
DISABLE_DACSIMO();
|
|||
|
|
ENABLE_DACSIMO_OUTPUT();
|
|||
|
|
CLR_DACSIMO();
|
|||
|
|
|
|||
|
|
DISABLE_DACCLK();
|
|||
|
|
ENABLE_DACCLK_OUTPUT();
|
|||
|
|
CLR_DACCLK();
|
|||
|
|
|
|||
|
|
LOOP_LATCH_PIN_OUTPUT();
|
|||
|
|
CLR_LOOP_LATCH();
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
//******************************************************************************
|
|||
|
|
void ComputCurrentLoopAndOutput(void)
|
|||
|
|
{
|
|||
|
|
float LoopOutputValue;
|
|||
|
|
|
|||
|
|
if(flowRate > maxFlowRate) LoopOutputValue = 65535; //<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ֵ<EFBFBD><D6B5><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>20mA
|
|||
|
|
else
|
|||
|
|
{
|
|||
|
|
//unsigned long int tmp = maxFlowRate *10 / 12;
|
|||
|
|
LoopOutputValue = 65535;
|
|||
|
|
LoopOutputValue /= (float)maxFlowRate; //LoopOutputValue /= (unsigned long long int)LoopOutputMaxFlowrate;
|
|||
|
|
LoopOutputValue *= (float)flowRate; //<2F><><EFBFBD><EFBFBD>fr= (displayUpdata*65535)/maxFlowrate
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
#ifndef ENABLE_4_20MA_ALL
|
|||
|
|
#pragma message("[undefined] ENABLE_4_20MA_ALL")
|
|||
|
|
#elif(ENABLE_4_20MA_ALL)
|
|||
|
|
if(SysLoopChip == DAC8760) DAC8760Output((unsigned int)LoopOutputValue, FR_20MA);
|
|||
|
|
else if(SysLoopChip == AD5420) AD5420Output((unsigned int)LoopOutputValue, FR_20MA);
|
|||
|
|
#else
|
|||
|
|
#ifndef ENABLE_USE_AD5420
|
|||
|
|
#pragma message("[undefined] ENABLE_USE_AD5420")
|
|||
|
|
#elif(ENABLE_USE_AD5420)
|
|||
|
|
AD5420Output((unsigned int)LoopOutputValue, FR_20MA);
|
|||
|
|
#endif
|
|||
|
|
|
|||
|
|
#ifndef ENABLE_USE_DAC8760
|
|||
|
|
#pragma message("[undefined] ENABLE_USE_DAC8760")
|
|||
|
|
#elif(ENABLE_USE_DAC8760)
|
|||
|
|
DAC8760Output((unsigned int)LoopOutputValue, FR_20MA);
|
|||
|
|
#endif
|
|||
|
|
|
|||
|
|
#endif
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
//##############################################################################
|
|||
|
|
#endif
|
|||
|
|
//##############################################################################
|