Пример #1
0
// returns the measured temperature
double get_measurement(unsigned int channel,  int* semaphorePtr) {
	int result;
	int local_data;
	double result_d;
	
	ads_config(INTERNAL_SENSOR,channel);  // start internal sensor measurement
	delay_ms(10);
   while (*semaphorePtr != 0) {delay_ms(1);}
   *semaphorePtr = 1;
	local_data=ads_read(EXTERNAL_SIGNAL,channel); // read internal sensor measurement and start external sensor measurement
   *semaphorePtr = 0;
	delay_ms(10);
   while (*semaphorePtr != 0) {delay_ms(1);}
   *semaphorePtr = 1;
	result=ads_read(EXTERNAL_SIGNAL,channel); // read external sensor measurement and restart external sensor measurement
   *semaphorePtr = 0;
	
	local_comp = local_compensation(local_data);
	result = result + local_comp;
	result=result & 0xffff;
	result = adc_code2temp(result);
	
	//printf("10x temp is %d\n", result);
	result_d=((double)result)/10;
	
	return(result_d);
}
Пример #2
0
// returns the measured temperature
double
get_measurement(void)
{
	int result;
	int local_data;
	double result_d;
	
	ads_config(INTERNAL_SENSOR,0);  // start internal sensor measurement
	delay_ms(10);
	local_data=ads_read(EXTERNAL_SIGNAL,0); // read internal sensor measurement and start external sensor measurement
	delay_ms(10);
	result=ads_read(EXTERNAL_SIGNAL,0); // read external sensor measurement and restart external sensor measurement
	
	local_comp = local_compensation(local_data);
	result = result + local_comp;
	result=result & 0xffff;
	result = adc_code2temp(result);
	
	//printf("10x temp is %d\n", result);
	result_d=((double)result)/10;
	
	return(result_d);
}
Пример #3
0
double
get_measurement_fast(void)
{
	int result;
	double result_d;
	
	result=ads_read(EXTERNAL_SIGNAL,0); // read external sensor measurement and restart external sensor measurement
	result = result + local_comp;
	result=result & 0xffff;
	result = adc_code2temp(result);
	
	result_d=((double)result)/10;
	
	return(result_d);
}
Пример #4
0
double get_measurement_fast(unsigned int channel,  int* semaphorePtr) {
	int result;
	double result_d;
	
   while (*semaphorePtr != 0) {delay_ms(1);}
   *semaphorePtr = 1;
	result=ads_read(EXTERNAL_SIGNAL,channel); // read external sensor measurement and restart external sensor measurement
   *semaphorePtr = 0;
	result = result + local_comp;
	result=result & 0xffff;
	result = adc_code2temp(result);
	
	result_d=((double)result)/10;
	
	return(result_d);
}