Sander van Vliet

Fabacademy2016
@Fablab Amsterdam


Electronics Production

Week 4 (17 - 24 February)


Lecture

This weeks lecture was about electronics production and specifically about printed circuit board (pcb) fabrication.

Assignment

Make a FabISP (in-system programmer)







What is it?
An in-system programmer is a device which can be used to program embedded devices like microcontrollers (so you can program the microcontroller while it is already installed in a complete and working system). A Fab ISP is an ISP which can be fabricated in any Fablab using the standard set of machines and inventory.
At this point we only need to learn how to mill the board and how to solder the electronic components on it. In later assignments we will learn how to design circuit boards and how to program the micro-controllers on them using our FabISP.

Choosing which one to make
In the Fablab community there are several Fab ISP designs available. Here are a few of them: David Mellis, Limor Fried and Dick Streefland.
Although they all can do the same thing, the FabTiny* designed by Zaerc also has a reset button, a target power LED and switch and a LED that blinks when communication is in progress. These extra features + the fact it is quite small seemed handy so I chose to make that one.

Making it
In our lab we have a Roland Modela MDX-20 small milling machine which can be used for precision 3D milling and 3D scanning, as well as for circuit board milling. Its working area is 200mmx160mm. We will use it to mill the copper traces on the board (actually remove copper to form the traces) and to mill the outline which will form the shape/outer length and width dimensions of the board itself (cutting the board). This board will be rectangular, but in general boards can be in any shape you want.
The next step will be to solder the components on the board by means of surface-mount type fixation. This means the components will be mounted on and are connected to copper on 1 side of the board. There also are the through-hole and chip-scale fixation methods, which are used on other types of boards.
The last step is programming the board so it will be able to program other microcontrollers.

Milling the board
We had an instruction session on how to use the Roland Modela MDX-20 and a few students of our group got to milling a board. I did not get to milling my board yet, but will do that after the weekend.
So on monday I came in early and followed my notes to use the Modela milling machine and it all went well. I put the acryllic plate on which the sacrificial layer and the single sided copperplate was placed on the bed of the Modela milling machine. I opened up Fabmodules and entered the needed information like format of the source file: .png and under 'process' selected Roland Modela. Then I loaded the correct .png file with the traces for the FabTiny* as below
and checked the other fields like offsets (4), overlap (0,5), intensity (0,5), speed (0,4mm/sec) and Z(mm) (0,1mm).
Then I put in the 1/64 (0,4mm) end mill for milling the traces first. Now I needed to place it at the correct origin point and lower the end mill so it was touching the top of the material, tightened the screw again securing the end mill and now we're good to go. Click "make rml" to create the file which the Modela will use to mill my board and click the "Send it!" button to send it to the milling machine.

There it goes:


When it was done I checked the traces and they all looked fine!
Now I loaded up the .png file for cutting out the board as below
and put in the 1/32 end mill and went to the same process basically. Only setting that is different now is: offset (1). Also with cutting the board the mill needs to go deeper to go through the material so we use topz (-0,6) and botz (-1,7). These are the values for how deep the first layer is and how deep the bottom of the lowest needed layer is. The cutting out of the board was succesful too, so I could go on to the next step.

Soldering the components on to the board a.k.a. "Stuffing the board"
Once I checked the traces on the board visually and with a multimeter to see if there are any shorts (short circuits; unwanted connections) I collected all the necessary components from the lab's inventory.
In the below table you find the needed components in the order I soldered them on the board:
Part Value Package
inventory ideal
R1 1 Kilo-Ohm 2.2 Kilo-Ohm SMD-1206
R2 1 Kilo-Ohm SMD-1206
D1 3.3-Volt Zener 3.6-Volt Zener SMD-SOD123
D2 3.3-Volt Zener 3.6-Volt Zener SMD-SOD123
C1 10 micro-Farad SMD-1206
R3 49 Ohm 68 Ohm SMD-1206
R4 49 Ohm 68 Ohm SMD-1206
R7* 0 Ohm PTC 0.5 Ampere SMD-1206
C2 100 nano-Farad SMD-1206
IC1 ATTiny45 ATTiny85 SMD-SOIC8
JP1 2x6 ISP 2x8 header SMD pinheader
S2 B3SN-3112 SMD tactile switch
S1 AYZ0102AGRLC SMD slide switch
R5 1 Kilo-Ohm SMD-1206
LED1 red LED SMD-1206
R6 499 Ohm 470 Ohm SMD-1206
LED2 green LED SMD-1206

