networking and communications

this is week 2 page.

Atmega328

for this week i will design a new board using atmega328 because it has more pins, and it will be usefull for my final project check the datasheet for more information about it.

atmega328.jpeg

microchip parametric

parametric

Designing New board using Kicad

In this section i will not go through all details on how to make new boards because i already did that in Electronic Design Week, so here i will go through the steps.

Step 1: Add the component

Start by adding Electronic commpnnet of your board in the schematic Editor,

save-module01
save-module01
save-module03
save-module04

Step 2 : Connect them

in this step you need to connect the component together with atmega328 pins,

schematic

Step 3 : Annotate schematic

in this step you need to annotate the component or click on the Annotate button to do the annotation. The annotator automatically replaced the question marks with numbers so that each component has a unique designator. schematic

Step 4: Assign footprint

Unlike other PCB design tools, in Kicad, schematic components are not automatically linked to a footprint. This of a footprint as the outline of a component that is mounted on a circuit board. It contains the outline of the pins, the device, and often text markings with the name of the device or its values schematic

Step 5: Generate netlist

click on Generate to generate the Netlist file. Next, choose the location for the exported file to be saved schematic

Step 6: load netlist in pcp layot

choose the file that you saved in step 5 and loaded into pcp layot

schematic

Step 7 : connect Traces

in this step you need to connect the traces of the component. schematic

Step 8: Gnd Fill Traces

Fill the empty spaces with copper and let it be connected to all GND pins, schematic

Step 9: Export as svg

Export the board as svg

s
ff

Generate tool path

Go to Mods and generate a toolpath depend on the milling machine you have schematic

for this week i was planning to mill my atmega328 board in the lab and use it in this assignment, but one of the staff got infected with covid19 and they had to close the workshop tell everyone doing the covid test, plus we had here in saudi arabia a Eid vacation start from next week.

Serial Communication

Serial communication is the most widely used approach to transfer information between data processing equipment and peripherals. I schematic

serial protocol.

The protocol is the secure and reliable form of communication having a set of rules addressed by the source host (sender) and destination host (receiver). To have a better insight, I have explained the concept of serial communication.

In embedded system

In embedded system Serial communication is the way of exchanging data using different methods in the form of serial digital binary. Some of the well-known interfaces used for the data exchange are RS-232, RS-485, I2C, SPI etc.

Data in Serial Communication

In serial communication, data is in the form of binary pulses. In other words, we can say Binary One represents a logic HIGH or 5 Volts, and zero represents a logic LOW or 0 Volts. Serial communication can take many forms depending on the type of transmission mode and data transfer. The transmission modes are classified as Simplex, Half Duplex, and Full Duplex. There will be a source (also known as a sender) and destination (also called a receiver) for each transmission mode.

schematic

Serial Vs Parallel

Data transfer can happen in two ways. They are serial communication and parallel communication.

schematic From the above diagram, for every clock pulse; the transmitter sends a single bit of data to the receiver.

schematic

Clock Synchronization

For efficient working of serial devices, the clock is the primary source. Malfunction of the clock may lead to unexpected results. The clock signal is different for each serial device, and it is categorized as synchronous protocol and asynchronous protocol.

The asynchronous interface does not have an external clock signal, and it relies on four parameters namely

Baud rate control Data flow control Transmission and reception control Error control.

1 What is Baud rate?

Baud rate is the speed of transferring data from the transmitter to a receiver in the form of bits per second. Some of the standard baud rates are 1200, 2400, 4800, 9600, 57600.

Note:
The Higher a baud rate, more data can be transferred in less amount of time.
You have to set the same baud rate on both Master and Clint’s

2 Framing

Framing shows how many data bits you want to send from the host device (Laptop) to mobile (receiver). Is it 5, 6, 7, or 8 bits? Mostly many devices, 8 bits are preferred. After selecting the8-bit data chunk, endianness has to be agreed by the sender and receiver.

3 Synchronization

Transmitter appends synchronization bits (1 Start bit and 1 or 2 Stop bit) to the original data frame. Synchronization bits help the receiver to identify the start and end of the data transfer. This process is known as asynchronous data transfer.

4 Error Control

Data corruption may happen due to external noise at the receiver end. The only solution to get the stable output is to check the Parity.

If the binary data contains an even number of 1’s it is known as even parity and the Parity bit is set to ‘1’. If the binary data include an odd number of 1’s, it is called odd parity, and now parity bit is set to ‘0’.

Asynchronous Serial Protocols

The most common question that will come to mind when you start working on the embedded system is why to use Asynchronous protocols?

Some of the asynchronous communication protocols are:

RS-232 protocol

schematic

RS422 Interface

We can transfer data only up to 1Mpbs limit using RS232. To overcome this problem RS422 comes into the picture. RS422 is a multi-drop serial interface. we can connect ten transmitters to 10 receivers at a time using the single bus. It sends data using two twisted pair cables ( differential configuration). Cable length is 4000 feet with a baud rate of 10Mbps.

serial 06

RS485 Interface

RS485 is the industry preferred protocol. Unlike RS422, you can connect 32 line drivers and 32 receivers in a differential configuration. The transmitter is also called Line driver. However, only one transmitter is active at a time.

Note: For both RS232 and RS485, you have to terminate the connection manually.


programming

After understanding how serial communication work, its time to apply our understanding practically. to do that i have started with Hello Serial Bus - Using C Tutorial i used the example hello.bus.45.c that was in the tutorial and made a modification

serial 06

1.jpeg 1.jpeg

Opened the serial monitor

then connect TX and RX of the Arduino here what you have to do

Alternately- If you don’t have / want to use the Arduino IDE,

In Ubuntu this is:

The node name (ex: node 1) should echo in on the serial monitor and the LED on the board that was flashed with the node id of 1 should flash.

Attiny85

serial 06 serial 06

Attiny45

serial 06 serial 06 serial 06 serial 06
Then i uploaded the files to the boards and connected the arduino TX , RX to bridge
1.jpeg
Opened the serial monitor

after Connecting TX and RX of the Arduino here what you have to do

Project in Action

Download Sofware

Node 0 Node 1 Node 2

Referace

How Serial Communication Work