 |
 |
| View previous topic :: View next topic |
| Author |
Message |
fiasgardone
Joined: 19 Jan 2010 Posts: 71
|
|
Posted: Sun Jan 24, 2010 3:35 pm |
|
|
Sorry, I did not understand well the datasheet!
I think it is just as is down?
| Code: |
#include <16F877A.h>
#fuses XT,NOWDT,NOPROTECT,PUT,NOLVP,NOBROWNOUT
#use delay(clock=4000000)
#include <flex_lcd.c>
// Tell the driver to use pins D0 and D1 for the i2c bus.
#define DAL_SCL PIN_D0
#define DAL_SDA PIN_D1
#include <DS1631.c>
//=================================
void main()
{
float value;
lcd_init();
delay_ms(100);
init_temp();
while(1)
{
delay_ms(750);
value = read_full_temp();
value /= 100.0;
value=(value-32)/1.8;
lcd_gotoxy(15,2);
printf(lcd_putc,"temp.%04.1f", value);
}
}
|
|
|
 |
PCM programmer
Joined: 06 Sep 2003 Posts: 21708
|
|
Posted: Sun Jan 24, 2010 3:38 pm |
|
|
| Did that improve the results ? |
|
 |
fiasgardone
Joined: 19 Jan 2010 Posts: 71
|
|
Posted: Sun Jan 24, 2010 4:22 pm |
|
|
| PCM programmer wrote: | | Did that improve the results ? |
Now is still 1.5 ° C above the other thermometer!
What will be the error?
Tentative conversion error? |
|
 |
PCM programmer
Joined: 06 Sep 2003 Posts: 21708
|
|
Posted: Sun Jan 24, 2010 5:10 pm |
|
|
Call this routine instead of calling read_full_temp().
It reads in degrees C. See if this gives a better result.
| Code: |
float read_temp_c(void)
{
int8 lsb, msb;
float temp_c;
i2c_start();
i2c_write(0x90);
i2c_write(0xaa);
i2c_start();
i2c_write(0x91);
msb=i2c_read();
lsb=i2c_read(0);
i2c_stop();
if(msb >= 0x80)
temp_c = ((float)(make16(msb, lsb))/256.0) - 256.0;
else
temp_c = (float)(make16(msb, lsb))/256.0;
return(temp_c);
}
|
Change your while(1) loop so it displays the floating point result
directly, without doing any math operations on it. Example:
| Code: |
while(1)
{
delay_ms(750);
value = read_temp_c();
lcd_gotoxy(15,2);
printf(lcd_putc,"temp.%04.1f ", value);
}
|
Also, I notice that you're not clearing the LCD each time.
Make sure you over-write the old number completely,
so that you only see the digits for the new number. |
|
 |
fiasgardone
Joined: 19 Jan 2010 Posts: 71
|
|
Posted: Sun Jan 24, 2010 6:11 pm |
|
|
HI..PCM Imade the changes but still does not work out, the resiltado is 1.5 ° C difference!
What will be the error? I think that should not have that much difference in a sensor to another? |
|
 |
PCM programmer
Joined: 06 Sep 2003 Posts: 21708
|
|
Posted: Sun Jan 24, 2010 6:15 pm |
|
|
| How do you know your thermometer is correct ? |
|
 |
fiasgardone
Joined: 19 Jan 2010 Posts: 71
|
|
Posted: Sun Jan 24, 2010 6:33 pm |
|
|
| PCM programmer wrote: | | How do you know your thermometer is correct ? |
The thermometer with which I compare the DS1631 sensor?
I bought the new, I think to be right! |
|
 |
PCM programmer
Joined: 06 Sep 2003 Posts: 21708
|
|
Posted: Sun Jan 24, 2010 8:17 pm |
|
|
I don't think I can do much on this. Make sure the Vdd voltage for the
ds1631 is +5v, from a regulated power supply. Make sure you have a
100 nF ceramic capacitor connected between the Vdd Vdd pin and ground.
My advice is to get a 2nd ds1631 chip. See if you get the same result. |
|
 |
fiasgardone
Joined: 19 Jan 2010 Posts: 71
|
|
Posted: Mon Jan 25, 2010 4:16 am |
|
|
| PCM programmer wrote: |
My advice is to get a 2nd ds1631 chip. See if you get the same result. |
Hi...I checked all my power supply has at 4.96V output through the voltage regulator uA7805c, also have the 100 nF capacitor.
I changed the DS1631, but the results are the same! |
|
 |
