Articles Hierarchy

Articles Home » Arduino Projects » PIC MAX32: POWER MONITOR

PIC MAX32: POWER MONITOR


project 2 for this board is
to use it with the EMON hardware reading GRID AC Volt and Ampere.

Starting with a arduino project FULL WAVE EMON, a modified library incl diagnostic
and better program start and batch start.

After copy to MPIDE ( with rename .INO to .PDE )
the readVCC function in EMON did not compile because it contains AVR code.
for PIC just fix it to 3300.
using compiler switches the code will still run on arduino uno ( arduino1.0.1)

But now the real problem start, if the analog input is only 3V3 can we still read VOLT and AMP?
First we need a new virtual zero, hardware change use 3V3 shield PIN instead of 5V. (board shield pins are arduino compatible)
this will give a new zero of 3V3/2=1V65
The Volt signal is quite high, its +- 1.16V, ? 9V ( rms to peak ) 12.73V / voltage divider 11
at 5Vcc/2 , 2V5 it is about 1.34 to 3.66V signal
at 3V3/2 1V65 it would be 0.49 to 2.81V signal
the AD values 274 to 748 change to now 152 to 870 ( of 1023 )

we still can measure up to 327 Vrms.
for the Amps it has to be checked again.

we could use the 5V and use different resistors in the divider to make the 3V3/2
this would be the way if the 3V3 usage disturbs the CPU or communication.
but then it would be varying with (USB)-Vcc again.
lets hope we can use the 3V3.

for a arduino type shield (on stripes exp. board ) i use a selector 5V / 3V3.
Layout

work log in google spreadsheet

thats the good news:
the EMON FULL WAVE sketch from ARDUINO UNO, with same tuning...
works, even the shield is now connected to 3V3 Volt ( for 3V3/2 zero).
but the Volt and Amp about 7% to small, so the Watt 15% to small.
the 2Ain sample rate is 30.95kHz compared to UNO 2.59kHz.
data

now using a delay timer of 353usec in EMON batch, samplerate, volt, amp same as with ARDUINO UNO.
this tells us that the above mentioned 7% error is from the "oversampling" and the
high pass filter to eliminate the virtual zero offset:
filteredV = 0.996*(lastFilteredV+sampleV-lastSampleV);
so the 0.996 will be tunable in future

pls find the code in the download area ( MAX32: EMON full wave )

why i want use the MAX32 board for power monitoring?
i can not load all my add tools to arduino because of ram and flash limits.
now i want start porting them: ( already running )
- EMON
- with 5 instances for 5 current lines
- Hz and kWh
- operating menu
- EE PROM setup
- FFT ( batch array 128 bytes * 2 )
- SD card
- CHART recorder tool with processing SCOPE ( batch array 400 int * 2 )
- WIFI server
- GSM GPRS SIM 900 shield for DATA / ALARM SMS
-
currently i am stuck with the missing NEW SOFT SERIAL
to connect the modem on soft serial D7,D8, (D9 start puls ) of the SEEED GPRS shield

MAX32_datasheet
MAX32 PWM: 3,5,6,9,10
ext INT: 3,2,7,21,20
CN pin: 4(CN0),10(CN13),16(CN18),17(CN17),18(CN21),19(CN20)

UNO32_datasheet
UNO32 PWM: 3,5,6,9,10
ext INT: 38,2,7,8,25
CN pin: 10(CN13),11(CN10),12(CN9),13(CN8),14(CN4),15(CN6)

so, on both luckily D10, but not D7 should be usable for rx (buffered)
i found some code reg. new soft serial for UNO32 from forum
and KurtE say D7 can not be used for rx, D10 should work
and very lucky, the only one thats same for UNO32 and MAX32.
start testing: run my power monitor toolbox on MAX32 and ARDUINO
that software has a XTERM module for play with the modem link
but not using a modem, just connect the 2 boards:
GND-- GND
D7 -- D8
D8 -- D7
menu "x" starts the terminal emulation,
type text in MPIDE terminal window, see text in arduino terminal window OK
type text in arduino terminal window see NOTHING
ok, if it is about the available and interrupt, CNx ( that he never see the data coming )
while(GPRS_serial.available()!=0) { Serial.write((char)GPRS_serial.read()); }
i test using just a read: Serial.write((char)GPRS_serial.read()); and get for ever


test with
(MAX32 -- UNO )
GND-- GND
D10 -- D8
D8 -- D7
and it works
means i have to change the modem wiring!
by a wire from middle 3 pin selector (rx, send line modem )
to (rx new soft serial MAX32 ) D10.
AND SMS WORKS!!
pls find POWER METER TOOLBOX ( rev 32V1.1a1 ) at download area


there is a follow up article now, called Power Monitor Tool Box V2 PMTV2