Jump to content
  • 0

Custom Channel and Javascript


myfinalstraw

Question

Hi,

I would like to add several custom measurements based on my Scope Channel 1 signal:

1. Current measurement through a 220 ohm resistor

2. Min and max Frequency measurement of the signal applied to the same 220 ohm resistor.

For number 1 I clicked "Add Channel" -> Custom, and added C1/220 to the textarea. This resulted in a new channel in the scope.channel column. I then went to Measurements column and did "Add" -> Custom Channel -> Math 1. This added an M1 measurement to my measurements. I modified the default Javascript to the code below, which (if I understand correctly) should average current through the resistor:

value = 0

Channel.data.forEach(function(sample){

value+=sample

})

value /= (Channel.data.length)

value *= 1000

 

Is there a cleaner, better way to do this?

 

Regarding #2, I wasn't able to figure out how to to obtain time measurements, which I assume I would have to do. My guess is I would have to diff two sequential times, and get their inverse to calculate the frequency. If someone could provide an example I would greatly appreciate it.

 

Thank you in advance,

-Nathan

Link to comment
Share on other sites

3 answers to this question

Recommended Posts

Ni Nathan,

1. Right done. You can also change the unit for the Math channel to be Ampere. The unit for Average measurement will show wrongly V, but you can add a custom measurement with proper unit. You don't need to multiply the measurement value to obtain the mA value, the kilo/milli/micro is automatically prefixed to the unit.
2. You can find predefined the Frequency measurement. After checking min/max close and reopen the measurement view in order these to appear.
The average/min/max is shown for the extreme periods and it is stored for multiple acquisitions.

img8.png

Link to comment
Share on other sites

Hi Attila,

Thank you for your reply. I am still unsure how to get the min/max frequency. The only way I can measure frequency is by using pre-defined measurements.. I do that by "Add" -> Defined Measurements -> Channel 1 -> Horizontal -> Frequency. Then I click "Show" -> Min + Max. I get the attached screen. Your screenshot has M1 for frequency measurements, which I believe has to do with the custom channel Math 1. How did you get that to show up? 

Thank you again,

-Nathan

waveforms.jpg

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...