Home
JAQForum Ver 24.01
Log In or Join  
Active Topics
Local Time 07:07 02 Aug 2025 Privacy Policy
Jump to

Notice. New forum software under development. It's going to miss a few functions and look a bit ugly for a while, but I'm working on it full time now as the old forum was too unstable. Couple days, all good. If you notice any issues, please contact me.

Forum Index : Microcontroller and PC projects : SiliconChip Appliance Energy Meter Aug-Oc

Author Message
Kitski
Newbie

Joined: 01/05/2019
Location: Australia
Posts: 6
Posted: 04:25am 01 May 2019
Copy link to clipboard 
Print this post

Hello to the forum. I’m experienced in analogue design and building but a MM micro ‘newbie’, so this journey is a big learning curve !

I recently built 2 of these kits from Silicon Chip (SC) and had no problems in building. Testing and confirming correct basic operation of the analog hardware section was straightforward.
When testing the completed kits, I found a reading anomaly which strongly pointed to a software issue (major maths error) with both (preassembled) MM boards when mated with either of the 2 ‘hardware’ PCB’s

Hoping I may have been supplied 2 pre-programmed PICs with the wrong firmware version, I attempted to reload the latest code from SC to the MM PIC’s (PIC32MX170F-256B) following the SC article (Sept ’16) using MMEdit but this resulted in a “dead PIC” - a blank MM screen. I suspect in hindsight this was because I didn’t run the MMEdit ‘LIBRARY DELETE’ command first.
(I couldn’t find either the DELETE or SAVE command in MMEdit’s screen. Help .. where is it ?)

Assuming this exercise had been successful, I don’t understand how the new firmware could be saved to the PIC without a suitable programmer (which I don’t have). This requirement is noted in SilChip Feb ’16 – The MicroMite LCD BackPack, pages 26-27.

Many emails to SC seeking assistance regarding the suspected SW bug have remained unanswered, possibly because it’s an ‘old project’. Web searches for possible clues proved fruitless. I’ll leave discussing the suspected SW bug (displayed Power Factor value changing significantly with varying input AC voltage – which it shouldn’t ! - for those interested) for another posting.

Would appreciate what options I now have other than buy a new pre-programmed PIC from SC to at least get the meter working again, even (in)correctly.

Thanks,

Kitski
 
TassyJim

Guru

Joined: 07/08/2011
Location: Australia
Posts: 6283
Posted: 06:05am 01 May 2019
Copy link to clipboard 
Print this post

LIBRARY DELETE and LIBRARY save are micromite commands so you run them from a terminal screen.

I don't know the SC energy meter software but at a guess,
do a NEW command to delete the main program
then
LIBRARY DELETE to delete the library
then
load the library code using MMEdit (easiest ftom a chat window rather than 'load and run')
then issue the command
LIBRARY SAVE
and the file just loaded gets transferred to the micromite library area.
then
NEW
and load the main program.

Jim



VK7JH
MMedit
 
panky

Guru

Joined: 02/10/2012
Location: Australia
Posts: 1114
Posted: 06:15am 01 May 2019
Copy link to clipboard 
Print this post

Hi Kiski,

Welcome to the forum.

Firstly, with the MM Backpack connected to your PC and with MMEdit running, if you select the Micromite Chat option ( the blue M on the taskbar), do you get the MMBasic prompt (a > character)?

If you do, then MMBasic ( the Basic interpreter) id alive and almost certainly OK.

Now, regarding the steps referred to as LIBRARY DELETE, these are MMBasic commands and should be entered from the Chat Window (as given above). This command tells the MMBasic interpreter to clean out the LIBRARY area ready to load the new library code. Once you have completed this step, you can then proceed to load the new library code, SCAppEnergyMeter_Library.bas and, again from the CHAT window, enter the LIBRARY SAVE command. If you now enter (from the CHAT window) LIBRARY LIST, you should see a message detailing the newly loaded library code.

If this looks OK, then you can now proceed to load in the actual program, SCAppEnergyMeter_Main.bas. Again, once the load is complete, at the CHAT window just type LIST to see if your main program has loaded OK.

You can now enter RUN at the CHAT window to determine if the program works.

Let us know how you go,

panky.

PS. Jim beat me to it!!
Edited by panky 2019-05-02
... almost all of the Maximites, the MicromMites, the MM Extremes, the ArmMites, the PicoMite and loving it!
 
Kitski
Newbie

Joined: 01/05/2019
Location: Australia
Posts: 6
Posted: 07:12am 01 May 2019
Copy link to clipboard 
Print this post

Thanks Jim & Panky,

Will try out your suggestions later this week.
Appreciate your prompt replies !!

Kitski
 
Turbo46

Guru

Joined: 24/12/2017
Location: Australia
Posts: 1642
Posted: 03:10am 02 May 2019
Copy link to clipboard 
Print this post

