Embedded Networking and Communications
- Salem AlMarri
- Super FabLab UAE
- Last Reviewed on 15/5/2019
- Last Modified by Salem AlMarri
Introduction
In embedded networking and communications week,a wired node will be designed, built and connected to another device using serial communication.
Node - EAGLE Schematic
This node device consists of ATTiny84 micro-controller which would be programmed through an FTDI cable using the USBATinyISP.
Node - EAGLE Board
The schematic is then converted into a board and all the components were connected using routing. The DRC settings are the same as the one used in previous assignments. Adding a ground layer would make routing components to each other easier. Also same as the steps documented in the previous weeks. Adding a polygon around the components, and naming it to GND. Also in properties the isolation was set to 17.
I wanted to place a 3mm hole around the board to support packaging of the device. The 3mm holes are used in various commercial micro-controllers and single-board computers. The drills were first made visible. Then, a hole of drill 120 was placed on the board, equivalent to 3mm radius. It is important to note that RATNEST functionality must be used to show the ground layer on the board.
Exporting EAGLE Board
Top and pads layers must be shown. Using GIMP, three different schematics were made, one for milling the routes, one for milling the holes, and one for cutting the board from the copper sheet. The steps are documented in previous assignments.
Milling ATtiny84 Node Board
The milling step is also covered in previous assignments. This time it was necessary to use a sanding paper as the board was not milled neatly.
Burning the Bootloader
This step was also documented in previous assignments. Proof of burning bootloader.
LED Issue
For some reason, the LED from the two boards was not working, I was not able to identify the reason, but it worked after replacing it. The issue was verified using diode testing functionality of a multi-meter.
Communication Protocol - I2C
Inter-Integrated communication protocol is a serial communication protocol intended to allow communication between multiple slave nodes with one or more master nodes through two wires of SCL and SDA. ATMEGA328P based board was the master, and the ATtiny84 was the slave board. As a requirement the ATtiny84 board required the use of the following TinyWire library, and the ATMEGA328p used Arduino's default Wire.h library for I2C communication.
In the code, ATMEGA328P is programmed to send two different signals serially to the slave. As the master, every 500 milliseconds a different signal is sent to the slave. As the slave, the ATtiny84 acts according to the received signal, the two different signals either turn ATtiny84's LED ON or OFF.
Issues
Since the ATtiny84 board was initially powered using the fabISP, it was causing an issue were the communication was not successfully established between the master and slave. Powering the ATtiny84 from the ATMEGA328p was moving us closer to the solution. Without the following line code "Wire.setClock(10000);", the I2C communication would have not been initiated. After numerous tries and strong support from our mentors it has been concluded that the above were the most notable issues which were solved during this week's assignment.
ATMEGA328P - Master Arduino Code
#include <Wire.h> byte on = 100; byte off = 200; void setup() { //Wire.begin(); pinMode(13,OUTPUT); Wire.begin(); Wire.setClock(10000) ; } void loop() { Wire.beginTransmission(55); Wire.write(on); Wire.endTransmission(); delay(500); Wire.beginTransmission(55); Wire.write(off); Wire.endTransmission(); delay(500); }
ATtiny84 - Slave Arduino Code
#include <TinyWire.h> #define led_pin 3 byte own_address = 55; byte received; void setup() { // config led_pin as Output for driving an LED pinMode(led_pin, OUTPUT); digitalWrite(led_pin, HIGH); // config TinyWire library for I2C slave functionality TinyWire.begin( own_address ); // sets callback for the event of a slave receive TinyWire.onReceive( onI2CReceive ); } void loop() { } /* I2C Slave Receive Callback: Note that this function is called from an interrupt routine and shouldn't take long to execute */ void onI2CReceive(int howMany){ received = TinyWire.read(); if(received==100){ digitalWrite(led_pin, LOW); }else if(received==200){ digitalWrite(led_pin, HIGH); } }