⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 struct.h

📁 串行通讯程序,为电池分析仪与电脑通讯软件,效果不错.
💻 H
📖 第 1 页 / 共 3 页
字号:
	UINT rate;
	int  ma;
	long mw;
} scaled_ccode;

#include "stnstat.h"

struct battery_process {							/* battery processing information			*/
	UINT	bat_SN;
	UINT	days;								/* elapsed days									*/
	UINT	elapsed;                                			/* elapsed minutes								*/
	ULONG	cycle_elapsed;							/* elapsed time of current cycle in seconds		*/
	ULONG	timer1;								/* cycle timer 1 (1/5 second)				*/
	ULONG	timer2;								/* cycle timer 2 (1/5 second)				*/
	char	irq;								/* interrupted cycle					*/
	char	irq_cnt;							/* interrupted cycle					*/
	UINT	chg_cnt;							/* charge cycle count					*/
	UINT	dchg_cnt;							/* discharge cycle count				*/
	UINT	recon_cnt;							/* recondition cycle count				*/
	char	cap[5];								/* capacity readings					*/
	unsigned long captick;
	char	status[5];							/* status codes						*/
	char	phase;								/* current phase					*/
	char	step;								/* current step of the phase				*/
	char	loop[5];							/* loop counter (1 for each phase)			*/
	char    rest_cnt;							/* rest cycle count for NiMH				*/
	unsigned char started	:1;						/* actual cycle has started				*/
	unsigned char fault  	:1;						/* fault present					*/
	unsigned char tc     	:1;						/* trickle charge flag					*/
	unsigned char td	:1;						/* recondition flag					*/
	unsigned char ctc    	:1;						/* cold trickle charge flag				*/
	unsigned char standby	:1;						/* standby cycle flag					*/
	unsigned char done   	:1;						/* finished processing flag				*/
	unsigned char resume	:1;						/* set if power was interrupted				*/
	unsigned char calibrate :1;						/* performing station calibration			*/
	unsigned char cal_zero  :1;						/* zero charge current calibration			*/
	unsigned char ctp	:1;						/* constant voltage CTP reached				*/
	unsigned char quicktest :1;						/* quick test data collection flag			*/
	unsigned char qt_done	:1;						/* quick test discharge finished			*/
	unsigned char qt_verr   :1;						/* quick test under voltage				*/
	unsigned char rt_dchg   :1;						/* doing runtime discharge				*/
	unsigned char           :1;
	UINT	start_date;							/* julian date when battery inserted			*/
	UINT	start_time;							/* time when battery inserted				*/
	char	batid[11];							/* battery ID number					*/
	unsigned char inserted	:1;						/* battery inserted					*/
	unsigned char measure_v	:1;						/* set to enable voltage measurements			*/
	unsigned char skip	:1;						/* set to skip measurements for one cycle		*/
	unsigned char vcal	:1;						/* voltage calibration in progress			*/
	unsigned char measure_ma:1;						/* measure the ma flag					*/
	unsigned char drain     :1;						/* battery detect drain enabled flag			*/
	unsigned char pa        :1;						/* charge/discharge power allocated			*/
	unsigned char queued    :1;						/* on the charge wait queue				*/
	unsigned char err112	:1;						/* cell mismatch error					*/
	unsigned char err115	:1;						/* target not met error					*/
	unsigned char err118	:1;						/* soft battery error					*/
	unsigned char did118	:1;						/* did a soft battery error occur			*/
	unsigned char err135    :1;						/* impedance threshold exceeded				*/
	unsigned char lowvolt   :1;						/* delay flag for low voltage detection			*/
	unsigned char auto_ohm  :1;						/* ok to perform automatic impedance test		*/
	unsigned char wakeup    :1;						/* Wakeup selected by holding station key		*/
	ULONG	timer3;								/* cycle timer 3 current timer				*/
	UINT	timer4;								/* cycle timer 4 current timer				*/
	long	mw;								/* current charge or discharge power			*/
	UINT	c_rate;								/* the c-rate						*/
	UINT	volts;								/* milli-volts per cell (current)			*/
	UINT	v_peak;								/* peak voltage reading					*/
	UINT	v_plateau;							/* plateau voltage reading				*/
	UINT	ma_low;								/* constant voltage low mA reading			*/
	int	ma;								/* xxxxx  mA						*/
	int	ma_cycle[8];							/* last 8 currents, averaged to smooth display	*/
	int	ma_last;							/* last ma reading					*/
	int    	current;							/* current for automatic impedance test cycle	*/
	char	ts_glitch;							/* tsense glitch counter				*/
	UINT	ctp_ma;								/* minumum charge current				*/
	int	temp_last;							/* temperature timer					*/
	char	stn_ms;								/* millisecond timer					*/
	int	ma_1st_read;							/* 1st Current read (step==4) for impedance  	*/
	UINT	volt_1st_read;							/* Lower load Voltage of all cells together:CU2 */
	UINT	volt_2nd_read;			   	                        /* Higher Voltage in Step 4 of waveform 	*/
	long	sum_impedance;							/* Used for filtering fluxation impedance... 	*/
	long    sum_1nd_read;							/*放电电压和*/
	
