Goal
The goal of this assignment is to make our own version of the FAB ISP In-circuit programmer. Neil says that it is easy, that it can take as low as 10 minutes to mill and another ten minutes to stuff the board. I'll tell you later, Neil.
Last week MIT Lecture Review
Today we had another hour and and a half of assignments showcase. The random script did not choose me either this week. I wonder when am I going to be picked by the script. The first time Neil runs the script, the probability of not being picked is 119 in 120. Since the picking is without replacement (because even if the script repeats a student Neil will execute the script again) the probability of not being picked the second time he runs the script is 118/119 and so on. Since these are dependent events the overall probability of not being picked is the multiplication of all of them, that is 120-n/120. Assuming that we pick about 30 students every week, the probability of not being picked by the script any given week is 0.75 (75%). But, what is the probability of that the script is not going to pick me next week either? if I remember my statistics lectures every week event is independent from the other, so the probability of that the script is not going to pick me for the next week (this assignment) is going to be 0.75x0.75x0.75=0.422 (42.2%), so I have 57.8% probability that the script is going to pick me this week. I'd better get it right this time.
Today we talked about electronics production. This was an interesting topic this week because we are going to learn to mill and populate our own circuit boards. We are going to mill them using the fab modules.
Later in the local session Luciano showed us a Fabduino he designed and made. It was very nice. He told us that we were not allowed to use commercial Arduino in our projects in the academy. He said that if we want to use arduino we should make our own. The Fabduino costs around 5 bucks (compared to the 25 of the commercial one) and it can be made in less than an hour (he can even make 2 in one hour). That is cool, isnt it? I will have to make all my electronics here.
Hands On with the FAB ISP
One board, three flavors
There are three versions of the FAB ISP board: David's, Andy's and Valentin's versions. David's version is the original one. Andy modified David's design to integrate the USB connector in the circuit board, which I think is quite an intelligent way to proceed. And then Valentin made a further modification to Andy's board in order to avoid desoldering the jumpers. I will (try to) make Andy's version. I already measured the space around both USB ports on my Macbook Air and Andy's FAB ISP will not collide with the Thunderbolt port or the Magsafe.
I made a couple of modifications to Andy's PNG image. I added the word FAB! and a face because there was some free space left on the board. I later realized that this was not free space, it was actually a ground pound. It caused minor difficulties later, when stuffing the board.
Milling the board
Milling is the easy part of this week assignment. Apart from zeroing the Z of the machine and changing bits, the only thing you have to do is watching the Roland Modela as it mills the board. Not that bad entertainment for a Friday night.
Refining the board
I think one of the settings was not set properly on the fab modules. In the computer where I milled my board there was an old version of the fab modules and the default settings for milling where different from the new one. I think that an overlap of 0.25 (25%) is not enough. It should be 0.5 at least. I saw some other boards with 50% of overlap and they looked better than mine. The result was tiny copper lines in between the lanes as you can see in the image below. This could also be caused because I set offsets to 6 and Andy states in his page that it should be -1.
I had to use a sharp blade to manually remove those copper lines left in between the lanes. I don't think I would be able to remove them if necessary once the board is stuffed.
Below you can see the difference after removing those lines. Much more cleaner now.
Also I noticed that the FabISP was a bit loose in the USB port. If you want it to make good contact with the computer you need to hold it with your hand at all the times. I was afraid that it could loose contact while programming or being programmed so I looked for some plastic to attach at the bottom of the board in order to make it a bit more thick. The piece of plastic I found was my travelclub points card. I cut the card to match the shape of the FabISP and glued it with double side tape and now it fits quite better. I didn't have many travel points anyway.
Stuffing the board
You were right Neil. I surprised myself that soldering SMD was not that difficult. To be honest I have to admit that it is easier than soldering through-hole components. I really didn't think I would be able to solder those tiny things into the board.
Here you are some tips that helped me a lot when soldering:
- Use very little solder
- Remember the FILO rule: first input is last output: soldering iron first, then solder. First output solder, last output soldering iron.
- Lit well your workplace
- Use a magnifying glass
- Stick the board to the table with double-side tape
Also, SMD components can be reused if you unsolder then properly. It is difficult to unsolder and reuse through-hole components, because the length of the legs will be very short. Eventually, I had my board stuffed with all the components. I really made it. There were no 8pF capacitors in the lab so I used 10pF instead. I should ask Andy if this is OK. Also if you see the image below you will see that I made the jumpers with a small piece of hard wire. I finally replaced them with a solder blob because the multimeter was giving me lack of continuity, they name it a cold joint.
Programming the FAB ISP
There is a nice tutorial made by Anna Kaziunas France on how to install the necessary software for programming the FabISP. Since I already had Fab Modules installed I downloaded and installed CrossPack-AVR-20130212.dmg from here. Then I downloaded and unzipped the firmware.zip file and the Week 04 Odyssey in the Lab started: make clean OK, make hex ERROR. Oh Lord, why me?!
MacBook-Air:firmware Francisco$ make hex
avr-gcc -Wall -Os -DF_CPU=20000000 -Iusbdrv -I. -DDEBUG_LEVEL=0
-mmcu=attiny44 -c usbdrv/usbdrv.c -o usbdrv/usbdrv.o
In file included from usbdrv/usbdrv.c:12:0:
usbdrv/usbdrv.h:455:6: error: variable 'usbDescriptorDevice' must
be const in order to be put into read-only section by means of
'__attribute__((progmem))'
usbdrv/usbdrv.h:461:6: error: variable
'usbDescriptorConfiguration' must be const in order to be put into
read-only section by means of '__attribute__((progmem))'
usbdrv/usbdrv.h:467:6: error: variable 'usbDescriptorHidReport'
must be const in order to be put into read-only section by means
of '__attribute__((progmem))'
usbdrv/usbdrv.h:473:6: error: variable 'usbDescriptorString0' must
be const in order to be put into read-only section by means of
'__attribute__((progmem))'
usbdrv/usbdrv.h:479:5: error: variable 'usbDescriptorStringVendor'
must be const in order to be put into read-only section by means
of '__attribute__((progmem))'
usbdrv/usbdrv.h:485:5: error: variable 'usbDescriptorStringDevice'
must be const in order to be put into read-only section by means
of '__attribute__((progmem))'
usbdrv/usbdrv.h:491:5: error: variable
'usbDescriptorStringSerialNumber' must be const in order to be put
into read-only section by means of '__attribute__((progmem))'
usbdrv/usbdrv.c:70:14: error: variable 'usbDescriptorString0' must
be const in order to be put into read-only section by means of
'__attribute__((progmem))'
usbdrv/usbdrv.c:89:14: error: variable 'usbDescriptorStringDevice'
must be const in order to be put into read-only section by means
of '__attribute__((progmem))'
usbdrv/usbdrv.c:111:14: error: variable 'usbDescriptorDevice' must
be const in order to be put into read-only section by means of
'__attribute__((progmem))'
usbdrv/usbdrv.c:142:14: error: variable
'usbDescriptorConfiguration' must be const in order to be put into
read-only section by means of '__attribute__((progmem))'
make: *** [usbdrv/usbdrv.o] Error 1 MacBook-Air:firmware
Francisco$
I googled for the error (Google is your friend) and found this forum http://forums.obdev.at/viewtopic.php?f=8&t=6424 where someone named funkenregen stated that:
So did I: I used MacVim to replace every instance of PROGMEM
with const PROGMEM
in
usbdrv.h and usbdrv.c (there are instances in both files). I plugged
the AVR programmer into one of the USB ports, my FabISP to the other
USB port, and both connected through the programmer cable. I typed make
hex
in the terminal yet another time and it worked! sudo
make fuse
worked also! sudo make program
worked as well! My board was programmed.
I finally checked under Mac OS X System Information that the computer was recognizing the FabISP properly. Some buddies here in Fablab Barcelona making Andy's version like me (Ferran and John Rees) were having trouble in this last step. They programmed their boards and all went fine, but then the boards were not recognized by any computer. Weird. They didn't find a solution so they are starting over again from the beginning with David's version of the board.
Programming another FabISP with your FabISP
The final step is to program another board using yours as a programmer. Actually, that is what is all about. So in Andy's version you must remove jumpers 1 and 2 and the zero ohm resistor in the board, and also edit the Makefile in order to change the comment in two lines in because you now want to use usbtiny instead of avrisp2 to program the boards:
...
#AVRDUDE = avrdude -c usbtiny -p $(DEVICE) # edit this line for
your programmer
AVRDUDE = avrdude -c avrisp2 -P usb -p $(DEVICE) # edit this line
for your programmer
...
MAKEFILE AFTER
...
AVRDUDE = avrdude -c usbtiny -p $(DEVICE) # edit this line for
your programmer
#AVRDUDE = avrdude -c avrisp2 -P usb -p $(DEVICE) # edit this line
for your programmer
...
I tried to program one of my mates board and I faced further
problems. make clean
did work, make hex
did work as well, but sudo make fuse
failed with an
unknown error:
MacBook-Air:firmware Francisco$ sudo make fuse
avrdude -c usbtiny -p attiny44 -U hfuse:w:0xDF:m -U lfuse:w:0xFF:m
avrdude: error: usbtiny_transmit:
usb_control_msg(DeviceRequestTO): unknown error
avrdude: initialization failed, rc=-1
Double check connections and try again, or use -F to override this
check.
avrdude: error: usbtiny_transmit:
usb_control_msg(DeviceRequestTO): unknown error
avrdude done. Thank you.
make: *** [fuse] Error 1
You are welcome avrdude. I found someone with a Macbook Air mid 2012 (like mine) in a forum of Adafruit Industries having the same problem. It is supposedly due to the USB 3 ports, it looks like usbtiny does not work with these ports so far. And both of my USB ports are USB 3. A workaround is to use a USB 2 port (if you have a free one left) or use a USB 2 hub between the USB 3 port and the FabISP. I haven't tested it but I'll hopefully have it sorted out by the time the script picks me.
On week 09 I used a USB 2 hub between my USB3 port and the FABISP and I was able to sucessfully program the echo-hello world board. Take into account that this is only a limitation when you use make command in terminal. You can use USB3 ports without problems if you program the ATtiny with the Arduino IDE.
What I learned
This week I learned that there are some things are not as difficult as they look like and also there are some others that are not as easy as they look like either. So the point is try them all and do not leave those easy things for the last minute.
Download files
You can download all the files related to this week here.