adc.h

来自「单相电机变频驱动原码,采用DISPIC30芯片」· C头文件 代码 · 共 78 行

H
78
字号
/****************************************************************
*
*		Microchip 16-bit Embedded Control Design Contest
*
*		Entry # MT2268
*
*		Spa Pump Controller
*
*****************************************************************
*
*		ADC definitions
*
*****************************************************************/


#define ADCBUF_isns_pfc		ADCBUF0		// ADC channels
#define ADCBUF_vsns_bus		ADCBUF1
#define ADCBUF_vsns_ac		ADCBUF2
#define ADCBUF_temp_pfc		ADCBUF3
#define ADCBUF_isns_aux		ADCBUF4
#define ADCBUF_temp_inv		ADCBUF5
#define ADCBUF_isns_run		ADCBUF6


/*
	The following structure holds all the measurement values
	All WORDs are in Q.14 format, and LONGs are Q.30
*/
struct MEAS_VALUES {

	WORD	vsns_ac;		// AC line voltage
	LONG	vsns_ac_pk;		//  " - peak value
	WORD	vsns_bus;		// DC bus voltage
	LONG	vsns_bus_avg;	//  " - average value
	WORD	isns_pfc;		// PFC input current
	SWORD	isns_aux;		// Motor aux (start) winding current
	LONG	isns_aux_sum;	//  " - RMS intermediate sum
	WORD	isns_aux_rms;	//  " - RMS value
	SWORD	isns_run;		// Motor run winding current
	LONG	isns_run_sum;	//  " - RMS intermediate sum
	WORD	isns_run_rms;	//  " - RMS value
	SWORD	isns_com;		// Motor common current (computed from aux & run currents)
	WORD	temp_pfc;		// PFC heatsink temperature
	WORD	temp_inv;		// Inverter heatsink temperature
};

/*
	The above structure is declared with both volatile
	and non-volatile versions. This allows us to use the
	non-volatile version inside interrupt routines (which
	lets the compiler do better optimization), and the
	volatile version elsewhere.
*/
EXTERN union {

	struct			MEAS_VALUES nv;
	volatile struct	MEAS_VALUES v;

} meas;


/*
	ADC input offset values

	These are subtracted from the converted values
	to compensate for the hardware offset voltages
*/
struct ADC_OFFSET_S {
	WORD	isns_pfc;		// PFC input current
	WORD	isns_run;		// Motor run winding current
	WORD	isns_aux;		// Motor aux (start) winding current
};

EXTERN struct ADC_OFFSET_S offset;	// ADC input offset values


void ADC_init (void);

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?