Searching \ for '[PIC] 1 wire parasite mode' in subject line. ()
Make payments with PayPal - it's fast, free and secure! Help us get a faster server
FAQ page: massmind.org/techref/microchip/devices.htm?key=pic
Search entire site for: '1 wire parasite mode'.

Exact match. Not showing close matches.
PICList Thread
'[PIC] 1 wire parasite mode'
2011\03\02@042552 by Manu Abraham

picon face
Hi,

I have been trying to use a DS1820 in conjunction with an 18F452.

- I am using the parasite mode of power for the DS1820
(DQ pin connected for Data; VDD connected to GND)
- The DS1820 manual states that:

"In some situations the bus master may not know whether the DS18B20's
on the bus are parasite powered or powered by external supplies. The
master needs this information to determine if the strong bus pullup
should be used during temperature conversions."

Now, I have the DS1820 pin pulled up to VDD (+5V) using a 4.7k
resistor and connected to RA0 of the 18F452.

My question is:
How can I pullup RA0 while TRISA is configured as HiZ mode (input,
TRISA.0 = 1) ? That line from the datasheet has added a bit of
confusion to my mind.

Any ideas ?

Thanks,
Man

2011\03\02@064642 by Matt Callow

flavicon
face
On 2 March 2011 20:25, Manu Abraham <spam_OUTabraham.manuTakeThisOuTspamgmail.com> wrote:
{Quote hidden}

Hi,

If you really want to keep RA0 as an input, then you need to use a
separate output pin on the PIC to drive a FET (or similar) to provide
the strong pullup.
But it's much easier to switch RA0 to an output to provide the strong
pullup when required.
I've done this in the past and it works fine, as long as you apply the
strong pullup within the time limits specified in the data sheet.
The method for determining if parasite power is required is also in
the data sheet. I haven't implemented this in my application as I know
what sensors I have on the 1-wire bus, and I know that they need
parasite power. Therefore no need to check.


Mat

2011\03\02@080446 by Olin Lathrop

face picon face
Manu Abraham wrote:
> My question is:
> How can I pullup RA0 while TRISA is configured as HiZ mode (input,
> TRISA.0 = 1) ?

With a pullup resistor.  Resistor goes between RA0 and Vdd.


********************************************************************
Embed Inc, Littleton Massachusetts, http://www.embedinc.com/products
(978) 742-9014.  Gold level PIC consultants since 2000

2011\03\02@080509 by Manu Abraham

picon face
On Wed, Mar 2, 2011 at 5:16 PM, Matt Callow <.....mc-listsKILLspamspam@spam@tesco.net> wrote:
{Quote hidden}

Yeah, sounds similar to what I am doing:

- I have just 1 sensor and I know that it is parasite powered, hence
no need to check the type of power supply mode.
- I am toggling RA.0 as input and output, rather than having a fixed
RA.0 as input

But my question is:

- When RA.0 is input, how will the 1 wire slave be powered ? (ie
according to the DS1820 datasheet, how to enable a strong pullup)

I will simplify my question a bit more:

- send Master Tx Command 0x44
- I know it is Parasite powered
- The master needs to enable Strong pullup on DQ
- 1820 does conversion
- The master disables Strong pullup


Strong pullup would imply TRISA.0 = 1 ? I see that PORTB can use weak
pullups, but can't see how the same can be achieved with PORTA ?

Best Regards,
Man

2011\03\02@081216 by Olin Lathrop

face picon face
Manu Abraham wrote:
> Strong pullup would imply TRISA.0 = 1 ?

No, that means the PIC is letting the line completely float.  If you want a
strong pullup, you have to add one externally to the PIC.

> I see that PORTB can use weak
> pullups, but can't see how the same can be achieved with PORTA ?

On most PICs you can't.  Most likely the pullups built into the PIC wouldn't
be able to guarantee the relatively narrow current range required for
one-wire devices in parasitic power mode.


********************************************************************
Embed Inc, Littleton Massachusetts, http://www.embedinc.com/products
(978) 742-9014.  Gold level PIC consultants since 2000

2011\03\02@081432 by Manu Abraham

picon face
On Wed, Mar 2, 2011 at 6:35 PM, Olin Lathrop <.....olin_piclistKILLspamspam.....embedinc.com> wrote:
> Manu Abraham wrote:
>> My question is:
>> How can I pullup RA0 while TRISA is configured as HiZ mode (input,
>> TRISA.0 = 1) ?
>
> With a pullup resistor.  Resistor goes between RA0 and Vdd.


Yeah, that's what I wondered. I already do have a 4k7 resistor from DQ
to Vdd as described in the DS1820 datasheet. But the whole confusion
that dawned upon me is from the flow chart where it mentions "Master
Enables Strong pullup". Since it is already pulled up by a resistor,
why mention that it in a software flowchart ?

Best Regards,
Manu

2011\03\02@083412 by Olin Lathrop

