jgyates / genmon

Generac (and other models) Generator Monitoring using a Raspberry Pi and WiFi
GNU General Public License v2.0
379 stars 76 forks source link

External CT Monitor shows double KW Output #645

Closed TopBanana123 closed 2 years ago

TopBanana123 commented 2 years ago

Expected Behavior

L1 amps + L2 amps should be x120 to get the KW output

Actual Behavior

L1 amps + L2 amps are x240 to give double the KW output

Steps to Reproduce (including precondition)

Use the PintSize.me Sensor hat, add CT's to leg 1 and leg 2 and look at the KW, its showing for example a 3.6KW load when there is 15a load on the generator

There is 10a on L1 (120v) and 5a on L2 (120v) meaning the total load would actually be 1.8kw

Screenshot or Pictures relating to the problem (if possible)

Screenshot_2022-01-13 14 56 06_uBBWkG

Your Environment

dennis48755 commented 2 years ago

Bit whacked is right. Mine has been showing 498.74 A steady all afternoon with or without the CT's connected Screenshot 2022-01-29 192658 .

dennis48755 commented 2 years ago

and even when the hat is removed entirely

I can confirm, these weird readings appear without the Sensor HAT attached.

skipfire commented 2 years ago

Without the sensor HAT attached at all I'm not surprised to see it pegged like that. My guess is that not having it there is defaulting the input value to 0, which would equal ~250A on the bottom of the sine wave.

jgyates commented 2 years ago

@TopBanana123

When you removed the HAT and restarted the pi, did you refresh the browser? Then browser loads it requests the gauges and they type of data expected and it only refreshes the expected data after that. If you change the config if genmon you will need to refresh the browsers.

Also, sending your log files form the about screen would be helpful.

TopBanana123 commented 2 years ago

Yes I refreshed the page, I must because I have it served through a reverse proxy (No caching)

I just submitted my logs, but I believe I turned off the CT debug logging we enabled before. Is that what you'd be looking for?

jgyates commented 2 years ago

I checked in an update that should help the issue when the HAT shows up if the HAT is not present. Since the SPI bus shows up as long as the changes are in /boot/config.txt, reading the device returns zeros if the HAT is not present. Since the zero current reading is 512 this makes an unusually large reading. The change makes the HAT add on ignore any readings if they are all zero.

One thing to keep in mind is that the can be up to a 20 second delay in the readings of the HAT until the time the web page is updated. 15 seconds for the default "Poll Time" in the CT Hat settings and another 5 seconds for how often the web page refreshes.

skipfire commented 2 years ago

@TopBanana123 or @dennis48755 are either of you up for running a python script to see if I've got a possible solution? The script checks the inputs from the CTs, and calculates amps, and then it prints 2 values per second, a "filtered" amps (new value) and a peak amps (current value). The current code in genmon takes many samples (hundreds) to try and get one as close as possible to the crest or trough of the sine wave but only preserving the single greatest offset, this method includes inrushes and noise (I gave jgyates this code so my bad). The new code does that 5 times and takes the lowest peak value. I have a steady 3.7A load that was reading 3.42A to 4.64A, now it is 3.66A with a rare 3.42A or 3.91A, which are only a single step different (there's nothing between 3.42 & 3.66 or 3.66 & 3.91). Hopefully it at least filters out basic noise, but if there is an inrush current that could be longer than the scan duration, my fridge has an inrush period of about 400ms. This script is currently stand alone to try and confirm that it is a viable fix, which I would say is it being within 1A per leg, preferably 0.5A. If you do this on the Pi that has GenMon I believe all the dependencies should be in place to run the script successfully.

Change the script extension to a .py if you want, python doesn't actually care what extension it is. test.txt

dennis48755 commented 2 years ago

I will give it a try tomorrow.

Can you give me instructions how & when to run it, I'm not very Linux literate.

skipfire commented 2 years ago

