• 0
myfinalstraw

Custom Channel and Javascript

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

Share this post


Link to post
Share on other sites

3 answers to this question

Recommended Posts

  • 0

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

Share this post


Link to post
Share on other sites
  • 0

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

Share this post


Link to post
Share on other sites
  • 0

Hi Nathan,

If understand correctly you problem is that you can't see the measured values.
In this case make the measurement view wider or dock it to the bottom of the scope tab.

It seems that you are using an earlier version of the software. You can find the latest one at https://reference.digilentinc.com/waveforms3

Edited by attila

Share this post


Link to post
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