face picon face
Manu Abraham wrote:
> On Wed, Mar 2, 2011 at 6:35 PM, Olin Lathrop
> <EraseMEolin_piclistspam_OUTspamTakeThisOuTembedinc.com> wrote:
>> Manu Abraham wrote:
>>> My question is:
>>> How can I pullup RA0 while TRISA is configured as HiZ mode (input,
>>> TRISA.0 = 1) ?
>>
>> With a pullup resistor. Resistor goes between RA0 and Vdd.
>
>
> Yeah, that's what I wondered. I already do have a 4k7 resistor from DQ
> to Vdd as described in the DS1820 datasheet. But the whole confusion
> that dawned upon me is from the flow chart where it mentions "Master
> Enables Strong pullup". Since it is already pulled up by a resistor,
> why mention that it in a software flowchart ?

Argh!  I just sent you a reply and now see that I replied to a CC you sent
me and it therefore didn't go to the list.  There is nothing in it for me to
send you a personal reply.

STOP SENDING ME PRIVATE MESSAGES.


********************************************************************
Embed Inc, Littleton Massachusetts, http://www.embedinc.com/products
(978) 742-9014.  Gold level PIC consultants since 2000

2011\03\02@084044 by Manu Abraham

picon face
On Wed, Mar 2, 2011 at 7:04 PM, Olin Lathrop <olin_piclistspamspam_OUTembedinc.com> wrote:
{Quote hidden}

I am not sending you private messages. I always do a Reply-All

2011\03\02@084347 by Manu Abraham

picon face
On Wed, Mar 2, 2011 at 7:09 PM, Manu Abraham <KILLspamabraham.manuKILLspamspamgmail.com> wrote:
> On Wed, Mar 2, 2011 at 7:01 PM, Olin Lathrop <RemoveMEolin_piclistTakeThisOuTspamembedinc.com> wrote:
>> Manu Abraham wrote:
>>> But the whole confusion
>>> that dawned upon me is from the flow chart where it mentions "Master
>>> Enables Strong pullup". Since it is already pulled up by a resistor,
>>> why mention that it in a software flowchart ?
>>
>> I haven't read that data sheet,



http://pdfserv.maxim-ic.com/en/ds/DS18B20.pdf

hardware connected to RA.0 as in Fig:4, Page 6/22


>  but if they talk about the pullup being
>> "enabled", it implies that sometimes it needs to be disabled too.  That
>> means you can't just put a fixed resistor between the line and Vdd.  It has
>> to be switched somehow.  The easiest way would be to put the external pullup
>> resistor between the data line and another PIC pin.  If it's 4.7 KOhms, then
>> a PIC pin will have no problem driving it.
>


OK, so that would imply that if I float RA.0 that would be as good as
"Master enables strong pullup" ?

2011\03\02@084928 by Olin Lathrop

face picon face
Manu Abraham wrote:
>> STOP SENDING ME PRIVATE MESSAGES.
>
> I am not sending you private messages.

You are, including a copy of this message too:

From: "Manu Abraham" <spamBeGoneabraham.manuspamBeGonespamgmail.com>
To: "Microcontroller discussion list - Public." <TakeThisOuTpiclistEraseMEspamspam_OUTMIT.EDU>
Cc: Olin Lathrop <RemoveMEolin_piclistspamTakeThisOuTembedinc.com>

> I always do a Reply-All

So don't do that then.  There is no reason to reply-all to the list, and
good reason not to.

2011\03\02@090015 by Manu Abraham

picon face
On Wed, Mar 2, 2011 at 7:19 PM, Olin Lathrop <olin_piclistEraseMEspam.....embedinc.com> wrote:
> Manu Abraham wrote:
>>> STOP SENDING ME PRIVATE MESSAGES.
>>
>> I am not sending you private messages.
>
> You are, including a copy of this message too:
>
> From: "Manu Abraham" <EraseMEabraham.manuspamgmail.com>
> To: "Microcontroller discussion list - Public." <RemoveMEpiclistEraseMEspamEraseMEMIT.EDU>
> Cc: Olin Lathrop <RemoveMEolin_piclistspam_OUTspamKILLspamembedinc.com>
>
>> I always do a Reply-All
>
> So don't do that then.  There is no reason to reply-all to the list, and
> good reason not to.


It would be better then, if the ML would then set a Reply-to field
rather than letting the user figure it out. Generally most ML's where
I am involved with explicitly state that a Reply-All is the option. It
is very hard to keep a track ML, individual preferences.

I guess, the preference of the ML is a Reply-All, hence it's default behaviour.

2011\03\02@091441 by Jan-Erik Soderholm

face picon face


Manu Abraham wrote 2011-03-02 15:00:
{Quote hidden}

You don't have to figure anything out.

Just hit "Reply" (non-all!) and the reply should go directly
back to the list-server, just as everyone want.

If you hit "Reply", what does the "To:" field say in your mail tool ?

Note that your last post was still sent with CC to Olin's
private address. Don't do that. Simple as that. The main address
was the list server, and that is what you should get with a
simple "Reply" also.

Noone have ever had any trouble with this over the close
to 10 years I've been on the list.

2011\03\02@093640 by Manu Abraham

