matlab_23550/Inu/Src/N12_Xilinx/xp_inc_sensor.h

119 lines
3.8 KiB
C

#ifndef XP_INC_SENS_H
#define XP_INC_SENS_H
#include "x_basic_types.h"
#include "xp_cds_in.h"
#include "xp_id_plate_info.h"
//Äèñêðåòèçàöèþ, ïðè êîòîðîé ðàñ÷èòûâàåòñþ äëèòåëüíîñòü èìïóëüñîâ
#define SAMPLING_TIME_NS 1 // 16,666667ns
#define SAMPLING_TIME_MS 0 // 1,666667us
//Àâòîìàòè÷åñêè ïåðåêëþ÷àåò ñ÷¸ò÷èê, êîãäà êîëè÷åñòâî îòñ÷¸òîâ
// íà 1 èìïóëüñ ñòàíîâèòñß ñëèøêîì áîëüøèì èëè ìàëåíüêèì.
#define AUTO_CHANGE_SAMPLING_TIME 1
/*
×òî áû ïðî÷èòàòü äàííûå èç äàò÷èêà, íóæíî âûçâàòü
rotation_sensor.read_sensors(&rotation_sensor);
Ðåçóëüòàò ïëàòû IN áóäåò â
rotation_sensor.in_plane.out....
*/
/////////////////////////////////////////////////////////////
// IN plane
/////////////////////////////////////////////////////////////
// Registers with data for incremental 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_inc_sensor_comand;
#define T_INC_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_inc_sensor_comand write_comand_reg;
T_inc_sensor_comand read_comand_reg;
} T_inc_sensor_regs;
#define T_INC_SENSOR_REGS_DEFAULTS {0,0,0,0, 0,0,0,0, T_INC_COMAND_DEFAULT, T_INC_COMAND_DEFAULT}
////////////////////////////////////////////////
////// incremental sensors with IN plane
///////////////////////////////////////////////
typedef struct {
//UInt16 plane_address;
unsigned int count_wait_for_update_registers;
unsigned int error_update;
unsigned int use_sensor1;
unsigned int use_sensor2;
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
unsigned long TimeCalcFromImpulses1; // Ïåðåñ÷åò âðåìåíè èìïóëüñà èç êîëè÷åñòâà Impulses1 è âðåìåíè Time1
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
unsigned long TimeCalcFromImpulses2; // Ïåðåñ÷åò âðåìåíè èìïóëüñà èç êîëè÷åñòâà Impulses1 è âðåìåíè Time1
int direction2; // 1 - direct; 0 - reverse
} data;
T_inc_sensor_regs pm67regs;
void (*set)(); // Pointer to calculation function
void (*update_sensors)();
void (*read_sensors)();
void (*read_sensor1)();
void (*read_sensor2)();
} 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}
//////////////////////////////////////////////////////////////////////////////////
////
//////////////////////////////////////////////////////////////////////////////////
//Public functions
void inc_sensor_set(T_inc_sensor *inc_s);
void inc_sensor_read1(T_inc_sensor *inc_s);
void inc_sensor_read2(T_inc_sensor *inc_s);
void inc_sensor_read(T_inc_sensor *inc_s);
void update_sensors_data_s(T_inc_sensor *inc_s);
extern T_inc_sensor inc_sensor;
#endif //XP_INC_SENS_H