we are facing an issue with one-wire communication by using DS2485

Status
Not open for further replies.

sumitthorat0909

New Member
we are facing an issue with one-wire communication by using DS2485,
We not getting correct data while communicating.

I followed the command sequence as per the datasheet after matching the ROM id by using command 55h .
I do not get any data while trying to read the next block by using the command (66H). I did delay calculation as per the data sheet.
It’s always returning scratchpad data only.
Also refer bellows debug log :
Device: 1 1A00000004959C42: 55 42 9C 95 04 00 00 00 1A
Ttx_buff : AB 0A 07 55 42 9C 95 04 00 00 00 1A//Match ROM
Trx_buff : 0A AA 55 42 9C 95 04 00 00 00 1A FF
Ttx_buff : AB 0B 07 66 FF FF FF FF FF FF FF FF FF//Read scratch Pad
Trx_buff : 0B AA 66 FF FF FF FF FF FF FF FF FF FF
Scratchpad: [66 FF FF FF FF FF FF FF FF FF ]

- tF: -196
Temperature: -196 [F], -127 [C]
Can you suggest what I need to do to resolve this issue .
Code:
code :
if (DS2485_OWNext())
{
if (*romPtr == OW_FAMILY_DS28EA00)
{
#define SP_TEMP_LSB_INDEX (1)
#define SP_TEMP_MSB_INDEX (2)

int tC = 0;
int tF = 0;
int tVal = 0;

// Print device found.
for (i = 7; i >= 0; i--)
{
printf("%02X", *(romPtr + i));
}

printf(": ");

// Device already selected from search
// send the convert command.
if (!OWWriteBytePower_Ds2485(0x44))
{
printf("Fail convert command\n");
return(FALSE);
}

// Delay for 1 second.
msDelay(1000);

// Turn off the 1-Wire Net strong pull-up.
config_reg=0;
// default configuration
m_c1WS = 0;
m_cSPU = 0;
m_cPPM = 0;
m_cAPU = ACONFIG_APU;
config_val[1]=m_c1WS | m_cSPU | m_cPPM | m_cAPU;
// write the default configuration setup
if (!DS2485_write_config(config_reg,config_val))
{
printf("DS2485_write_config() failed.\n");
return(FALSE);
}

// Verify complete.
if (OWReadByte_Ds2485() != 0xFF)
{
printf("ERROR, temperature conversion was not complete\n");
return(FALSE);
}

// Select the device.
sendpacket[0] = 0x55; // Match command.

for (i = 0; i < 8; i++)
{
sendpacket[i+1] = *(romPtr + i);
}
if(DS2485_OWReset())
{
// MATCH ROM sequence.
OWBlock_Ds2485(sendpacket,9);

// Read Scratch pad.
sendlen = 0;
sendpacket[sendlen++] = 0x66;

for (i = 0; i < 9; i++)
{
sendpacket[sendlen++] = 0xFF;
}

OWBlock_Ds2485(sendpacket,sendlen);
//DS2485_Data(romPtr,sendpacket);
tVal = (sendpacket[SP_TEMP_MSB_INDEX] & 0x07) << 8;
tVal += sendpacket[SP_TEMP_LSB_INDEX];
//tVal = ((sendpacket[SP_TEMP_LSB_INDEX] << 8) | sendpacket[SP_TEMP_MSB_INDEX])/65536;
//tVal = -45 + (175 * tVal);
//printf("\nCalculated Temperature: %d C\n", tVal);
/* Celsius.
*****/
tC = tVal;
tC /= 16;

if ((sendpacket[SP_TEMP_MSB_INDEX] & 0xf8))
{
tC *= -1;
}

/* Fahrenheit.
*****/
tF = ((tC * 9) / 5) + 32;
printf(" - Temperature: %i [F], %i [C]\n", tF, tC);
}
else
{
printf("NO RESET\n");
return(FALSE);
}
}
}
OW block code :
int OWBlock_Ds2485(unsigned char* tran_buf, unsigned int tran_len)
{
int status = TRUE;
unsigned char Trx_buff[tran_len+3];
unsigned int TxRx_len=tran_len+1;
int i = 0;
//Timing Parameter as per Ds2485 Datasheet
unsigned int t_w0l=68;
unsigned int t_rec=6;
unsigned int t_rstl=560;
unsigned int t_rsth=560;
unsigned int tOP=40;
unsigned int tSEQ=20;

// delay calculation as per the 1W Block length
unsigned int t_slot = t_w0l + t_rec;
unsigned int ow_rst_time = t_rstl + t_rsth;
unsigned int one_wire_time = ((t_slot * 8) * (tran_len)) + ow_rst_time;
unsigned int delay = tOP + (tSEQ*(tran_len + 1)) + one_wire_time+1000;

Trx_buff[0]=ACMD_1WBRW; // 1W Block Read Write Command
Trx_buff[1]=TxRx_len; // 1W Block length
Trx_buff[2]=0x07; // 1W Block configuration Parameter OW_RST=1,IGNORE=1,SPU=1

#if defined(OW_VERBOSE_DEBUG)
printf("%s(): Enter, tran_len: %i.\n", __func__, tran_len);
#endif
memcpy(&Trx_buff[3], (void *)tran_buf, tran_len);
status = I2cWrite(Trx_buff, sizeof(Trx_buff),DS2485_DEVICE_ADDRESS);
if (status == FALSE)
{
printf("%s: Failed to Write OWBlock", __func__);
}
else
{
udelay(delay);
status = I2cRead(Trx_buff, sizeof(Trx_buff),DS2485_DEVICE_ADDRESS);
if(status)
{
if(Trx_buff[0]== TxRx_len && Trx_buff[1]==0xAA)
{
memcpy(tran_buf,&Trx_buff[2],tran_len);
}
else
{
printf("%s: Failed to Read OWBlock", __func__);
return 0;
}
}
else
{
printf("%s: Failed to I2C Read OWBlock", __func__);
return 0;
}

}
return tran_len;
}
 
Last edited:
Just for future reference, when you post code use the code tags, preserves tabs and indent,
so code more readable.




Regarding signaling you see proper rise/fall times on the buss as well as logic levels ?


Regards, Dana.
 
Does that mean that you are operating this thing at -127DegC ??

The DS2485 datasheet clearly states:
View attachment 137639

If my understanding is correct, you may be running this thing a little bit too cold.

JimB
No Jim I got the wrong value on one wire. value is -127 because there is some calculation to convert data to proper formate . when I try to receive data I got the wrong data and the calculation also goes wrong.
 
You've only posted partial code - where are functions such as

DS2485_OWNext()
OWWriteBytePower_Ds2485()
DS2485_write_config()

etc.
 
Status
Not open for further replies.
Cookies are required to use this site. You must accept them to continue using the site. Learn more…