	uint    cnt_OCV;
	long    sum_OCV;
	uint    bat_OCV;    
	uint    cnt_ID;
	uint    sum_ID;								/*电池ID电阻测试和*/
	uint    sum_NTC;							/*电池NTC电阻测量和*/
	uint    bat_ID;								/*电池ID电阻*/
	uint    bat_NTC;							/*电池NTC电阻*/
	UINT    Volt_DCHG;							/*电池负载电压*/

	char    charge_status;							/*充电功能状态*/
	char    discharge_status;						/*放电功能状态*/
	 
	char    OCV_test;							/* Open circuit voltage rest enable flag */
	char    Short_test;							/* Battery short protect test enalbe flag*/
	char  	Short_status;							/* the battery short circuit status      */
	char	cnt_of_impedance; 		  				/* ... measurement defined by IMP_RESOLUTION	*/
																				/* don't clear this data						*/
	char	cycle;								/* current cycle								*/
	char	last_cycle;							/* cycle to start after equalization			*/
	char	adapt_type;							/* adapter type						*/
	UINT	adapt_no;							/* adapter ID						*/
	char	v_atten;							/* atten value for reading vsense			*/
	UINT	a2d_mv;								/* mV per A to D step					*/
	UINT	vs_raw;								/* vsense raw - last sample				*/
	UINT	is_raw;								/* isense raw - last sample				*/
	UINT	ts_raw;								/* tsense raw - last sample				*/
	int	temp;								/* temperature in C					*/
	UINT	impedance;							/* last impedance measurement				*/

	
	UINT	life_ohm1;							/* 1st ohm reading for Life cycle program		*/
	ULONG	rtime;								/* runtime discharge					*/
	unsigned char adapter	:1;						/* adapter present flag					*/
	unsigned char battery	:1;						/* battery present flag					*/
	unsigned char tsense 	:1;						/* temperature sensor active				*/
	unsigned char dchglast	:1;						/* set if discharge was the last cycle			*/
	unsigned char resumed	:1;						/* program resumed flag					*/
	unsigned char cyc_start	:1;						/* cycle start flag					*/
	unsigned char user_time	:1;						/* user defined timeout					*/
	unsigned char processed	:1;						/* don't save						*/
	unsigned char autodone  :1;                                             /* last impedance measurement				*/
	unsigned char imped_test:1;						/* impedance test flag					*/
	unsigned char diag      :1;						/* running diagnostics for this station			*/
	unsigned char smbus     :1;						/* smbus adapter					*/
	unsigned char smdone    :1;						/* cycle complete from SMBUS battery			*/
	unsigned char sba_comm  :1;						/* talk to the SMBUS device				*/
	unsigned char vclamp    :1;						/* voltage clamp adapter				*/
	unsigned char polarized :1;						/* polarized adapter					*/
};


/******************************************************************************/
/*		QUICKTEST DATA STRUCTURES					  */
/******************************************************************************/	

struct quick_test {
	int  temp;
	UINT ocv1;
	UINT r1;
	UINT v1;
	UINT v2;
	UINT ocv2;
	UINT r2;
	UINT v3;
	UINT v4;
	UINT t1;
	char capacity;
	char result;
	char grade;
	UINT delta;
	UINT v_avg;
	UINT v_drop;
};