picon face
On Wed, Mar 2, 2011 at 7:44 PM, Jan-Erik Soderholm
<spamBeGonejan-erik.soderholmSTOPspamspamEraseMEtelia.com> wrote:
{Quote hidden}

That does indeed work.


> Note that your last post was still sent with CC to Olin's
> private address. Don't do that. Simple as that. The main address
> was the list server, and that is what you should get with a
> simple "Reply" also.


In fact what I did, A "Reply-All", (this caused Olin to be in CC). Now
Olin did a "Reply", which caused him to send me a private mail as
opposed to the other way around.


> Noone have ever had any trouble with this over the close
> to 10 years I've been on the list.


A lot too many years on a few dozen ML's forces some habits down the
road. The Reply-all happened to be one of them. I apologize if that
got somebody into trouble. Maybe it is good to have such preferences
mentioned someplace.


Best Regards,
Manu

2011\03\02@095108 by Jan-Erik Soderholm

face picon face
Manu Abraham wrote 2011-03-02 15:36:
> On Wed, Mar 2, 2011 at 7:44 PM, Jan-Erik Soderholm
> <.....jan-erik.soderholmspam_OUTspamtelia.com>  wrote:
>>
>> If you hit "Reply", what does the "To:" field say in your mail tool ?
>
>
> That does indeed work.

OK, so in other words, you never checked that, right ? :-)

I've been on many mail-lists and never had a list where
"Reply" didn't work. That would, IMHO, be a brooken list
server software. The list server should behave as a
single-point-of-contact where you get mails and reply
back using a simple "Reply".



> Maybe it is good to have such preferences
> mentioned someplace.

The piclist works in a standard/normal/expected way, no reason
to document that specificaly. :-)

2011\03\02@101234 by nextime

flavicon
face
part 1 1324 bytes content-type:text/plain; charset="us-ascii" (decoded quoted-printable)

On Wed, Mar 02, 2011 at 03:51:08PM +0100, Jan-Erik Soderholm wrote:
> > I've been on many mail-lists and never had a list where
> "Reply" didn't work. That would, IMHO, be a brooken list
> server software. The list server should behave as a
> single-point-of-contact where you get mails and reply
> back using a simple "Reply".
>

For the love of the thruth, the right thing should
be the "reply to list" implemented by using the List-Post header,
and the Reply should go to the original sender of the post you are replying..

Anyway, for the common mistake to press "reply", it is now usual to have
the list manager configured to override the "Reply-To" header with the list post address.

--
Franco (nextime) Lanza
Busto Arsizio - Italy
SIP://TakeThisOuTcasa.....spamTakeThisOuTcasa.nexlab.it

NO TCPA: http://www.no1984.org
you can download my public key at:
http://danex.nexlab.it/nextime.asc || Key Servers
Key ID = D6132D50
Key fingerprint = 66ED 5211 9D59 DA53 1DF7  4189 DFED F580 D613 2D50
-----------------------------------
echo 16i[q]sa[ln0=aln100%Pln100/snlbx]sbA0D212153574F444E49572045535520454D20454B414D204F54204847554F4E452059415020544F4E4E4143205345544147204C4C4942snlbxq | dc
-----------------------------------



part 2 181 bytes content-type:text/plain; name="ATT00001.txt"
(decoded base64)

--
http://www.piclist.com PIC/SX FAQ & list archive
View/change your membership options at
mailman.mit.edu/mailman/listinfo/piclist

2011\03\02@105415 by Bob Axtell

face picon face
On 3/2/2011 6:05 AM, Manu Abraham wrote:
{Quote hidden}

I  see now.

You must drive enough current into the DS1820 to power it while it calculates. Do thjs by
setting the TRIS pin to 0 (drive) then set the PORT pin to HI (5V). Keep the pin at 5V for al least the stated
time required by the DS1820 (add a few mS for safety)..

I have done this exact thing for several years without the slightest problem. The DS1820 is s fine part.

--Bob

2011\03\02@110831 by Manu Abraham

picon face
On Wed, Mar 2, 2011 at 9:24 PM, Bob Axtell <RemoveMEengineerspamspamBeGonecotse.net> wrote:
{Quote hidden}

Right. But another tangential thought that arises: the strong pullup
is required due to the controller's additional current draw for
computations ?

> I have done this exact thing for several years without the slightest
> problem. The DS1820 is s fine part.
>

Thanks, that does clear it up.

Best Regards,
Manu

2011\03\02@112547 by Manu Abraham

picon face
On Wed, Mar 2, 2011 at 8:21 PM, Jan-Erik Soderholm
<jan-erik.soderholmEraseMEspamtelia.com> wrote:
> Manu Abraham wrote 2011-03-02 15:36:
>> On Wed, Mar 2, 2011 at 7:44 PM, Jan-Erik Soderholm
>> <RemoveMEjan-erik.soderholmEraseMEspamspam_OUTtelia.com>  wrote:
>>>
>>> If you hit "Reply", what does the "To:" field say in your mail tool ?
>>
>>
>> That does indeed work.
>
> OK, so in other words, you never checked that, right ? :-)


It's not the question, that I have checked or not, imagine that have
had the habit of taking your morning coffee for many years, that habit
will just stick, whatever you do. Even if you try to stop it, it will
simply come over automatically, as though like a reflex action.


> I've been on many mail-lists and never had a list where
> "Reply" didn't work. That would, IMHO, be a brooken list
> server software. The list server should behave as a
> single-point-of-contact where you get mails and reply
> back using a simple "Reply".


Generally what I see and understood, also accepted by a very large
community globally (Linux) where I hail from;

- On ML's, where the ML volume is quite high ~ 50 - 500 posts, people
do even request that they be CC'd, such that they can reply to the
posts that is relevant to them. For example on some Open source ML's,
appropriate people are expected to CC'd. Lack of doing so, they might
not even know such a post existed. Some people even do consider that a
lack of CC to them on certain areas, such as patches to certain
drivers etc, is simply not courtesy.

- On lists where the volume is quite low, it does indeed make sense to
Reply to the ML server alone, since these posts are archived and
easily searchable over a period of time.


Just as a simple example: If someone posts patches and/or require help
with regards to drivers that I have written with regards to a certain
OS, the poster could possibly expect a faster reply, IFF he has CC'd
myself. If not, I will check the ML posts in the regular spree that I
am on, as opposed to a faster response with a CC.


>  > Maybe it is good to have such preferences
>> mentioned someplace.
>
> The piclist works in a standard/normal/expected way, no reason
> to document that specificaly. :-)


Again, there is confusion by stating "standard/normal/expected" way,
though I very well by now understand that your preference is as well a
simple "Reply".

2011\03\02@163505 by Barry Gershenfeld
picon face
<metadiscussion subj="ML">
James Newton would counsel to remind us that this issue can never be solved
to everyone's satisfaction (not with the current tools and protocol).  So it
just wastes time, and annoys the PIC.  When tempted to contribute, please
consider just avoiding it.

In the duration, my eyes glazed and fell out so I apologize if the following
information has already been supplied.
</meta>

<realdiscussion>
When Maxim tells you that "The master needs to enable Strong pullup on DQ",
they don't know what your processor or your design is capable of.  So, using
an external pull up resistor as described just takes the place of a strong
internal pullup, or a current source switched by an I/O pin, or whatever
else might accomplish that.
</real

2011\03\02@173326 by Adam Field

flavicon
face
> No, in this case strong pullup implies TRISA.0=0 AND LATC.0=1 (i.e put
> the port in output mode and drive it high)
>

Yes, "strong" pull-up as in PIC's output FET R-on driving RA0. I would
set PORTAbits.RA0 to 1 before setting TRISAbits.RA0 to 0, otherwise
you would probably see a momentary glitch on RA0 and that would upset
your DS1820

2011\03\02@173535 by Adam Field

flavicon
face
> Yes, "strong" pull-up as in PIC's output FET R-on driving RA0. I would
> set PORTAbits.RA0 to 1 before setting TRISAbits.RA0 to 0, otherwise
> you would probably see a momentary glitch on RA0 and that would upset
> your DS1820.
>

To correct myself, on an 18F part, use LATA (the latch), to change the
output state, not PORTA, and then set TRISA

2011\03\02@175734 by Olin Lathrop

face picon face
Adam Field wrote:
>> No, in this case strong pullup implies TRISA.0=0 AND LATC.0=1 (i.e
>> put the port in output mode and drive it high)
>
> Yes, "strong" pull-up as in PIC's output FET R-on driving RA0.

No.  That's not a pullup but rather explicitly driving the line high.  I
haven't looked at the DSxxxx datasheet, but from what was said here earlier
it needs a "strong" pullup when in parasitic power mode.  This is so that it
can derive power from the line to operate when it is high.  But the "pullup"
part also implies the device will in certain cases drive the line low.  So
pullup means what it says, which is not TRIS 0 (driven) and LAT 1 (high).

What is needed therefore is a pullup external to the PIC since there is
nothing in the PIC that can act like the required strong pullup.  This can
be a resistor to Vdd if it can always be present, or a resistor to another
PIC pin that is either driven high or left floating.


********************************************************************
Embed Inc, Littleton Massachusetts, http://www.embedinc.com/products
(978) 742-9014.  Gold level PIC consultants since 2000

2011\03\02@181818 by Manu Abraham

picon face
On Thu, Mar 3, 2011 at 4:27 AM, Olin Lathrop <@spam@olin_piclistRemoveMEspamEraseMEembedinc.com> wrote:
> Adam Field wrote:
>>> No, in this case strong pullup implies TRISA.0=0 AND LATC.0=1 (i.e
>>> put the port in output mode and drive it high)
>>
>> Yes, "strong" pull-up as in PIC's output FET R-on driving RA0.
>
> No.  That's not a pullup but rather explicitly driving the line high.  I
> haven't looked at the DSxxxx datasheet, but from what was said here earlier
> it needs a "strong" pullup when in parasitic power mode.  This is so that it
> can derive power from the line to operate when it is high.  But the "pullup"
> part also implies the device will in certain cases drive the line low.  So
> pullup means what it says, which is not TRIS 0 (driven) and LAT 1 (high).
>
> What is needed therefore is a pullup external to the PIC since there is
> nothing in the PIC that can act like the required strong pullup.  This can
> be a resistor to Vdd if it can always be present, or a resistor to another
> PIC pin that is either driven high or left floating.


