Previous Page                                       Home                                                   Next Page

 

 

Week 15

Networking and Communications

 

The objective :

 

The assignment for this week is to design and build a wired or wireless network connecting at least two nodes For this week's , I decided to build a wired serial network using hello.bridge board and two boards of LED.

 


Tools :

 

Name

Uses

1

Arduino (software)

Programing

2

Eagle (software)

Designing

3

PCB copper clad board

Board Mterial

4

Hakko-936

Soldering Machine

5

UT39A

Digital Multimeter

6

Cirqoid

milling machine

 

 

WORK FLOW

 

 

1.Boards preparation:

I used Eagle for redesigning the board  As I Did in previous weeks. The designing as process  became easier than before But much complicated with this amount of elements and boards. I did the design several times  this week due many reason such as shorted circuits.

 

 

A. Master Board :

 
 


 âž”The final design that I used ( .sch .brd
 

 

 

 

B. Slave Board :

 

 




 

âž”The final design that I used for the output (.brd,sch) .





C. PCB Milling & Soldering:

After boards designing has been completed I started milling the PCB and soldering the components as shown below.



My master board and 2 slave boards after milling and soldering

 




D.Programing:








1.For the master board I use the following code:



#include <Wire.h>

void setup()

{

  Wire.begin(); // join i2c bus (address optional for master)

}

byte x = 0;

byte x1 = 0;

void loop() {

  Wire.beginTransmission(0x1);

  Wire.write(++x % 2);

  Wire.endTransmission();

  delay(5000);

  Wire.beginTransmission(0x2);

  Wire.write(++x1 % 2);

  Wire.endTransmission();

  delay(5000);

}

 

 

2.For the slave board 1 I used this code :

 


#define output(directions, pin) (directions |= (1 << pin)) // set port direction for output

#define input(directions, pin) (directions &= (~(1 << pin))) // set port direction for input

#define set(port, pin) (port |= (1 << pin)) // set port pin

#define clear(port, pin) (port &= (~(1 << pin))) // clear port pin

#define LED_PIN PB4

#define I2C_SLAVE_ADDRESS 0x1 // Address of the slave 1

#include <TinyWireS.h>

void setup()

{

    output(DDRB, LED_PIN);

    clear(PORTB, LED_PIN);

    TinyWireS.begin(I2C_SLAVE_ADDRESS); // join i2c network

}

void loop()

{

  byte recd = 1;

  if(TinyWireS.available()) {

      recd = TinyWireS.receive();

      if(recd == 1) {

          clear(PORTB, LED_PIN);

      } else {

          set(PORTB, LED_PIN);

      }

  }

}

 

3.For the slave board 2 I used the same code but I defined different address:

 

#define output(directions, pin) (directions |= (1 << pin)) // set port direction for output

#define input(directions, pin) (directions &= (~(1 << pin))) // set port direction for input

#define set(port, pin) (port |= (1 << pin)) // set port pin

#define clear(port, pin) (port &= (~(1 << pin))) // clear port pin

#define LED_PIN PB4

#define I2C_SLAVE_ADDRESS 0x2 // Address of the slave 2

#include <TinyWireS.h>

void setup()

{

    output(DDRB, LED_PIN);

    clear(PORTB, LED_PIN);

    TinyWireS.begin(I2C_SLAVE_ADDRESS); // join i2c network

}

void loop()

{

  byte recd = 1;

  if(TinyWireS.available()) {

      recd = TinyWireS.receive();

      if(recd == 1) {

          clear(PORTB, LED_PIN);

      } else {

          set(PORTB, LED_PIN);

      }

  }

}

 

5.Networking :


After programing the master and salve boards I connected them as shown in video below and worked perfectly :


 


 

 

Previous Page                                       Home                                                   Next Page