struct learned_profile {
	UINT header;
	UINT r1[3][3];
	UINT dv1[3][3];
	UINT dv2[3][3];
	UINT t1[3][3];
	char cntr[8];
	char spare[18];
};
	

struct dacout {									/* DAC Current Value					*/
	unsigned char coarse;
	unsigned char fine;
};

typedef union {
	unsigned int  dac;
	struct dacout bf;
} dac_bit;

struct wave_form {								/* charge/discharge waveform structure			*/
	char	step;								/* the current step					*/
	char    cv_chg;								/* constant voltage charge table being used     	*/
	int	ma_max;								/* max target current (for SLA)				*/
	int	ma_target[5];							/* the target current for each step - in mA		*/
	int	ma_actual[5];							/* the actual current for each step - in mA		*/
	dac_bit	ma_dac[5];							/* the dac settings					*/
	UINT	period[5];							/* timer values for waveforms				*/
	char	duty[5];							/* duty time of waveform in ms				*/
	UCHAR	active	:1;							/* waveform is active					*/
	UCHAR	pending	:1;							/* irq from PIC is pending				*/
	UCHAR           :6;
};

struct wave_table {								/* structure for waveform processing			*/
	int	min;								/* minimum current for the waveform			*/
	int	max;								/* maximum current for the waveform			*/
	UINT	period[5];							/* counter value for waveform part			*/
	char	duty[5];							/* ms time for waveform part				*/
};

struct station_parameters {
	c_code cc;								/* c-code info						*/
	char   setups;								/* number of c-codes in the adapter			*/
	char   setup;								/* the current setup in use				*/
	char   program;								/* station program option				*/
	char   target;								/* station target option				*/
	UINT   is_zero;								/* station zero level					*/
	UINT   vs_offset;							/* calibration offset value mV				*/
	UINT   v_mult;								/*The battery voltage mult for 1/2/3/4cells lion battery*/
	UINT   NTC;								/*   2 bytes - NTC pull up,Pls fix the normal value	*/
	UINT   ID;								/*   2 bytes - ID pull up,Pls fix the normal value	*/
	uint   sn;								/* The battery process sequence number 			*/
	struct battery_process	bp;						/* battery process info					*/
	struct wave_form	wave;						/* charge/discharge waveform				*/
};

struct station_process {							/* Station processing structure				*/
	struct station_parameters *stn;
	char station;
};

struct vsense_atten	{							/* analog attenuator setup structure			*/
	char atten;								/* attenuator value					*/
	UINT mv_step;								/* real mV/step (not per cell)				*/
};


/*************************** PROCESSING PROGRAM STRUCTURE *********************/

typedef struct {								/* time structure used in custom program		*/
	char	hrs;
	char	min;
	char	sec;
} hms;

struct program_phase {								/* custom program phase structure			*/
	char	cycle[2];							/* the cycle to use					*/
	hms	timed[2];							/* max cycle times in seconds				*/
	char	pwr[2];	 							/* percentage of discharge pwr				*/
	char	test;		 						/* condition to test for				*/
	char	state[2];	 						/* "then" clause = 0, "else" clause = 1			*/
	char	count;								/* max loop value					*/
	hms	rest[2];		 					/* rest time						*/
	char	repeat[2];	 						/* repeat count						*/
};

struct program_phase_set {							/* custom program phase structure			*/
	char	cycle[2];							/* step cycle						*/
	char	t_hrs1;								/* time for cycle 1					*/
	char	t_min1;
	char	t_sec1;
	char	t_hrs2;								/* time for cycle 2					*/
	char	t_min2;
	char	t_sec2;
	char	pwr[2];	 							/* percentage of discharge pwr				*/
	char	test;		 						/* condition to test for				*/
	char	true;		 						/* "then" clause					*/
	char	false;		 						/* "else" clause					*/
	char	count;								/* max loop value					*/
	char	r_hrs1;                                                         /* rest time for TRUE condition				*/
	char	r_min1;
	char	r_sec1;
	char	r_hrs2;                                                         /* rest time for FALSE condition			*/

⌨️ 快捷键说明

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