Below you can see the layout of the board and its components. Some components are directional which can be noticed by their schematic symbol not being symmetrical.

To keep track of these very small parts I made a sheet to place them on, including their reference numbers to be able to identify them.
During soldering I used a magnifier with a built in light which helps with seeing things, but I did need to get used to moving my hands around and underneath it without bumping in to it all the time.

On the left you can see the ATtiny45 microcontroller indeed is quite tiny =)
And on the right, after about 3 hours of soldering (it was my first time) my completed FabTiny* ISP!

BUT, when I inserted it in the USB slot of my laptop the red LED did not light up like it should when it is powered... Obviously something was wrong, but what? And where to start debugging this? I showed my ISP to Emma and she noticed that I had put the LED's (1 green and 1 red) both in the wrong direction! Apparently I did not notice that their schematic symbols have a dot (on the left top of the circle, if you like to look for it) and are actually not symmetrical so are to be used directionally. I corrected it by taking them off the board using the hot air blower and soldering them on again now facing the correct way. And indeed, this fixed it so now it seemed ready to be programmed!

Programming it
The last step is to program the ISP and put a firmware onto it so it will actually become a working in-circuit programmer. I did this as a first step because I did not get to milling on the first day and while I was waiting in line we programmed the ISP of fellow student Paul. He had already completed the milling and soldering of his ISP. With the help of his tutorial and Zaerc himself I managed to program Paul's FabTiny* ISP from my laptop's Linux Ubuntu partition using the ISP of our instructor Emma as programmer.
Download the entire Ubuntu command line text of the programming process as described below here.

Although the tutorial was written for using an Arduino Uno as programmer, the necessary steps are there (and we just skipped the Arduino specific steps).
Before I could start I needed to install some software on my laptop using the following commands:
sudo apt-get install flex byacc bison gcc libusb-dev avrdude
sudo apt-get install gcc-avr
sudo apt-get install avr-libc
sudo apt-get install libc6-dev

Now we are all set, let's program it! First we checked if we could initialize communication with Paul's ISP with the command:
snader@Duck:~/Desktop$ sudo avrdude -c usbtiny -p t45 avrdude: AVR device initialized and ready to accept instructions avrdude: safemode: Fuses OK (H:FF, E:DF, L:62)


Then we programmed the fuses, initially without disabling the reset pin, as this is still needed to program the flash memory further on. In the command for this we had to replace the part "stk500v1 -P/dev/ttyACM0 -b19200" with "usbtiny" as described in the tutorial.
snader@Duck:~/Desktop$ sudo avrdude -c usbtiny -p t45 -V -U lfuse:w:0xe1:m -U hfuse:w:0xdd:m -U efuse:w:0xff:m avrdude: AVR device initialized and ready to accept instructions Reading | ############################################## | 100% 0.01s avrdude: Device signature = 0x1e9206 avrdude: reading input file "0xe1" avrdude: writing lfuse (1 bytes): Writing | ############################################## | 100% 0.02s avrdude: 1 bytes of lfuse written avrdude: reading input file "0xdd" avrdude: writing hfuse (1 bytes): Writing | ############################################## | 100% 0.02s avrdude: 1 bytes of hfuse written avrdude: reading input file "0xff" avrdude: writing efuse (1 bytes): Writing | ############################################## | 100% 0.00s avrdude: 1 bytes of efuse written avrdude: safemode: Fuses OK (H:FF, E:DD, L:E1) avrdude done. Thank you.


