NETWORKING AND COMMUNICATIONS


TASKS TO DO-
Design and build a wired & /or wireless network connecting at least two processors
send a message between two projects



In this week we have to talk between two/more microcontroller boards. This can be either a wired or a wireless connection.This is known as embeddeded communcation.Communication is a major topic which is used in most of the products where there are different MCU units doing different tasks and they need to be communicated internally. For communication there needs to be transmitter and receiver.Coming to communication it can be synchornous and asynchronous communication. In synchronous communication the sender and receiver used the sam clock signal while in asychronous a synchronizing signal is rend to the receiver before sending the message. According to the data send communication is mainly generalised into two main categories:
1)Parallel communication
2)Serial communication

Parallel communication


In parallel communiation ,multiple bits are transfered at the same time.Data transfer is in huge.Usually more wiring needed.It is widely used in memory devices.

Serial Communication


In serial communication,data are send as a bit a time.Uses very less wires.


parallel and serial communication

Communication Protocols

Communication Protocols are aa system of rules that allows two or more entities of the communication system to transmit information via any kind of variation of a physical quantity.They include authentication,error detection and correction and signaling.There are two main categories in this:

1)Inter system Protocol

Inter Sysytem protocol is used to communicate between two devices like a communication between a computer and microcontroller.It uses a dedicated bus for communication.

Different Types of InterSystemProtocol are :UART,USART and USB protocol.

UART communication


The UART communication is asynchronous by nature. This means data is transmitted asynchronously, from the Tx pin of the UART transmitter to the Rx pin of the UART receiver. There is no clock signal used to synchronize the output. Instead, the UART transmitter makes use of start and stop bits along with the data packets.The receiving and transmitting UARTs should function at the same baud rate. Even if the baud rate between the UART transmitter and UART receiver was to differ, it shouldnot vary by more than 10 percent.

2)Intra system Protocol

Intra Sysytem protocol is used to communicate between two within a circuit Different Types of Intra SystemProtocol are :I2C,SPI,CAN protocol etc

I2C communication


I2C or IsquaredC (Inter integrated circuit) is a synchronous serial computer bus communication.It was implemented by philips. I2C bus has two wires one for clock, and the other is the data line, which is bi-directional.I2C uses only two wires: SCL (serial clock) and SDA (serial data). Both need to be pulled up with a resistor to +Vdd. There are also I2C level shifters which can be used to connect to two I2C buses with different voltages.


Assignment


UART- Assignment 1

I have made an attempt to know about UART and I2C communication.Likely to implement both according to the time constraints. An assignment in my mind is to use input week assignment using a SONAR To take reading from a SONAR and light the led in the other board according to the varying distance which I had already done in that week but want to know how it will work between two different boards.

I have milled 2 Attiny 44 boards with same design but no pinout for SDA and SCL. I have checked for fuses and the boards are working.The next 2 days are holidays here and I am already lagging for this week,so I plan to take these board home and test it. I took some female to female connector wires and along with me.


I wanted to try sonar and led combination for communication but I2C is not working.I think two tiny44 can work in I2C communication and beleive some problem with my arduino version .So I need to check with the Rx,Tx,communication(UART).


wiring photos

In This the sender and receiver are Attiny and here while connecting I noticed something wierd!.The resistor I kept for the leds are 499 Kohm and not 499 ohm. Also I dont have anything with me to change,there is no chance for the led to light.

To my rescue I remembered about the RGB led module that I have and the whole lot of pins here out.For one second I just got panic and came back to my normal. After connecting the RGB module with female jumper wires to the Tiny board I tried burning a code for different distances measured by sonar in one board send different data for different distance and in the other for this input this colour led to be lit.

The wiring is as follows: Sender Attiny 44:
A2 connected to Triger pin of Sonar sensor,
A3 Connected to Echo pin of sonar sensor,
Receiver Attiny 44:
TX pin connected to RX sender Attiny ,
RX pin of Atiny connected to Tx pin of sender.
Both the boards have GND in common.
The code is given below:

Sender CODE
Receiver CODE

It worked from the very first time and here is the working video of it.


I2C -Assignment 1

Next I wanted to try the I2C communication which I am doing after some days ,so after reaching the lab I told my collegues about this.Most of them have used two different IC's (Mega and tiny)for I2C communication.So they told me to use another IC.I reffered some previous year pages and decided to make a Board with ATtiny 45 to work as slave.Here is the Design of the board.



After soldering the components I took the board and started testing.By the time EBY told about wire.hlibrary can both work for slave and master.He has downloaded one and used it.So I think had a doubt for my arduino version of my pc therefore borrowed his laptop for some time.

I first had an idea of having all my tiny45 boards communicating with a master tiny44(with the overconfidence of reading more on networking and communication). Later decided to use my Tiny44 as master and Tiny 45 as slave.It took me some time to get the connections done properly.First I got a trial run testing the two boards.Wrote a code to check i.e., when a data is send ti slave from master the led of the slave blinks.
MASTER CODE

For the master the SDA and SCL Pins are internally pulled up. Receiver CODE

Here you can see the working video.The led was green and has less visibility:


I2C -Assignment 2

And now I have seen a PIR sensor with Abhilash which he used for his input week assignment,therefore I borrowed it and gave it a try. A PIR sensor connected to the master and the code is written is such a way that when a motion happens,the master led lits up and the slave led blinks.


Connection picture

Connection picture

MASTER CODE

For the master the SDA and SCL Pins are internally pulled up. Receiver CODE

The communication is working but still there is a small delay happening in between the two processors.Master led lights up and slave responds after few seconds. Amith was disturbing the PIR sensor by making motions and he kept on making motions with hand. The working video is given below: