Friday, January 2, 2015

Getting Started with USBAspLoader from ground up and troubleshooting

The Beginning

It has been a long absent since the last post of my electronic project and hacks.
Time to get my dusty arduino out of the shelf. G*! I don't know what to do with

All i could remember is that i tried to get USBAspLoader up and running on my
Atmega8A-16PU. Ok, here is the deal. I write this article to aid anybody that
in my situation or maybe to refresh how to get USBAspLoader running.


All Bill of materials are well described in the schematic below. Noticed i don't put
100nF electrolytic capacitor between uC Vcc and GND. But i do add 10nF capacitor
at my soldered board. Why? Well i forgot to add one on my breadboard, sorry.

And here is the schematic.

Don't get confused of the uC label, Atmega168, is has the same pin layout with Atmega8.
With the schematic reading given me some clue the arrangement on the breadboard. Plug
the USB cable and my Linux (Fedora 19) detected as

kernel: [27618.902659] usb 3-3: new low-speed USB device number 2 using xhci_hcd
kernel: [27619.073587] usb 3-3: New USB device found, idVendor=16c0, idProduct=05dc
kernel: [27619.073592] usb 3-3: New USB device strings: Mfr=1, Product=2, SerialNumber=0
kernel: [27619.073594] usb 3-3: Product: USBasp
kernel: [27619.073596] usb 3-3: Manufacturer:

Fiuh.. ok enough with the prototyping, it is time to move it to real soldered board.
Here is the minimum configuration to get the USBAspLoader working. And why
am i writting this article and to use USBAspLoader? Simple it is play well with arduino
and to upload/program a firmware or Arduino sketch file is blazing fast!

If you noticed that i only use USB connector as Power and Data in/out. That is the
power of USBAspLoader, it is so compact and minimum to be setup and running.


Here are some problems i had faced while setup USBAspLoader to run.

  • Device detected as High Speed USB.
    Usually the D- and D+ is swapped. Try to swap the connection.
    The arrangement starts from Vcc, D-, D+ and GND. Check out this Wiki link
  • Device is unable to be enumerated. You have to check whether USBAspLoader
    is uploaded correctly. Also the Jumper must be active low, connected to ground.
    My jumper port is assigned to pin PD6. You could check it from the firmware,
    since i compiled the firmware from scratch then the setup pin is located in ../usbasploader/firmware/bootloaderconfir.h just set the JUMPER_BIT
    to any desired value. If you don't know what you are doing just check it
    and leave it as default. If you see it is set to 6 then it refers to PD6 and if 7,
    older version, then PD7.
  • The Device seems not responding although is already RESET.
    Simply leave the JUMPER_BIT floating and then press RESET.
    The bootloader will start bootloading the firmware which uploaded.
  • Device is restart by it self. Make sure the RESET pin of the uC has
    a pull-up resistor. Simply add a 15k resistor between Vcc and the RESET pin.

Hope this article would help. Keep soldering! :p

Breadboard Self-Capacitance Problem

Just found out how self-capacitance or parasitic capacitance very annoying.
Let me share the experienced i had with breadboard self-capacitance.
I am driving a relay with a transistor, BC 337 (npn). With my usbasploader
on Atmega8 as my On/Off controller.

Here is the schematic.

The problem starts to showing. I had arranged all parts as in the diagram above
on a breadboard. When an On signal raised from microcontroller, Atmega8
with usbasploader, to the transistor and the relay starts to make a tick sound,
telling me that it is at "On" state. When the "Off" signal triggered... nothing happens.
The next "On" state nothing happens and so on. It is just turned "On" and hang.
Humm.. after several trials

1. Adding a capacitor 10uF at the transistor B-E pins

2. Adding a pull down resistor at the transistor Base pin, 10K Ohm.

The trials said above results the same condition whenever the transistor
had been raised to "On" it can not be switched "Off". Aha! I put a LED 1Watt
or a forward-bias diode as shown below figure.

The relay starts to ticking On and Off as expected. And the LED looks dimmed
when the transistor at "Off" state. Now i remembered that i have been warned
that breadboard has stray-capacitance or a well known name parasitic capacitance
and its 10pF. Big enough to hold some voltage to maintain the relay at "On" state.

I don't know whether the voltage that were trapped between the "free-wheel"
diode and the relay is oscillating since have no scope to check.But i am guessing it is.
Final summary is that soldered board more accurate, while breadboard still
a good choice to do some prototyping. So do both to make sure everything works
as expected