Networking and Communications

This week is about making the boards talk to each other, so we were assigned to design and build a wired &/or wireless network connecting at least two processors.

Designing the transmitter:

I started this assignment by taking Neil's bridge board and modifing it a little bit by adding a button to PB1, so that I can control the output in the other board using it. I used kokopelli to modifiy the board as am always using it in designing my boards. and then I took the board from the Electronics design week that I designed to act as the node board. Below is Neil's Board.

The board after my modification.

Producing the transmitter board:

Now it was time to mill the board and to stuff it, so I exported the traces png image and the outline png image and imported them to fabmodules to calculate the toolpath and start milling using our Roland SRM-20.

And now it was time to stuff the board, so I started as always by sorting all of the needed components and later on solder them to the board.

Making the receiver:

As I mentioned befor I used the board that I designed and produced during week6. Now that I have the two boards ready - on the left the receiver and on the right the transmitter, it was time to make them Communicate.

The first thing I did was taking Neil's hello bus code and modified it a little bit so that I can use it with my boards.

Making the protocol:

The next day after the lecture Francisco gave us a breif lecture about Networking and during that he told us before starting to design or programme anything for this week we need to make a protocol that will be later on implemented into code when we start programming the boards. So for example lets say that I have two boards. The first one Board M and it has an LED, and the second Board is S and it also have an LED. In order to to switch the LED ON the board must receive the letter N, and to turn the LED OFF the board must receive L. Now if you send MN, the LED on the M board will be ON, and if you send SN the LED on the S board will be on. To turn OFF the LED on the S board you have to send SL, and so on.

My protocol to address the identity will be even much simpler, because I have only one function and am using the same letter for addressing and for the function, that will send the letter M from the transmitter to the receiver to toggle the LED. And only because the receiver has this letter "M" as identity it will only perform this action.

Understanding Neil's code:

In his code Neil implemented the serial Communications by creating functions, like get_char() to obtain the character using the Rx pin, and put_char() to send the character using the Tx pin. I will be able to send and receive character using these functions.

Programming the transmitter:

Now in the code the first thing I did was to define the pins according to my board, so Tx & Rx pins are the same, as this is Neil's Board in the first place, but I defined the Button that I added.

DDRB &= ~(1 << PB1); // set PB1 as input in DDRB After that in main loop I modified the code so that if the button is pressed it sends the character 'M'.

Then I used the FTDI USB to serial module to read what am sending using the arduino serial monitor.

Programming the receiver:

As I mentioned above I took the board from electronics design week to act as the receiver.

The next step was to programme the receiver so that it receive the character 'M' and toggle LED , so I took the same code and started modifing it, the first thing I did was to define the Tx, Rx and the LED according to my board. After that in main loop I modified it using the get_char function and the if statement that if it receive the character 'M' it will toggle the LED which means alternating the state in which the LED is in; if open, close it and if close, open it. and then I uploaded the code to the board.

Connecting both boards togather:

I was ready to connect the boards togather, so I connected the boards using female connectors, GND to GND, VCC to VCC and Tx to Rx. I powered the two boards using the Fab ISP that I created during week4, and also to programme both boards. What you will see in the following video is both boards working togather, so if I pressed the button on the transmitter board it will toggle the LED on the receiver board.

Previous Week |-----------| Next Week

Home Page

Attachments:

transmitter code

makefile - T

receiver code

makefile - R

kokopelli file - T

kokopelli file - R