Track every Watt(TEW) is one of the new Open Hardware based project which I am working on for the past few weeks. Track Every Watt is a pluggable device which can be used to measure power consumed by an electrical appliance. The device to be measured is connected to the TEW which has an LCD display which shows power consumed and also some additional information. TEW was inspired from Kill A Watt which is a device that can only measure devices with voltage rating 110V. TEW has a voltage rating of 230V and this is the reason why I started this project.
Track Every Watt can display additional information such as Voltage(V), Current(A), Watts(W), Volt-Amp(VA), Frequency(Hz), Power Factor(PF), Kilo Watt Hour(KWH), Time Elapsed. It uses an Analog Devices Energing Metering IC ADE7763. There is also an application note AN-564 for this IC.
Today I got a chance to do some hacks on Phoenix-MDK. There was a need of a bootloader for this board. Along with that, we should be able to program the board without hitting any reset switch. The first thing which came into my mind was the arduino boards. They had all the above mentioned features. So I started understanding how the arduino board works, which boot loader is used inside, how reset can be triggered through software etc.
The bootloader used in arduino’s are the optiboot which has a very small footprint (around 512kb) and it was using the serial protocol STK500 for its communication. So I took the optiboot and made some modifications. But it failed. I don’t know where I went wrong and also I bricked one ATMega32 chip.
I had one more ATMega32 chip with me. But this time I was really careful not to brick again a chip. It was really hard to find a bootloader. After a long search I found this page which really helped me a lot – http://wiki.edwindertien.nl/doku.php?id=software:bootloaders
The bootloader can be obtained from http://wiki.edwindertien.nl/lib/exe/fetch.php?media=software:atmegaboot-32.zip. Phoenix-MDK uses 8MHz crystal. So I had to modify a line in the makefile which contains the clock frequency to AVR_FREQ = 8000000L . Thats all. I gave a make and got the hex file.
Below are the steps for flashing the bootloader and using it.
1) Flashing the bootloader using parallel programmer
flashing the hex:
avrdude -c dapa -patmega32 -U flash:w:ATmegaBOOT_168_atmega32.hex
flashing the fuse:
avrdude -c dapa -patmega32 -U lfuse:w:0xff:m -U hfuse:w:0xda:m
2) Testing the bootloader
avrdude -b 19200 -P /dev/ttyUSB0 -pm32 -c stk500v1 -n
This should give a proper response.
3)Uploading a hex file using the serial bootloader
avrdude -b 19200 -P /dev/ttyUSB0 -pm32 -c stk500v1 -U flash:w:a.hex
For the above code to work on Phoenix-MDK, I also had to do some hardware hack. Now the DTR pin is connected to the reset pin so that reset can be done by software. I have to find a software way to reset the chip.
Today I fabricated the PCB for GNUduino (Arduino made with gEDA). I used screen printing to transfer the PCB layout. Screen printing is another way to transfer the PCB layout to the copper clad instead of the conventional toner transfer method. Download GNUduino design files
The PCB was successfully fabricated and also tested the LED blink sketch. Everything is working fine.
NOTE: The below shown are only prototype’s to verify the design. High quality PCB’s cab be made with the design files.
Here are some snapshots
The screen printed copper clad’s
Etching the PCB
After drilling holes
GNUduino is ready