If you are on Mac I'm not sure if scp is present or has the same switches or not. Download the file, open a command prompt and get to the folder you downloaded to. If you use the default download folder then you will need to cd c:\users\{username}\downloads and then to transfer the file scp test.txt pi@{Pi name or IP}:~

To execute the script, ssh into the Pi ssh pi@{Pi name or IP} enter your password and then to execute the file, python3 test.txt You can stop the script with Ctrl+C. It will output the readings once per second until you stop it and it will show data for both clamps.

jgyates commented 2 years ago

scp is on a mac, to copy just open Terminal and type:

 cd Downlaods
 scp test.txt pi@{Pi name or IP}:~

then enter the password of the pi user on your raspberry pi.

jgyates commented 2 years ago

I checked in a new version of the add on that incorporates @skipfire's new approach in the test app. Let us know how your testing goes.

skipfire commented 2 years ago

@TopBanana123 I just tested using the Sensor HAT without a connection to the generator and GenMon does still show the data.

Also keep in mind that CTs have their own magnetic field, so if they are close enough to each other they will mess with each other. I had one on hot and one on neutral for the same load and the clamps were touching and I had some readings that were 1A off, when I held them so they were a few inches apart that gap dropped off.

Also, the 100A clamps datasheet only has spec'd accuracy between 10% to 120%, 120%-150% is graphed and non-linear, but below 10% there was no information.

dennis48755 commented 2 years ago

Here are the results of running Test.txt.

Note: this was without @jgyates updates from last night Test Rewsults.txt Screenshot 2022-01-30 092308 .

skipfire commented 2 years ago

Was the HAT disconnected for that test? The script was indicating that it is not seeing the Sensor HAT.

dennis48755 commented 2 years ago

@skipfire, yes Sensor HAT installed & CT's connected. 20220130_094013

skipfire commented 2 years ago

Ok, part of the problem may be the pin headers. You have the black wire, which I'm assuming you are using as ground, connected to the SPI1-CS0 pin that Sensor HAT uses. Ground is the next pin over, or next to the green wire. I'm surprised the ttl is working.

dennis48755 commented 2 years ago

Yeah, sorry, I also noticed that from the pic I sent. That occurred later yesterday when looking at the HAT.

The new readings (attached) match more closely with my discussions earlier with yo Screenshot 2022-01-30 095618 .

skipfire commented 2 years ago

Ok, so the script does look like it at least improves the data, but that's still more noise than I would expect.

Anyone know if some of the low readings could be from the 120v battery charger?

dennis48755 commented 2 years ago

@skipfire, regarding my setup, My pi3B is powered from a 5v USB power adapter plugged into my household AC. It is mounted in an Elk metal panel box in my basement next to my Generac transfer switch. My TTL DB9 has three wires into the transfer switch and through the conduit (~35ft) to the generator. The CT's are connected in the transfer switch to the generator output mains.

TopBanana123 commented 2 years ago

I'll read back through these comments, I see a few directed at me

The battery charger at least on my model comes in on a seperate line from the TS. So putting the clamps on the generator output would make no difference, it should read zero. My clamp meter reads zero when the CT's show 2a

jgyates commented 2 years ago

For what is is worth there are two settings that may help.

On the add on settings the "Strict Usage of CT data" setting will not use the CT data for power calculations unless the system is in an outage.

an undocumented setting in for the add on that sets a minumum value of a given CT. The default value is 0.6A. In /etc/genmon/gencthat.conf adding this value

 singlelegthreshold = 1.0

would make readings of 1.0A or lower return zero amps. This value can be any floating point value.

TopBanana123 commented 2 years ago

Sorry for being so quiet on this, been very busy with other things

I'm going to update and test tomorrow morning, and I also got IoTaWatt installed in my panel with CT's on the generator input wires in my ATS, so I have something to directly compare against

jgyates commented 2 years ago

@TopBanana123, I am going to close this issue for now. Let me know if you have any other feedback on this thread.