Skip to content
Snippets Groups Projects
Networking & Communications.md 4.9 KiB
Newer Older
Mitalee Parikh's avatar
Mitalee Parikh committed
##### Week of 28 April 2021
Mitalee Parikh's avatar
Mitalee Parikh committed
#### [notes](http://academy.cba.mit.edu/classes/networking_communications/index.html) + [video](https://vimeo.com/415632350)
Mitalee Parikh's avatar
Mitalee Parikh committed

Mitalee Parikh's avatar
Mitalee Parikh committed

### This Week's Assignments
1. Group assignment: Send a message between two projects
2. Individual assignment: design, build, and connect wired or wireless node(s) with network or bus addresses
Mitalee Parikh's avatar
Mitalee Parikh committed
This week's class had a lot of new information, so it was quite difficult for me to follow everything.
Mitalee Parikh's avatar
Mitalee Parikh committed

Mitalee Parikh's avatar
Mitalee Parikh committed
### The Basics
Mitalee Parikh's avatar
Mitalee Parikh committed
To understand basics of communication protocols, this [basics of protocols series on circuitsbasics.com](https://www.circuitbasics.com/basics-of-the-spi-communication-protocol) was very useful. For effective communication between electronic devices, they need to use the same language. This language is called communication protocol. Some basic protocols are *SPI, I2C and UART.* These are generally slower than protocols like *USB, ethernet, bluetooth and wifi*, but are ideal for communication between microcontrollers and sensors where the large amounts of high-speed data does not need to be transferred.  
Mitalee Parikh's avatar
Mitalee Parikh committed

Mitalee Parikh's avatar
Mitalee Parikh committed
Since I do not have access to a lab or a lot of inventory right now, I chose to understand wired communication protocols - SPI & I2C, with Arduino Unos that I do have access to. When I'm in the lab, or get more access to parts, I want to learn about the other wireless protocols too.
Mitalee Parikh's avatar
Mitalee Parikh committed

Mitalee Parikh's avatar
Mitalee Parikh committed
#### Serial vs Parallel Communication
Mitalee Parikh's avatar
Mitalee Parikh committed
While communicating, bits are transferred from one device to another by quick changes in voltage. In a 5V system, O corresponds to 0V and 1 corresponds to 5V voltage.
In parallel communication, multiple bits are transferred at the same time through different wires. Whereas in series, the bits are transferred one after the other through the same wire. The following diagram shows the difference between the two.  

![Parallel v Series Communication](./images/nc/parallelvseriescommunication.jpg)

Mitalee Parikh's avatar
Mitalee Parikh committed
### [SPI protocol](https://www.circuitbasics.com/basics-of-the-spi-communication-protocol)
Mitalee Parikh's avatar
Mitalee Parikh committed
Serial-Peripheral Interface  



Mitalee Parikh's avatar
Mitalee Parikh committed
### [UART protocol](https://www.circuitbasics.com/basics-uart-communication/)
Mitalee Parikh's avatar
Mitalee Parikh committed
Universal Asynchronous Receiver/Transmitter  



Mitalee Parikh's avatar
Mitalee Parikh committed
### [I2C protocol](https://www.circuitbasics.com/basics-of-the-i2c-communication-protocol/)
Mitalee Parikh's avatar
Mitalee Parikh committed
I2C stands for-Inter Integrated Circuit.  
Mitalee Parikh's avatar
Mitalee Parikh committed
I2C communication allows for a single or multiple masters (unlimited) to talk to a single or multiple slaves (max. 1008). It uses two wires to transmit data between devices. Since it follows series communication, it transfers bits one by one through the same wire.  
Mitalee Parikh's avatar
Mitalee Parikh committed
![SDA & SCL](./images/nc/sdascl.jpg)  
Mitalee Parikh's avatar
Mitalee Parikh committed
* **SDA (Serial Data)** - to send as well as receive data between the master/s and slave/s  
* **SCL (Serial Clock)** - sends the clock signal  
The clock signal is controlled by the master, and the data is *synchronized* to the bit sampling.  
Mitalee Parikh's avatar
Mitalee Parikh committed

Data is sent in messages. Here is a diagram of the structure of a message.
![Message Structure](./images/nc/message.jpg)

Mitalee Parikh's avatar
Mitalee Parikh committed
A pull-up resistor needs to be connected from the Master's SDA and SCL each to VCC, if there are more than one slaves or more than one masters.
Mitalee Parikh's avatar
Mitalee Parikh committed

Mitalee Parikh's avatar
Mitalee Parikh committed
Since I have access to some Arduino Unos, I tried [this guide on Instructables](https://www.instructables.com/Arduino-I2C-and-Multiple-Slaves/) to explore the communication between various numbers of masters and slaves.

Mitalee Parikh's avatar
Mitalee Parikh committed
Arduino Uno has I2C pins: **A5** is SCL and **A4** is SDA as shown in this [Arduino pinout diagram by pighixxx](https://commons.wikimedia.org/wiki/File:Pinout_of_ARDUINO_Board_and_ATMega328PU.svg).
![Arduino Pinout Diagram](https://upload.wikimedia.org/wikipedia/commons/c/c9/Pinout_of_ARDUINO_Board_and_ATMega328PU.svg)

Mitalee Parikh's avatar
Mitalee Parikh committed
#### **I2C with one master and one slave**
Using the pinout, I first made the circuit with these steps:
Mitalee Parikh's avatar
Mitalee Parikh committed
1. Connected GND of both Arduinos.
2. Connected analog pin A5 to A5 (SCL) and analog pin A4 to A4 (SDA).
Mitalee Parikh's avatar
Mitalee Parikh committed
![Connections](./images/nc/connections.jpg)
Mitalee Parikh's avatar
Mitalee Parikh committed
3. Powered up both Arduinos by connecting them to my computer, and setting the boards ands ports for both.
Mitalee Parikh's avatar
Mitalee Parikh committed

Next, writing the program for the master- Here is what the code means, line by line.
Mitalee Parikh's avatar
Mitalee Parikh committed

'#include <Wire.h>'
Includes the wire library for I2C  

'String readString;'
String used to store commands displayed in the serial monitor






Mitalee Parikh's avatar
Mitalee Parikh committed
##### I2C with one master, multiple slaves.
Mitalee Parikh's avatar
Mitalee Parikh committed

Mitalee Parikh's avatar
Mitalee Parikh committed
##### I2C with multiple masters and slaves.
Mitalee Parikh's avatar
Mitalee Parikh committed









### Student Checklist
1. Linked to group assignment page
2. Documented your projects
3. Documented what you have learnt fromimplementing networking and/or communication protocols
4. Explained the programming process/es you used
5. Outlined problems and how you fixed them
6. Included design files (or linked to)


































Mitalee Parikh's avatar
Mitalee Parikh committed

Mitalee Parikh's avatar
Mitalee Parikh committed
## Design Files
Mitalee Parikh's avatar
Mitalee Parikh committed

Mitalee Parikh's avatar
Mitalee Parikh committed
### Bridge
Mitalee Parikh's avatar
Mitalee Parikh committed
 * [schematic](./images/nc/Networking-bridge.pdf)
Mitalee Parikh's avatar
Mitalee Parikh committed
![traces](./images/nc/Networking-bridge-traces.png)
![outline](./images/nc/Networking-bridge-outline.png)  
Mitalee Parikh's avatar
Mitalee Parikh committed

Mitalee Parikh's avatar
Mitalee Parikh committed
### Node  
 * [schematic](./images/nc/Node.pdf)  
Mitalee Parikh's avatar
Mitalee Parikh committed
![traces](./images/nc/Node-traces.png)
![outline](./images/nc/Node-outline.png)