Week 7. Electronics Design

Go to:
  1. Group work
  2. Designing the Hello World Board
  3. Programming the Hello World Board
  4. Results
  5. Download the materials

1. Group Work

Small time shift, because the group work was done after the individual assignment.

Task: Use the test equipment in your lab to observe the operation of a microcontroller circuit board.

Group:

We had a Hellow Word board, oscilloscope, FTDI cable and PuTTY terminal, opened in serial mode on 115200 BPS.

We used oscilloscope to check the signal by connecting the probe.

Baud rate seen in the oscilloscope (11,49 kHz) is near to the Speed defined in Putty configuration (115200).

Typing a letter on a keyboard, you can see the binary format of the letter on the screen of the oscilloscope. Without any preferences, we typed a few random letters: "U","S" and "B"

Binary code for “U” 01010101. This can be seen also in the signal, you need to look at it reversed, least significant bit (LSB) is sent first.

Binary code for “S” 01010011.

Binary code for “B” 01000010.

2. Hello World Board

Tasks:

I started working on this weeks assignment by downloading Eagle from official web page. Another new software for me. A long time ago in galaxy far far away I was using P-CAD but this knowlege didn't helped me at all. After installing Eagle I downloaded eagle_fab.lbr and put it into libriries folder.

options/directories - here you can change paths. I'm using defaults.

After that eagle_fab can be found in libraries list. I enabled it by Right Click on it and put a tick in the regiment Use . Then I created a new project and named it ElectronicsDesign_FabAcademy. Then I created a new schematic (Right Click on project name New/Schematic).

Eagle menu