According to the datasheet: http://pdfserv.maxim-ic.com/en/ds/DS18B20.pdf

Even in non-parasitic mode, ie using external supply (Fig:5), the 4k7
resistor is required, according to the datasheet. But only in the
parasitic mode (Fig:4), the STRONG_PULLUP comes into the picture
(Fig:12), else not. So, if the resistor is the STRONG_PULLUP, then why
mention in the software flowchart, that STRONG_PULLUP is required in
parasite mode ? Logically, I am more drawn to the micro pulling up the
pin using TRIS=0 and LAT=1, though I am not still very clear on that
aspect.

2011\03\02@184955 by Oli Glaser

flavicon
face

On 02/03/2011 23:18, Manu Abraham wrote:
> So, if the resistor is the STRONG_PULLUP, then why
> mention in the software flowchart, that STRONG_PULLUP is required in
> parasite mode ? Logically, I am more drawn to the micro pulling up the
> pin using TRIS=0 and LAT=1, though I am not still very clear on that
> aspect.

The resistor is not the strong (enough) pull up. The datasheet
recommends a MOSFET to Vdd but it may be fine to use a PIC pin set to
high as the datasheet says there is no activity on the bus during the
time the strong pull up is activated. The current needed is about 1.5 mA
so it should work okay.
The strong pull up is necessary in parasite mode as the 4k7 pull
up/parasite power capacitor cannot supply enough current for some
commands, namely Temperature Conversion and Write Scratchpad. The
DS18B20 says on page 5:

In parasite power mode, the 1-Wire bus and CPP can provide sufficient
current to the DS18B20 for most
operations as long as the specified timing and voltage requirements are
met (see the DC Electrical
Characteristics and AC Electrical Characteristics). However, when the
DS18B20 is performing
temperature conversions or copying data from the scratchpad memory to
EEPROM, the operating current
can be as high as 1.5mA. This current can cause an unacceptable voltage
drop across the weak 1-Wire
pullup resistor and is more current than can be supplied by CPP. To
assure that the DS18B20 has sufficient
supply current, it is necessary to provide a strong pullup on the 1-Wire
bus whenever temperature
conversions are taking place or data is being copied from the scratchpad
to EEPROM. This can be
accomplished by using a MOSFET to pull the bus directly to the rail as
shown in Figure 4. The 1-Wire
bus must be switched to the strong pullup within 10μs (max) after a
Convert T [44h] or Copy Scratchpad
[48h] command is issued, and the bus must be held high by the pullup for
the duration of the conversion
(tCONV) or data transfer (tWR = 10ms). No other activity can take place
on the 1-Wire bus while the pullup
is enabled.



2011\03\02@185010 by Kerry Wentworth

flavicon
face
Manu Abraham wrote:
>
> According to the datasheet: http://pdfserv.maxim-ic.com/en/ds/DS18B20.pdf
>
> Even in non-parasitic mode, ie using external supply (Fig:5), the 4k7
> resistor is required, according to the datasheet. But only in the
> parasitic mode (Fig:4), the STRONG_PULLUP comes into the picture
> (Fig:12), else not. So, if the resistor is the STRONG_PULLUP, then why
> mention in the software flowchart, that STRONG_PULLUP is required in
> parasite mode ? Logically, I am more drawn to the micro pulling up the
> pin using TRIS=0 and LAT=1, though I am not still very clear on that
> aspect.
>
>   You are correct.  The PIC should drive the line high directly during conversion and during scratchpad to EEPROM transfer.  The rest of the time, it should be an input with a 4K7 pull-up.

Kerry



-- Internal Virus Database is out-of-date.
Checked by AVG Anti-Virus.
Version: 7.0.289 / Virus Database: 267.11.13 - Release Date: 10/6/05

2011\03\02@195210 by Manu Abraham

picon face
On Thu, Mar 3, 2011 at 5:19 AM, Oli Glaser <EraseMEoli.glaserspam@spam@talktalk.net> wrote:
{Quote hidden}

That clears up almost all the doubts I had. Much appreciated.

I have the following pseudo code in C18, does it look sane enough with
regards to the timings ?

#define OW_PORT                        LATAbits.LATA0
#define OW_PORT_MODE                TRISAbits.TRISA0

#define OW_STRONG_PU                (OW_PORT_MODE = 0, OW_PORT = 1)
#define OW_PORT_HIGH                OW_STRONG_PU
#define OW_PORT_LOW                (OW_PORT_MODE = 0, OW_PORT = 0)
#define OW_PORT_RPU                (OW_PORT_MODE = 1, OW_PORT = 0)

