Sunday, March 31, 2013

Soldering Brage

It is not as if I need another Arduino, but...

I bought two Arduino like PCB's not long ago and I have looked forward to soldering them. I find it fun soldering, and I have made a few Arduino boards of my own, all on perf-board or strip-boards. Usually I have to work at night after the kids are sleeping and I sometimes do a sloppy job, because of fatigue and amateurishness...Tonight I got the rest of the family at my parents in law so for once I can go soldering early in the evening.

I did not order any parts, I had most of the parts at home, except for the crystal and the intended caps, but I worked with what I had... I replaced the crystal with a 16 MHz resonator. I only had a 25 MHz and a 12 MHz crystal at home, both intended for other projects so I had to go for the resonator. A resonator has a little bit worse precision, but I have never noticed that.

The board is called Brage (from the Bragi son of Odin) from Lawicel

Soldering went ok, but I think its time for me to upgrade my solder iron.
I think I for once did a nice job. It is so nice to work on a well-made PCB, where everything is laid out nicely and you can relax and just follow the instructions.

Features:

The PCB is a Arduino board but with a non-standard layout. All the pins are laid out along one of the sides. That way if you use a bent header you can place it sideways standing from a breadboard. It also has a ISP and a I2C pinout. I chose to use regular male headers, since I have lots of them and use cables with female connections.

There is no USB or FTDI chip on board so you need a USB to serial programmer to program it. It has one power LED and one D13 LED and a reset button. 

It can be powered from the FTDI or from a VIN pin using a 7805 IC. 

In short a nice board and a fun soldering experience. No problem getting it to run the blink sketch.

Brage with ATmega328 from Lawicel-shop

Programming Brage using FTDI and Arduino IDE

Wednesday, March 27, 2013

Magnetic compass Circuit

Introduction

Now when the trilateration project is well on its way, I needed to rest my ears for a while, since those sound localization experiments makes a lot of noise!

The trilateration aims to localize my robot in the room, giving it a coordinate position,  but in order to create a map of the room I also need to know the robots orientation. To achieve that I ordered a electronic compass Circuit based on the HMC5883L chip. The HMC5883L is a "Three Axis Magnetic Field / Electronic Compass Sensor" 

"The Honeywell HMC5883L is a surface-mount, multi-chip module designed for
low-field magnetic sensing with a digital interface for applications such as lowcost compassing and magnetometry"
- datasheet
pinout

I connected it to my Arduino Ethernet 
  • VCC to 3.3V on the Arduino
  • GND to GND on the Arduino
  • SCL to A5 on the Arduino
  • SCA to A4 on the Arduino
  • DRDY was not connected (it is used to interrupt)
I found a library and a tutorial but in Arduino IDE 1.0.3 the names for some methods in the Wire library had changed so I changed the Wire.send() to Wire.write() and Wire.receive() to Wire.read() in the library.

connected

Experimental Setup

The Library contains an example and I ran it as it was, it outputs the direction in degrees. Something did not quite add up so I decided to draw the directions on a paper with 45 degree increments.

Results

Every line is a 45 degree output increment. It seems the angles calculated by the examples is not linearly divided on the circle...
I have no graduated arc but it is quite clear something is wrong. The first 180 degrees are more like 110 degrees. It is quite repeatable so I get almost the same measurements every-time, some noise.

Interpretation

This is my first 3D compass so my first guess was that the magnetometer is slightly misplaced or angled on the PCB.

There was also a little bit of measurement error on my behalf, since I moved the paper a few times, but should not be more than a few degrees and not such large errors.

Apparently this kind of error has been encountered before:
http://arduino.cc/forum/index.php?topic=100672.0


And I found a tutorial to help
https://www.loveelectronics.co.uk/Tutorials/13/tilt-compensated-compass-arduino-tutorial


They say that the IC should be tilted to work correctly... hm... and combined with a accelerometer, but why? I only intend to use it flat and not to tilt it in any direction...

I guess the earths magnetic field is tilted somehow and I need to compensate for that.

This blogger has similar problem but on another sensor, I must be missing something
http://www.varesano.net/blog/fabio/first-steps-hmc5843-arduino-verify-accuracy-its-results

If I want to use this as a compass it needs to be calibrated and compensated for the error.

