DIY Arduino ISP
At some point I realized that it was time to move on from convenient prototyping boards to more aschetic ones to both save in energy consumption and in money. As I've always wanted my hobby projects to be small in size I spotted those cheap arduino pro mini clones on eBay that suited my search criteria. (Search for an atmega328 running on 3.3V at 8 MHz. Anything under 3 EUR will do - there are just too many of those clones to point out any of them separately)
Pro mini boards do not have an FTDI chip meaning that programming can only be done via an external programmer. As I didn't have any I turned one of the MINI-AT boards to an ISP. That was really easy - the hardest part being solving the wiring and connectors problem (PC signal cables are notoriously fragile without dedicated connectors on either side) since I needed the programming process to be repeatable with many pro-mini boards that might end up on my workbench.
The key to my problem was in finding a spare 15 pin connector I had salvaged from an old printer just recently. By cutting off the excess the connector matched perfectly with the pro-mini 12 pin headers I was about to re-flash. To the other side of the programming cable I clamped a 6 pin type RJ11 connector and hid the wiring, status-LED's and an entire AT-MINI board inside a small telephone connection-box. (I had to take two extra connector-wires from another box since these are all shipped with just four wires. Same trick with the RJ11 plug - two extra metal tooth were needed from another connector-plug.)
Wiring
Programmer --> pro-mini board
VCC (+3.3V) VCC
GND GND
SCK SCK
MISO MISO
MOSI MOSI
SS RST
PS! It is advised in forums to add some caps for the programming to be successful. I ended up with adding just one balancing 100uF 16V electolytic capacitor between VCC and GND. Nothing more, nothing less.
Uploading the code
To upload code via an external programmer one has to select 'Upload Using Programmer' from an arduino IDE (File menu) or press a keybord shortcut CTRL+SHIFT+U
Showing posts with label avr. Show all posts
Showing posts with label avr. Show all posts
Sunday, January 11, 2015
Tuesday, February 14, 2012
measuring energy consumption
1. Theory of operation
The energy meter used in our house is a Siemens ZMD120AMtr53 which capable of measuring 3x230/400V (e.g. industrial power) electricity consumption in preprogrammed day and night shift. The energy company charges less for nighttime usage (EUR 0.08 cents) and considerably more during daytime use (0.14 cents)
The meter has three ways of communicating it's readings to interested users:
- dedicated DLMS port for programming and data readouts;
- IR test diode pulses (each 0.2 ms long) with a rate of 10000 = 1 kWh;
- via on-board LCD "graph" (regular users, simple inspection)
The formula for calculating present power consumption via short pulsing IR light is brought by the data sheet:
Example: Meter constant R = 1000
Power P = 36 kW
f-LED = R x P / 3600 = 1000 x 36 / 3600 = 10 imp/s
In my case, the meter was programmed to have the constant 10 times bigger to achieve more precise readings. Thus, once you have an impulse count in seconds, it's easy to calculate real-time power usage.
2. Selecting an IR sensor
A sample graph for 12h power consumption with RRD |
3. Building a prototype
Prototyping is fun! Although I googled for some samples of other fine projects I came up with a more simple and straightforward solution. Firstly, as I formulated the problem very precisely, I ended up getting exactly what I needed. No additional calculations were expected from my 8-bit AVR microcontroller. It's quite the opposite I saw around. Thus I really count pulses and deliver the pulse count in selected timeframe to a logfile.
From software perspective, the key is utilizing the power of AVR chip's interrupts thus leaving more room for other interesting tasks.
volatile long pulseCount = 0;
// interrupt attached to IRQ 1 = pin3
attachInterrupt(1, onPulse, RISING);
and the function to perform is simply
void onPulse() {
pulseCount++;
}
Subscribe to:
Posts (Atom)