const rom char crc_table[] = {
       0,94,188,226,97,63,221,131,194,156,126,32,163,253,31,65,
       157,195,33,127,252,162,64,30,95,1,227,189,62,96,130,220,
       35,125,159,193,66,28,254,160,225,191,93,3,128,222,60,98,
       190,224,2,92,223,129,99,61,124,34,192,158,29,67,161,255,
       70,24,250,164,39,121,155,197,132,218,56,102,229,187,89,7,
       219,133,103,57,186,228,6,88,25,71,165,251,120,38,196,154,
       101,59,217,135,4,90,184,230,167,249,27,69,198,152,122,36,
       248,166,68,26,153,199,37,123,58,100,134,216,91,5,231,185,
       140,210,48,110,237,179,81,15,78,16,242,172,47,113,147,205,
       17,79,173,243,112,46,204,146,211,141,111,49,178,236,14,80,
       175,241,19,77,206,144,114,44,109,51,209,143,12,82,176,238,
       50,108,142,208,83,13,239,177,240,174,76,18,145,207,45,115,
       202,148,118,40,171,245,23,73,8,86,180,234,105,55,213,139,
       87,9,235,181,54,104,138,212,149,203,41,119,244,170,72,22,
       233,183,85,11,136,214,52,106,43,117,151,201,74,20,246,168,
       116,42,200,150,21,75,169,247,182,232,10,84,215,137,107,53
};

void ow_parasite_init(void)
{
       OW_STRONG_PU; /* initially power parasite */
       mdelay(1); /* wait a bit */
}

int8_t ow_parasite_reset(void)
{
       int8_t detect;

       OW_PORT_LOW;    /* DQ Low by Master */
       udelay250();    /* 480us min delay */
       udelay250();
       OW_PORT_RPU;        /* resistor pulls it up */
       udelay80();     /* wait for slave to pull it down */
       detect = OW_PORT; /* read Slave state */
       udelay250();        /* wait for end of Slot */
       udelay250();
       return detect;
}

int8_t ow_parasite_get_bit(void)
{
       int8_t val;

       OW_PORT_LOW;        /* DQ LO by Master */
       udelay1();        /* wait for 1us */
       OW_PORT_RPU;        /* release */
       udelay10();        /* master samples within 15us */
       val = OW_PORT;        /* read parasite state */
       udelay50();        /* wait for end of Slot */
}

int8_t ow_parasite_set_bit(uint8_t b)
{
       OW_PORT_LOW;        /* master pulls LO */
       if (b) {
               udelay1();
               OW_PORT_HIGH;
       }
       udelay60();
       OW_PORT_RPU;
}

uint8_t ow_parasite_read(void)
{
       uint8_t i, val;

       for (i = 0; i < 8; i++) {
               if (ow_parasite_get_bit())
                       val |= (1 << i);
               udelay50();
       }
       return val;
}

void ow_parasite_write(uint8_t val)
{
       uint8_t i;

       for (i = 0; i < 8; i++) {
               ow_parasite_set_bit((val >> i) & 0x01);        
               udelay50();
       }
}                

void read_temperature(void)
{
       uint8_t owcrc, scratch[9];
       int16_t t;

       ADCON1        = 0x0f;

               ow_parasite_init();        /* parasite power */
               if (!ow_parasite_reset()) {        /* detect parasite */
                       dev_1w = 1;
                       ow_parasite_write(0xcc); /* skip ROM cmds */
                       ow_parasite_write(0x44); /* convert temp. */
                       OW_STRONG_PU;                 /* master enables strong pullup */
                       mdelay(250); /* wait 750ms */
                       mdelay(250);
                       mdelay(250);
                       OW_PORT_RPU; /* master disables strong pullup */
               }
               if (!ow_parasite_reset()) {
                       ow_parasite_write(0xcc); /* skip ROM cmds */
                       ow_parasite_write(0xbe); /* read scratchpad */
                       for (bytes = 0; bytes < 8; bytes++) {
                               scratch[bytes] = ow_parasite_read();
                               crc_table[owcrc ^ scratch[bytes]];
                       }
                       scratch[8] = ow_parasite_read();
                       ow_parasite_reset();
                       if (scratch[8] == owcrc) {
                               t = scratch[1] << 8 | scratch[0];
                               if (t >= 0)
                                       t = (t + 8) / 16;
                               else
                                       t = (t - 8) / 16;
                       } else {
                               t = 0;
                       }
               }

}

2011\03\02@213816 by Oli Glaser

flavicon
face
On 03/03/2011 00:52, Manu Abraham wrote:
> I have the following pseudo code in C18, does it look sane enough with
> regards to the timings ?

