PDA

View Full Version : Retrieving infos from multiple PICs on a bus/chain



flotulopex
- 14th October 2007, 09:09
Hello,

I'm building up a system using twenty-two PICs ("sensor") connected to one PIC ("master").

The distance between each "sensor" PIC is two meters so the bus or daisy-chain will be around 25 meters long, end-to-end to the "master" PIC.
<img src="http://www.picbasic.co.uk/forum/attachment.php?attachmentid=2084&stc=1&d=1192348044">
The "sensor" PICs control photodiodes and have to provide a binary value to the "master" PIC anytime it has changed. They also have to provide their ID (i.e. PIC's #).

The "master" PIC will gather and convert this info to an 0V to 10V information for the BMS (Building Monitoring System = alarm visualisation system).

Since I have a few of them in my drawer, I have chosen 10F202 PIC as the "sensor" PICs and will see if the same one can be use as the "master" one.

Question: to get me started correctly, how do I connect the PICs (I2C, SPI,..?) and how am I retrieving their information?

Jerson
- 14th October 2007, 12:29
Have you considered RS485? Looks like a suitable application for it.

flotulopex
- 14th October 2007, 12:49
Yes, but how to implement this?

Any example just for a good start?

Acetronics2
- 14th October 2007, 12:57
Hello, Roger

How are you ???

You SHOULD consider the Maxim's DS 2405 ( not expensive at all ) ... and its one wire bus.

Also could permit Bidirectionnal functionning with your Pics ... ahaaaaaa !!!

Alain

Dave
- 14th October 2007, 14:48
flotulopex, A simple oper collector transistor for each PIC output. These would be tied togeather to the bus. The master would have a resistor tied to VCC to source current to the bus. Each PIC would also have this bus line as an input. Then before the remotes transmit they would check to see if the bus is active (low) before they transmit there data. This bus structure is used in vehicles and one of the physical layer types is ISO-9141.
The standard baudrate for ISO-9141 is 9600.
Dave Purola,
N8NTA

flotulopex
- 14th October 2007, 15:36
Thanks Alain,

Good idea. But Switzerland is not like other countries: a DS2405 costs around €2.- as a 10F200 only €0,80...

Furthemore, I'll have to build some circuitry to make the Input a Schmitt trigger (wich I won't have to do with the PIC).

Thank you Dave. I was assuming the master PIC "interrogating" the slaves one would be the simplest way of doing.

BrianT
- 14th October 2007, 23:05
If all units are plugged in to a single power point then you might get away with direct connecting each device but 25 metres is getting up to the distance limits, particularly if devices can be powered by different phases of the mains along the length. The common mode problems will almost certainly bite you.

Optical isolation, RS422/485 or transformer isolation were all devised to get around this problem. The simplest/cheapest is RS485 IMHO.

If the system will have only one power supply then a direct connect system with three signalling wires is what I would use. One wire is calle ATTention, the second is ACKnowledge and the third is DATa. These three are resistively pulled high and all devices are set with their three pins as inputs. When any device wants to send it pulls the ATT line low and repeatedly sends the ID it is trying to call on the DATa line. When the selected receiver senses its address on the data line it pulls the ACK line low. The sender now knows it has a link to the desired address and now the sender repeatedly sends the message (with checksum) until the ACK line floats high which signals the recevier has got a clean message through. I just use TTL RS-232 via SERIN/SEROUT for this and it works a treat.

HTH
Brian

Jerson
- 15th October 2007, 04:42
Flotul

Here is a link to get you started on RS485.

http://www.bb-elec.com/technical_library.asp


Jerson