Calibration discussion for another chip
http://arduino.cc/forum/index.php/topic,38104.0.html

And some code from David W. Schultz
http://home.earthlink.net/~david.schultz/rnd/tracker/cal.c

Really good discussion on the sparkfun forum.
https://forum.sparkfun.com/viewtopic.php?f=14&t=18510&start=45

From that I started on a calibration method that calculates the minimum and maximum X and Y values (in Gauss) and re-centers the measurements using the map function. So before you measure anything you turn the robot around. Make sure you do not lift it and tilt it!


  if (raw.XAxis < minX && raw.XAxis > -1000) {
      minX = raw.XAxis;
  }
  if (raw.YAxis < minY && raw.YAxis > -1000) {
      minY = raw.YAxis;
  }
  if (raw.XAxis > maxX && raw.XAxis < 1000) {
      maxX = raw.XAxis;
  }
  if (raw.YAxis > maxY && raw.YAxis < 1000) {
      maxY = raw.YAxis;
  }
 
  //recenter
  float rX = map(raw.XAxis, minX, maxX, -255, 255);
  float rY = map(raw.YAxis, minY, maxY, -255, 255);
 
  // Calculate heading when the magnetometer is level, then correct for signs of axis.
  //  float heading = atan2(raw.YAxis, raw.XAxis);
  float heading = atan2(rY, rX);
This gives very much better results slightly skewed angles but so much better...
Two measurements, still skewed... but better...
To be continued...



Links:

Datasheet:
http://www51.honeywell.com/aero/common/documents/myaerospacecatalog-documents/Defense_Brochures-documents/HMC5883L_3-Axis_Digital_Compass_IC.pdf

dx.com
http://dx.com/p/three-axis-magnetic-field-electronic-compass-sensor-module-for-arduino-148734

Tutorial
https://www.loveelectronics.co.uk/Tutorials/8/hmc5883l-tutorial-and-arduino-library

My declination according to http://magnetic-declination.com/ 4° 15' EAST
http://www.wolframalpha.com/input/?i=%284%C2%B0+15%27%29+in+radians gives me 74.18milliradians

New parts received from Lawicel-Shop

Two Brage PCB´s, Arduino female headers, pushbuttons and a LED-matrix.
Today I got the package from Lawicel-Shop. They have really fast deliveries, I ordered it on Monday and got it on Wednesday. Everything was nicely packaged and marked.

I intend to get cracking on the Brage(arduino clone) soldering very soon...

Tuesday, March 26, 2013

Three microphone circuits

Three Arduino boards with three microphones, trilateration here I come! ... wait I´m lacking a USB to serial...