Timings look pretty reasonable from what I can recall from my code (though I haven't examined them in great detail)
However I was wondering about the read_temperature function - you set the ow_parasite_init, which if I am right sets the strong pullup for 1ms, before executing the 0x44 read temp command - why do you do this?
If I get the datasheet right it says to set it within 1us *after* calling read temp, then leave it on for the duration (750ms for 12 bit) as you have done also.
So I am not sure that the the ow_parasite_init is necessary (though it shouldn't stop anything working) as apart from during Read Temperature and Copy Scratchpad it should work fine with just the 4k7 pull up.

2011\03\02@214142 by Oli Glaser

flavicon
face
Just to correct myself - I meant to say the strong pull up has to be enabled within 10us (not 1us) after calling read temp.

2011\03\02@225015 by Denny Esterline

picon face
Ok, skipping all the off-topic stuff.
Maxim/Dallas's one wire parts use the phrase "strong pullup" to
indicate the line SHOULD BE DRIVEN HIGH. The pullup resistor is not
enough, a PIC's weak pullups is not enough, the combination is not
enough. The specs vary across the product range, but holding 90% of
Vcc at 10mA is a good place to start.
This is only necessary for the parasite powered parts, and only during
certain times (like doing a conversion or writing to EEPROM).

Some of the data sheets show an external FET controlled from another
output pin to do this, many people have successfully toggled the TRIS
bit and used the PIC to drive it high, including myself.


It's been a while since I had my head in that code, but as I recall
there's a certain time limit. Strong pullup _must_ be active within a
certain time of issuing the command. It bit me on the backside because
I had about 10 sensors to watch and the software had several nested
calls to manage them all. In the end I had to separate out a couple of
the routines to meet the timing requirement.

-Denn

2011\03\03@030704 by Manu Abraham

picon face
On Thu, Mar 3, 2011 at 8:11 AM, Oli Glaser <@spam@oli.glaserspam_OUTspam.....talktalk.net> wrote:
> Just to correct myself - I meant to say the strong pull up has to be
> enabled within 10us (not 1us) after calling read temp.

Thanks, I will adapt the code to your suggestion and give it a run and see

2011\03\03@031126 by Manu Abraham

picon face
On Thu, Mar 3, 2011 at 9:20 AM, Denny Esterline <spamBeGonedesterlineEraseMEspamgmail.com> wrote:
{Quote hidden}

Thanks for the clarification

2011\03\03@031417 by Ruben Jönsson

flavicon
face
> Adam Field wrote:
> >> No, in this case strong pullup implies TRISA.0=0 AND LATC.0=1 (i.e
> >> put the port in output mode and drive it high)
> >
> > Yes, "strong" pull-up as in PIC's output FET R-on driving RA0.
>
> No.  That's not a pullup but rather explicitly driving the line high.  I
> haven't looked at the DSxxxx datasheet, but from what was said here earlier
> it needs a "strong" pullup when in parasitic power mode.  This is so that it
> can derive power from the line to operate when it is high.  But the "pullup"
> part also implies the device will in certain cases drive the line low.  So
> pullup means what it says, which is not TRIS 0 (driven) and LAT 1 (high).
>
> What is needed therefore is a pullup external to the PIC since there is
> nothing in the PIC that can act like the required strong pullup.  This can
> be a resistor to Vdd if it can always be present, or a resistor to another
> PIC pin that is either driven high or left floating.
>
Now would have been a good time to read the datasheet before replying since this will most likely confuse the OP more than it will help.

A strong pullup for a 1-wire device means that the data line needs to be able to supply enough current at a certain minimum voltage during a certain minimum time while the 1-wire device is performing an operation which consumes more power than usually. In this case, the operation is a temperature conversion which will consume up to 1.5mA during 100ms - 750ms (depending on resolution) at a minimum voltage of 3.0V. During this time, no other activity can take place on the data line, not by the uController and not by any of the 1-wire devices on this data line (the 1-wire bus). A quick ohms law calculation shows that a pullup of 4700 ohm to 5V will not be enough.

One way to solve this is to drive the data line high with the uController port pin during the conversion time. Sicne all communication is initiated by the uController, this will not be a problem, even if the pin is held high for a longer duration than the temperature conversion time.

However, this may not be the best approach since the 1-wire bus can be several 100 feet long and you don't want to expose the uController pin to the real world in this way.

I have been using the following circuit with good result:
<http://www.edn.com/file/24756-3499di.pdf?force=true>
It uses two I/O pins (one bidirectional and one pure output) instead of one..
However, the text in the article is wrong. It says that the input signal to Q3 has to be set low in order to activate the pullup circuit. This is wrong. Setting the base of Q3 low only switches off  the pulldown. In order to activate the pullup, the input line also has to be switched to an output and set low. The pullup will be activated when the clamping resistor has pulled up the line higher than around 0.6V. So it only is activated if there isn't anything else on the line that pulls it low, preventing a  short.
I also use a lot lower pull up resistor than 4.7k ohms. I think it is down to 510 ohms. This is possible since the PIC isn't driving the data line directly. I also terminate each 1-wire trunk with a RC network to avoid ringing and data corruption on long lines.
The output is protected by two 3.3 ohm resistors in series and inbetween them there are two shottky diodes (BAT54S), one connected to ground and another connected to a 6.8V (breakdown, Vrm=5.8V) TVS diode. The TVS can not be directly connected to the 1-wire line because of its relatively high internal capacitance.
This has served me well for several hundreds installations with some of them with more than 1000 sensors (not all at the same 1-wire bus though).

Another thing to look out for is to keep the data line relatively stable during the strong pullup (temperature conversion) since not doing so can disturb the sensor and it may not produce the correct temperature.
/Ruben
==============================
Ruben Jönsson
AB Liros Electronic
Box 9124, 200 39 Malmö, Sweden
TEL INT +46 40142078
FAX INT +46 40947388
rubenspamBeGonespampp.sbbs.se
==============================

2011\03\03@072914 by Olin Lathrop

face picon face
Manu Abraham wrote:
> So, if the resistor is the STRONG_PULLUP, then why
> mention in the software flowchart, that STRONG_PULLUP is required in
> parasite mode ?

Probably because it is.  In parasite mode the device gets its power from the
data line.  That data line therefore has to be able to source current within
some range.  At the low end, it must source enough current to keep the
device powered.  At the high end, it must not source so much current that it
and other devices on the bus can't pull the line low.

When it's not operating in parasitic power mode, then the data line doesn't
need to source as much current since it's not powering the device.
Therefore the pullup can be more weak.


********************************************************************
Embed Inc, Littleton Massachusetts, http://www.embedinc.com/products
(978) 742-9014.  Gold level PIC consultants since 2000

2011\03\03@103203 by Michael Rigby-Jones

flavicon
face


> -----Original Message-----
> From: RemoveMEpiclist-bounces@spam@spamspamBeGonemit.edu [.....piclist-bounces@spam@spamEraseMEmit.edu] On
Behalf
{Quote hidden}

from
> the
> data line.  That data line therefore has to be able to source current
> within
> some range.  At the low end, it must source enough current to keep the
> device powered.  At the high end, it must not source so much current
that
> it
> and other devices on the bus can't pull the line low.
>
> When it's not operating in parasitic power mode, then the data line
> doesn't
> need to source as much current since it's not powering the device.
> Therefore the pullup can be more weak.

On a one wire bus the so-called "strong pull-up" is only applied very
briefly prior to communicating with a peripheral.  It is not a resistive
pull-up as such, since nothing is expected to pull the bus low when it's
applied.
Regards

Mike

=======================================================================
This e-mail is intended for the person it is addressed to only. The
information contained in it may be confidential and/or protected by
law. If you are not the intended recipient of this message, you must
not make any use of this information, or copy or show it to any
person. Please contact us immediately to tell us that you have
received this e-mail, and return the original to us. Any use,
forwarding, printing or copying of this message is strictly prohibited.
No part of this message can be considered a request for goods or
services.
=======================================================================

2011\03\03@104321 by Olin Lathrop

face picon face
Michael Rigby-Jones wrote:
> On a one wire bus the so-called "strong pull-up" is only applied very
> briefly prior to communicating with a peripheral.  It is not a
> resistive pull-up as such, since nothing is expected to pull the bus
> low when it's applied.

Ah.  Then in that case it is appropriate to drive the bus from a high PIC
output during that time.  Sorry for adding confusion.


********************************************************************
Embed Inc, Littleton Massachusetts, http://www.embedinc.com/products
(978) 742-9014.  Gold level PIC consultants since 2000

2011\03\03@132714 by Ruben Jönsson

flavicon
face
>
> On a one wire bus the so-called "strong pull-up" is only applied very
> briefly prior to communicating with a peripheral.  It is not a resistive
> pull-up as such, since nothing is expected to pull the bus low when it's
> applied.
>
> Regards
>
> Mike
>
No, it is applied when one or more parasitically powered 1-wire devices need to do a lengthy operation which consumes relatively much current (more than the pullup resistor can supply), like temperature measurement, voltage measurement or writing to eeprom.

There is no need to apply a strong pullup for communication. There is an internal capacitor in each device that supplies power when the bus is low during communication.

It is correct that nothing is expected to pull the bus low during the strong pullup.

/Ruben

==============================
Ruben Jönsson
AB Liros Electronic
Box 9124, 200 39 Malmö, Sweden
TEL INT +46 40142078
FAX INT +46 40947388
.....rubenRemoveMEspampp.sbbs.se
==============================

2011\03\04@065127 by Michael Rigby-Jones

flavicon
face


{Quote hidden}

I didn't say the strong pull-up was required for communication, or at least I certainly didn't mean to imply that.  As you say, the strong pull-up is to power the device during operation, after which you can release the strong pull-up and communicate with it to get the result.

Regards

Mike

=======================================================================
This e-mail is intended for the person it is addressed to only. The
information contained in it may be confidential and/or protected by
law. If you are not the intended recipient of this message, you must
not make any use of this information, or copy or show it to any
person. Please contact us immediately to tell us that you have
received this e-mail, and return the original to us. Any use,
forwarding, printing or copying of this message is strictly prohibited.
No part of this message can be considered a request for goods or
services.
=======================================================================

More... (looser matching)
- Last day of these posts
- In 2011 , 2012 only
- Today
- New search...