We are running a survey to help us improve the experience for all of our members. If you see the survey appear, please take the time to tell us about your experience if you can.
Hi , I have problems with interfacing DS1820 to LPC2368. i can see only "127" on display. Thnks.
Hi,
I have problems with communicating LPC2368 and DS1820
I connected DS1820 to P2.7 pin of LPC. and 4.7K to Vdd of LPC.
i connected DS1820 's Vdd pin to 5Vdc. Because in datasheet i saw that DS1820's working voltage is between 3.6V - 5V. LPC Vdd is 3.2V
And here is my code :
----------------------------------------------------
#define DQ_SET FIO2SET |= 0x00000080; #define DQ_CLR FIO2CLR |= 0x00000080;
void onewire_reset()
{
FIO2DIR = 0XFFFFFFFF; FIO2MASK = 0xFFFFFF00;
DQ_CLR delay_us(600); DQ_SET delay_us(600); DQ_CLR
}
void command(BYTE data) { int i;
for(i=0; i<8; i++) {
DQ_CLR
delay_us(16);
if (data & 1 << i) DQ_SET
else DQ_CLR
delay_us(240);
DQ_SET
} }
int read_bit() { int bit=1;
FIO2DIR = 0XFFFFFF7F; FIO2MASK = 0xFFFFFF00;
if(!(FIO2PIN & 128)) bit=0;
return bit;
unsigned char read_byte(void) { unsigned char i; unsigned char value = 0;
for (i=0;i<8;i++) { if( read_bit() ) value|= 1 << i; delay_us(240);
} return(value); }
unsigned char Read_Temperature(void) { int lsb=0; int msb=0; int temp=0; float temp_c=0;
onewire_reset();
command(0xCC); command(0x44);
command(0xCC); command(0xBE);
msb = read_byte(); // Read msb
lsb = read_byte();
temp = msb<<8 + lsb;
temp_c = (temp>>5) * 0.125;
sprintf(sicaklik_deger,"T:%2.1f",temp_c);
return(1);
You don't seem to read the presence pulse after the reset.
When reading, you generate a 16us pulse and then read the bit after a further 16us. But shouldn't you read within the first 15us from the start of the read operation?
Have you verified - by sampling the signal continuously after starting a read cycle - that you can see both a zero and a one from the sensor?
Have you used an oscilloscope to verify the signal?
You don't seem to emit any debug output. You should verify what happens long before you get to the conversion to a floating point value. By the way - you don't need floating point for printing the temperature. You can used fixed-point integers instead.
what is maximum frequency you want to use?
Well, that depends of a lot of things:
Which frequency you are using to clock the code? What is the language you will use in the project when you worked? Assembler ?, C ? Basic? Who long is the code inside the interrupt?
Did you post in the wrong thread?
You can't choose the communication frequency for the DS1820. You can choose how long to pause between each bit (infinity is ok as long as the device stays powered), but the bit timing for the communication is dictated by the datasheet. It isn't like I2C where you configure a baudrate, and then clock the data synchronously.
i use c language.
Here are the frequencies :
/* Clock Definitions */ #define Fosc 12000000 /* System frequence,should be less than 80MHz. */ #define Fcclk 57600000 #define Fcco 288000000
i testes several pauses , but at all of them there is no different result.
can DS1820 run at 3.2V ?
See the Datasheet for the answer to this question!
Now it occurs to you to ask yourself that? After you've written all this code based on the vague assumption that the hardware just might work?
I strongly suggest you reconsider your work flow. HW interface issues should be dealt with before you start designing software.