Electronics > Projects, Designs, and Technical Stuff

Create a "small network" of devices

(1/1)

Moriambar:
Hi,
I currently have a project on-hand and I need to determine how to connect it in order to communicate.
First of all the network is composed by:

* 17-20 boards with an ATTINY 45
* a PN532 nfc reader
* an arduino nano as a main board
The basic functionality is:

* the pn532 reads a card and signals it to the nano
* the nano determines which one oh the tiny boards (2 per time) has to activate
* the configuration after 5s a new input can be provided
I actually am not interested in the code, but in how to link the boards together. Each one of the 17-20 boards have an average distance of 1m from the nano, while the pn532 is 0.6m far. The maximum board distanca is ~2m. all of it will be installed in an electronically quiet environment (nothing else will be influencing the circuit).

Since I found it a really simple protocol (with many already available libraries), I was thinking about connecting all of the boards through an i2c bus. This would simplify greatly the wiring, the pin usage (I usually have 2 pins available per tiny board), and the programming time (I know and used i2c a lot). I never used that protocol over such a long bus, though. Is it viable? Do you think I have better solutions? After all I am still a beginner and I'd like to learn.


cheers

dom0:
~20-30 meters of cable on a single I2C will not work too well, but there are I2C repeater chips. If I understand correctly, you have a star topology? If so, you can use a couple of those repeaters in the center (at the star) to segment the bus into smaller pieces.

If this were larger, or more like a daisy-chain, then RS-485 would be a very sensible idea.

Moriambar:

--- Quote from: dom0 on May 20, 2019, 02:59:49 pm ---~20-30 meters of cable on a single I2C will not work too well, but there are I2C repeater chips. If I understand correctly, you have a star topology? If so, you can use a couple of those repeaters in the center (at the star) to segment the bus into smaller pieces.

--- End quote ---

Thanks for your reply. Yes it is a star configuration. I thought of splitting the net into 5 subnets (4 boards each), which will cut off drastically the total length of the single net segment. I did this mainly to organize the wiring, but I can also do it with this in mind. Do you think that this way could be more reliable?


--- Quote ---If this were larger, or more like a daisy-chain, then RS-485 would be a very sensible idea.

--- End quote ---

Hmm, I don't need it for this project, but perhaps it could come in handy in the future. Do you know a good place to start for a kinda beginner?


Cheers!

mariush:
If you can manage two wires for each device, you could read one bit at a time from devices easily.

You have data and clock / next bit for each chip.

The data wires from all 20 devices can go into 3 x 8 bit parallel to serial shift registers linked together.... Or you can use a port expander IC which creates additional IO pins and you can connect that chip using i2c or SPI.

You can do the same for the clock/bit wires just have 3 8 bit serial to parallel shift registers (or two 16 bit, or one 24bit shift registers)

To read data from a particular device, set the bit for that device high,shift data into the shift registers, then enable the shift registers. You get your 24 bits (for 3 x 8 bit shift registers) sent to all devices.
Only the device you want gets a digital 1 (bit set).
Device sees the digital 1 and puts a bit on the data wire.
you wait 5-10ms or whatever you think it's enough, and then read the data bits from the shift registers.
set all clock bits to low, wait a few ns, then set the bit to high again to get the next data bit through the data wire.
Repeat 8 times or 16 times or whatever, as much as you need

An 8 bit shift register (serial to parallel) is less than 0.5$ for easy DIP package, here's an example: https://www.digikey.com/product-detail/en/texas-instruments/SN74HC595N/296-1600-5-ND/277246

IO Port expanders are cheap, and work both ways, input or output

PCAL6416APW 16 io pins, i2c connection to your nano :
https://www.digikey.com/product-detail/en/nxp-usa-inc/PCAL6416APW118/568-9922-1-ND/3677048
https://www.digikey.com/product-detail/en/nxp-usa-inc/PCA6416APW118/568-9911-1-ND/3677037

MCP23017-E/SP  if you want DIP package , 16 i/o pins read/write through i2c : https://www.digikey.com/product-detail/en/microchip-technology/MCP23017-E-SP/MCP23017-E-SP-ND/894272

With the MCP23017 you can have up to 8 of them on the i2c bus, so you could have 2 of them for the data input and 2 of them for the clock signals and you can handle 32 devices.

Moriambar:

--- Quote from: mariush on May 20, 2019, 03:54:14 pm ---If you can manage two wires for each device, you could read one bit at a time from devices easily.

You have data and clock / next bit for each chip.

The data wires from all 20 devices can go into 3 x 8 bit parallel to serial shift registers linked together.... Or you can use a port expander IC which creates additional IO pins and you can connect that chip using i2c or SPI.

You can do the same for the clock/bit wires just have 3 8 bit serial to parallel shift registers (or two 16 bit, or one 24bit shift registers)

To read data from a particular device, set the bit for that device high,shift data into the shift registers, then enable the shift registers. You get your 24 bits (for 3 x 8 bit shift registers) sent to all devices.
Only the device you want gets a digital 1 (bit set).
Device sees the digital 1 and puts a bit on the data wire.
you wait 5-10ms or whatever you think it's enough, and then read the data bits from the shift registers.
set all clock bits to low, wait a few ns, then set the bit to high again to get the next data bit through the data wire.
Repeat 8 times or 16 times or whatever, as much as you need

An 8 bit shift register (serial to parallel) is less than 0.5$ for easy DIP package, here's an example: https://www.digikey.com/product-detail/en/texas-instruments/SN74HC595N/296-1600-5-ND/277246

IO Port expanders are cheap, and work both ways, input or output

PCAL6416APW 16 io pins, i2c connection to your nano :
https://www.digikey.com/product-detail/en/nxp-usa-inc/PCAL6416APW118/568-9922-1-ND/3677048
https://www.digikey.com/product-detail/en/nxp-usa-inc/PCA6416APW118/568-9911-1-ND/3677037

MCP23017-E/SP  if you want DIP package , 16 i/o pins read/write through i2c : https://www.digikey.com/product-detail/en/microchip-technology/MCP23017-E-SP/MCP23017-E-SP-ND/894272

With the MCP23017 you can have up to 8 of them on the i2c bus, so you could have 2 of them for the data input and 2 of them for the clock signals and you can handle 32 devices.

--- End quote ---

Thanks for your suggestion. What is the advantage of this solution over the i2c? Is it just about "cutting the length of the bus"?
I like it a lot, if that's the case and it's more robust than the "naked" i2c.

thanks

Navigation

[0] Message Index

There was an error while thanking
Thanking...
Go to full version
Powered by SMFPacks Advanced Attachments Uploader Mod