Networking and communications


In this week I studied different types of communication tools and there uses too.The aim of this week is to get an understanding on how to communicate between board/nodes.I will use simple communication between two boards. then move on to making a serial bus, I was trying LDR and IR for sending and recieving that signals but after that I change my plan to make samething this....

I will use brigde and node boards for sending signal to the hello word board and I will define Rx and Tx pins for recieving and transmmiting that signals.

Upto this I will complete first stage of networking.After that I will use my input board for further communication.I was downloading Neil's node board for my assignment.

Serial Communication with addresses

Here I need to have a board with provision to access the Tx and Rx pins from two sets of pins, one for connecting to the computer for debugging and the other pair for connecting to the serial bus. So I made the bridge board in Neils serial communication example, and named it node 1. I milled two node boards and one bridge board. So, my PC is master and all 3 node boards are slave.They will communicate with each other.

  • Download files
  • Firstly, I was checking connection of bridge board and node board.Actually I was uploading simple blink program in it by using ardiuno IDE for checking of board. Then I was downloading c & make file.

    As Neil said , each code has different ID. This C code said that "while (1){" --that the flash the LED in first time. Where the bridge board trasmit and recieves data from the master. In this case my computer is master and all boards which is connected to the computer are the slave.

    "if (chr==node_id){" -- that means check the character match id or not .

    "output(serial_direction, serial_pin_out)" that means check the pin serial pin make it an output.

    Then further lines of code says that send out the massage and flash the LED once again.

    //

    static char chr;

    static int index

    index = 0

    do {

    chr = pgm_read_byte(&(str[index]))

    put_char(&serial_port, serial_pin_out, chr)

    ++index

    } while (chr != 0)

    }

    void flash() {

    //

    // LED flash delay

    //

    clear(led_port, led_pin)

    led_delay()

    set(led_port, led_pin)

    }

    int main(void) {

    //

    // main

    //

    static char chr

    //

    // set clock divider to /1

    //

    CLKPR = (1 << CLKPCE)

    CLKPR = (0 << CLKPS3) | (0 << CLKPS2) | (0 << CLKPS1) | (0 << CLKPS0)

    //

    // initialize output pins

    //

    set(serial_port, serial_pin_out)

    input(serial_direction, serial_pin_out)

    set(led_port, led_pin)

    output(led_direction, led_pin)

    //

    // main loop

    //

    while (1) {

    get_char(&serial_pins, serial_pin_in, &chr)

    flash();

    if (chr == node_id) {

    output(serial_direction, serial_pin_out);

    static const char message[] PROGMEM = "node ";

    put_string(&serial_port, serial_pin_out, (PGM_P) message);

    put_char(&serial_port, serial_pin_out, chr);

    put_char(&serial_port, serial_pin_out, 10); // new line

    led_delay();

    flash();

    input(serial_direction, serial_pin_out);

    }

    }

    }

    Then I followed embedded programing steps for my networking boards.I was editing c file for three different boards.Then create hex file.

    Edited file for board 1.

    Edited file for board 2.

    Then, open number of ports and select ttyusb0.After that click enter. Then type 1,2, and 0 in serial monitor.

    The program is simple one! When I press 1 or 0 . Then node should blink there LED and blink twice which board has serially printed.

    Watch

    Node 1 and 0 is successfully print on serial monitor.But node 2 has some problem in program or in connection. I did lots of troubleshooting but it doesn't print.It blinks when I press 2. But doesn't print serially.

  • Download files