Reply by madid87 August 23, 20062006-08-23
Here was the problem.

int init_ds1820(void)
{
IODIR0=0x01; // P0.0 out
IOCLR0=0x01; // Low level
delayus(500);
IODIR0=0x00; // Free line
delayus(100);
if(!(IOPIN0 & 1))
return 1; !!!!! BUG !!!!
delayus(500);
return 0;
}

Notice that there is no 500us delay is sensor transmits precense pulse :)
Correct -->

if(!(IOPIN0 & 1))
{
delayus(500);
return 1;
}

Thanks all !

An Engineer's Guide to the LPC2100 Series

Reply by Robert Adsett August 19, 20062006-08-19
At 02:21 PM 8/18/2006 -0400, subscript,,, wrote:
>You'll need more that that. One-wire requires that the slave can pull the
>line down (there are other requirements relating to drive currents etc..)
>so yo cannot drive it high during the off periods. There are a number of
>circuits lying around. If I get a chance this weekend I'll try to post the
>one I've been using.

I[ve looked up the circuit I've used and I'll quote the message I sent to
the list in June

>I just did a quick and dirty app note showing such a circuit
>http://www.aeolusdevelopment.com/AppNotes/one-wireapp.pdf
>
>It takes 3 pins but that does include an optional strong pull-up. It's
>the same circuit the one-wire library port I did uses, the driving
>routines are on the same site.
>
>I really do mean quick and dirty, it's missing component and value
>information. I'll try to pretty it up and comment it properly. Google
>around there are a number of circuits out there.

I've not had the time to fill it out yet but it's a start.

Robert

http://www.aeolusdevelopment.com/

From the Divided by a Common Language File (Edited to protect the guilty)
ME - "I'd like to get Price and delivery for connector Part # XXXXX"
Dist./Rep - "$X.XX Lead time 37 days"
ME - "Anything we can do about lead time? 37 days seems a bit high."
Dist./Rep - "that is the lead time given because our stock is live.... we
currently have stock."
Reply by Richard August 19, 20062006-08-19
I am using the DS1820 with an AVR micro (gasp). It is on a GPIO pin
which I can set to high impedance.

Make sure you disable interrupts during communications or you will
hose your timeslots.

Rich

--- In l..., "subscriptions@..."
wrote:
>
> You do realise you need some additional circuitry? You cannot
hook-up the
> one-wire directly to an I/O pin.
>
> There is some ported Dallas code at http://www.aeolusdevelopment.com
>
> Robert
> Original Message:
> -----------------
> From: madid87 madid87@...
> Date: Fri, 18 Aug 2006 17:07:58 -0000
> To: l...
> Subject: [lpc2000] 1-wire protocol functions -Dont work, why ?
> I have two 1-wire devices. Both termo sensors. DS1820 and DS18B20.
> They will be used in LPC2129 projects.
>
> But for some reason something is wrong with my function to
communicate with
> 1-wire devices. I'm trying to fix them for 2 days now and nothing so
far :(
>
> So if someone have some experiance with 1-wire protocol please take
a peak
> at my C functions. For communication I use P0.0 (do I have to use a
open
> drain pin??). Thank you very much !
>
> int init_ds1820(void)
> {
> IODIR0=0x01; // P0.0 out
> IOCLR0=0x01; // Low level
> delayus(500);
> IODIR0=0x00; // Free line
> delayus(100);
> if(!(IOPIN0 & 1))
> return 1;
> delayus(500);
> return 0;
> }
>
> void write_0()
> {
> IODIR0=0x01; // P0.0 out
> IOCLR0=0x01; // Low level
> delayus(1);
> IODIR0=0x01; // Free line
> delayus(60);
> }
>
> void write_1()
> {
> IODIR0=0x01; // P0.0 out
> IOCLR0=0x01; // Low level
> delayus(1);
> IODIR0=0x01; // Free line
> delayus(60); // Wait till the end of time slot
> }
>
> void command(int data)
> {
> int i;
> for(i=0; i<8; i++)
> {
> if(data & 1)
> write_1();
> else
> write_0();
> dataa>>1;
> }
> }
>
> int read_bit()
> {
> int bit=1;
> IODIR0=0x01; // P0.0 out
> IOCLR0=0x01; // Low level
> delayus(1);
> IODIR0=0x01; // Free line
> delayus(5); // Wait some time
> if(!(IOPIN0 & 1))
> bit=0;
> delayus(60);
> return bit;
> }
>
> int read_owi(int bits)
> {
> int i,data=0;
> for(i=0; i > {
> if(read_bit())
> dataa | 1<<(bits-1);
> dataa>>1;
> }
> return data;
> }
>
>
>
Reply by "sub...@aeolusdevelopment.com" August 18, 20062006-08-18
You'll need more that that. One-wire requires that the slave can pull the
line down (there are other requirements relating to drive currents etc..)
so yo cannot drive it high during the off periods. There are a number of
circuits lying around. If I get a chance this weekend I'll try to post the
one I've been using.

Robert

Original Message:
-----------------
From: madid87
Date: Fri, 18 Aug 2006 18:07:47 -0000
To: l...
Subject: [lpc2000] Re: 1-wire protocol functions -Dont work, why ?
--- In l..., "subscriptions@..."
wrote:
> You do realise you need some additional circuitry? You cannot hook-up
the
> one-wire directly to an I/O pin.
> There is some ported Dallas code at http://www.aeolusdevelopment.com

I know. 4.7k pull up is on the line!
It doesn't work :(

--------------------------------
mail2web - Check your email from the web at
http://mail2web.com/ .
Reply by David Hawkins August 18, 20062006-08-18
madid87 wrote:
> --- In l..., David Hawkins wrote:
>> There is no difference between your write-0 and write-1 code :)
>
> Here copy-paste bug here on forum :)
>
> Correct functions
>
> void write_0()
> {
> IODIR0=0x01; // P0.0 izlazni
> IOCLR0=0x01; // Niska razina
> delayus(60);
> IODIR0=0x00; // Otpusti liniju
> }

You'll probably still need a delay after, eg.

void write_0()
{
IODIR0=0x01; // P0.0 izlazni
IOCLR0=0x01; // Niska razina
delayus(60);
IODIR0=0x00; // Otpusti liniju
delayus(1);
}

otherwise back-to-back calls to write_0() will probably not
deassert the bus (since the RC time of the bus is probably
longer than the back-to-back calls).

Try that.

Also try looking on the bus with a scope :)

