08-10-2022 07:21 AM
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
Solved! Go to Solution.
08-10-2022 07:49 AM
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.
08-10-2022 09:07 AM
Thank you for your reply ☺️
Could you please give more details? I'm quite new in LabView 😅
08-10-2022 03:33 PM
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
08-11-2022 05:03 PM
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.
08-12-2022 04:20 AM
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 🙂
08-12-2022 10:33 AM
You'll need a DAQmx Channel property node:
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.
08-18-2022 05:26 AM - edited 08-18-2022 05:27 AM
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!