Networking and Communications
WEEK 13
(28/04/2021 18:12 p.m.) Wednesday afternoon. This week is a bit weird. We have had a very interesting but very complicated class on Networking and Communication, and I don´t know very clear about what we have to do. 😅😅
(29/04/2021 10:25 a.m.) During our Local Review, Adrián, Nuria and Pablo, have warned us this week is quite complex to understand and execute. Adrián has repeated to us like a Mantra the five principles that Fran Sánchez relates in his videos "Surviving Fab Academy" to have communication between our boards: Transmitter, Receiver, Channel, Code and Message. If any of these five fail ... we are lost. 😱😱
So I have to organize the rest of the week to be able to make one more board I want to use for my Final Project, and I have started looking for information on how to communicate an accelerometer with the rest of the outputs that I want to implement.
(03/05/2021 11:53 a.m.). Unfortunately, the week has been pretty bad. On Friday, I started to feel sick, I did the antigen tests and I have tested positive for COVID-19 🦠. I have spent a very regular weekend, breathing badly and a lot of discomfort 😷🤒. Also, having been in direct contact with some of my crewmates like Alberto, he has had to confine himself at home for 10 days too. Fortunately, he has no symptoms, but the virus has disrupted our regular activity during this week. 😭😭
Since I have to be confine at home for 10 days (minimum) and I have felt quite ill for the weekend, I have progressed very slowly on this assignment. (03/05/2021 17:13 p.m.). Today, I feel much better! The fever has disappeared and I only have some mucus and a cough. That is a good sign! 💪💪
Although the week has been a bit difficult, we will continue to maintain the rhythm of good attitude and positivity. So, for this week's song, we're going to start with one of my favorite bands, Connection by OneRepublic .
Can I get a connection?
Can I get, can I get a connection?
Organizing tasks
Like previous week, we have two types of assignments, one's group and other individual. So as usual, I organize my schedule and here the following Evaluation Criteria that we have to approach to complete the Assignment:
- ✓ Send a message between two projects (between any combination of boards, computers and/or mobile devices)
- ✓ Document our work
- ✓ Design, build, and connect wired or wireless node(s) with network or bus addresses
- ✓ Documented what we have learned from implementing networking and/or communication protocols
- ✓ Explained the programming process/es we used
- ✓ Explained problems and how you fixed them
- ✓ Included our design files and codes
Group Assignment
- SEND A MESSAGE FROM HELLO PIÑA! 3.0 TO THE COMPUTER
For part of the group assignment, and given the confinement situation in which I find myself, I do not have access to another project with which to test. So, as part of the debugging of my final project, I will try to get my monitor send me messages and informing me in what position I am, according to the rotation angle of the accelerometer.
Since the accelerometer measures acceleration in the XYZ axes, I am going to focus on using an axis, the one that best suits me for the movement I am going to do.
In this case I start with the X axis, and define four positions in which I am going to place my accelerometer.
For this, I will use the Hello Piña! 3.0 + ADXL 345 that I did during Input Devices week.
(04/05/2021 12:31 p.m.)To do this, I had some debugging sessions with my Jedi master Pablo 💚, who explained me some examples of how I can collect data with the accelerometer, and then use an average of values to communicate with boards and / or send messages in this case.
So the first thing I do is, make a simple data reading where the monitor shows me a sequence of numbers, which are the position of the accelerometer on the X axis, following a base code from Luis Llamas.
Here you can see the base code:
//Lorena Delgado Piña, 2021 Fab Academy, Networking and Communications week
//Hello Piña! 3.0 + Accelerometer + Computer
//Accelerometer Data read at X axis
//Code modified by Lorena Delgado Piña
#include SPI.h
#include Wire.h
#include SparkFun_ADXL345.h
ADXL345 adxl = ADXL345();
void setup()
{
Serial.begin(9600);
Serial.println("Begin");
Serial.println();
adxl.powerOn();
adxl.setRangeSetting(16); //Define the range, values 2, 4, 8 o 16
}
void loop()
{
//read the values and print it
int x, y, z;
adxl.readAccel(&x, &y, &z);
Serial.println(x);
delay(500);
}
Once the code is loaded, I begin to test the data provided by the accelerometer according to each of the positions that I have defined.
In general, depending on each of the positions, you usually see an average value that is constantly repeated and varies around ±2 as a movement margin.
So, what I'm going to do now is integrate some position variables in the new code, which will be the simulation of my future body postures. Here you can see the code:
//Lorena Delgado Piña, 2021 Fab Academy, Networking and Communications week
//Hello Piña! 3.0 + Accelerometer + Computer
//Code made by Lorena Delgado Piña
#include SPI.h
#include Wire.h
#include SparkFun_ADXL345.h
ADXL345 adxl = ADXL345();
//accelerometer values
int xposition0 = -33;
int xposition1 = 2;
int xposition2 = 35;
int xposition3 = -24;
int margin = 2;
void setup()
{
//accelerometer
Serial.begin(9600);
Serial.println("Iniciar");
Serial.println();
adxl.powerOn();
adxl.setRangeSetting(16); //Definir el rango, valores 2, 4, 8 o 16
}
void loop()
{
//leer los valores e imprimirlos
int x, y, z;
adxl.readAccel(&x, &y, &z);
//Si el valor de accelerometro conincide con la posicion cero, se encienden en rojo)
Serial.println(x);
if (x > xposition0 - margin && x < xposition0 + margin){
Serial.println("POSITION ZERO");
} else {
if (x > xposition1 - margin && x < xposition1 + margin){
Serial.println("POSITION ONE");
}else {
if (x > xposition2 - margin && x < xposition2 + margin){
Serial.println("POSITION TWO");
}else {
if (x > xposition3 - margin && x < xposition3 + margin){
Serial.println("POSITION THREE");
}else {
Serial.println(",");
}
}
}
}
delay(500);
}
Once loaded, I start to test with the accelerometer and when I perform the movements, the monitor sends me messages telling me what position of the exercise simulation I am in 😍:
Individual Assignment
UART COMMUNICATION (SERIAL BUS)
(29/04/2021 10:17 a.m.) For this assignment, it has been a bit complex to understand and explain how communications work and the different protocols exist. 😅
As we are quite inexperienced and Adrián, Nuria and Pablo have already warned us of the complexity this week has, we have started in spirals!, first trying to understand how one of the simplest communication protocols works, UART communication.
It is a simple serial and asynchronous communication protocol where a host communicates with an auxiliary device through two data lines, one that transmits, or Transmitter (Tx) and another that receives, or Receiver (Rx).
This type of communication is crossed, so, the transmission of information from the host, master or bridge (Tx), has to be received by the following auxiliary devices (or nodes) through its receiver (Rxn). And these devices, must connect its transmission pins with "the mother" or master receiver pin to close the communication.
To understand it better, I have made some diagrams to better know how the physical communications are between the devices that we want to connect:
(29/04/2021 10:49 a.m.) During our local review, on Thursdays, we were doing a review on how to carry out communications and Pablo showed us Adrián´s work did during the past year to make the physical connections. As some of the communication pins we have incorrectly oriented to use the Serial Bus cable 😅, Adrián has advised us to use Dupont cable, to succeed in this assignment.
The first thing we did during the review was to do a very illustrative practical exercise in Tinkercad, following the guidelines of this tutorial made by our Jedi master, Pablo💚. He explains us how asynchronous communication is and how are the codes used to communicate (in this case) four Arduinos One with each other. Here you can see the practice exercise I did:
Following the outlines of I have explained before, this is the type of physical connections that I have to make, and embed its corresponding code on each Arduino boards. These simple codes are very helpful to understand some language and programming concepts, which will serve us in the future for communication between our boards.
- COVID SITUATION (HOME CONFINEMENT)
So, please, stay save! Not only for you, for your family, for your friends, your instructors, your crewmates... for everyone. Its our responsability! ☘☘
- FIRST TEST SERIAL BUS COMMUNICATION
(03/05/2021 18:13 p.m.) As I have explained to you before, after the situation in which I find myself, I have gradually progressed in parts of this assignment. So with the last boards that I had available and working, I have drawn graphically how are the connections and communications I want to make between my boards.
As I am going to use my latest microcontrollers (ATtiny 1614 and 412), to program the code on each of the boards we will need the Serial UPDI connector we use from Adrianino's 🦋 documentation . To connect the Nodes with my bridge, as I placed bad the serial bus pins on my previous boards 😅I have to use Dupont cables to connect from the serial bus. In such a way that this is the color distribution:
GREEN = RX
BLUE = TX
YELLOW = VCC
ORANGE = GND
Using as an example the code that Pablo left us in his tutorial, I do the first debugging about communication programming between the boards, changing the name of the pins for corresponding ones to the LEDs of my different boards and uploading the code.
Finally, here you can see how it works when connecting my FTDI with the serial communication between my boards 🤗:
- ACCELEROMETER ADXL345 COMMUNICATION TO TWO NODES
(14/05/2021 11:27 a.m.) Already recovered and with all the forces recovered 💪, following the scheme of my first communication tests, I am going to incorporate into the equation the tests that I have done with the accelerometer for the group assignment, but this time the nodes will tell me if I am in the correct positions.
So, following the first sketches, I am going to make my Hello Piña! 3.0 send information that the accelerometer measures to the nodes, to indicate if it is in the correct positions the accelerometter. In this case, I will program only the zero and one positions.
So, following the example of Pablo´s tutorial and what my Jedi master explained to me well during my confinement, I prepare the Accelerometer Master Code + Node 1 Code + Node 2 Code. ino.
And I program one by one, each of the codes in the Hello Piña!´s ...
It seems all very easy, right?
Illusions! 🤣🤣🤣
What would one of my electronics and programming assignments be without some of my usual stupid dramas or glitches?
A few minutes ago, before I could successfully program the Hello Piña! 4.0 that I did in Output Devices week, as soon as I connected the Serial UPDI to the board, the N-Mosfet and the Zener Diode returned to give problems like two evil villains looking for revenge 😈😈. Such was their rebellion, that from the heat they generated they desoldered themselves 😱😦.
Why?!?! That's a good question. 🙃😅
However, as it did not intend to connect the vibration motor but to turn on the led, my main concern was whether the ATtiny 412 was still alive. So, quickly load up a quick Blink example, and luckily it's still alive!!! 🎉🎉
After this little mishap 😅, I connected my boards via serial bus and Dupont cables.
When connecting the FTDI to my master board, the accelerometer, according to the position it was in, the nodes sent signals to one board or another, thus verifying that it was in the correct positions 😍😍. Here you can watch a short video making the communications:
HELLO LIGHT PIÑA! 4.0 (RGB LED)
(29/04/2021 13:49 p.m.) For this week, one of the things I wanted to communicate was to introduce in my final project some board with RGB or neopixel LEDs that would communicate with my accelerometer depending on the position of my arm when doing the exercise.
During Thursday, I designed the second version of Hello light Piña 4.0!, following Neil's schematics in Output Devices week. This is the final schematic of my Hello light Piña! 4.0 Schematic + Board :
And there are the files of Hello Piña! light 4.0 Traces. PNG and Hello Piña! light 4.0 Outlines. PNG :
(20/05/2021 12:37 p.m.) The Hello Piña! 4.0 (RGB LED), finally I did not get to mill it and program it. At first I thought that for my Final Project I was going to need to make communications between three boards: one incorporated an accelerometer, another the RGB LEDs or a neopixels strip, and another incorporated the vibration motor. But speaking with Adrián, he told me in my case it was not necessary to do networking for the type of inputs and outputs I wanted to connect. And I can connect them all with an ATtiny 1614.
So, during these next weeks I have dedicated fully to Project Development and Electronics Design and Production, and I have not been able to test this board. However, it is still a job that I have done during this week, so I want to test and document better this part in the future.
FILES
SEND A MESSAGE FROM HELLO PIÑA! 3.0 TO THE COMPUTER
FIRST TEST SERIAL BUS COMMUNICATION
ACCELEROMETER ADXL345 COMUNICATION TO TWO NODES
HELLO LIGHT PIÑA! 4.0 (RGB LED)
REFERENCES