Week 14: Networking and Communications

This week's tasks:

  • Group assignment:
  • Individual assignment:
    • Designing and building a wired and/or wireless network connecting at least two processors

Challenges:

  • Milling: some parts of the board could not be cut deep enough.
  • Programming: I had some challenges in figuring out how to connect everything (c codes, hex files, wires and etc., since this time it was about programming 3 boards and make them connected.
  • Only one of the nodes along with the bridge worked properly! I reprogrammed and double checked ecerything but I could not fix the issue.

Considerations:

  • Being careful when trying to cut a board that already has some components soldered on it. One could easily break the milling bit, as unfortunately I did.
  • Always remember to consider enough space for FTDI header to the edge of the board (Not too much not too less). I have experienced both. I could not do anything about it when it was less but I could manage to cut extra parts when it was too much (but still it was time consuming.)
  • For milling it is better to cut the pcb in almost the same size as your board and also to set the z origo in the middle of the board not in the edges.
  • I created 3 projects for bridge, node1 and node2 using the same code of Neil. What I change was adding #define F_CPU 8000000UL for all codes. And changing the line: #define node_id '0'. For node1 project I changed it to: #define node_id '1' and for node2 project I changed it to #define node_id '2'.

Technology used:

  • ATMEL Studio Software
  • PuTTy Program
  • AVRDUDE
  • Eagle Software
  • Fabmodules.org
  • Milling Machine
  • Soldering Iron

A word about my plan for this week's task

My final project do not have any networking feature so I decide to follow Neil's example for asynchronous serial bus. In this example three ATtiny45 processors are network connected via wire. 2 boards named nodes and one board named bridge, which connects to computer using FTDI cable so it will receive serial input from keyboard and illustrate it on terminal. Through typing 0,1 or 2, a message would be shown containing the node_iD for example node 0, node 1 and node 2. And then the corresponding LED would be turned on. Following Dorina's documentation I also added another LED to the bridge board for indicating power.

Special thanks to Ivan for helping me figuring out the solutions for some problems that I faces in Milling and other stages.

Designing The Bridge Board

The Microcontroller in bridge board is ATtiny45. I designed the board based on Neil's example (Serial bus > asynchronous)
For programming the microcontroller, 2x3 pin header is used.
For connecting the databus (DB) pins RX and TX to the microcontroller and to connect power and GND, 2x2 header is utilized.
FTDI header is used for connecting to FTDI cable and then to PC. The connected pins are VCC, TX, RX and GND.

The Schematic for the Bridge

The Board for the Bridge

Designing The Node Boards

The Microcontroller in node boards are ATtiny45. I designed the board based on Neil's example (Serial bus > asynchronous)
For programming the microcontroller, 2x3 pin header is used.
For connecting the databus (DB) pins RX and TX to the microcontroller and to connect power and GND, 2x2 header is utilized.

The Schematic for the Node

The Board for the Node

PNG Files for Milling Traces and Outlines

The PNG Files for Bridge Board

The PNG Files for Node Boards

Using http://fabmodules.org/ to Create .rml files for Milling

The PNG Files for Bridge Board
  • For bridge board traces I used :
    cut depth: 0.11
    tool diameter: 0.36
  • For node board traces I used :
    cut depth: 0.14
    tool diameter: 0.36
  • For outline of all boards I used :
    cut depth: 0.6
    tool diameter: 1
  • Milling the Boards

    Unsuccessful Milling Time
  • I had 3 unsuccessful milling. As Ivan guided me, what I did eventually to get it work, was cutting the PCB to the almost same size as my board and setting the z origo in the middle of the board.
  • Successful Milled Board for Bridge

    Successful Milled Boards for Nodes

    List of Components for Soldering

    1x ATtiny 45
    1x 2x2 pin header
    1x 2x3 pin header
    1x resistor 1 K
    1x resistor 10 K
    1x capacitor 1 UF
    1x LED orange

    1x ATtiny 45
    1x FTDI header
    1x 2x2 pin header
    1x 2x3 pin header
    1x resistor 1 K
    1x resistor 499 ohm
    1x resistor 10 k
    1x LED green
    1x LED blue
    1x capacitor 1 UF

    Soldering

    Good to mention that I am happy that I am getting more confident and comfortable with soldering. Thanks to Jari for the useful tips that he provided me with, for soldering in a right way.

    At this stage, I noticed a problem with the bridge board. If I attach the FTDI header, it would not be possible to connect it to FTDI cable later on, because the distance is too much! So I needed to cut the board as much as possible. I had lots of challenges at this stage to cut it becuase I wanted to cut extra part with milling machine so I had to be so careful not to make the traces cut. So I did some experiments with the previous unsuccessful boards in milling. And eventually after a few failures I could manage to cut it properly in a way that I wanted.

    Making the Cables and the Connections

    It is important to keep in mind to prepare the databus cable with 4 wires for Rx, Tx, power and Ground.


    Programming

  • I used neil's c code for programming using ATMEL studio and GCC compiler for creating hex file.
  • The main loop in Neil's code is as following:
    • It reads the data from input pin PB3 and stores it in rxbyte (PB3 gets the data/signal directly from TX)
    • Then the led flashes
    • It checks if node_id ('0', '1', '2' ) was called
    • Then it put led on
    • Writing on the terminal the node id:
    • If yes, DDRB is set/toggled as output direction port and PB4 will be written
    • And a variable message is defined for progmem which is written with string "node "
    • And the output pin PB4 is written with "node "
    • The PB4 is set again as input
  • Tx in FTDI cable is connected to PB3 in all boards.

  • So I created 3 projects using Neils's code with some minor modifications for each project.
  • For all three projects, before the line #include < util/delay.h>, I added #define F_CPU 8000000UL, to define the clock frequency for the microcontroller.
  • In bridge project I let the line: #define node_id '0' remain the same.
  • When I copied Neil's code, I also modified the value for node1 (in node1 project): #define node_id '1'
  • I also modified the value for node2 (in node2 project): #define node_id '2'
  • For all 3 projects, I also added a few flash(); for prolonging the blink.

  • After copying the c code in ATMEL studio and adding the line for defining the clock frequency, I did as following:
  • Build > compile

  • And then: Build > Build solution
    It resulted in a hex file. The hex file is written in the flash memory of ATtiny45 microcontroller through AVRDUDE program and the usbtiny programmer.

  • Then I ckecked Neil's make file for finding the command for program-usbtiny:

  • Then Now Tools > External Tools:
    Title: AVRDUDE
    Command: C:\Program Files (x86)\avrdude\avrdude.exe
    Arguments: -p t45 usb -c usbtiny -U flash:w:$(TargetDir)$(TargetName).hex:i
    Initial Directory: C:\Program Files (x86)\avrdude\
    And now AVRDUDE is added under the tool tab.

  • Now for programming the flashes I hit: (more details on how to start programming the board using Amel Studio could be found in my documentation of Input Devices week.)
    Tools > AVRDUDE

  • I did the previous step 3 times for bridge, node 1 and node 2. It resulted in 3 c code files and 3 hex files.
  • Checking the Results

  • Checking the serial port from control panel > device manager
    And opening PuTTy program and inputing the serial line (which COM) and also inputting the value 9600 for speed.
  • When I hit 0 on keyboard, all the LEDs in 3 boards flash and the LED in bridge board remain ligtened up for a few seconds more. When I hit 2 on the keyboard, all the LEDs in 3 boards flash and the LED in node2 board remain ligtened up for a few seconds more. And when I hit 1, all the LEDs in 3 boards flash but nothing else happens in LED in node1 board. I tried to program node1 board again to get the problem fixed. But it didn't help. So all boards are functioning weel except node1 board that is not working in a way that it is supposed to.
  • The funny thing is that I programmed node1 that was not working with node2 code and then I tested it and the issue was not fixed. I decided to reprogram node1 with its own code so after that I tested again and surprisingly this time node 1 is working but node 2 is not working although I had not touched the code for node2!

  • Original Design Files

    Schematic for Bridge
    Board for Bridge
    Schematic for Node
    Board for Node
    Board for cutting extra part of Bridge
    Bridge Traces .rml file
    Bridge Outline, .rml file
    Node Traces, .rml file
    Node Outline, .rml file
    bridge c code
    node 1 c code
    node 2 c code
    bridge hex file
    node 1 hex file
    node 2 hex file