PDA

View Full Version : pic as 1-wire Slave



HanSolo
- 10th July 2008, 17:21
Has anyone been successful in getting this to work?
I have spent hours on this but no success. This is more difficult than it first appears. You must create a 64bit id and generate valid crc. What I would like to do now is find some kind of bridge from my pic to the 1-wire network. Does anyone know what would work?
I am still interested in making a 1-wire slave from a pic also.

skimask
- 10th July 2008, 20:20
Has anyone been successful in getting this to work?
I have spent hours on this but no success. This is more difficult than it first appears. You must create a 64bit id and generate valid crc. What I would like to do now is find some kind of bridge from my pic to the 1-wire network. Does anyone know what would work?
I am still interested in making a 1-wire slave from a pic also.
A search on "1-wire slave" doesn't bring up a lot, at least nothing finished...

http://www.maxim-ic.com/appnotes10.cfm/ac_pk/1
has a bunch of good notes..
as does
http://www.maxim-ic.com/appnotes.cfm/appnote_number/126

manwolf
- 11th July 2008, 01:34
Might be something of use here also.

http://www.melabs.com/resources/samples.htm

BobK
- 11th July 2008, 11:31
Hi HanSolo,

You basically have 1 wire that would be used for bi-directional communications. Several years ago I made 2 annunciator system2 for a customer that each had 20 PICs talking to a display panel. My idea was assisted by Steve Collins who had discussed the idea on the PIC List with several other people. His program on the ME Labs samples section "SIX PICS" is suppose to be about this idea. Steve and I discussed this concept and he got me going in the right direction.

Basically all PICs in the "network" have a pin that is set to an input. All of the slaves "listen" to the comm line. When the master wants to talk to a particular slave it sends out the slaves address and then that particular slave responds. The other slaves do nothing until their address is put out on the comm line.

My project had a BUSY line in addition to the comm line just to make sure there weren't any collisions. As long as the BUSY line was low, no other PIC could talk until the line went high again an then had to wait 10ms before talking.

All pins on the comm line are set to be inputs until one slave needs to talk to the master. Then it is made an output. When each communication is made the pin is an output then you return it to the input or high impedance state until it talks again. A resistor is in series with the comm line to prevent damage in case 2 PICs went to outputs at the same time.

Steve didn't come right out and tell me everything but he gave me enough information to get the juices flowing and I took it from there. He did say that this setup could be made to supervise each of the slaves by setting up a polling situation where the master is constantly asking each slave if it has anything to report and a code system could be setup where AAA means nothing to report and ZZZ means I need to talk to you.

Not knowing anything about what you are doing other than trying to come up with a 1-wire system I could suggest anything else for you. I made two different systems and they have been out there for 2 years now still working great.

Check the forums here as Mister E posted a simple PIC Network program using a DIP switch to set the addresses. This could also give you some ideas.

Got to go to work. Have a nice day!

HTH,

BobK

Charles Linquis
- 11th July 2008, 15:19
If you are going to use two wires, then you might as well use software RS-232 in it's open-collector, idle-high incantation. The best reason to use this protocol is the large amount of support already in PBP. RS-232 open-collector operation gives the advantages of I2C without the hassle.

In my network, I send out the slave's address, plus a command byte, plus a checksum.
When the slave decodes it's address, it sends back the slave address, the data and a checksum.
It very reliably "talks" at 38.4Kbaud across a large network. The Master is a 18F8723 running at 40MHz, but all the slaves are 18F2221's running on their internal 8MHz oscillators ! If you have a chip with a less stable oscillator, you can just run at a slower baud rate.

An additional benefit of doing things this way is that you can use the hardware receiver shift register (HSERIN). This gives you a two-byte buffer and an easy interrupt source.
Because of the interrupt and the buffer, the slave never misses any data and can do other tasks while waiting for a poll. On the slave side, you can't use HSEROUT (at least without a hardware buffer) because it isn't open-collector, but that isn't a problem.
The host can use HSERIN as well, reducing the load on that side.


I have a network "reserved" address of 253. All slave devices are initially programmed to that address. Whenever the MASTER calls that address, the command byte it sends contains the new address that I want to give the slave. That new address value is stored in the EEPOM of the slave device. The slave reads that value from EEPOM every time it powers up. I can easily program the slave address of the device that way, and no dip switches are needed. I write the device's address on a label to keep track.

Before anyone says that I'm lying about getting 38,400 baud with an 8Mhz oscillator and SEROUT2, I should admit that I'm actually using DEBUGOUT, which has lower software overhead than SEROUT2. I modified the PBP libraries to give me an open-collector output on the DEBUGOUT command.
If you don't want to modify any libraries, you can still easily get 19.2Kbaud using an 8MHz oscillator and SEROUT2.

I use 4.7K pull-ups on TRANSMIT and RECEIVE of all devices (including the host), and have no trouble across at least 25' of wire.

One final benefit: You can hook a MAX-232 to the two data lines and easily debug any communication issues with your PC.

falingtrea
- 11th July 2008, 21:26
I think Hansolo is trying to make a slave device for 1-wire. There are nice parts that Maxim is DNRing as the DS2423, that I would like to make a replacement for.

HanSolo
- 12th July 2008, 16:46
I have several ideas now. I am using a vb.net program I wrote using the DS9490 to talk to 1-wire network. If I could use serial I would but I am looking at a way to bit bang a protocal just for pic communication using a .dll. If I do this it could be a cheap way to talk to pics using a ready made usb link in the DS9490. I will post the code if I do this. I am also looking at the DS2423 but it says "Do not use for new designs".
I guess I could use a DS2405 to latch a pin on a pic then write to a memory 1-wire using master mode then read the data. This seems excessive.
Thanks for all the Ideas.

kartem
- 20th May 2011, 21:07
I found this pic 1-wire slave (http://www.fabiszewski.net/1-wire-slave/)
k