14. Networking and communications¶
Group assignment: * Send a message between two projects. Link here.
Individual assignment: * design, build, and connect wired or wireless node(s) with network or bus addresses
Learning outcomes
- Demonstrate workflows used in network design
- Implement and interpret networking protocols and/or communication protocols
Have you answered these questions?
- Linked to the group assignment page and reflected what you learned individually of the group assignment.
- Documented your project.
- Documented what you have learned from implementing networking and/or communication protocols.
- Explained the programming process/es you used.
- Outlined problems and how you fixed them.
- Included design files (or linked to where they are located if you are using a board you have designed and fabricated earlier) and original code.
Construction of the data line¶
Handful of six pin connectors were aquired from Fablab Oulu. The connectors have the same density as the connectors of the microcontroller boards produced on Electronic production week. The connector consists of two parts.
Six pin ribbon cable was aquired from Fablab Oulu. The ribbon cable was unfortunately narrower than the connectors
The individual wires were separated for fitting the connector.
The wires were placed on the tracks in the connector. It took multiple attemps to install the connectors straight.
A flathead screwdriver was used to push the wires firmly in their correct positions.
It took some time to learn the correct way to push the wires in their pins. The pins were first pushed down inside the pin. Then the wires were locked by pushing towards the sides of the connector.
The white locking part was pushed in its position where it locked. The ribbon cable connector was installed.
The same procedure was repeated multiple times and the cable was ready.
Note that there are no termination in the bus and multiple UART devices are now conneted to the same serial bus without any glue logic. This is not recommended, especially in more serious and faster designs.
Setting up the individual nodes.¶
A USB to UART data line cable was aquired from SP-elektroniikka. (See the external link PL2303HX USB to TTL RS232 COM UART Module Serial Cable module for details and pricing.)
The cable has female ends as the connector cable has. A pin row was installed in order to change the gender of the connector. The position of the plastic part connecting the individual pins was adujsted to more robust position.
The UART module serial cable connectors were inserted in the pin row. The positions of the pins were checked from the Electronics production week documentation (The connector closer to the MCU chip, the same connector which was used at Output week to connect the LCD module.) Red color states +5V, black color ground. White and green connector are for serial communication (RX and TX, depending on the view).
The UART data cable end including the pin row was inserted in the last slot in the data bus.
I had a few extra faulty MCU cards. I fixed some shorts, changed some components, resoldered connectors and removed unneccessary components for this task. I managed to get four working boards.
Three of the boards were versions of the microcontroller board manufactured on the Electronics design week.
One of the boards was a version was not designed by me. We manufactured this board with Max as an option as a device for measuring the current consumption.
I had prepared to use more boards in the same way. There is room for five boards in the bus. Unfortunately the fifth board had a broken trace in the build-in led line. I connected the led to a pin/pad which was connected to physical pin 7 / logical pin number 4 (PA3) instead of physical pin 3 / logical pin 1 connected to the internal led. Modification to the software is required.
The correct serial port for UPDI programmer was selected and the procedure follows the embedded programming week. For programming, the cards were connected to an UPDI programmer and programmed one card at a time.
The specific changes for the card 5 (one with the external led) is shown below.
Programming the boards¶
I decided to use software given by instructor on previous years in FabLab Oulu Networking and Communications week as the basis for the networking demonstration.I found the link for the code given by instructor on Antti Rytilahti Fab Academy Networking week page. I decided to use that code for testing the bus. The code uses Arduino SoftwareSerial library (headers defined in SoftwareSerial.h).
The code defines the number of the board as its adress in the bus. When the host sends number of the board to serial bus, the board responds and blinks the led.
The number of the board is defined this way:
const char node = '1'; // network address
The led pin is also defined in the code:
const int ledPin = 1; // the number of the LED pin
The code (linked above) was compiled in Arduino IDE.
The network adrress was changed for each board. The led address was changed for the board 5 because it uses an extenal led.
After the boards were programmed, they were plugged to the bus. Ground wire of the external led on board 5 was moved to the pin previously used by programmer. This was done in order to free the second six pin connector. That connector is now used for connecting the card to the bus.
The USB to UART cable was then connected to the host computer. This computer had already the driver for the cable installed. The driver can be downloaded here.
After the cable is connected, Arduino IDE sees the card as a new serial port. This time the number of the port was 5 (COM5).
The port was selected and Serial Monitor was opened from Tools -> Serial Monitor . The Serial Monitor window opens.
I checked the baud rate setting. The window above says that the Baud rate was 9600. In the code there is a line
mySerial.begin(9600);
Both the code and the terminal window use the same Baud rate.
Testing the software round 1¶
I checked the connections and found out that the UART cable pins were connected in reverse order. I turned the pin row.
I decided to check first, if all the cards were connected to the bus.
I tested the program by pressing enter in the terminal window. Only card number 1 reacted. I switched the cards one by one to the slot where card 1 was and every board worked. Then I moved the UART connection to other slots, but it didn’t help. Cards were working, UART cable was working but there was something wrong with the bus.
A closer examination revealed, that the cable was not suitable for this kind of connectors and the connectors could not handle thicker jumper wire I also tried to use instead. Only the first two connectors were properly connected.
New bus hardware¶
I acquired new ribbon cable and suitable connectors. Female 14-pin connectors for cards and a male connector for USB to UART cable.
The new connectors could just be pressed to the bus. They consist of two parts as well, but the way the parts are connected is different. See image below.
I used the nearest table for pressing the connector to the ribbon cable.
I tested the cable before installing rest of the connectors. Green light means that the control signal from computer reached the microcontroller card.
I installed the connectors. There is room for one extra card. Before continuing testing, I decided to fasten the led to card 5 more properly with a pair of connectors. The led was pressed hard, not soldered, to the connector pins. The connector still doesn’t let the led drop off.
The connectors were tested and the boards were installed to the bus.
There is a male connector for the USB to UART cable.
Testing and modifying the boars¶
The original software with modifications discussed earlier as well as some blinking tests (different delays, etc.) was installed to the boards using the method familar from Embedded programming week. The boards were accessed from Arduino IDE serial console (Tool -> Serial Monitor). The com port number had to be switched between the programmer and the USB to UART cable when one was used. the board replied to serial console when accessed to show that the addressing worked. All the leds blinked. The video of test is below.
I modified the software so, that the leds blinked only when accessed. That required moving the original blinking under if branch that checked if the node was accessed with its address number. The video of the tests is shown below.
I also made some tests and managed to make a board to access other boards. However, accessing both the other boards and the host computer proved to be difficult, so I decided to leave the experimenting to this point. Adressing works and I made functional modifications to the code.
** Files