In Scheme1 file I started redrawing Hello World Board. Before start I turned on Grid for better positioning. I opened thisPNG and started adding components to the sheet. To add an element to the sheet I typed add in command line (there's an add tool on the tool panel as well). In Add window you can choose a component from the libraries. From eagle_fab library I added:

Add

Using Name and Value tools I named the elements ans defined values of the components. I connected components following the paths on the drawing using the Net tool and after that I added ground, button, few resistors and LED. I connected them as well and I did it wrong! It happened that I accidentally connected the LED to PB3 pin instead of PB2. I haven't realised it on the design stage, so I milled the board an only when I started soldering I found the mistake. I soldered the board anyway, but I made another one later.

Fail on my scheme

Anyway, after plasing all components and connecting them I switched to board mode. For me it was the most time consuming part.

Grid is helpful thing here because it helps to place a path in between elements contacts. 50 - is normal spacing and by holding Alt you can move element or path by 25 mil (1mil = 0,001inch = 0,0254mm)

I was trying to place all components in a nice compact way so the paths won't cross. To move an element I used Move tool (click on the cross to select, RMB to rotate). To make a connection between contacts I used Route tool wtith width 16 mil. Using Polygon tool I draw a frame around my design and Named it GND. It is my ground signal. Ratsnest tool connects everything to it. After drawing a path or moving a component it doesn't refresh so you need to press it again. To remove it type ripup GND in command line. After plasing all elements and drawing all paths I checked if my drawing fits my design rules. To do it I typed drc in command line. In this window I defined design rules and clicked apply. The program found a few things like unconnected routes and components placed too close to each other. It was easy to fix it all.

Common milling drill width is 0,4mm or 16 mil

My layer1

I drew a frame around my board in 46 milling layer using line tool and exported two PNG files: traces and outcut. To export only needed layer type in command line:
display none - hides everything
display 1 - showes only layer1
display all - shows everything

To save PNG file go File/Export/Image, place a mark Monochrome and choose the resolution (I put 1500 and it worked well).

Traces Outcut

To mill my board I used the same process that I used on week 5. I downlaoded my PNG file to Mods, opened server program SRM-20/PCB PNG, deleted WebSoket module and added file/save module. I used 0.2-0.5mm V-shape milling drill to cut traces and 1mm flat to do the outcut.

Moment I realised I needed to invert my PNG file...

Settings I used to get I final cut

Traces check

Final Cut

List of components

Hint for soldering Soldered

According to my design I did soldering right. According to what was needed it's wrong...

Correct schematic

Components layout and Outcut

Traces Outcut

I milled the correct board, using the similar settings that were shown before. I soldered all components and started programming the board.

Programming the board

To program my board I used my version of Brian's programmer. I plugged it to USB 2.0 port (I know that it's better to use a extension cable, but I don't have one so everything looked like that). Then I connected the programmer and ISP header on my board with self-made 6 pin AVR-programming cable. Then I powered the board from FTDI-cable connected to usb port.

Sponsors of ugly blobs of solder on my board are: resoldered resonator and my home soldering iron with a wide tip. Looks bad, but works good.

Since my laptop operating on Linux has found his peace in the digital Valhalla, I went through this tutorial to make it work on my Win7 machine.

This was the result after couple of hours of trobleshooting. It worked, but the signal was a total mess. from my previous experience I can say that the problem was in the wrong signal speed.

It wasn't the result I expected, so I started to look for a better easier way to do the programing. And I found it!

I downloaded Arduino IDE and lived happily ever after my life became brighter.

Full tutorial I followed to set the Arduino IDE can be found here

First things first, by deafult Arduino IDE does not support ATtiny. But it's reale easy thing to fix: open Preferences(File/Preferences of Ctrl+Comma)

Paste this link: https://raw.githubusercontent.com/damellis/attiny/ide-1.6.x-boards-manager/package_damellis_attiny_index.json in the additional board manager

Then go Tools/Boards Manager

Type in the search field: "attiny" and install the package

Choose ATtiny24/44/84

Choose ATtiny44

Time to set the clock!

Choose your programmer. I used my copy of the Brians programmer made on the Week 5.

Ok, now we are ready to go. I copied the code from the hello.ftdi.44.echo.c file to an empty scketch in Arduino IDE, saved it, Verified it and Uploaded it to my board.

Settings for the terminal. The serial port number you can get from the Device Manager (COM and LTP). I recommend to set it as default settings. You are gonna to open the terminal for a multiple times.

And this is what I saw...

*swearing in russian*!!!

But If I set the clock to internal/external 8 MHz it looked like that. So the problem was clear: I didn't check and had soldered the wrong resonator (8 MHz instead of 20 MHz). In my defence I can say, that I took it from the right box in the storage.

After replacing the resonator I finaly got it!

Then, on Antti's page I found a code sample for turning on the led by pressing button. Since he was the man who teached us the Electronics design my board looked similar and there was no need even to change the pin numbers. After I uploaded the code to my boad using my USBtinyISP programmer everything worcked from the first try.

         http://www.arduino.cc/en/Tutorial/Button
         
         I took this code from Antti's page:
         http://archive.fabacademy.org/archives/2016/fablaboulu/students/161/Assignment8.html
         
         */

        // constants won't change. They're used here to
        // set pin numbers:
        const int buttonPin = 7;     // the number of the pushbutton pin
        const int ledPin =  8;      // the number of the LED pin

        // variables will change:
        int buttonState = 0;         // variable for reading the pushbutton status

        void setup() {
            // initialize the LED pin as an output:
            pinMode(ledPin, OUTPUT);
            // initialize the pushbutton pin as an input:
            pinMode(buttonPin, INPUT);
        }

        void loop() {
            // read the state of the pushbutton value:
            buttonState = digitalRead(buttonPin);

        // check if the pushbutton is pressed.
        // if it is, the buttonState is HIGH:
        if (buttonState == HIGH) {
            // turn LED on:
            digitalWrite(ledPin, HIGH);
            } 
        else {
            // turn LED off:
            digitalWrite(ledPin, LOW);
            }
        }

        

Success!

For the demonstration I connected the FTDI cable to a small power bank. Works as planned!

4. Results of the week

5. Download the materials: