14 - networking & communication

hello serial bus

This time  I worked with serial bus, made by 3 boards, 1 Bridge and two Nodes.
Basically the computer can talk to the Nodes thanks to the Master (bridge) that is in the middle.
All these boards are identical (with the exception that inside the Bridge there is the FTDI header to connect the network to a computer)  and also their code is identical, but each gets its own name (0, 1, 2).

So, I milled those board and stuffed them with all the components:

x1 Bridge [board - traces - outline] and [x1 ATtiny 45, x1 Resistor 10k, x1 Resistor 1k, x1 Capacitors 1uf, x1 jumper with 4 pins to which I will connect the cable that allows the board to communicate between them,  x1 LED, x1 jumper with 6pin necessary to program it with USBTiny and 6pins for FTDI cable)

x2 Nodes [board - traces - outline] and [x1 ATtiny 45, x1 Resistor 10k, x1 Resistor 1k, x1 Capacitors 1uf, x1 jumper with 4 pins to which I will connect the cable that allows the board to communicate between them,  x1 LED and x1 jumper with 6pin necessary to program it with USBT

Before flashing this code , I had to edit the file "hello.bus.45.c" with the program Notepad + +, in order to give a different identity onto each board.


So, in the line

"#define node_id '0'",

I changed the number 0 with 1 (and then 2, as shown in the previous picture), i.e. the number that define one of the two nodes. I saved the file and I flashed it on the first node with the FabISP:

"make-f hello.bus.45.make program-usbtiny"

I then repeated the process for the second node, saving the notepad's file again but without changing the name (otherwise I think the code does not work).

NB:the bridge is also a node, and I defined it with "0"

At this point I was ready to test my serial bus. So I connected the boards with a cable and then plugged the bridge into the computer. Then I opened the Serial Monitor window in the Arduino IDE (which is located inside Tools - set 9600 baud) in order to communicate with all the boards.
What happens now?
Everytime I type a number between 0,1 and 2 and press enter, there is a general blink in all the boards'LED (which proves that there has been a first step of information). Then there's the blink of the node I have chosen (in response to the number that I typed).

Since the blink was quite fast, I decided to to change the timing ot the comunication.
I opened again the file "hello.bus.45.c" with Notepad++ and I changed the line

#define led delay() delay ms(100) // LED flash delay

into -> #define led delay() delay ms(1000) // LED flash delay

I've flashed again the c code on my second node (as I did before with FabISP and cmd) and by now it will always blink longer than the others, look:

Serial Bus - Embedded Networking and Communications from Lorenzo Negri on Vimeo.

Published on   July 1st, 2013