Dave
Reply by madid87 August 18, 20062006-08-18
--- In l..., David Hawkins wrote:
> There is no difference between your write-0 and write-1 code :)

Here copy-paste bug here on forum :)

Correct functions

void write_0()
{
IODIR0=0x01; // P0.0 izlazni
IOCLR0=0x01; // Niska razina
delayus(60);
IODIR0=0x00; // Otpusti liniju
}

void write_1()
{
IODIR0=0x01; // P0.0 izlazni
IOCLR0=0x01; // Niska razina
delayus(1);
IODIR0=0x00; // Otpusti liniju
delayus(60); // Do kraja write slota
}
Reply by madid87 August 18, 20062006-08-18
--- In l..., David Hawkins wrote:

> There is no difference between your write-0 and write-1 code :)
> To write zero you need to delay for 60us *while* holding the
> bus low.
> http://www.ovro.caltech.edu/~dwh/correlator/pdf/sys_hdl.pdf
> p88 has some scope traces
> Dave
This is a copy paste bug here on forums :)
Correct function is this.
Simply, it doesn't work !

void write_0()
{
IODIR0=0x01; // P0.0 izlazni
IOCLR0=0x01; // Niska razina
delayus(60);
IODIR0=0x01; // Otpusti liniju
}
Reply by madid87 August 18, 20062006-08-18
--- In l..., "subscriptions@..."
wrote:
> You do realise you need some additional circuitry? You cannot hook-up
the
> one-wire directly to an I/O pin.
> There is some ported Dallas code at http://www.aeolusdevelopment.com

I know. 4.7k pull up is on the line!
It doesn't work :(
Reply by "sub...@aeolusdevelopment.com" August 18, 20062006-08-18
You do realise you need some additional circuitry? You cannot hook-up the
one-wire directly to an I/O pin.

There is some ported Dallas code at http://www.aeolusdevelopment.com

Robert
Original Message:
-----------------
From: madid87 m...@yahoo.com
Date: Fri, 18 Aug 2006 17:07:58 -0000
To: l...
Subject: [lpc2000] 1-wire protocol functions -Dont work, why ?
I have two 1-wire devices. Both termo sensors. DS1820 and DS18B20.
They will be used in LPC2129 projects.

But for some reason something is wrong with my function to communicate with
1-wire devices. I'm trying to fix them for 2 days now and nothing so far :(

So if someone have some experiance with 1-wire protocol please take a peak
at my C functions. For communication I use P0.0 (do I have to use a open
drain pin??). Thank you very much !

int init_ds1820(void)
{
IODIR0=0x01; // P0.0 out
IOCLR0=0x01; // Low level
delayus(500);
IODIR0=0x00; // Free line
delayus(100);
if(!(IOPIN0 & 1))
return 1;
delayus(500);
return 0;
}

void write_0()
{
IODIR0=0x01; // P0.0 out
IOCLR0=0x01; // Low level
delayus(1);
IODIR0=0x01; // Free line
delayus(60);
}

void write_1()
{
IODIR0=0x01; // P0.0 out
IOCLR0=0x01; // Low level
delayus(1);
IODIR0=0x01; // Free line
delayus(60); // Wait till the end of time slot
}

void command(int data)
{
int i;
for(i=0; i<8; i++)
{
if(data & 1)
write_1();
else
write_0();
dataa>>1;
}
}

int read_bit()
{
int bit=1;
IODIR0=0x01; // P0.0 out
IOCLR0=0x01; // Low level
delayus(1);
IODIR0=0x01; // Free line
delayus(5); // Wait some time
if(!(IOPIN0 & 1))
bit=0;
delayus(60);
return bit;
}

int read_owi(int bits)
{
int i,data=0;
for(i=0; i {
if(read_bit())
dataa | 1<<(bits-1);
dataa>>1;
}
return data;
}
Reply by David Hawkins August 18, 20062006-08-18
> For communication I use P0.0 (do I have to use a open
> drain pin??). Thank you very much !

Yes you do, since either the master or the slave drives
the bus low.

Note that for EEPROM and temperature devices, you can
drive the bus high while its performing a conversion
to provide it with additional current.

Dave