コード例 #1
0
ファイル: reflowControl.c プロジェクト: junglejim63/pi-reflow
// 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
void ADC_display()
{
	//char data[5];
	//float sensor;

	static signed int local_data, far_data;
	signed int temp;
	flag &= ~ BIT4;					// flag is reset
	if (!(flag & BIT5))
	{
		local_data = ADS_Read(1);	//read local temperature data and start a new
	}								//conversion for far-end temperature sensor.
	else
	{
		far_data = ADS_Read(0);		//read far-end temperature,and start a new conversion
									//for local temperature sensor.

		// transform the local_data to compensation codes of far-end.
		temp = far_data + local_compensation(local_data);

		temp = ADC_code2temp(temp);	// transform the far-end
									// thermocouple codes to temperature.

		if(flag & BIT8)				// display temperature in Fahrenheit
		{
			Act_temp = temp * 9 / 5 +320;
			LCD_display_temp(1,8,Act_temp);
			LCD_display_char(1,14,'F');
		}
		else
		{
			Act_temp = temp;
			LCD_display_temp(1,8,Act_temp);
			LCD_display_char(1,14,'C');
		}

	}
}
コード例 #3
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);
}