fiasgardone
Joined: 19 Jan 2010 Posts: 71
|
|
Posted: Tue Jan 26, 2010 4:07 pm |
|
|
Hi...After we managed to run the two separate DS1307 and DS1631, it's time to add them to communicate on the same bus line, and it worked well, but has a problem that shows the temperature flash on the LCD, and seconds of the clock so show 2 in 2 seconds on the LCD! but the clock works well, shows a 2 in 2 seconds because the temperature is always blinking.
I checked everything but could not resolve, once again need your help!
Here is the code to see where this is not good!
| Code: |
#include <16F877A.h>
#fuses XT,NOWDT,NOPROTECT,PUT,NOLVP,NOBROWNOUT
#use delay(clock=4000000)
#include <flex_lcd.c>
// Tell the driver to use pins D0 and D1 for the i2c bus.
#define DAL_SCL PIN_D0
#define DAL_SDA PIN_D1
#include <DS1631.c>
#include <RTC_DS1307.c>
//=================================
void main()
{
BYTE sec;
BYTE min;
BYTE hrs;
BYTE day;
BYTE month;
BYTE yr;
BYTE dow;
float value;
lcd_init();
delay_ms(100);
init_temp();
ds1307_init();
// Set date for -> 15 June 2005 Tuesday
// Set time for -> 15:20:55
ds1307_set_date_time(15,6,5,2,15,20,55);
while(1)
{
delay_ms(1000);
ds1307_get_date(day,month,yr,dow);
ds1307_get_time(hrs,min,sec);
lcd_gotoxy(1,1);
printf(lcd_Putc,"\f \%02d/\%02d/\%02d",day,month,yr);
lcd_gotoxy(1,2);
printf(lcd_Putc," %02d:\%02d:\%02d", hrs,min,sec);
delay_ms(750);
value = read_temp_c();
lcd_gotoxy(15,2);
printf(lcd_putc,"temp.%04.1f ", value);
}
}
|
|
|
 |
PCM programmer
Joined: 06 Sep 2003 Posts: 21708
|
|
Posted: Tue Jan 26, 2010 4:19 pm |
|
|
| How big is your LCD ? How many rows, and how many columns ? |
|
 |
fiasgardone
Joined: 19 Jan 2010 Posts: 71
|
|
Posted: Tue Jan 26, 2010 4:42 pm |
|
|
| PCM programmer wrote: | | How big is your LCD ? How many rows, and how many columns ? |
Hi..PCM, My LCD has 2 rows of 40 columns!! |
|
 |
PCM programmer
Joined: 06 Sep 2003 Posts: 21708
|
|
Posted: Tue Jan 26, 2010 5:04 pm |
|
|
| Quote: |
but has a problem that shows the temperature flash on the LCD, and
seconds of the clock so show 2 in 2 seconds on the LCD! but the clock
works well, shows a 2 in 2 seconds because the temperature is always
blinking. |
Can you explain what this means ? I don't understand this "2 in 2 seconds" stuff. |
|
 |
fiasgardone
Joined: 19 Jan 2010 Posts: 71
|
|
Posted: Tue Jan 26, 2010 5:24 pm |
|
|
| PCM programmer wrote: | | Quote: |
but has a problem that shows the temperature flash on the LCD, and
seconds of the clock so show 2 in 2 seconds on the LCD! but the clock
works well, shows a 2 in 2 seconds because the temperature is always
blinking. |
Can you explain what this means ? I don't understand this "2 in 2 seconds" stuff. |
OK...The LCD shows the following for example;
15/06/05
15:20:00
temp.22.6 <-here always shows flashes
15/06/05
15:20:02
temp.22.6 <-here always shows flashes
15/06/05
15:20:04
So always followed |
|
 |
PCM programmer
Joined: 06 Sep 2003 Posts: 21708
|
|
Posted: Tue Jan 26, 2010 5:31 pm |
|
|
| Quote: |
while(1)
{
delay_ms(1000);
ds1307_get_date(day,month,yr,dow);
ds1307_get_time(hrs,min,sec);
lcd_gotoxy(1,1);
printf(lcd_Putc,"\f \%02d/\%02d/\%02d",day,month,yr);
lcd_gotoxy(1,2);
printf(lcd_Putc," %02d:\%02d:\%02d", hrs,min,sec);
delay_ms(750);
value = read_temp_c();
lcd_gotoxy(15,2);
printf(lcd_putc,"temp.%04.1f ", value);
} |
The printf() statement for the "day,month,yr" has a "\f" in it.
This will clear the entire 40x2 screen, and is the cause of the "flash"
in the temperature digits. |
|
 |
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
Powered by phpBB © 2001, 2005 phpBB Group
|