2
\$\begingroup\$

I'm looking to bit bang 1-Wire from an Atmega uC. My design calls for the Atmega (acting as Host) to detect the presence of a single 1-wire eeprom when it's physically connected to the uC.

I don't want to continually poll the line, as that seems a waste of battery. I've not used 1-wire before, so I might be missing something obvious; for instance, can a peripheral assert a logic low on power up that I could use as an interrupt to wake the uC?

(I'm working on the assumption that the eeprom will be powered by the uC over the data line).

EDIT: I'm thinking something like this: http://datasheets.maximintegrated.com/en/ds/DS28E05.pdf

From what I understand, it will respond after the bus master initiates a reset pulse. But, this gets back to the polling method, which I don't want to use.

Does applying power to the EEPROM "look" like a reset pulse to it? (I doubt it).

\$\endgroup\$
  • \$\begingroup\$ As per your comments below about it being a 3V system is there a reason you can't increase it to 3.3V? If so I've done something similar in the past just using an I/O pin for the 1-wire Vcc. \$\endgroup\$ – PeterJ Aug 26 '13 at 4:08
  • \$\begingroup\$ @PeterJ: It should be possible -- I've inherited this design, and it would take a bit of time to study the impact on the rest of the system. I could also use a lower voltage eeprom -- found some that work at 2.8V. Could you elaborate on your method? \$\endgroup\$ – hex4def6 Aug 26 '13 at 17:18
  • \$\begingroup\$ I realised when I re-read your question the way I went didn't address part of the question about not using polling. I did use polling / sleep mode but one extra thing I did was power the 1-wire bus from an I/O pin (which should be OK when at 3.3V) just so the pull-up wasn't drawing current the whole time. \$\endgroup\$ – PeterJ Sep 25 '13 at 7:14
1
\$\begingroup\$

If memory serves, one-wire devices define a reset pulse is any low pulse longer than a specified duration (I think about 600us) with no maximum duration. Being unplugged for four months and then having voltage applied would qualify as a 10,368,000,000us low pulse, which is certainly longer than 600us. Consequently, the devices generally assert a "presence" pulse shortly after power is first applied. Depending upon contact bounce, it is possible that touching a device may not cause a clean reset, in which case one might possibly not get the "present" pulse, but I've found that triggering on a falling edge triggered by a remote device seems to be pretty reliable.

\$\endgroup\$
0
\$\begingroup\$

1-wire is kind of designed for this polling, but you might be able to get around it with some creative analog circuitry.

Presumably the EEPROM will draw some current when it is connected. You could use a 10 or maybe even 100 ohm resistor in series with the ground line for the 1-wire device you want to detect. Use a comparator to compare the voltage across this resistor to some reference voltage that works for you, and connect the output of the comparator to an interrupt line on your microcontroller.

schematic

simulate this circuit – Schematic created using CircuitLab

With the example above, your reference voltage is VCC * 1k/121k or about 41mV for a 5V supply. 41mV across a 10 ohm sense resistor is about 4mA of current to trip the comparator. This is just a wild guess, your levels may be much lower. Check the EEPROM datasheet. Depending on the comparator you might also have to include a pull-up resistor on its output and you might also want to include a bit of hysteresis. Note that I've connected the reference and sense resistor up so that when the EEPROM draws more than the reference, the output of the comparator goes LOW.

You would want to experiment with the resistor to find the highest resistance you can get away with without making the 1-wire bus flaky (the higher the resistance, the more of a voltage drop you'll have which makes detection easier, but also the more of a difference in what the EEPROM sees as 0V and the real system 0V level).

You could also put the resistor on the data line but you'll then have to use either a differential amp or a high side current sensing circuit, and again too high of a resistance will muddle the communications.

In either case, you'll probably want to disable the interrupt when you are actively communicating to prevent a whole storm of interrupts as the device current consumption goes up due to an active communications link.

\$\endgroup\$
  • \$\begingroup\$ Thanks for the idea. Unfortunately, I'm not able to have the low-side method you've got shown, as I'm really restricted in the number of wires between both sides. In my case, I get Power, 1-Wire bus, and GND (Which has to be at 0V potential for the power line). Could I do a similar high side idea -- use a 10/100 ohm on the pullup to VCC for the data bus, and look at the voltage that develops accross that? I'm using a 3V rail, so I'm not too sure that I have a lot of headroom. EDIT: eek. 2.97V minimum voltage on the eeprom I listed. \$\endgroup\$ – hex4def6 Aug 26 '13 at 1:40
  • \$\begingroup\$ Wow, that's a pretty tight margin. If you really don't want to poll you could always use a hall-effect current sensor. I took a quick look on digikey and you might have some design work ahead of you to get it working at 3V. I'd be inclined to look at a smaller resistor to keep your voltage drop down and maybe amplifying the voltage, but that can be noisy. You can measure the high side, I mentioned that in my answer as well, but involves more components and you still have to worry about the voltage drop across the sense resistor. BTW: a 100mA LEM current sensor is $97 for one. Yikes! \$\endgroup\$ – akohlsmith Aug 26 '13 at 3:38
  • \$\begingroup\$ I don't think this qualifies as an answer. Did you even read the EEPROM datasheet, which tells us that it only draws 5 uA typ (20 uA max)? Have you ever had a circuit like this working reliably? \$\endgroup\$ – Dave Tweed Aug 26 '13 at 12:09
  • \$\begingroup\$ @DaveTweed no, I did not read the datasheet and I made note in the answer already that the levels may be incredibly low. I do notice that the device can draw almost a half mA when programming, which while still terribly low, suggests that there may be a detectable surge current when connected. You would have to experiment and see, which was the point of my answer. \$\endgroup\$ – akohlsmith Aug 26 '13 at 14:07
  • \$\begingroup\$ I'm starting to feel like this is not a sensible idea; I just wanted to make sure I wasn't missing something obvious in the 1-Wire protocol. Perhaps polling isn't the worst idea; I could do it every second or so, which should be too bad in terms of power consumption. \$\endgroup\$ – hex4def6 Aug 26 '13 at 17:17

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.