Optimal frequency to capture a 50Hz peak signal

WingNut
Posts: 127
http://meble-kuchenne.info.pl
Joined: Tue Jul 13, 2021 1:53 pm
Has thanked: 8 times
Been thanked: 6 times

Optimal frequency to capture a 50Hz peak signal

Post by WingNut »

Hi all. Has anyone done any work on sampling a 50Hz signal such as an ouput from a CT to capture the peak voltage? Also, if i use an interrupt to capture this, how many separate interrupts can i use that won't affect the performance of the circuit? I already use one interrupt and IOC. Is there a limit?
PIC16f18877 (if you have been following my posts you'll figure out I'm trying to buld a resonably accurate energy monitor)

N

BenR
Matrix Staff
Posts: 1106
Joined: Mon Dec 07, 2020 10:06 am
Has thanked: 281 times
Been thanked: 377 times

Re: Optimal frequency to capture a 50Hz peak signal

Post by BenR »

Hello,

Yes there will be a limit, it all boils down to how long you spend inside each interrupt and the frequency of your microcontroller. Ideally you want to be in and out as quickly as possible and also clocking the micro as fast as possible.

Theoretically a sample rate of at least 12X the max frequency of a signal would allow you to fairly nicely approximation of a signal. So anything you can do above this will give you more accurate peak detection at a cost of smaller accuracy gains.

Maybe aim for 12X (12 x 50Hz = 600Hz which is very acheivable) and then try and push it harder and harder until your main program is starting to become sluggish, i.e. you're spending most of the CPU runtime inside the interrupt macros. Then you can back off again knowing what the real limit is and making a nice balance between sampling and processing.

For our electrical machines range there was a definite point where the comms commands as part of the main loop would start to fail due to the high interrupt driven sample rate which gave me a really nicely defined maximum allowable throughput.

As a further improvement you can implement a nice averaging filter, maybe a combination of a median and a mean.

WingNut
Posts: 127
Joined: Tue Jul 13, 2021 1:53 pm
Has thanked: 8 times
Been thanked: 6 times

Re: Optimal frequency to capture a 50Hz peak signal

Post by WingNut »

Thanks Ben. Some working out to do then

steve001
Valued Contributor
Posts: 134
Joined: Wed Jan 13, 2021 7:15 pm
Has thanked: 66 times
Been thanked: 18 times

Re: Optimal frequency to capture a 50Hz peak signal

Post by steve001 »

Hi Wingnut
WingNut wrote:
Thu Jan 06, 2022 10:10 pm
sampling a 50Hz signal such as an ouput from a CT to capture the peak voltage?
Just read your post, the output from a CT is not a voltage unless you have a special CT that dose this for you, or a Hall Sensor Type device

The output is current that is in relation to the ratio i.e 100:1 so at 100 Amps Primary current you would get 1 Amp in the secondary

Please note, open circuit CT's can have a very high open circuit voltage, and this condition can stress the insulation and cause them to fail.
CT's should always have a load connected to them.
WingNut wrote:
Thu Jan 06, 2022 10:10 pm
(if you have been following my posts you'll figure out I'm trying to buld a resonably accurate energy monitor)
Martin has also done one on the app developer page, that might give you some ideas

Steve

WingNut
Posts: 127
Joined: Tue Jul 13, 2021 1:53 pm
Has thanked: 8 times
Been thanked: 6 times

Re: Optimal frequency to capture a 50Hz peak signal

Post by WingNut »

Thanks Steve. Yeah Im familiar with transformer theory. The ct im using has a 10 ohm load resistor connected across the terminals. I'm trying to figure out the most accurate way of sampling the waveform presented to the analogue input of the micro. I currently have 3 different methods non inverting op amp, differential op amp and voltage divider (resistor network). They currently produce vwery different results but until I can get the sampling right I won't have a stable input on any of them.
I'll take a look for Martins
Thanks again

steve001
Valued Contributor
Posts: 134
Joined: Wed Jan 13, 2021 7:15 pm
Has thanked: 66 times
Been thanked: 18 times

Re: Optimal frequency to capture a 50Hz peak signal

Post by steve001 »


WingNut
Posts: 127
Joined: Tue Jul 13, 2021 1:53 pm
Has thanked: 8 times
Been thanked: 6 times

Re: Optimal frequency to capture a 50Hz peak signal

Post by WingNut »

Hi Steve. Yes thats interesting. I had to purchase 2 more modules - app developer and comms c to examine that correctly :|. But the work is being done by a third party device and i want to do it all on as small a circuit as possible and on a PIC micro so I'll park app developer for a bit but i do plan to use wireless comms for a future project with similar features

medelec35
Matrix Staff
Posts: 729
Joined: Wed Dec 02, 2020 11:07 pm
Has thanked: 267 times
Been thanked: 269 times

Re: Optimal frequency to capture a 50Hz peak signal

Post by medelec35 »

Thanks, Steve for posting the link.
WingNut, all you need is a tiny micro e.g PIC12F1840, the Power monitor PZEM-004T and if you want a display, use an I2C or SPI version.
E.g 20x4 LCD with I2C backpack.
It does not have to be used with App developer, but it's great for monitoring.
For example, the data can be logged within a CSV file showing AC voltage, current power, power factor, frequency etc.
I have been using the ESP32 to send all the data to the internet, so I can access the data from my mobile, live from all over the world.
Power monitor live .jpg
Power monitor live .jpg (45.02 KiB) Viewed 1528 times
This is using a Raspberry pi as a broker.
The only thing is there has been an update with the latest PI operating system to make it more difficult to do.
Martin

WingNut
Posts: 127
Joined: Tue Jul 13, 2021 1:53 pm
Has thanked: 8 times
Been thanked: 6 times

Re: Optimal frequency to capture a 50Hz peak signal

Post by WingNut »

Hi Martin. Yeah I appreciate what it does. Question is is it True RMS?

medelec35
Matrix Staff
Posts: 729
Joined: Wed Dec 02, 2020 11:07 pm
Has thanked: 267 times
Been thanked: 269 times

Re: Optimal frequency to capture a 50Hz peak signal

Post by medelec35 »

No, I don't believe it is as true RMS will not be required to measure low impedance AC mains.
However I do have a true RMS meter and when compared the mains voltage, there was 0% difference in the readings
Martin

Post Reply