Software

The software is running on a PIC16F877a microcontroller made by Microchip. Some people have a programmer device which connects your computer to the microcontroller to upload programs and data. We will have preprogrammed chips available soon, so you won't need to have any extra tools or know how microcontrollers work to build one of these. They are really cool to have though. I own the

Overview

The analog circuit measures the voltage and current traveling through the mains. These are converted from large voltages (120VAC) and currents (0-20 A) to small voltages that can be read by the microcontroller and then displayed on the LED display.

The analog circuit connects with the digital circuit through 5 signals:

center voltage reference

about 2.5 volts. The center tap voltage for the AC signals voltage and current

voltage

an AC signal between vref- and vref+. Proportional to the voltage on the mains line that we are measuring.

current

an AC signal between vref- and vref+. Proportional to the current on the mains line that we are measuring.

vref- and vref+

voltage range that the voltage and current will always be within.

All of the signals are connected to the PIC's analog to digital converters. vref- and vref+ are used by the converters as the minimum and maximum range for the other 3 signals. These sample the voltage of each signal at around 2khz with a resolution of 10 bits (possible values are 0-1023). These samples are then used to compute the power consumed and the output is displayed on the LED display.

Math

Power is computed by multiplying the voltage and current and then averaging these values. This calculates the real power. For more information about what exactly power is, please see the Power page on wikipedia.

First, the voltage reference is subtracted from the samples read from voltage and current. This is because they are sin waves whose center is at voltage reference. These centered values are multiplied together and then added to a total for calculating an average. The values are sampled or measured about 1000 times per second. Each reading is currently 256 samples long. The averages are then fed through a 5 value running average to provide a more stable reading. This running average is the value displayed.

LED display

How does an LED display work?
The LED display only allows one digit to be on at a time (unless you want the same number displayed on every digit). To get around this, each digit is turned on in order one at a time. This happens so quickly that you can not tell that this is what is happening.

To accomplish this, each digit must be turned on in between sampling the data. So, a few samples are read from the pins, the first digit is turned on. Then a few more samples are read and the next digit turns on. The digit is rotated about every 4 samples, however this may be changing in the near future with due to a faster clock speed.

More details coming soon. If you have specific questions post a comment here or in the forums. I hope to explain a lot of this in a lot more detail, but I can start with the things people are most interested. There are also some comments in the code. So please refer to that to better understand how this is working.

Code

The code is available at the bottom of the page. hex files, c code and asm code are all provided. All coding was done with piklab compiling with sdcc under linux (although these tools also work under windows and mac). The code should work with minimal changes using other compilers. Let me know if you'd like to get it working in another environment, I will try to help, I have used others before and might know where to look for changes. To those of you who don't know what any of this means but would still like to build one of these, let me know, we are trying to determine the demand and should be getting you hooked up soon (free hardware?)

AttachmentSize
enerjar-0.8.tar.gz73.7 KB
enerjar-0.8.zip74.98 KB

Great Going

Really Superb Concept sir

using programming editor

Hi,am not really good at programming,but i need your help in programming the enerjar using the software called the programming editor.thanks

enerjar software

hi...i'm planning to make my project on enerjar but i am facing a problem in oppening the above two zipped files...plz help me in this matter....

MPLAB

Gud day sir Matt...!!! i really want to build dis project but i have a problem in building your codes... i'm using MPLAB IDE..i alredy tried to buil your codes in MPLAB but therse so many errors...just wanna ask your help so that i can make my own enerjar...thank u so much and more power...!!!GodBless!!!

software

ei guys...!!!i'm planning to make my own enerjar but i have a problem in oppening ur codes...can i ask for ur help..????thanx!!!

to built my own enerjar as collageproject

please send the ener jar program and complete circuit to me

at
narencp04jntc@gmail.com

energar

i want to build one of the energar, but i am not good at programming. Do i need both the assembly and C code to build this project. Also I am working in windows environment, what changes do i need to make to the C code for it to run.

AVR

Any chance this will get ported to AVR chips?

Phase between current and voltage

Very neat idea,

One of the concern is the phase variation between current and voltage, representing a significant error on energy measurement and wondering how the software might accomodate the phase.

May I suggest to add protection diode across the current sense and voltage sense to reduce risk of damage to electronics associated with abnormal surge currents, for example lighting strike, power cuts, live disconnection.

Good luck

Richard Payne

Cool

This is AWESOME, but I think it should have a plastic lid and blue LED displays. It would also be nice if you could use the power from hte plug instead of a seperate wall wart.

Re: Cool

We're getting a lot of suggestions to use a plastic lid or grommets. It is something we will need to address before we start shipping these.

There is no separate wall wart. The cell phone charger has been stripped down and is mounted near the lid of the jar.

A Very Well Done From HomeBrewPower UK

Just thought I would drop you a mail to congratulate you on the Enerjar meter!

Keep up the hard work

Andy Mahoney
www.HomeBrewPower.co.uk

SPAM?

Nice way of trying to get more hits on Andys homepage loaded with ads. Not much to read there that doesnt cost money.

additional specifications

I love the project, I am trying to build a"watts Showing fromt he old Nuts and Volts article, but what I want to do is add a totalizer/persistent memory/computer interface. I would love to be able to hook up a device that would log kwh/h consumption for a preset period( a day, a week, a month) and retain it after power was removed, and then like a data logger, upload it into a computer for insertion into a spread sheet. This way you could really analyze the best and most effective measures to reduce electrical consumption. i alone would build like 6 of them if I could get plans.

Any ideas/plans for such a beast?

Martin

Add a serial EEPROM to store

Add a serial EEPROM to store data and an IR LED or bluetooth module to upload data.

Very interesting project

This project is very exciting, I am not much for programing PICs so I would be very interested in purchasing one straight from you guys if/when you get around to selling them. I'm fairly well versed in electronics otherwise (3rd year engineering student too, chemical though, and in Australia!) and I could probably put the rest of it together myself.

Let me know if you start selling these PICs (or need the assistance of an undergrad chemical engineer, for whatever reason, I would LOVE to help out!)

Suggestion

Great idea! When you have got sick of making these, how about making one that is just a readout of mains frequency?
A good stand-alone frequency meter for mains is hard to get and expensive.
Thousands of people around the world use generators and knowing the frequency is really important.
This sort of unit would serve them well.

All the best from New Zealand!

Purchase

Hi, love your device and would like to purchase one completely made up (will provide own glass jar if required, as it may be expensive for postage to Australia).

I will also purchase Mark#2 of your fabulous design, which gives a progressive total time switched on (I have a bathroom hot water heater I suspect is chewing up more than it should, due to poor insulation of the pipes, but don't want to sit there for a day with a stopwatch).

Fond regards from down-under,

Ray G.

Purchase

Graham,

I have measured the duty cycle of my electric hot water heater using my PC and a microphone on a long lead. I ran sound recording software (Goldwave) for 48 hours and positioned the mike right next to the thermostat on the heater. It made a loud click each time it turned on and off. Then I found the clicks visually in Goldwave (they appeared as sharp spikes), noted their times and worked out the duty cycle. The heater's name-plate had the power rating in kW consumed when the thermostat was on, so using the duty cycle I could work out the kWh consumed per day without so much as a multimeter in sight.

Regards, Brendan (also down under)