Jump to content
  • 0

Waveforms: Math functions in Logger


towen

Question

Hi,

Is it possible to log math functions with the data logger, or how could I do this with the Python API?

The logger only allows me to add C1 or C2, not M1.

The closest I have got to this, is to use the logging function of the scope measurements pane, where I can use `Scope.Math1.measure("AC RMS")` for example in the logging script.

However this is not ideal for me as it throws away some data (the scope can only trigger so fast) and I am trying to make a continuous datalogger on the AC Mains, using a current clamp probe. Whereas I believe that the logger uses all available samples to calculate each RMS sample.

FYI I am making a kind of DIY smart meter, to see just how much the power companies are fleecing me when  turn on loads such as LED lights which have a high crest factor. (I believe that they sample at the peak of the AC waveform only, and assume the current is sinusoidal, but it is not, due to the bridge rectifier on the front end of most DC-powered devices like computers and LEDs)

It would be great to have RMS power (using a 100:1 voltage probe and a math multiplication) in the data log as well as a measure of the crest factor (I was thinking of using "Amplitude" / AC_RMS, but other suggestions are welcome)

 

The other niggle I have with the logger is that the UI is not very useful for viewing the data, since it discards data when you zoom in. It also doesn't support different units or probe attenuation factors. There also seems to be a bug where the last channel cannot be removed. If you untick all channels then the last one still remains displayed, but even if you try to enable another channel instead, you cant get rid of the last one.

Link to comment
Share on other sites

3 answers to this question

Recommended Posts

  • 0

Hi @towen

In Logger the selected and checked channels are drawn.
The attenuation can be specified under the gear option.
Custom channels can be added under the plus button / Function.

The Scope offers Math channels (function performed on each sample) and Measurements (performed on capture, on array of samples).

image.png

Link to comment
Share on other sites

  • 0

This is the way I ended up doing it, using the scope measurements instead of the logger:


FileAppendLine("~/Desktop/scope/elec_meter.csv", [
Date.now(),
Scope.Channel2.measure("AC RMS"),
Scope.Channel1.measure("AC RMS"), 
Scope.Math1.measure("Average"),
Scope.Channel1.measure("AC RMS") * Scope.Channel2.measure("AC RMS"),
Scope.Channel1.measure("Frequency")
])

image.thumb.png.221cb2cc9bb1e5d722b63e8346cd6791.png

BTW, you'll notice that my current draw is anything but sinusoidal - this is what LED lamps look like! (and why peak-sampling smart meters can over-read LED lighting by a factor of 7 - https://www.bleepingcomputer.com/news/hardware/millions-of-smart-meters-may-over-inflate-readings-by-up-to-600-percent/)

If I turn off some LED lights then it looks like this:  (the rest of the spikiness is probably other non-PFC DC rectifiers like cheap switching PSUs)

image.thumb.png.1a93c3f46ade0d0de2e78b826b6b587c.png

 

It'd be great if there was some way to measure THD on these waveforms and log that to CSV as well!

My next challenge is to do this using a raspberry pi without the GUI so that I can have a continuous logging server - I assume the best way is using the Adept python API? Or is there an easier way?

(note on safety of measuring the mains: Of course, I am using a 100:1 high voltage probe, via a fuse and 1 MR resistor, to measure the voltage safely)

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...