Reply by galapogos August 16, 20072007-08-16
On Aug 16, 12:13 pm, DJ Delorie <d...@delorie.com> wrote:
> galapogos <gois...@gmail.com> writes: > > I guess bitbanging it with a timer interrupt would be the best bet > > huh? > > Might be useful to have an falling-edge-triggered interrupt on that > line, too. I've done master-mode 1-wire with just timer interrupts, > it's not *that* hard. Once you have reset and single bit read/write > done, everything else is written in terms of those. > > Which spec do you have? The one I reference is the iButton spec, > which is about 158 pages long.
Yup, I have that one. I also have a 1-wire bus article from the journal of applied sensing technology, but that's just 3 page article w/o details. I also have Dallas semiconductors(Maxim) application note 74 on "Reading and writing ibuttons via serial interface" but I'm not sure how useful that is.
> > I guess it shouldn't be *that* hard. Just have to find out how the > > ASIC is talking to the ibutton with a logic analyzer, and then try > > to replicate the same response with my MCU? > > Better to meet the spec than follow some example, as the 1wire spec > allows devices to be very flexible with the timing (they're RC > self-clocked), but everyone has to meet the master spec. I used a > logic analyzer to tweak the timing on mine.
OK, but I'm thinking it'd be useful to see the exact communication between the default ASIC/ibutton as well, and perhaps match that with the official specs...
> > Oh, 1 more question regarding the voltage levels, according to spec > > it's anything from 2.6V to 6V IIRC...is there a standard voltage > > level? My MCU is running on 3.3V so I hope the GPIO pins are voltage > > compatible. > > 1wire slaves are normally powered by the bus itself through parasitic > power, but you should be able to use I2C level converters with it. > Since you're providing the pullup, you can pull up to 3.3v and see if > the master is TTL compatible. > > > And also another question regarding connections...can I simply > > connect my GPIO pin to the ASIC's 1-wire pin, or would some > > pullup/pulldown or other passives be required? > > A pullup of 1k-5k is needed. The devices only ever pull down, giving > you a wired-AND. Some line drivers will pull up when they detect a > rising slope anyway (to compensate for line capacitance), but you > don't need to worry about that. > > Other than the pullup, every device just connects to the same wire. > Hence, 1-wire :-)
Thanks :)
Reply by August 16, 20072007-08-16
galapogos <goister@gmail.com> writes:
> I guess bitbanging it with a timer interrupt would be the best bet > huh?
Might be useful to have an falling-edge-triggered interrupt on that line, too. I've done master-mode 1-wire with just timer interrupts, it's not *that* hard. Once you have reset and single bit read/write done, everything else is written in terms of those. Which spec do you have? The one I reference is the iButton spec, which is about 158 pages long.
> I guess it shouldn't be *that* hard. Just have to find out how the > ASIC is talking to the ibutton with a logic analyzer, and then try > to replicate the same response with my MCU?
Better to meet the spec than follow some example, as the 1wire spec allows devices to be very flexible with the timing (they're RC self-clocked), but everyone has to meet the master spec. I used a logic analyzer to tweak the timing on mine.
> Oh, 1 more question regarding the voltage levels, according to spec > it's anything from 2.6V to 6V IIRC...is there a standard voltage > level? My MCU is running on 3.3V so I hope the GPIO pins are voltage > compatible.
1wire slaves are normally powered by the bus itself through parasitic power, but you should be able to use I2C level converters with it. Since you're providing the pullup, you can pull up to 3.3v and see if the master is TTL compatible.
> And also another question regarding connections...can I simply > connect my GPIO pin to the ASIC's 1-wire pin, or would some > pullup/pulldown or other passives be required?
A pullup of 1k-5k is needed. The devices only ever pull down, giving you a wired-AND. Some line drivers will pull up when they detect a rising slope anyway (to compensate for line capacitance), but you don't need to worry about that. Other than the pullup, every device just connects to the same wire. Hence, 1-wire :-)
Reply by galapogos August 16, 20072007-08-16
Thanks guys. I've actually downloaded 3 documents about ibutton/1-wire
interface, and I'll read it to find out more. I guess bitbanging it
with a timer interrupt would be the best bet huh? I guess it shouldn't
be *that* hard. Just have to find out how the ASIC is talking to the
ibutton with a logic analyzer, and  then try to replicate the same
response with my MCU?

Oh, 1 more question regarding the voltage levels, according to spec
it's anything from 2.6V to 6V IIRC...is there a standard voltage
level? My MCU is running on 3.3V so I hope the GPIO pins are voltage
compatible.

And also another question regarding connections...can I simply connect
my GPIO pin to the ASIC's 1-wire pin, or would some pullup/pulldown or
other passives be required?

Reply by Jim Granville August 15, 20072007-08-15
rickman wrote:

> On Aug 15, 5:53 pm, Jim Granville <no.s...@designtools.maps.co.nz> > wrote: > >>galapogos wrote: >> >>>Hi, >> >>>I have a microcontroller with GPIO, I2C and UART, and I'm trying to >>>emulate a 1-wire interface so that the microcontroller appears as an i- >>>button to another ASIC. I'm wondering if it would be easier to use >>>either of the serial channels(UART or I2C) or should I just emulate it >>>with GPIO? >> >>>Would also appreciate any tips/help on how to emulate, and 1-wire >>>standards, since I'm new to 1-wire and ibutton. >> >>1 Wire is commonly a edge triggered PWM modulated data stream. >>Thus Rx would be possible with a UART, but TX is not so simple, as >>you need to pull the 1 wire node low, Sync'd with the Start edge. >>However, RX int does not fire until the mid-stop bit timeslot. >>- so TX needs a different timing-pacer scheme. >> >>Most common is to use a combination of EDGE INTERRUPT, + GPIO + Timer, >>tho you could maybe use the UART RXD for the SYNC pulse detect/check, >>if it was not doing anything else. >> >>Normally the uC idles until an edge is found, then starts the >>RX/TX pulse-width timings, from there. > > > Some UARTs can be throttled by the RTS/CTS handshake lines. Perhaps > this could be used to sync the slave response to the start edge? That > could take a lot off of the CPU in terms of timing the individual bits > if it has other things to do.
I thought about this some more, and we did once do a system (not 1 wire) that varied the baud rate dynamically, but that's probably too complex here. The main sticking point is TxPhase, and so an EDGE interrupt, that then triggers TXD Load, as needed, could work. Most TXD's free-run the BIT clock, so you would have 1 baud time jitter, but 1 wire systems are very time tolerant. -jg
Reply by rickman August 15, 20072007-08-15
On Aug 15, 5:53 pm, Jim Granville <no.s...@designtools.maps.co.nz>
wrote:
> galapogos wrote: > > Hi, > > > I have a microcontroller with GPIO, I2C and UART, and I'm trying to > > emulate a 1-wire interface so that the microcontroller appears as an i- > > button to another ASIC. I'm wondering if it would be easier to use > > either of the serial channels(UART or I2C) or should I just emulate it > > with GPIO? > > > Would also appreciate any tips/help on how to emulate, and 1-wire > > standards, since I'm new to 1-wire and ibutton. > > 1 Wire is commonly a edge triggered PWM modulated data stream. > Thus Rx would be possible with a UART, but TX is not so simple, as > you need to pull the 1 wire node low, Sync'd with the Start edge. > However, RX int does not fire until the mid-stop bit timeslot. > - so TX needs a different timing-pacer scheme. > > Most common is to use a combination of EDGE INTERRUPT, + GPIO + Timer, > tho you could maybe use the UART RXD for the SYNC pulse detect/check, > if it was not doing anything else. > > Normally the uC idles until an edge is found, then starts the > RX/TX pulse-width timings, from there.
Some UARTs can be throttled by the RTS/CTS handshake lines. Perhaps this could be used to sync the slave response to the start edge? That could take a lot off of the CPU in terms of timing the individual bits if it has other things to do.
Reply by Jim Granville August 15, 20072007-08-15
galapogos wrote:
> Hi, > > I have a microcontroller with GPIO, I2C and UART, and I'm trying to > emulate a 1-wire interface so that the microcontroller appears as an i- > button to another ASIC. I'm wondering if it would be easier to use > either of the serial channels(UART or I2C) or should I just emulate it > with GPIO? > > Would also appreciate any tips/help on how to emulate, and 1-wire > standards, since I'm new to 1-wire and ibutton.
1 Wire is commonly a edge triggered PWM modulated data stream. Thus Rx would be possible with a UART, but TX is not so simple, as you need to pull the 1 wire node low, Sync'd with the Start edge. However, RX int does not fire until the mid-stop bit timeslot. - so TX needs a different timing-pacer scheme. Most common is to use a combination of EDGE INTERRUPT, + GPIO + Timer, tho you could maybe use the UART RXD for the SYNC pulse detect/check, if it was not doing anything else. Normally the uC idles until an edge is found, then starts the RX/TX pulse-width timings, from there. -jg
Reply by msg August 15, 20072007-08-15
galapogos wrote:

> Hi, > > I have a microcontroller with GPIO, I2C and UART, and I'm trying to > emulate a 1-wire interface so that the microcontroller appears as an i- > button to another ASIC. I'm wondering if it would be easier to use > either of the serial channels(UART or I2C) or should I just emulate it > with GPIO? > > Would also appreciate any tips/help on how to emulate, and 1-wire > standards, since I'm new to 1-wire and ibutton. >
Hi, I sent an email to the address in your posting header -- an invite to look at code and schematics of 1-Wire examples on the i8096. http://www.cybertheque.org/homebrew/hmi-200 The ICE is currently offline but all references are alive. You will need to navigate a bit to find things. Regards, Michael
Reply by rickman August 15, 20072007-08-15
On Aug 15, 4:51 am, galapogos <gois...@gmail.com> wrote:
> Hi, > > I have a microcontroller with GPIO, I2C and UART, and I'm trying to > emulate a 1-wire interface so that the microcontroller appears as an i- > button to another ASIC. I'm wondering if it would be easier to use > either of the serial channels(UART or I2C) or should I just emulate it > with GPIO? > > Would also appreciate any tips/help on how to emulate, and 1-wire > standards, since I'm new to 1-wire and ibutton.
I don't think you have a choice, because the 1-wire interface requires the output to go hi-z, you have to use GPIO to do it entirely in software. If you are willing to add a tri-state/open collector buffer or transistor it will be possible to use a UART. I2C has its own protocol that is not compatible with 1--wire, but I guess you might be able to make it work, certainly this is not *my* first choice. SPI can likely do the job as well as a UART. There are several levels to the 1-wire protocol. The master initiates all transfers on the bus at the bit level and bits are pulse width modulated. The higher levels of the protocol define when the master is writing or reading bytes. All devices are open collector on the bus. The master sends a bit by pulling the line low for either a short time (~5 us in slow mode) for a one or a longer time (~60 us) for a zero. Reading is done by the master by initiating the transfer with a short pulse. When the master releases the line, the slave (addressed in higher levels of the protocol) either allows the line to rise to signal a one or keeps it low for a zero. Each bit transferred also has a "frame" time of about 100 us meaning you can't start another transfer so that the slave can recover. Slaves are often powered by the line and need some "one" time to recharge. There are also reset pulses and presence acknowledge pulses. The higher levels of the protocol allow the master to address slaves, identify slaves and poll the slaves for activity. Transfers typically have checksums for important commands and data and can operate pretty reliably in many environments. The protocol is a bit unusual, but very effective. There is a "high speed" mode with shorter pulse times which can be used with a sub-set of devices and more limited line lengths. I may have the polarities reversed and of course I may not remember the times exactly, so read the docs. Also, read the timing info carefully since there are windows of tolerance (which are not spec'd clearly) which you must meet for the protocol to work reliably. So there is your nickel tour of 1-wire interfaces. I don't know if there are any good web pages describing the protocol or not. The Dallas docs are ok, but some parts are a bit hard to interpret. If I do another project using it I will consider preparing a doc that does a better job of explaining the *how to* than what Dallas provides.
Reply by August 15, 20072007-08-15
galapogos wrote:

> I have a microcontroller with GPIO, I2C and UART, and I'm trying to > emulate a 1-wire interface so that the microcontroller appears as an i- > button to another ASIC. I'm wondering if it would be easier to use > either of the serial channels(UART or I2C) or should I just emulate it > with GPIO?
By all means GPIO. Or, if you want it simple, use a 1-wire slave device with an I2C or similar interface to your micro.
> Would also appreciate any tips/help on how to emulate, and 1-wire > standards, since I'm new to 1-wire and ibutton.
DalSemi/Maxim has lots of reading material.
Reply by galapogos August 15, 20072007-08-15
Hi,

I have a microcontroller with GPIO, I2C and UART, and I'm trying to
emulate a 1-wire interface so that the microcontroller appears as an i-
button to another ASIC. I'm wondering if it would be easier to use
either of the serial channels(UART or I2C) or should I just emulate it
with GPIO?

Would also appreciate any tips/help on how to emulate, and 1-wire
standards, since I'm new to 1-wire and ibutton.