14. Networking and communications¶
Assignment¶
- Design,
- build,
- and connect wired or wireless node(s) with network or bus addresses
Challenge¶
I want to connect my nodes using only two wires, that will be used for communication and power supply.
Looking for a reference design, I found a document from Texas Instruments named RS-485 Power Over Bus. In the schematic, the RS-485 lines are isolated with 10µF capacitors and the power line is isolated with inductors (from 100µH to 1mH, depending of the distance between nodes).
PCB¶
The PCB is designed around a MAX485 module that I bought on eBay.
I had no inductors, only ferrite chokes (8-10µH). And the 10µF capacitance seemed a bit too high for me, so I used 1µF bipolar electrolytic capacitors.
I knew that it would be safer to isolate the bus power from the main supply (USB power in this case) so I added a DC-DC converter. I soldered it on the first (powering) board and I replaced it with a diode on the second (powered) board.
EAGLE files¶
EAGLE schematic and board files are archived into MAX485.zip
Testing¶
I tested simplex transmission with a one meter wire pair and a 10 meter twisted pair, it worked for 9600bps and higher baud rates. But some characters were received as a different character.
For example, sending a zero would always return a eight. This is how the signals looks at the input/output of the MAX485 transceivers :
Left picture is for the eight character and right picture is for the zero. The lower trace is the output (transmitter) signal and the upper trace is the input (receiver) signal.
Looking back to the Texas Instruments doc, it’s said that Manchester encoding is a common way to eliminate the DC portions of a data signal. So I searched for an Arduino Manchester Encoding library.
I tried the example codes from the library but it did not work. I mean, it worked when the TX pin is connected directly to the RX pin (and not with any baud rate) but I couldn’t receive anything when transmitting through the RS-485 transceivers.
Back to the oscilloscope, I looked at the signal coming from the RS-485 transmitter and it seemed quite curved.
Then I decided to replace the ferrite inductors with a larger inductance (220µH), as shown in Texas Instruments’s schematic.
It did not worked with Manchester encoding so I tried transmitting simple serial data from a FTDI adapter to another. It only worked with the higher baud rate (921.6kbps) in Tera Term serial port setup. In fact it worked perfectly, without any corrupted characters. But I kow that the ATtiny (running at 20MHz on my HelloBoard) can’t reach such a fast data rate.
So I guess I should have followed Texas Instruments’s schematic and use a larger capacitance.
Not a challenge…¶
…But it works. My attempt do do communication with power over bus was time consuming so I paused it. In order to complete the assignment, I edited the C code from week 9 to make my HelloBoard switch from a LED to another when it receive a 0/1 character, and send a 0/1 character when it’s button is pushed :
It use software serial communication at 9600 baud, with pin PA0 as RX and PA1 as TX. The 0/1 character is sent as a single byte and the software automatically switch between zero and one anytime the button is pushed.
The push-button is wired to pin PB2 (as an input with internal pull-up) to trigger INT0 interrupt on a falling edge.
LEDs are wired to pins PA2 and PA3.
Device and target addresses must be defined in the C file before compiling.
C file¶
The code I used is hello.duplex.id.c
Makefile and compiled binaries are archived into hello.duplex.id.zip