Esempio n. 1
0
int main(void)
{
	DDRB |= (1<<PB0);
	PORTB |= (1<<PB0);

	DDRD &= ~(1<<PD6);
	PORTD &= ~(1<<PD6);

	czujniki_cnt = search_sensors();

	DS18X20_start_meas(DS18X20_POWER_EXTERN, NULL);
	_delay_ms(750);
	if(DS18X20_OK == DS18X20_read_meas_single(0x28, &subzero, &cel, &cel_frac_bits)) display_temp();
	else {
		lcd_puts_P("err");
	}

     lcd_clrscr();   /* clear display home cursor */

 for(;;){


 }


}
Esempio n. 2
0
void read_temp() {
	uint8_t gSensorIDs[OW_ROMCODE_SIZE];

	uint16_t decicelsius;
	uint8_t diff, i, subzero, cel, cel_frac_bits;

	OW_set_bus(&PORTC,5);
	//	DS18X20_find_sensor(&diff, &gSensorIDs[0]);


	DS18X20_start_meas( DS18X20_POWER_PARASITE, NULL );
	delayms(DS18B20_TCONV_12BIT);
	DS18X20_read_meas_single(0x10, &subzero, &cel, &cel_frac_bits);
	decicelsius = DS18X20_temp_to_decicel(subzero, cel, cel_frac_bits);

}
Esempio n. 3
0
void Temp_handler(void)
{
      static Temp_ReadState_t state = TEMPERATURE_MEASURE_REQUEST;
      unsigned char counter = 0;

      switch (state) 
      {
   		case TEMPERATURE_MEASURE_REQUEST:
         {
            //		i = gSensorIDs[0]; // family-code for conversion-routine
            DS18X20_start_meas( DS18X20_POWER_EXTERN, NULL );
            counter = 0;
            state  = TEMPERATURE_WAITING_FOR_RESPONSE;
            break;
         }
      
         case TEMPERATURE_WAITING_FOR_RESPONSE:
         {
            counter++;
            if(counter > TEMP_GET_COUNTS_MS(DS18B20_TCONV_12BIT))
            {
               state  = TEMPERATURE_UPDATE;
            }
            break;      
         }
         
         case TEMPERATURE_UPDATE:
         {
            DS18X20_read_meas_single(0x28, &subzero, &cel, &cel_frac_bits);
		      Temp_decicelsius = DS18X20_temp_to_decicel(subzero, cel, cel_frac_bits);
            Temp_decicelsiusAvg = MovingAvg(Temp_decicelsius, 6u);
            state  = TEMPERATURE_MEASURE_REQUEST;
            break;
         }
      }
}