LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Can we use a simple switch spdt to count the switchings? I do not want to do it in software to avoid the bouncing signals.

Counting the contact making of a standard switch
0 Kudos
Message 1 of 7
(3,216 Views)
Please be a little more detailed.

If you are having problems with the signal being noisy, you can use signal conditioning. Check the NI catalog under SCXI. Also, contact your local sales rep to see if they can help.
0 Kudos
Message 2 of 7
(3,215 Views)
Thanks for noticing my problem!
I want to count a simple contact switching on-off;
I am using BNC-2121 for 5Vdc, my spst switch and the connection to the SOURCE of selected counter(6602). The results are not accurate due to the switch contact bouncing.I wonder how can I do it in hardware without building debouncing circuitry.
Thanks
Regni
0 Kudos
Message 3 of 7
(3,215 Views)
Hello;

Depending on the DAQ device you already have, you can take on approach or another.
In case you have a DAQ board with general purpose counters available and your signal to be count is TTL type, you can use a counter as simple or buffered event counter to count the transitions of the TTL pulse.

Hope this helps.
Filipe A.
Applications Engineer
National Instruments
0 Kudos
Message 4 of 7
(3,215 Views)
I do not have a TTL type pulse! Just a switch that closes and opens a circuit with 5 Vdc.
0 Kudos
Message 5 of 7
(3,216 Views)
That is exactly what TTL is.

If you don't want to build debounce hardware, then you are going to have to apply the same design into software. I don't quite remember how they work, but debounce should be able to be programmed quite easily in software. However; I don't know if it will be fast enough for on-demand acquisition, you may have to post-analyze the data.

In this case, you want to use Analog Input, of course.
0 Kudos
Message 6 of 7
(3,215 Views)
Hi Regni,

I think I understand what you are asking.

If you do not want to use an external debounce circuit, it can be done in software.

You could use either an analog input or a digital.

In either case you will want to emulate what would be happening in a hardware de-bounce ckt.

You should first convince yourself about how the switch works. Examples are How fast will switch be switched?
How long does the bouncing continue, etc.

In your code you will then have to watch the incoming switch signal and determine if the bouncing is done and what state it ended up setling in. For this, I would look for some number of contiguous samples to be in one state or the other. When the code detects that the required number of samples are the same, THEN I would call
that done bouncing and read the value.

Another way of handling this, would be to use the hardware filters on the board. If so equiped, you may be able to configure the input for a low pass filter, where the cut-off freq. is lower than your bounce freq.

This may get you started, Are we getting close yet?

Ben
Retired Senior Automation Systems Architect with Data Science Automation LabVIEW Champion Knight of NI and Prepper LinkedIn Profile YouTube Channel
0 Kudos
Message 7 of 7
(3,215 Views)