Cześć, mam problem z programem wykorzystującym bibliotekę "rklibavr", a konkretnie chodzi o obsługę DS18B20. Mianowicie wszystko działa ładnie jeśli DS18X20_read_meas_single korzysta z DS18S20 (czujnik mam 18B20) i dopóki temperatura nie przekracza 26C. Potem temperatura mi się zeruje.
Jeśli dam DS18X20_read_meas_single(DS18B20_ID, &subzero, &cel, &cel_frac_bits); to pokazuje nieprawidłową temperaturę zawsze.
Czytałem m.in. ten post ale nie pomaga.
Poniżej załączam kod programu. Jest to prosta modyfikacja standardowego przykładu dołączonego do biblioteki "rklibavr".
Poprawiłem tytuł.
[zumek]
Jeśli dam DS18X20_read_meas_single(DS18B20_ID, &subzero, &cel, &cel_frac_bits); to pokazuje nieprawidłową temperaturę zawsze.
Czytałem m.in. ten post ale nie pomaga.
Poniżej załączam kod programu. Jest to prosta modyfikacja standardowego przykładu dołączonego do biblioteki "rklibavr".
#define F_CPU 2000000L
/* pod którym portem jest szyna danych */
#define HD44780_DATA_GPIO C
/* jaką część portu zajmuje szyna danych:
* true: DB4 = bit 4, DB5 = bit 5, DB6 = bit 6, DB7 = bit 7
* false: DB4 = bit 0, DB5 = bit 1, DB6 = bit 2, DB7 = bit 3
*/
#define HD44780_DATA_HIGHHALFBYTE 0
#define HD44780_RS_GPIO C
#define HD44780_RS_BIT 4
#define HD44780_E1_GPIO C
#define HD44780_E1_BIT 5
#define HD44780_E2_GPIO C
#define HD44780_E2_BIT 6
#define HD44780_WIDTH 16
#define HD44780_HEIGHT 2
#include <avr/io.h>
#include <avr/interrupt.h>
#include <avr/eeprom.h>
#include <string.h>
#include <util/delay.h>
#include "ds18x20.h"
#include <tAvrLib/hd44780.h>
#include <tAvrLib/hd44780-charsets/pl.h>
int main()
{
uint16_t decicelsius;
uint16_t subzero, cel, cel_frac_bits;
const char *p1;
/* inicjacja wyświetlacza */
hd44780_init();
/* powiązanie wyświetlacza ze standardowym wyjściem */
HD44780_BIND_STREAM(stdout);
/* wczytanie polskiej strony kodowej */
hd44780_loadCharSet(hd44780_charset_pl);
hd44780_clear();
p1 = PSTR("test");
hd44780_goto(0, 0);
hd44780_putPStr(p1, 4);
_delay_ms(500);
while(1)
{
DS18X20_start_meas( DS18X20_POWER_PARASITE, NULL );
delayms(DS18B20_TCONV_12BIT);
DS18X20_read_meas_single(DS18B20_ID, &subzero, &cel, &cel_frac_bits);
decicelsius = DS18X20_temp_to_decicel(subzero, cel, cel_frac_bits);
hd44780_goto(0, 0);
hd44780_putInt((decicelsius/100), 10,0);
hd44780_putChar(',');
hd44780_putInt((decicelsius%100), 10,0);
}
}
Poprawiłem tytuł.
[zumek]