The next step was writing the flash onto the memory of the FabTiny* ISP. I downloaded the firmware source code specifically for the FabTiny* ISP and with the following command executed from the folder location where the firmware files were located the firmware was flashed to the FabTiny* its memory:
snader@Duck:~/Documents/fabacademy/04/fabtinyISP/vusbtiny$sudo make install avrdude -c usbtiny \ -p t45 -e \ -V -U flash:w:vusbtiny.hex avrdude: AVR device initialized and ready to accept instructions avrdude: Device signature = 0x1e9206 avrdude: erasing chip avrdude: reading input file "vusbtiny.hex" avrdude: input file vusbtiny.hex auto detected as Intel Hex avrdude: writing flash (2488 bytes): Writing | ############################################## | 100% 1.35s avrdude: 2488 bytes of flash written


Before continuing the programming steps we disconnected Paul's FabTiny* from the programmer FabTiny and connected it directly to the usb port of my laptop. This was to check if Paul's FabTiny* ISP was recognized by the Ubuntu OS as a proper usb device. (lsusb is a utility for displaying information about USB buses in the system, in this case my laptop, and the devices connected to them)
snader@Duck:~/Desktop$ lsusb Bus 002 Device 003: ID 05a9:2640 OmniVision Technologies, Inc. OV2640 Webcam Bus 002 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub Bus 007 Device 001: ID 1d6b:0001 Linux Foundation 1.1 root hub Bus 006 Device 002: ID 04b3:310c IBM Corp. Wheel Mouse Bus 006 Device 001: ID 1d6b:0001 Linux Foundation 1.1 root hub Bus 005 Device 018: ID 1781:0c9f Multiple Vendors USBtiny Bus 005 Device 001: ID 1d6b:0001 Linux Foundation 1.1 root hub Bus 001 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub Bus 004 Device 001: ID 1d6b:0001 Linux Foundation 1.1 root hub Bus 003 Device 001: ID 1d6b:0001 Linux Foundation 1.1 root hub


So it was indeed recognized as being a USBtiny!

Now we connected it to our programmer (the FabtinyISP of Emma) again for the final step: disabling the FabTiny*ISP's own reset pin, as it will be used to actually reset the target instead while programming. This step is close to irreversible because afterwards you can no longer program the USBTiny* ISP itself anymore. If you would want to reverse this step, a HVSP (High Voltage Serial Programmer) will be required to reset the fuses again and probably the capacitors will have to be desoldered as well.
snader@Duck:~/Desktop$ sudo avrdude -c usbtiny -p t45 -V -U lfuse:w:0xe1:m -U hfuse:w:0x5d:m -U efuse:w:0xff:m avrdude: AVR device initialized and ready to accept instructions avrdude: Device signature = 0x1e9206 avrdude: reading input file "0xe1" avrdude: writing lfuse (1 bytes): avrdude: 1 bytes of lfuse written avrdude: reading input file "0x5d" avrdude: writing hfuse (1 bytes): avrdude: 1 bytes of hfuse written avrdude: reading input file "0xff" avrdude: writing efuse (1 bytes): avrdude: 1 bytes of efuse written avrdude: safemode: Fuses OK (H:FF, E:5D, L:E1) avrdude done. Thank you.


This means we succeeded and Paul now has his own functioning ISP.

We gave the same command again just to see what would happen and as it should be, the command didn't run because of the fact that it can not be programmed anymore now.
snader@Duck:~/Desktop$ sudo avrdude -c usbtiny -p t45 -V -U lfuse:w:0xe1:m -U hfuse:w:0x5d:m -U efuse:w:0xff:m avrdude: initialization failed, rc=-1 Double check connections and try again, or use -F to override this check. avrdude done. Thank you.

After I had milled and soldered my own FabTiny* ISP I programmed it the same way as described above.