esorensen Posted March 16, 2016 Posted March 16, 2016 I'd like to count the number of rising edges on all digital input pins for a particular interval of time (30 sec). Is this possible?
attila Posted March 17, 2016 Posted March 17, 2016 For such long period you can use the Stream acquisition mode and have the sample rate to filter the eventual glitches. For instance, if you are interested in signals with frequency below 1kHz, set the rate to 4kHz or something between 2-10kHz depending on pulse duty. You can use the event view on one signal and filter the 1s to have to count of rising edges. With the following script you can filter and sum the edges for multiple signals: function filter(rgEvents){ var cEvent = 0; rgEvents.forEach(function(event){ if(event=="1") cEvent++; }) return cEvent; } var cSum = 0 cSum += filter(Logic1.Channels.DIO3.events) cSum += filter(Logic1.Channels.DIO2.events) cSum += filter(Logic1.Channels.DIO1.events) cSum += filter(Logic1.Channels.DIO0.events) print(cSum)
esorensen Posted March 17, 2016 Author Posted March 17, 2016 I'm new to this scripting language, so please bear with me. The DIOx objects don't appear to have "events" available. Also, how should I define "rgEvents"? I'm running on a Mac. (Pasted images aren't going through?)
attila Posted March 17, 2016 Posted March 17, 2016 The script syntax is javascript. The rgEvents is the argument of the defined "filter" function which returns the number of 1s (rising edges) in the array argument. To use this, you have to add the interested signals to the Logic Analyzer, change the summing list in the Script code to have these signals, DIO#.cSum += filter(Logic1.Channels.DIO#.events) ... After you have the acquisition data press Run in the Script tool.
esorensen Posted March 17, 2016 Author Posted March 17, 2016 I do have the signals in the logic analyzer. I get the following when trying to run the script: Error in line: 30 TypeError: Result of expression 'rgEvents' [undefined] is not an object. for the following line within the fuction: rgEvents.forEach(function(event){
attila Posted March 17, 2016 Posted March 17, 2016 Do you have the latest version (3.2.6) installed which supports the Events ?https://reference.digilentinc.com/waveforms3
Question
esorensen
I'd like to count the number of rising edges on all digital input pins for a particular interval of time (30 sec). Is this possible?
6 answers to this question
Recommended Posts
Archived
This topic is now archived and is closed to further replies.