Using ATmega128 ADC to read One-Wire protocol

Do you have a question? Post it now! No Registration Necessary

Translate This Thread From English to

Threaded View
I am looking at the feasibility of using a Maxim/Dallas One-Wire device
on an external input that is designed to read the value of a resistor.
Someone at this company thought a few resistor values would be all they
needed to identify attached equipment options.  Now they are out of
resistors and will be needing a new way of identifying the attached
equipment.  I thought that the One-Wire parts would be perfect for
this.

Here's the hard part.  The existing circuit is in nearly 100,000 units
in the field as well as in the new design that is currently going to
manufacturing and it is designed to filter out the type of pulses I
need to measure.  It uses a 5.6K pullup and an ADC input to measure the
voltage on the external resistor.  But there are two of RC filters on
this circuit.  One is about 1 uS RC and is between the resistor
pullup/FET pulldown and the outside.  I think I can live with this
since the required timing on the One-Wire interface are more along the
line of 15 uS.  I figure I can make the pulldown time a minimum of 3 uS
and still meet all the One-Wire specs.  But there is also an RC between
the pullup resistor/OD FET and the ADC input with an RC time of 22 uS.
This one is a killer since it makes reading the bus hard.  In the
required 15 uS it will be pulled down to about 50% of Vcc.

Obviously I can't use the ADC input as a digital input since the
voltage never reaches the Vil threshold.  But I was wondering if the
ADC could be used to read the voltage.  If the One-Wire slave is
returning a zero, it will hold the bus low for 15 uS, min, which will
pull the ADC input to 50% Vcc before releasing it and the voltage
starts ramping back up.  If the the One-Wire slave is returning a one,
it will never clamp the bus and it will ramp up to about 95% of Vcc at
the 15 uS time.  The data sheet on the AVR says it takes 1.5 ADC clocks
to sample the input.  So if I have the ADC running at the max 200 kHz
and start the ADC at about 7.5 uS into the 15 uS window, it might just
have a shot at reading this voltage.  But there seems to be a 5 uS
window to align with the ADC clock, so I might have to start the
conversion at say 5 uS into the 15 uS window which has sampling between
12.5 uS and 17.5 uS.

Anyone have an idea of whether this is likely to work?  I have little
experience with the AVR and it looks like this is likely to be on the
hairy edge of ADC timing.  I don't see a spec in the AVR data sheet on
the aperature window for the ADC timing. I guess the only way to know
is to hook it up and try it.  But I would have to test over temp, etc.
Testing with a One-Wire part would not do the job since their timing
has wide variation.  But I should be able to do my testing just using
the unit under test.


Re: Using ATmega128 ADC to read One-Wire protocol
Rickman,


The max. allowable ADC clock is 1MHz and the min. conversion time is 14
clock cycles. The analog voltage is latched at the first clock cycle of
the conversion. If you can provide for the precise ADC timing you should
be able to read 1-Wire bus as a master.


Vladimir Vassilevsky

DSP and Mixed Signal Design Consultant

http://www.abvolt.com


rickman wrote:

Quoted text here. Click to load it

Re: Using ATmega128 ADC to read One-Wire protocol
Quoted text here. Click to load it


Thanks for your reply.  I had looked at the data sheet and I thought
the max ADC clock rate was 200 KHz. Actually, I see where it says you
can run it faster, but you won't get the full resolution in the result.
 They don't provide info that I can find on how much resolution is lost
at higher clock speeds.  1 MHz may work fine for this measurement.  I
guess a test will tell!


Re: Using ATmega128 ADC to read One-Wire protocol
Quoted text here. Click to load it

If it's an SAR converter, it'll produce half the number of bits
in just over half the time. You probably only need 1 or 2 bits.

Re: Using ATmega128 ADC to read One-Wire protocol
Quoted text here. Click to load it

I don't think it works like that.  There is no control over how many
bits it converts.  But when you clock it faster, the comparator does
not have time to settle and the last few bits have no accuracy.

I will have to bench this and make sure there is plenty of head room to
allow for production variations.  I just thought someone here may have
have worked on a similar problem before.


Re: Using ATmega128 ADC to read One-Wire protocol
Quoted text here. Click to load it

You don't clock it faster, you just use the partial value
(and stop it clocking if you can) before it's clocked all
bits.

Clifford.

Re: Using ATmega128 ADC to read One-Wire protocol
On 3 Dec 2005 21:55:36 -0800 in comp.arch.embedded, "rickman"

Quoted text here. Click to load it
[...]
Quoted text here. Click to load it

I never used the mega128, but the mega16 (IIRC -- may be the mega32)
datasheet specifically stated (in the electrical specifications
section in the back) that running at 1MHz would cost you two bits of
accuracy, which leaves you with 8.  I would expect the mega128 to
behave similarly.  Worth a try anyway.

Regards,

                                        -=Dave

--
Change is inevitable, progress is not.

Site Timeline