LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Edge counting does not function when the graph doesn't intersect the zero

Solved!
Go to solution

Hi everyone, 

 

I'm struggling here to figure out why my counter doesn't count any edges, when I change the offset of my graph in a way that it doesn't intersect the x-axis anymore. 

 

Attached a screenshot as an example of the counter when the graph intersects the x-axis: (Counter_functions.png)

 

on the left side you can see the signal I'm using, which intersects the x-axis. On the LabView frontpanel you can see that the counter is actually working (number of edges = 13930). 

 

Now the example when I change the offset of my graph in a way that it doesn't intersect the x-axis anymore: (Counter_does_not_functions.png)

 

on the left side you can see the signal I'm using, which doesn't intersect the x-axis. On the LabView frontpanel you can see that the counter is not working (number of edges = 0). 

 

The signal I'm using is coming from a frequency generator and wired to the NI 9326

 

The code I'm using is from the following counter course  (page number 9)https://www.labviewforum.de/attachment.php?aid=9556

 

Attached you can find the code as well: Edge_counting.vi

 

Thank you for your time 🙂 

 

 

best regards 

ezzow

 

 

 

 

 

0 Kudos
Message 1 of 8
(1,342 Views)

Your counter works on the TTL range.  So you need to transition from something like 0.8V to 1.8V.  Double check these values with your counter card.


GCentral
There are only two ways to tell somebody thanks: Kudos and Marked Solutions
Unofficial Forum Rules and Guidelines
"Not that we are sufficient in ourselves to claim anything as coming from us, but our sufficiency is from God" - 2 Corinthians 3:5
0 Kudos
Message 2 of 8
(1,326 Views)

Thank you for your reply ☺️ 

 

Could you please give more details? I'm quite new in LabView 😅 

 

 

 

 

 

0 Kudos
Message 3 of 8
(1,308 Views)

From the two samples you show, you appear to be working with a signal that largely has two values, which I'll call "High" and "Low", and that (to a pretty good First Approximation) is either High or Low or "switching" from one to the other very quickly.  Many digital signals have this property -- one pretty common one is called TTL (Transistor-Transistor Logic), where "High" means "near +5 V" and "Low" means "near 0 V", with the "I'm not sure" zone around 3 V.

 

When High and Low are well-separated (and constant for the duration of the signal), finding the transitions is pretty simple.  First, find the "Dead Zone", the place in the middle where the signal almost never can be found, and where High and Low are not well-specified.  In the examples you show (where the amount of "High" and "Low" are about the same), a good guess would be "the mean of the entire signal".  Obviously, this doesn't work very well if the Signal is low 90% of the time.  Can you think of another "Measure of Central Tendency" (as the statisticians like to call it) that might give you a less "biased" estimate?  Or an algorithm?  Now find a way to estimate the "top" and "bottom" of the Dead Zone (maybe 75% of the distance between the middle of the Zone and the "average High", but then how do you estimate "average High"?).

 

This is an interesting problem, requiring some thinking (and testing!) to come up with a meaningful algorithm.  A very good homework assignment.  Please try to do this yourself...

 

Bob Schor

0 Kudos
Message 4 of 8
(1,273 Views)
Solution
Accepted by topic author Ezzow

I haven't used that particular device before, but I believe according to the manual (https://www.ni.com/docs/en-US/bundle/ni-9326-specs/page/specs.html) that the default edge threshold is 0V with a hysteresis of 31.25 mV. That defines what a "count" is. If you want it to detect something higher, you'll have to set the threshold level to something more "in the middle" of your signal range. For example, if you're using a 0-5V signal, I'd set the threshold to 2.5V. If you're using a 0-3.3V range, I'd set it to 1.5.

 

You may also need to explicitly configure differential or single ended.

Message 5 of 8
(1,231 Views)

I actually solved the problem yesterday. The thing is I was pretty sure that I have to change the threshold value. However there was no input in the code (in my first post) where I can adjust this value. At the end I created a task in NI MAX that fortunately allowed me to adjust the threshold. But I'm still interested if anyone has a suggestion on how to adjust this value from the code itself. 

 

Thank you all for your time 🙂 

0 Kudos
Message 6 of 8
(1,217 Views)
Solution
Accepted by topic author Ezzow

You'll need a DAQmx Channel property node:

 

BertMcMahan_0-1660318334189.png

 

If you don't see that property, right click the property node and click "Select Filter", then choose "Show All Attributes".

 

Right click the node, then select "Change to Write" to let you write a value to it.

Message 7 of 8
(1,199 Views)

Hi @BertMcMahan

 

I just tried your solution to control the threshold from the front panel and not from an extra NI MAX-task and it's working! Now I solved the problem completely. I really apreciate your help! 

 

 

0 Kudos
Message 8 of 8
(1,139 Views)