Tonight I soldered another microphone, together with the one on the breadboard I now have three in total. Two problems remain: 
  1. I need another USB to serial in order to connect them all three to my PC (I can however connect the one on the right to the RPi... Well yesterday I ordered more USB to serials
  2. The new microphone circuit did not get the full 200x amplification. It works but with lower amplification. I've checked the connections using my multimeter, My best guess is that it might just be the electrolytic capacitor that got broken. Unfortunately I do not have a multimeter that can measure caps. :(
Well tomorrow I will replace that cap, desoldering is fun!

New parts ordered

I placed two new orders for parts, one from dx.com and one from Lawicel
The USB to TTL (5V serial communication)

I keep wishing for more and more USB to serial devices. So I ordered myself another FTDI USB to TTL device of the same kind as last time. I also ordered two PL2303HX USB to TTL, these are very cheap and they do not have any DTR or reset capabilities but I keep creating more and more custom Arduino boards and need a cheap way of communicating with them. The programming can be done with the FTDI chips or by using the reset button. When I receive these I have 3 programming devices and 3 extra serial devices, that should be enough!!!

More female headers http://www.lawicel-shop.se/prod/Female-Header-Pack_880907/Sparkfun_64668/SWE/SEK

I also ordered some female headers. From dx I ordered 10 Double Row 10-Pin Headers. These can be used for my custom arduino boards. I also ordered two full sets of "Arduino headers" (2*6pins + 2*8pins).


Brage PCB http://www.lawicel-shop.se/prod/Brage-SIP-bare-PCB_947673/LAWICEL-AB_8758/SWE/SEK
I have a lot of ATmega328 and ATmega8 IC´s so I ordered two Arduino compatible PCB´s called "Brage" from Lawicel-shop. These can be programmed like an Arduino but have a different form factor and are intended to be placed on a breadboard I guess. I have not seen many Arduino bare PCB´s that can be ordered before this one, almost all come with components.

I also ordered a set of mini pushbuttons, you can never get to many of those.

Lastly I ordered a 8x8 Mini Green LED Matrix. I got na idea for a wireless board using these as output, and with a cheap distance sensor.

Monday, March 25, 2013

Multiple microphones

Background

In my previous experiments I have measured distance between a microphone and a speaker. In order to use trilateration to position the sound-source I need multiple microphones.

Multiple Microphones
The other day I built another Arduino-board intended to work with another microphone. Today I added some headers on it to make it easier to connect to the microphone.

Currently one of the microphones circuits is on a breadboard and the other one has been soldered to a perfboard. Eventually I will have three microphones in order to pinpoint the location of the sound.

The idea is that my Raspberry Pi is going to be connected to the Arduino´s. The RPi  sends a serial signal to the Arduino´s that initiates the distance measurements.

A measurement starts by sending a radio transmission to the robot. The robot responds by outputting a sound and the Arduinos use their microphones and sample like crazy until their buffers run full. After that they calculate their individual distances and report to the RPi.

Hardware prep and test

The new board with microphone on breadboard.

Two Arduinos with microphones and a single 433Mhz radio transmitter

The Java project

The java program is going to run on the RPi but since the pi is so slow to compile on I will write it on my Windows machine using Eclipse.

Serial communication might be tricky on Java but there is a library called RXTX

I downloaded from that site but ended up using the ones supplied with the Arduino IDE.

I copied the "rxtxSerial.dll" to my C:\Program Files (x86)\Java\jre7\bin

and jar file copied to project/libs of my Java project.

The outline of the code

The java program identifies the Arduinos by enumerating the serial ports. After that a calibration step happens to calibrate the sensors at a known distance. The calibration consists of 15 samples that are taken, any failing samples are discarded before the median error is used to correct the following samples.

It seems that the synchronization of the radio should be done last.

All serial communication is done asynchronous in separate threads. But I think that will be removed in favor for simpler synchronous communication.


Results

I have not done any detailed testing but initial results are very promising. I get very good results on short distances (within a cm, sloppily measured).
Two microphones listening to a speaker
The multiple measurements is done a lot slower than with a single Arduino, where I did everything on one board and no extra serial information was needed. But I got some ideas on how to speed things up.

With only two distances I can in theory calculate a position but will get an extra shadow position. Think of two circles that intersect in two positions. I expect that the measurement errors may result in the circles not connecting and overlapping in a larger area.

I need to wire or solder up another Arduino and a microphone circuit to get the trilateration working.

During this project I keep wishing for more Arduinos... Today I ordered 2 PCB´s from Lawicel to build me another set of Arduino boards.


Thursday, March 21, 2013

Soldered myself another Arduino like board

Almost all my general purpose Arduino boards are already used in Robot mapping project so tonight I intend to solder myself another board. The boards function is to listening to a microphone, measure time, and send that time over serial. That will be combined with measurements from other microphones to be able to locate my robot. I'm not after full pin-out this time. Just a few analog pins will do.

Trying out different layouts. Something like this?

The requirements:
  • Can be powered from battery
  • Can be programmed with my new USB to serial
  • Has at least one analog in
  • Has at least one digital in/out
  • Has one GND connection
  • Has one +5V connection
  • 16 Mhz clock
This is the first board I make that uses a 16 Mhz resonator instead of a crystal. Might be quite fatal for the project to use a resonator since they have less sensitivity. 

Going out to my workshop to solder...Be right back...

And 2 hours later...
The soldered board, is powered up and can be programmed. Only six analog pins have pins.
Oh I´m getting quite tired now, but the new board can be programmed using Arduino IDE as a regular UNO board. I have not tried any fancy stuff yet. I need to add headers for GND and +5V in order to be able to attach a microphone.




Wednesday, March 20, 2013

FTDI, new protoshields and a big doh!

Just received an order from dx.com and it finally arrived ordered the 2013-02-28 and it arrived today 20 days later. Well I guess you get the delivery time you pay for.

FTDI USB to serial


FTDI USB to Serial
I ordered a FTDI USB to serial. For my set of homemade Arduino boards[1][2] . Sometimes I need to program or have serial communication with more than one at once.

Right now I use a USB-Serial Light adapter. This new is based on a FTDI chip  seems to have the similar pin-out or so I hope.

FTDI Pinout
DTR, RX, TX, 5V, CTS, GND

USB-Serial Light Pinout
Reset, RX, TX, 5V, NC, GND


When I connected it to the computer drivers were installed and it identified itself as a serial port on Windows 7. Next I connected it to my a homemade Arduino board and tried to upload a sketch. No problem!


Programming a Arduino board with the FTDI. The USB Serial Light board to the right.

Arduino Prototyping shields

Two prototype shields, top and bottom.
I also got two Arduino prototype shields. The last one I bought ended up as an Arduino board for the Raspberry Pi. The quality was quite good so I ordered two more.

These boards have:

  • Place for LED-13 and resistor
  • Place for another LED
  • 14 pin SOIC area
  • 20 pin DIP area
  • Place for reset switch
  • Place for other switch


The board lacks one of the screw-holes normally found on a Arduino board.

I think I will use one of them to attach to my Nokia 5110 Screen, it is kind of messy to set that one up on a breadboard!
Maybe put the 5110 on a shield?

I think I might wait and see what to do with the other one....

And finally a ZIF socket for my programmer, but it was too large!

The zif socket I ordered is a bit on the wide side for a ATmega328...
I intended to use the ZIF socket for my programmer but this one was 0.6inches wide and not the 0.3inch that I hoped to get. DOH!
The intended programmer board for the ZIF socket.

Sparkfun sells the correct size if someone else is out to get one.


Tuesday, March 19, 2013

Lots of Beeping produces better measurements

Results are quite good now

I spent an hour today tweaking my sound distance measurement code. This measures the distance between a sound source and a microphone, synchronization is done by radio.
I actually get quite good results now, normally just a cm or so error after calibration. I am taking the median value from 12 measurements.

test setup 25 cm, sensor shows 23.8 cm

Challenge 1: Measuring longer distances, 

For the robot mapping I would like to get around 2 meters of accurately measured distance. Right now for short distances up to 120 cm the accuracy is acceptable (a few cm or mm error). At distances greater than 130 cm I suddenly get large errors...
I do not know why? Maybe the sound is not strong enough or get disturbed by noise? Must investigate.

A problem with longer measurements is that the SRAM memory on the Arduino is quite limited so the memory buffer has a very limited size. Since I sample the microphone sensor readings into an array of memory before analyzing, the amount of memory decides the range I can measure. If I use slower memory or transforms the measurement into smaller space I loose samples since such calculations take time from sampling.
Perhaps I could make up an algorithm that starts by measuring short distance, and if it does not find the sound there it asks for a new sound pulse and try measuring the larger distance.

Challenge 2: Get the measurements consistent

When I reset the test, change the code I must recalibrate the distance sensor for it to work properly, today with current setup I get an error of +15 cm, the other day it was 12.2 cm.

The calibration consist of measuring a known distance and calculate a mean error to subtract.
The sensor attempts to pick up the first peak in the 4.8 kHz wave. Here at 60 cm with 0.61 cm error after calibration. Before calibration the error was 15 cm
Not really sure on how to handle/automate calibration, I guess that is a pain we have to live with,

Challenge 3. Keep on testing despite the noise

Every measurement is a 20 millisecond 4.8 kHz beep, I put a delay of 20ms between the beeps... That means a lot of quite annoying noise. I have ordered a ultrasonic sender/receiver pair, I have high hopes for those...


Sunday, March 17, 2013

More ATmega8 ordered

I just got the email that my batch of 10 ATmega8 IC´s was shipped today. Yay!

Image from DIYGADGET
I ordered these from http://www.aliexpress.com, I have not tried aliexpress before since it felt a bit dodgy. The IC´s are going to be used for various Arduino experiments where there is less need of 32kB of flash memory, the ATmega8 only has 8kB.

Friday, March 15, 2013

Ultrasonic transducers ordered



Ultrasonic Wave TCT40-18R from dx.com
Last night I ordered a pair of Ultrasonic Wave Transmitter and Receiver heads. These are driven at 40kHz compared to the 4.8kHz I run the current radio beacons at. My hope is that I can use these to improve the accuracy of the radio beacons. The idea is not to measure distance to an object but to measure distance between two specific entities, the robot and a radio-beacon.

I have tried using two HC-SR04 units and tried measure the distance between them but the echo cannot be detected before the trigger has been activated.


A schematic for ultrasonic range finder from micro-examples.com

I intend to build one sending circuit for the robot and one receiver circuit for the radio-beacon with these. I found the above schematics from micro-examples.com with PIC example code. That circuit looks easy to connect and I just need to divide it into two parts. The code needs to be adapted to Arduino but that sounds even more easy, PWM at 40kHz, delay to avoid false readings and wait for the response... easy as pie. I can probably use the pulseIn Arduino function or a interrupt trigger.

USB-HUB

Not really related but I also ordered a 4-port USB HUB with individual switches for the new workshop. I hope that will save me from the wear and tear of pulling those USB cable out and press them in all the time.

Wednesday, March 13, 2013

Arduino Robot with homemade H-bridge

Since all my electronics is in boxes for the redecoration of my workshop. I thought it would be nice to show an old robot project of mine.

This robot was built as a line following robot. The motors, gears and wheels of the robot is from the scarab beetle robot I built with my 7 year old. 


Image from The Automata Blog on the scarab beetle
On top of that base I built myself a H-bridge circuit to control the motors. An H-bridge lets you run an engine in both the forward and the backward direction. To control two motors you need two H-bridge circuits. The H-bridge is built out of a set of npn and pnp transistors as well as some diods and resistors to protect the Arduino board from the inducted voltages from the motor.

The H-bridge on a protoboard running a 3V motor.

The H-bridge is controlled from an homemade Arduino board. The Arduino controlls the direction of the engines and collects sensor inputs from a set of photo diods and and IR-LED. The IR-led is turned on and off and the photo-diode captures the difference in amount of reflected light. That way the Arduino board can figure out the reflectivity of the surface under the robot.

Homemade Arduino
I put two sets of reflectivity sensors in the front of the robot on a breadboard so I can add and remove stuff. The robot starts by calibrating the sensors so it turns left and turns right and back to center in order for both sensors to capture the maximum and minimum reflective of the dark line versus the floor.

The robot in all its glory, lots of cable-mess
The robot could follow a line on the floor in a roughly circular pattern, it had to be driven quite slowly in order to not miss the line and run away. The code was very simple, if a sensor encounters the black line, turn in the opposite direction a bit.

This was built around a year ago, now I really want work on my Robot mapping project or I will when I'm finished with redecorating the workshop.


Monday, March 11, 2013

New electronics workshop in the making

New workshop with more room for electronics tinkering.

My old workshop acts as home office, my wife´s sewing studio, guest bed and electronics lab. That means the room have had a lot of furniture, computers, sewing machines, loads of fabrics and boxes of mixed electronics. 
Current work-space with very little room for electronics

The desk space have been really sparse so my electronics tinkering have been done mostly in front of the keyboard of my computer. Not having enough work-space hinders creativity so my wife and I decided to redecorate the room and make sure we have enough storage and work-space for all.

When image-searching for electronics work-bench, you realize that a work-benches tend to get really messy.

Requirements for the electronics lab


  • Work-area 
  • Close proximity to the computer
  • Close access to a USB-hub
  • Access to multiple power outlets
  • Storage for electronics parts
  • Storage for electronics projects, like robot and a few breadboards
  • Storage for cables
  • Storage for tools
  • Computer screen for the Raspberry Pi.

Progress

The room is emptied and walls are cleaned

Walls are grounded with white color.
Last night we started painting, first two layers of white color on top of the wallpaper and then one layer of  "Kaktus 809". We have one more layer to go before we are done painting.
"Kaktus 809" The new color for the walls...
After we are done with the walls we plan to put up a lot of shelves for storage and get some new desks from Ikea, perhaps the "Galant" desks. I want to have a dedicated work-area for the electronics with a low shelf .




To be continued...

Wednesday, March 6, 2013

The sound distance experiment, part 2

Introduction

In the Robot Mapping Project I want to measure the time it takes for sound to travel from my robot to a number of microphones in order to calculate the position of the robot.
the Arduino "robot" with speaker

the electret microphones


In previous blog post I have described the construction of the microphone circuits as well as my first attempts on measuring distance. The distance readings measured showed a large errors as shown i the figure below.

Red line is actual distance, blue is measured, the samples have been ordered in the X axis according to distance.

The median error from the last experiment was around + 14.8cm (that is the difference from middle of each red level to the blue.)  That error is probably since we measure the first valley in the sound wave and also from the setup time of the code and can be easily subtracted. It is the the other type of errors I would like to work on. 

There are two different errors that we encounter. 

First: Very much shorter distance readings.

Here we detect "false"-readings. These reading come from my code that detects the distance between the valleys in the incoming sound. I hope these will be kind of easy to correct since they are not directly followed by a 4.8Khz wave that lasts for a long time.

Second: Missing the first few waves

Here we fail to detect the valleys of the first waveform, I'm not so sure that I can easily solve this problem easy enough in code. But since the error seems to happen on a small amount of the samples I think that it can be remedied by taking more samples and use the median distance. I have done a few attempts and around 5 samples seems to work.
The incoming wave is detected. The valleys in the wave is displayed as small dots under the graph.

Why do I get these errors?

The errors come from
  • Noisy input
    • Low frequency noise from the USB
    • High frequency noise from components etc.
  • The detect valleys code
    • sometimes fails on detecting a valley and is also sensitive to noise.
  • The detect 4.8Khz wave train code.
    • Relies on the distance between valleys and need to have a sanity test. If there are two valleys with the correct distance but it is not followed by a lot of valleys its probably not the incoming wave.
Noise on the input

Method

The plan for tonight's experiments is to modify the code to better detect a incoming wave-train.
  1. First apply filtering on the samples to see if the noise gets reduced, try this also on battery.
  2. Rethink the detect valley code, there really has to be a good stable source out there that is better than mine.
  3. Add sanity test to the detect wave train code. The input to this code could be reduced to a boolean array of valley center positions.
  4. A multiple sampling and median selection algorithm should be used.

Experimental setup

Experimental setup

A experiment should be conducted to evaluate the quality of the samples

Distances between microphone and speaker should be 25, 50, 75cm.
50 measurements on each distance should be made.

Results

The code was rewritten
  1. The software filters did not smooth things as much as I liked
  2. The detect valley code now works much better
  3. The wave train is detected and I reject false readings
  4. 5 samples are taken with 20 milliseconds delay the median of the index 2 and 3 and  values are used. If a sample failes to be detected it is taken again.
150 measurements have been done on 25, 50 and 75 cm distance
The measured distances in red versus the actual distances.  The error deviation increases with distance.

The medium error is +12,21cm for the combined distances. 

When the medium error is subtracted it is quite accurate at short distances.

Future work


Examine how the amount of samples and use of other frequencies can improve the accuracy.

Monday, March 4, 2013

No serial connection with the Little Wire bootloader

I spent a few hours yesterday with the ATtiny85 trying to program it using serial input to the Little Wire-boot-loader using the method described here.
The ATtiny95 set up as a Little Wire USB tool.
I tried both the windows(XP) with FBOOT.exe(that cannot be run on a 64bit OS) and Linux with the custom download tool(just called "bootloader") as described in the v1.1 version of the bootloader. But I get no connection. There should be a moment 0.3s or something during bootup where the bootloader responds to incoming serial connection.

Dan Sheadel kindly presented me with this link to a arduino High voltage serial programmer that can as I understand unset the "disable Reset Fuse"

This it is not a serious crisis for me, its only one IC we are talking about and I got more, and it seems I can use this as the little wire ISP programmer... but its interesting to try putting that circuit to work without frying my Arduino. And I would like to try the cdc232 USB to serial firmware.

Saturday, March 2, 2013

USB project disabled future ISP-programming

Introduction

As part of my newly started USB-to-serial project I wanted to put my new programmer to use. While the family and I watched Harry Potter I found http://littlewire.cc/, a very nice little project with very little hardware demands. It is based on a ATtiny85 and uses 2 zener diods and a few resistors to do all sorts of cool things with USB. Since It also could be loaded with the cdc232 USB to serial firmware I fought it might be a good start for the project.

Well I connected the circuit from http://solderpad.com/ihsan_kehribar/minimal-avr-programmer-and-more/

Zenerdiods, USB breakout, resistors and a ATtiny85.
Then I used the new programmer to program the circuit with the firmware. After installing the driver it enumerated correctly as a USB device. Then I wanted to use the firmware-boot-loader to upload the CDC232 code but since I have a 64 bit OS it did not work...

Shame to the one who gives up easily! 

I reconnected my programmer and tried to program it again, no response. The avrdude replies -1 check connections or something similar. After checking the connections a few times and even testing the programmer on another MCU and testing another programmer on the same ATtiny85. I started to suspect something was wrong with the ATtiny85 chip.
Testing the programmer on another MCU a ATtiny25
When I burned the bootloader onto the chip I used the following line from the Readme.md file:
avrdude -c usbtiny -p t85 -C -U flash:w:combined.hex -U lfuse:w:0xe1:m -U hfuse:w:0x5d:m -U efuse:w:0xfe:m
Using the fuse calculator that I learned about from Lady Ada Fuse tutorial. I realized that the "Reset Disabled (Enable PB5 as i/o pin); [RSTDISBL=0]" fuse was enabled and that effectively stops any further programming using ISP. Or as Lady Ada puts it
"I would suggest you never set this fuse unless you really mean to." - http://www.ladyada.net/learn/avr/fuses.html
Not that it really is a bad thing, the "littlewire" project needs its extra pin and I can always buy another MCU.

Something that I wonder about is if I had a high voltage programmer could I change the fuses then? And where can I get one of those. High voltage sounds cool, but I guess its only 12 V.


Friday, March 1, 2013

From breadboard to protoboard

Programmer on breadboard
In my last post I assembled a USBtiny programmer on a breadboard. A programmer can be used to program the MCU´s directly or to put a bootloader on them like the Arduino bootloaders.


The buffer circuit from LadyAda schematics was left out since I was not totally sure that I bought the correct IC. I bought the 74HC125N and ladyada recommends a 74AHC125N. I could live with a missing "A" but the schematics says that "Only the 74AHC is compliant at lower VCC!". I tried to compare the datasheets but they where a bit different in their layout and I did not know what to look for. 

Last night I designed it the layout in Fritzing, printed it and the schematics and then I soldered it. 

The soldering went kind of OK, 
I´m really no expert in soldering and I consider it to be kind of messy when you are designing and making it up as you go. But it is fun kind of problem solving.

The soldered programmer, with female USB port

Instead of the Sparkfun MicroUSB I used on the breadboard I used the female USB header. Female type A headers are those mostly on USB-hosts like computer so putting a female type A header on a USB client is kind of weird, but hey I´m learning and I asked my wife to buy me a USB male to male cable. When she brought it home for work I was eager to test my circuit.


Kind of nervous I plugged in the USB cable without the ATtiny2313 chip in the circuit and spent a few minutes with the multimeter. Then I removed the USB and inserted the chip and plugged in the USB-cable again. The red LED should light up, but it remained black, so I quickly removed the power and started to search for an error... could not find any so I moved the ATtiny chip back to the breadboard, putting cables from the protoboard IC socket into the correct places on the ATtiny and it worked?! Moved the IC back to the protoboard and no light...

After 2 hours of searching for an error I just plugged it into the socked again and pressed it a little firmer into the socket and it the red LED lighted up, confirming correct USB connection!

Programming
I tested the board by programming the already wired up ATtiny85 that I think I will use in another USB project. Worked smoothly and without any problem.

My plan for the space left on the protoboard is to place a ZIF(Zero Insertion Force) socket so I can program new IC´s faster. I also plan to place male headers on the sides so I can select where I want the SCK, MISO, MOSI and RESET lines to go. If there is space I will also put in the buffer chip and a female header to put a crystal in.

dx.com zif socket hm looks a bit wide?

Lessons learned:

  • Plan ahead before you solder
  • Buy proper USB sockets, that you have cables for
  • Firmly insert IC´s in sockets