using PIC microcontroller for energy monitor

Hi,

is it the circuit http://openenergymonitor.org/emon/buildingblocks/how-to-build-an-arduino...

can use with PIC microcontroller instead of using arduoino.

it is because i want to built energy monitor using PIC as it is one of the condiotion of my project.

hope you guys out there can help me.

thank a lot.

Robert Wall's picture

Re: using PIC microcontroller for energy monitor

The Arduino and the PIC are generally similar and both use a 5 V input, but that is all. The connections - pin numbers - are different. None of the software for the Arduino will work on a PIC without a lot of changes.

But you could use the general ideas that you find in the programs (sketches) for the emonTx. In just a few minutes, I found much information about the PIC analogue inputs. I think that is your starting point. When you can read two analogue inputs, you can then use the algorithm in the emonTx sketches to calculate the voltage, current and power.

kllsamui's picture

Re: using PIC microcontroller for energy monitor

i will test the EMON on PIC soon, using the chipKIT MAX32

info about CPU: PIC32MX795F512H
- 512K Flash (plus 12K boot Flash)
- 128K RAM
- 80MHz, 1.56 DMIPS/MHz, 32-bit MIPS
- Fast and Accurate 16 channel 10-bit ADC, Max 1 Mega sample per second

Regarding EMON ARDUINO code, only in readVCC AVR specific code is used,

the arduino code will work.

the speed must be slowed down for EMON batch by a delay ( this PIC about 10 times faster ),

because of RAM and FLASH much more code / options can be loaded, (like SCOPE / FFT / GSM SMS ALARM.. )

As first step pls find my PoorManScope2 in the download area of my BLOG,

same code runs with arduino 1.0.1 and with MPIDE.

emon arduino

EMON shield , Volt, Amp signal, on arduino uno at 4.3kHz , that is max speed for 2 analog in, for this PIC it is 100kHz.

For one analog in, the limit is 8.3kHz (UNO), 199kHz (PIC).

The PMS2 scope window is a processing application, runs on PC, connected to UNO or MAX32 board. pls test it.

 pls check progress kll.byethost7.com/kll_en7/news.php

 

kllsamui's picture

Re: using PIC microcontroller for energy monitor

GOOD NEWS, on PIC:

with EMON FULL WAVE sketch,

 - only readVcc replaced with fix value 3300, ( because its AVR code what can not run on PIC )

 - a delaytimer in batch loop of 353usec

 and EMON shield virtual ZERO circuit: 

 - not to 5V, instead to 3V3 shield pin connected  ( i installed a 3pin jumper )

BUT SAME TUNING.. like on ARDUINO UNO

get same timing and results with the chipKIT MAX32 board.

using the full 30kHz speed the readings about 7% to small???

 

pls find attached code to be used in MPIDE (0023) or ARDUINO 1.0.1

for chipKIT MAX32 or ARDUINO UNO

and also PoorManScope2 ( CHART recoder sketch only for fast wave form check )

n3glv's picture

Re: using PIC microcontroller for energy monitor

Project to log and display DC wattage use.

I have a DC powered electric assisted bicycle. He runs on approx 24v although the range is more like 29.6 to 22v from charged

to full discharge states. I have a current circuit that sends 0-50A as 0-50mv to a milliavolt meter on my handle bars now.

Max reading is 35A (that is the PWM controller limit).

I'll soon be adding another feed wire to send raw batt voltage to the same area of the bike.

I have an arduino UNO, and also I pi, but I would very much like to use just the UNO.

What I am looking for is a trip-watt-o-meter (my term). I need to count current@voitage * minutes or seconds and log to NV /

send to some kind of display (I have some 16x2 lcd and other lcd on hand).

Ideally I want to be able to set a starting quantity equal to my fully charged 24v/20ah pack expected reserve. Lets call this wmax

(watts max available) And then count down to zero, based on use. If it could drive two horizontal graphs for real time V and I

(ideally going reverse of each other) and have the remaining at the end, or center, that would be fantastic.

So, if I say 0-33mv I can use the onboard 3.3v supply for A/D right? And directly read the current. I should also be able to (with

less resolution) devide the remainder above 22v by something to get 0-3.3v. (or run on external 5v ref, but that would reduce

the accuracy of the wattage calc from the ammeter).

It looks like I can use some of the sketch from emontx, I'm looking for thoughts / input from the group, thanks.

 

Robert Wall's picture

Re: using PIC microcontroller for energy monitor

Hello Jeff,

Firstly, we use mainly the Atmel (Arduino) processor here. There is quite a bit of information in the sketches, but I think little that will be of great help, simply because this site is all about monitoring a.c. power. But there is enough knowledge here to be able to help you, if you can put your own hardware together.

As I understand, you have a current signal of 0 - 50 mV, and a voltage signal of 0 - 30 V (approx). and you want a bargraph display of both these, and you want an estimate of energy remaining in your battery - as numbers and a bargraph?

If you can use the Atmel ATMEGA328P, then the emonGLCD has a LCD screen on which you can draw bargraphs and text, and the processor has analogue inputs that, with some amplification for the current signal and voltage dividers for the battery voltage, will give you your inputs.

So I am thinking that you take the emonGLCD circuit for the display, and build on to it the analogue inputs (you don't need the radio input). You can run the processor at 3.3 V but use the 1 V reference for the analogue inputs, which means the current input will require less amplification (20 x ) (without amplification, at best you only get 50 steps in the current measurement - that might be good enough but I don't really think so). The voltage input is not a problem.

Does that help?

Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.