Welcome Kitski,

If you haven't already, it would be handy to download the documents "Micromite User Manual" and "Getting Started with the Micromite" from Geoff's website here. You may not want to get into the Micromite but the manuals will give you a bit more understanding of what you are doing.

I don't think you should have to but you may have to configure the LCD screen and Touch options (using the chat window):
  Quote  OPTION LCDPANEL ILI9341, L, 2, 23, 6
OPTION TOUCH 7, 15
The manual will explain that.

I see a reference to MMEdit's 'crunch' option in the article - it seems like it would be a good idea to crunch the programs before loading also.

Silicon Chip are normally good at replying so they may be worth another try but I can't find any reference to revised firmware in the notes and errata for 2016.

Bill

PS Don't buy new chips - you haven't killed them.
Keep safe. Live long and prosper.
 
Kitski
Newbie

Joined: 01/05/2019
Location: Australia
Posts: 6
Posted: 07:12am 02 May 2019
Copy link to clipboard 
Print this post

Bill:
Your comments noted. The Meter and MM touch-screen all worked prior to my (failed) attempt to re-load the code.

Panky:
MM Edit being used: Mk2_V5.3
MM connection via the CP2102 module to the PC seen as COM6,38400.

1. With 'bad' MM board connected and with Chat enabled, all I see in the receive (lower) window in continuous scrolling of this text "CPU exception #7 (bus error on load or store).
2. With the 'good' MM board connected and Chat enabled, I don't see a '>' prompt in the command line window. Now this is a bit of a worry. Why no prompt ?

Will download the manual and look for clues.


Kitski


 
Kitski
Newbie

Joined: 01/05/2019
Location: Australia
Posts: 6
Posted: 07:30am 02 May 2019
Copy link to clipboard 
Print this post

A quick explanation what I'm using.
The MM PIC is aboard the MM LCD Backpack connected via ribbon cable to the CP2102 board which has a uUSB connector. This connects to my XP laptop running MMEdit.
Curious why I don;t see any command prompts or Geoff's MM banner.

Kitski
 
WhiteWizzard
Guru

Joined: 05/04/2013
Location: United Kingdom
Posts: 2944
Posted: 07:44am 02 May 2019
Copy link to clipboard 
Print this post

Hi Kitski,

IF your Micromite has AUTORUNning software then you need to press Ctrl key AND the C key (Ctrl-C).

Also ensure your BAUD rate is set correctly - usually 38,400 (but not always!).

IF your still getting CPU issues, then reset the Micromite by holding down the '!' key whilst powering the MM up. This will reset the MM to 38,400 - BUT it will wipe any program it contains. Loosing a program is not too much of an issue as it can always be re-loaded.

Let us know if any of this helps!

WW
 
Turbo46

Guru

Joined: 24/12/2017
Location: Australia
Posts: 1642
Posted: 07:45am 02 May 2019
Copy link to clipboard 
Print this post

For the good board: OPTION AUTORUN ON - is probably in force. In the chat window click the ^C button (control-C) to stop the program. That should bring back the prompt.

Bill
Keep safe. Live long and prosper.
 
WhiteWizzard
Guru

Joined: 05/04/2013
Location: United Kingdom
Posts: 2944
Posted: 07:46am 02 May 2019
Copy link to clipboard 
Print this post

Forgot to ask:

Can you use TeraTerm instead of MMEDIT whilst trying to debug this issue? MMEDIT is excellent for programming, but I find the Chat window is a bit limited. For what you are trying to do; my recommendation is to hook up to TeraTerm (see user manual for download instructions!)

WW
 
Turbo46

Guru

Joined: 24/12/2017
Location: Australia
Posts: 1642
Posted: 07:58am 02 May 2019
Copy link to clipboard 
Print this post

WW, you must have been typing at the same time! Agree with your comments about MMEdit and TeraTerm.

Kitski, don't try to use them at the same time - they argue over the port.

Bill
Keep safe. Live long and prosper.
 
WhiteWizzard
Guru

Joined: 05/04/2013
Location: United Kingdom
Posts: 2944
Posted: 08:59am 02 May 2019
Copy link to clipboard 
Print this post

Hi Kitski,

I have just remembered something when playing with the Energy software (with a later version of the MMBASIC firmware than when published). It resulted in what you saw (CPU exception error).

I simply recommend you reload the original .HEX file to begin with. This will be an old version of MMBASIC but it will RUN. However, your touch will probably be mis-aligned. To fix this, connect to TeraTerm at 38,400 and press Ctrl-C to stop the program running. Then at the Command Prompt, type GUI CALIBRATE and follow the instructions on the touch-screen. Then RUN and you should be back to where you were.

Don’t worry too much about updating MMBASIC as code does work.

To fix the maths error, stop the program (Ctrl-C) and type EDIT. Then its down to you to correct the maths ensuring you press F1 (or F2) after making your changes.

