David Collier wrote: > I want to string a load of simple slaves out along a serial bus. > > Does anyone think I could implement a 1-wire slave using an ATtinyx5? > > Yes I know it's patented. > > Alternatively does anyone have a better suggestion? Would the I2C > look-alike mode do it for me? Anyone got any experience of such a thing, > or know where to scrounge the necessary code? > > All suggestions gratefully received. You didn't say how far apart these slaves would be and what sort of environment etc. If they are within a metre or two you could use TWI aka I2C as this is well suited for low-speed local multi-drop. Although I2C is not suited for long stretches I used to run LCD displays off I2C over 10's of metres many years ago in harsh environments, but this is not recommended practice :) There is also SPI but not in the regular way which requires slave selects etc. You can use it in two wire mode by multi-dropping the clocks and the MOSI pins, forgetting the MISO as it becomes redundant. For the USI on the Tiny it looks like you need to join the DI and DO together to achieve this. It's usually good practice to isolate each pin via a small value resistor (I use 220R). Software leaves each device in slave mode until one wants to talk, and provided there are no collisions then each slave device gets the same message. When one wants to reply, well it does the same thing and switches to master mode temporarily. I have used this method on other micros at high-speed for locally connected modules. Also, the tinys do seem to work in half-duplex asynchronous mode, at least according to the docs. This is the method I have used on other micros where you can simply tie the txd and rxd of a uart together (assuming txd can be tristated) and form a 1-wire asynchronous multi-drop bus. Once again it is good practice to isolate the txd pin with a small value resistor and include a high-value resistor and optional filtering cap in the rxd pin for extra protection. If you want distance then there are many options with RS485 being the most common and quite doable on the tinys. *Peter*
Message
Re: [AVR-Chat] multi-drop slaves
2006-05-17 by Peter Jakacki
Attachments
- No local attachments were found for this message.