Exemplo n.º 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);
}
Exemplo n.º 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);
}