/*********************************************** * * ************************************************/ #define BASE_ADDR 0x02000a00 #define IMAX 0.020 #define R0 200. read_gas_mix(flow, iso_monitor) float flow[], *iso_monitor; { int cpu_nr, tcp_ip_nr; char *hv_config[3]; int gains_set[96], gains_read[96], data[96]; float datv[96]; float full_scale[3],percent[3]; unsigned base; int ndata, gain_mode, diff_mode, i; float vmin = -10.; /* give range of the A/D : settable only hardware ! */ float vmax = 10.; float nch = 4096; if (get_config( &tcp_ip_nr, &cpu_nr, hv_config) != 0){ printf (" error in get_config \n"); exit (0); } if (cpu_nr != 1){ return 1; } full_scale[0] =2000.; full_scale[1] =400.; full_scale[2] =120.; base = (unsigned) BASE_ADDR; diff_mode = 1; /* 1: 48 diff chan's; 0: 96 single ended chan's */ gain_mode = 1; /* 1: common amplification for all chan's 0: individual amplification */ gains_set[0] = gain_word(1); /* -> amplification = 1 */ anl_adc_init(base, &gain_mode, gains_set, &diff_mode); anl_adc_read(base, data, &ndata, &gain_mode, gains_read, &diff_mode); for ( i = 0; i < 4; i++){ datv[i] = (vmax - vmin)/(nch-1) * (float) data[i] + vmin; if (i > 0){ percent[3 - i] = datv[i] / (IMAX * R0); } else *iso_monitor = datv[i]; } for ( i = 0; i < 3; i++){ flow[i] = percent[i] * full_scale[i]; } return 0; }