initial check in based on SVN revision 575
This commit is contained in:
157
source/utils.h
Normal file
157
source/utils.h
Normal file
@@ -0,0 +1,157 @@
|
||||
/*
|
||||
* utils.h
|
||||
*
|
||||
* Created on: Jun 9, 2022
|
||||
* Author: Keith.Lloyd
|
||||
*/
|
||||
|
||||
#ifndef UTILS_H_
|
||||
|
||||
#define UTILS_H_
|
||||
|
||||
|
||||
#include "arm_math.h"
|
||||
#include "spi.h"
|
||||
//#define CLAMP 1 // Todo Fix later
|
||||
#define DDC 2
|
||||
#define MAX_CLAMP_VOLTAGE 170.0f
|
||||
|
||||
#define MAX_DC_VOLTAGE 90.0
|
||||
#define CLAMP_MIN 100 //Todo Calculate correct limit values
|
||||
#define CLAMP_MAX 200
|
||||
#define DC_MIN 220
|
||||
#define DC_MAX 250
|
||||
#define DDC_MIN 270
|
||||
#define DDC_MAX 300
|
||||
#define TGT_NOT_USED 330
|
||||
#define OUT_RELAY_OFF_MASK 0b11100111
|
||||
|
||||
#define PORT1A_ON 0b00001000
|
||||
#define PORT1B_ON 0b00011000
|
||||
#define PORT2A_ON 0b00000000
|
||||
#define PORT2B_ON 0b00010000
|
||||
#define XFRMR_HF_ON 0b00000010
|
||||
#define HF_AMP_ON 0b01000000
|
||||
|
||||
#define PORT_LE 5
|
||||
#define ESTOP 17
|
||||
#define BYPASS_ON 0b00000001 //
|
||||
#define HFDC_ON 0b00000010
|
||||
#define LFDC_ON 0b00000000
|
||||
#define LFANT_ON 0b00000100
|
||||
#define HFANT_ON 0b10000100
|
||||
#define PWR_CTL 16
|
||||
#define PWR_ON 1
|
||||
#define PWR_OFF 0
|
||||
//#define MAX_VOLTS 800 // RAW ADC VALUE for Maximum Voltage on DConnect output
|
||||
#define MAX_OP_VOLTS 180 //220.0 //1.68 Maximum VOLTS
|
||||
#define MAX_BYPASS_VOLTS 95.0//0.84
|
||||
#define MAX_BYPASS_VOLTS2 110.0
|
||||
#define MAX_CURRENT 950.0 // RAW ADC VALUE for Maximum Current on DConnect output
|
||||
#define MAX_HF_CURRENT 300.0
|
||||
#define VOLTAGE 7 // ADC address of voltage measurement
|
||||
#define CURRENT 0 // ADC address of current measurement
|
||||
#define ALL_RELAYS_OFF_UPPER 0 //ToDo
|
||||
#define ALL_RELAYS_OFF_LOWER 0 // Todo
|
||||
#define POT_CS 7 // Todo
|
||||
#define ERROR 8 // Bit position of ERROR Signal
|
||||
#define DAMP_EN_ON 0b00100000
|
||||
#define SLCT_AMPD_ON 0b00000010
|
||||
#define AMP_PSU_ON 0b11111011
|
||||
#define XFRMR_LF_ON 0b00000010 // Bit position of Xfrmr Mux.
|
||||
#define SLCT_XFMR XFRMR_LF_ON
|
||||
#define SLCT_AMP 0b01000000 // Matches Correct Xfrmr to Correct amplifier.
|
||||
#define MUX_AB_AMP 0b00000001
|
||||
#define ANT_AMP_EN 0b10000000
|
||||
#define ANT_AMP_SW 0b00000010
|
||||
#define BC_CLK 0
|
||||
#define DC_CLK 1
|
||||
#define I_GAIN 0b01000000
|
||||
#define SENTINAL 180
|
||||
#define MIN_POT 5
|
||||
|
||||
typedef enum {
|
||||
EMPTY,
|
||||
CLAMP,
|
||||
CONNECT_LEAD,
|
||||
DUAL_DC
|
||||
}OUT_CONNECT_t;
|
||||
|
||||
typedef enum{
|
||||
LFA_LFX,
|
||||
HFA_LFX,
|
||||
HFA_HFX
|
||||
} AMP_XFRMR_SLCT_t;
|
||||
|
||||
|
||||
typedef enum {
|
||||
OFF,
|
||||
ON
|
||||
}RELAY_SELECT_t;
|
||||
|
||||
|
||||
typedef struct ClampData_s
|
||||
{
|
||||
float slope;
|
||||
uint8_t pot;
|
||||
float voltage;
|
||||
float current;
|
||||
float impedance;
|
||||
float power;
|
||||
float maxPower;
|
||||
float targetPower;
|
||||
uint32_t timeout;
|
||||
bool regulate;
|
||||
uint8_t prevPowerLevel;
|
||||
|
||||
} ClampData_t;
|
||||
|
||||
|
||||
void Select_Estop(RELAY_SELECT_t);
|
||||
void Send_Pot_Data(uint16_t Data, SPI_MODE_t destination);
|
||||
void Send_Update_Port(void);
|
||||
void Clear_Relays(void);
|
||||
|
||||
uint8_t Check_Output_Status(char Connector);
|
||||
void Power_Down(void);
|
||||
void Power_ON_OFF(RELAY_SELECT_t Power);
|
||||
void Check_Over_Current();
|
||||
void Check_Live_Voltage();
|
||||
//void Check_Over_Voltage();
|
||||
|
||||
void Check_PSU_Short(void);
|
||||
void Estop_Mode(void);
|
||||
void Select_Transformer(void);
|
||||
void Select_Amp_Xfrmr_Rly(AMP_XFRMR_SLCT_t Amp2xfrmr);
|
||||
void Select_Bypass(RELAY_SELECT_t Bypass); // Bypass allows transmitting w/o full protection
|
||||
void Chk_Gain(void);
|
||||
void Check_Over_Power(void);
|
||||
void Check_Clamp_OverVoltage(void);
|
||||
void Adjust_Clamp_Volts(void);
|
||||
bool Compare_Voltage(float32_t source,float32_t limit);
|
||||
void Check_Over_Voltage(void);
|
||||
void Controlled_Pwr_Dwn(void);
|
||||
void Update_Amp_Pot(void);
|
||||
void Check_For_Clamp_On_Pwr_Up(void);
|
||||
void Adjust_Output_Power(float32_t New_Power_Limit);
|
||||
float Get_Max_Current(void);
|
||||
void Reduce_Kick_Back(void);
|
||||
float32_t Convert_Pot2_Volts(uint8_t value);
|
||||
void Cut_Signal_To_Min(void);
|
||||
bool Check_For_Clamp();
|
||||
void freq_key_process(void);
|
||||
void Init_LD_Sync(void);
|
||||
void Leica_Patch(void);
|
||||
void Umag_Patch(void);
|
||||
float32_t Get_Power_Limit(void);
|
||||
bool Check_For_Clamp_New();
|
||||
|
||||
|
||||
#endif /* UTILS_H_ */
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user