Hope this helps!

WWEdited by WhiteWizzard 2019-05-03
 
Turbo46

Guru

Joined: 24/12/2017
Location: Australia
Posts: 1642
Posted: 03:19pm 02 May 2019
Copy link to clipboard 
Print this post

WW, I recall your problems with this project but I think that MMBasic should be still intact in this case. Hopefully reloading the (crunched) library and software should work. Kitski doesn't have a suitable programmer to load the hex file.

Kitski, Preferably using TeraTerm. If typing ^C on the bad MM doesn't stop the error looping then holding down the '!' key as you power up the MM should (see the manual on 'Resetting MMBasic'). If you then get the prompt then you should follow the procedure described by Panky above. Don't forget the crunch!

Do you think the original problem may be a hardware one? If the zero crossover detection point varies with voltage/current levels that would affect phase angle measurement.

Bill
Keep safe. Live long and prosper.
 
Kitski
Newbie

Joined: 01/05/2019
Location: Australia
Posts: 6
Posted: 01:17am 07 May 2019
Copy link to clipboard 
Print this post

Been busy for the past few days ...
All - will restart this task by using TT today and report back, hopefully with a working PIC !

Turbo46 - it's with some irony that I determined the issue WAS a hardware issue after all. I assumed (yeh, I know: "ass between you and me") this was unlikely, so initially dismissed it. Upon re-analysing my test results and the published SC pix of the working product (all made with EXACTLY 230v AC input !) hinted there may be something going on in the hardware dept.

Non-hardware types can skip this para.
The device samples the mains voltage via a small 1.5VA transformer having a ~12v secondary reduced to about 1v via a medium-impedance resistive divider. Essentially, the transformer primary 'sees' an open-circuit secondary winding.
With a VARIAC on the primary and probing the 12v secondary with a CRO, the 50Hz waveform looked good (apart from typical minor waveform flat-topping) form 110v to 220v. From 230v to 260v, the waveform gradually became distorted with significant zero-crossing phase shifts. (The load current-sensed waveforms were good.) No wonder the PF went crazy !
Fully-loading the transformer secondary with a suitable resistor cured the waveform distortion until ~270v AC where the PF was degraded but was still acceptable (0.93 vvs 0.97). As built, it was 0.30 at this voltage.
The small "intrinsically-safe" transformer is only spec'd to 230v input (hmm, now there's another clue) and may have been magnetically designed with an air-gap to make it short-circuit proof.
End of hardware rant.

Come to think of it, who normally cares what a transformer's secondary waveform looks like !

Thank-you all for your helpful comments.

KitskiEdited by Kitski 2019-05-08
 
Kitski
Newbie

Joined: 01/05/2019
Location: Australia
Posts: 6
Posted: 01:43am 08 May 2019
Copy link to clipboard 
Print this post

Success !

Thanks to you all for your guidance and most helpful comments.
It took a couple of tries to complete due to my unfamiliarity with TT and MMEdit but we made it. Energy Meter now working as intended AFTER including my additional (resistor) modification to correct the erroneous PF

Would appreciate comments on issues I encountered along the journey.

1. After the first PIC load and invoking AUTORUN option, the GUI operation was strange, so decided to re-run the LCD panel as per Geoff G's article (SiChip, Feb'16). Snag - I couldn't stop the (running) MM pgm with ! or ^C as I couldn't get TT or MM to display the > prompt.
After playing around, the only way to get the > prompt was with MMChat and invoking the 'SET RTC' (macro) command. I couldn't find any command in TT to achieve the > prompt. What did I miss ?

Re-running the LCD configs a second time fixed the oddities.

2. Is there a way of interrogating a PIC to see it's contents (not necessarily any file contents) like the DIR command in DOS ?

Thanks again to you all for your assistance !

Kitski

 
Turbo46

Guru

Joined: 24/12/2017
Location: Australia
Posts: 1642
Posted: 02:20am 08 May 2019
Copy link to clipboard 
Print this post

Congratulations on solving the hardware problem and getting the software running again.

If ^C didn't work from TeraTerm then maybe the SC software changed the console baud rate - although I can't imagine why. I believe that holding down the ! key while powering up the MM should stop the MM running if the console baud rate has been changed BUT it will clear the program and library from memory! In the MMEdit chat window, clicking on the ^C button should also stop the program - typing ^C won't.

LIST will list the program.
LIBRARY LIST will list the library contents.
MEMORY will tell you the amount of memory in use.

Remember the program and library have been 'crunched' so any comments have been removed.

Bill

PS not able to run the SET RTC macro at the moment but it probably starts with a ^C to stop any MM program from running first.
Keep safe. Live long and prosper.
 
Print this page


To reply to this topic, you need to log in.

The Back Shed's forum code is written, and hosted, in Australia.
© JAQ Software 2025