Problems getting EmonTx to run new code repeatably

I am attempting to modify some of the posted codes and I am having problems with the Arduino IDE and the EmonTx not giving repeatable results. Although I have been programming since the 80s, I do not do much of it lately, and I am new to using this type of hardware and C++ code (my previous work has been in FORTRAN, Pascal, and VBA).

Anyhow, I am attempting to utilize the EmonLibPro software posted a few months ago by chaveiro, and the hardware / IDE is acting weird. One problem has been in using Windows Notepad to edit the .h and .cpp files with that. I open the file in Notepad to change one number, and then the IDE will refuse to compile it, stating incorrect syntax in a different part of the file. Running Git GUI to compare the changes shows my edit, but also shows some unusual characters introduced elsewhere in the file. It typically looks like: "@@ -95,26 +95,26 @@" in the middle of the file. Open in Notepad and it all seems normal. It will occur seemly randomly, not happening for awhile, and then happening every single time. No matter how much of the text on both sides of "hidden codes" I delete and retype, it is still there. I use Git GUI to revert, it it gone, as soon as I try to edit, it is back. I downloaded Notepad++ to try and fix it but it is still occurring. Then suddenly, the codes are still there but now the compiler doesn't seem to care. Anyone else have any ideas? It is very frustrating...

Secondly, the EmonLibPro code seems to be giving me erratic enough behavior that it almost make me think that something is not clearing in the CPU when I upload new code. it was working quite reliably for several days through several edits. I now cannot get it to run for more than 10 seconds before it locks up the controller. I revert back to the original code, and it still is locking it up. Is there a way to wipe or fully reset the controller on the EmonTx? I have tried after uploading to remove the FTDI cable and then ground all of the FTDI pins (no power on the USB connector). My thought is that sometimes you need to discharge everything to ground to get a proper reset. I don't see any options in the Arduino IDE that would reset or safely wipe it. Can anyone point me towards the proper and safe way to do this?

Thanks for all of your assistance and work on this.

Dan

Robert Wall's picture

Re: Problems getting EmonTx to run new code repeatably

"Although I have been programming since the 80s, I do not do much of it lately, and I am new to using this type of hardware and C++ code (my previous work has been in FORTRAN, Pascal, and VBA)."  I too have been programming since the 80s, also in FORTRAN, Pascal, many BASIC dialects, C then C++.

I cannot speak for "EmonLibPro".  As far as I'm aware, it hasn't been subjected to the extensive use and peer review that emonLib has had.

I suggest you try some of the example sketches to see if the problem persists.

I use Notepad++ all the time (even tweaked it to give the correct syntax highlighting) and I have never had a problem with spurious characters. I'm on XP, which OS are you using? Do you mean GIT GUI, or the Arduino editor? Can you zip and attach a small file that has the spurious characters?

Dan Woodie's picture

Re: Problems getting EmonTx to run new code repeatably

Robert,

Thanks for your comments. I know that the EmonLibPro is not a proven sketch. I messaged chaveiro and he gave me some limited assistance in getting it running. I have limited access to a Fluke 435 3 phase power analyzer which is hooked up to my home installation (2 120V phases plus one generation phase). I made some measurements of accuracy of the standard emonTx_CT123_Voltage sketch earlier in the week and I wanted to compare them to the EmonLibPro sketch.

I am attaching a zip file that contains the original header file, the one I edited, and the output from the GIT GUI program. I am doing all of my work in Windows 7 (64 bit), using the Arduino IDE, and the GIT GUI for github to maintain the code and revert back to the master branch as needed. I was editing the .h and .cpp files using Windows notepad before I switched to Notepad++ to try and correct this error. The problem has been very perplexing. The Arduino IDE compiler would not compile code that seemed to contain this spurious set of characters in it, giving errors related to those lines, but right now it is. i guess it is possible I misinterpreted the compiler errors but I checked it over and over. I can't seem to verify if this extra text is simply extra details the GIT GUI is providing or if they are hidden control codes in the plain text file. Web searches on it have been fruitless.

The other issue when I could get it to compile was that the EmonLibPro code seemed to be giving consistent results with each upload and restart of the EmonTx and then suddenly it stopped and would not run without locking up. I could revert the code back and it would not repeat capability that had been there 10 minutes before. I was hoping that I could perform some type of hard reset of the ATmega to get it back to a blank slate but I have not seen anything pointing me to that.

To check it I just reloaded the standard EmonTx sketch I had on before (emonTx_CT123_Voltage) and that is running stable now. So, it may be a code issue.  I would appreciate anyone who could check the attached file and let me know if they see anything that stands out as a problem character. Thanks.

Dan

Robert Wall's picture

Re: Problems getting EmonTx to run new code repeatably

The "@@" in GIT GUI Compare output.txt are markers inserted by the compare.

[Edit: See "combined diff format" in https://www.kernel.org/pub/software/scm/git/docs/git-diff.html ]

I can't see any spurious characters (i.e. non-printable apart from cr & lf) in your header file. You have a very good diff in Notepad++ (Plugins - Compare) and I have the hex Editor plugin too (OK, they say it is unstable and it automatically gets removed on each update, but I've never seen a problem and put it straight back) and that's what I'm using to look at your files.

 

You're not sending the output of the comparison to the compiler, are you? Of course ( ! ) once you have run the comparison between versions, it won't compile because of the two different lines in the same file.

If you attach the full set of files, I'll try compiling and running them.

Dan Woodie's picture

Re: Problems getting EmonTx to run new code repeatably

Robert,

Thanks for the analysis. I had wondered if the characters I was seeing were markup notes from GIT GUI, but they were appearing nowhere near where I was making my edits, and the compiler was giving errors on those lines. A quick search of the documentation on GIT GUI did not reveal anything either. If I reverted in GIT GUI back to the original it would compile. I would make one simple number change, the characters would appear in GIT GUI and then the compiler would error on those lines. And, no I was not sending the GIT GUI output anywhere, only using it to check for spurious characters in the file. The Notepad++ feature is nice so I will probably use that going forward.

Anyhow, the compiler is working on these files now so I am not sure sending them to you would make much sense but I appreciate the offer and assistance so far. I have some new code I am chewing into at this point, so I may not get back to this right away.

I am still looking for a good way to hard reset or memory wipe the ATMega so if anyone has any ideas I would appreciate it. Thanks to all.

Dan

Comment viewing options

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