Presentation
Project management
Computer-aided design
Computer-controlled cutting
Electronics production
3D scanning and printing
Electronics design
Molding and casting
Embedded programming
Computer-controlled machining
Input devices
Composites
Interface and App. programming
Output Devices
Networking and comunications
Mechanical Design
Machine Design
Applications and Implications
Invention, Intellectual Property
Project Development
Final Project Presentations
Extra Project
Links
http://ricardoorg.dx.am/
presentation contact

Networking and Comunications

In this assignment i decided to work the comunication between arduinos. In the example i made it with Arduino Uno, but i can make the same example with our own developed arduino that were made here in Fablab Lima by Cristian Cisneros.

The first part was to understand how the comunication between two arduinos works, everthing i learned from the tutorial of Satoshi Itaya.

This image explains that there are two things to comunicate SDA (clock to send sincronization) and SCL (used for sending data) the data will be sent to all slaves but only the slave that should receibe the data will answer a confirmation and will process the data. The most important thing here is to understand the process of comunication:

This steps i wrote on C language using the plattform of arduino, for this i had to include this:

This is the Master Programm

#include <avr/io.h> // this is for using IO registers ej DDR , PORTD etc.
#include <util/delay.h>
//initializer

void setup (){

DDRB= 0xff; // all Pin B is output mode
PORTB= 0x00; //all Pin B is low

TWSR= (1<<TWPS1)| (1<<TWPS0);
TWBR = 0xFF;

//This would be the same to write
// TWSR = 0b00000011;
// TWSR = Ox02;

}

// loop process
void loop (){

// start comunication
// send start signal
TWCR= (1<<TWINT)|(1<<TWSTA)|(1<<TWEN);
// TWCR= Ob10100100;
while (!(TWCR&1 <<TWINT));
_delay_ms(1);

if ((TWSR & 0xf8) == 0x08){ /// mask

TWDR = 0b00000010; //set slave adress
TWCR = 0b10000100; // update flag
while (!(TWCR&1 <<TWINT));
_delay_ms(1);
if ((TWSR & 0xf8) == 0x18){

TWDR = 0b10101010; //send data
TWCR = 0b10000100; // update flag
while (!(TWCR&1 <<TWINT));
_delay_ms(1);
}
}

TWCR = 0b10010100; //close comunication
_delay_ms(2);
PORTB= 0xFF;
}

 

And this is the Slave Programm:

#include <avr/io.h>
#include <util/delay.h>void setup(){
DDRB= 0xff; // all Pin B is output mode
PORTB= 0x00; //all Pin B is low

//adress setting

TWAR = 0b00000010;
}void loop() {

TWCR = 0b11000100; //
_delay_ms(1);

if ((TWSR & 0xF8) == 0x60){ //check ack response
while(1){

TWCR = 0b11000100; //waiting for data

while (!(TWCR&1 <<TWINT));
if ((TWSR & 0xf8) == 0x80){ ///check the ack
char data = TWDR;
PORTB = data;
}

if ((TWSR & 0xf8) == 0xA0){ ///check the ack
break;
}
}
}
}

This is the data master and the slave adress signal on osciloscope:

To be show the process of comunication i put a LED:

I made this with Arduino uno but, that was because i was not finished my own arduino component, so after a few weeks I finished my assignment i built the fab arduinos.

Repeating the same process with this new arduino would be the same. So I discover that i can also create my own arduinos!! and are much more cheap. Unfortunatly the video using my own arduinos has a mistake and the arduinos are no more working.

This are two new arduinos, the first is fab io and the other is a local designed arduino. Fab io had many problems and the documentation is false in many photos, schematic and board are different on the documentation. The other arduino i used for final project and no more for networking because i did just one.

Then i followed the Tutorial: Networking Hello Bus by Anna Kaziunas.

The idea here is to network the boards so i downloaded the boards, png to make the circuits.

Then i programm it on a macbook because on windows i heard some problems of other fabbers...

 

 

 

 

© copyright 2013 Web Design by Ricardo Torres Aragón