LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

counter digital

Solved!
Go to solution

Hello,i am working on a counter, but i need some help to do the next:

Instead of the red square in the picture,i would like to have the last input was recieved by my digital input and compare it with the next input.
i want to do it because when my counter is working i don´t want that it increases more than 1 time when it is reading a false input. i just want that it increases its value when it is reading a new false value.

for example:

input=F and the last measure was F, i don´t want that it increases its value

input=F and the last measure was T,i want that it increases its value

input=T i don´t want that it increases its value

 

how could i do it? with a shift register i can do it,but i would like to reduce my code in labview ,thanks

conta.JPG

0 Kudos
Message 1 of 27
(3,879 Views)

Use a feedback loop. That is what it is for. Look up the example on how it works and I think you will find that it is what you are looking for.

 

A diferent way would be to use an Action Engine to hold the value inside a subvi and have it give the result.

Tim
GHSP
0 Kudos
Message 2 of 27
(3,870 Views)

A shift register is the correct solution.  Why do you not want to use one?

 

Also, it is never necessary to compare a boolean value to a TRUE or FALSE constant.  Comparing a boolean with TRUE is exactly the same as removing the = entirely.  Comparing with FALSE is equivalent to insert NOT in place of =.

0 Kudos
Message 3 of 27
(3,868 Views)

with a shift register i did the next:

it works ok,but i have the next problem:

when DIO4 recieved a TTL signal of 50Hz the counter marks 500 in 10seg GOOD!

when DOI4 recieved a TTL siganl of for example 250Hz, the counter marks 500 NO GOOD! because if f=250hz T=4ms, so if it is working 10seg, i should watch: 10000ms/4ms=2500 times on my counter, not 500 as i can see on my counter.

Is it true?

contador.JPG

0 Kudos
Message 4 of 27
(3,866 Views)

On what type of system are you running this loop?  You may not be able to achieve a reliable 1ms loop time on a Windows machine.

0 Kudos
Message 5 of 27
(3,863 Views)

i am using compact rio,with the module of outputs and inputs digital NI9401,and windows xp

 

but for example if my input signal has 250Hz the period is 4ms,so my computer should be able to read it,shouldn´t it?

or the problem is about my labview code which has dt=1ms?

0 Kudos
Message 6 of 27
(3,860 Views)

Seems like it should work, if that loop is running on the cRIO.  Is your signal a 250hz continuous square wave, or something else?  Is it possible that your signal only has 500 transitions?

0 Kudos
Message 7 of 27
(3,855 Views)

yes,it is a square wave(TTL) which i am generating in a wave generator,so the wave has infinites transitions,hasn´t it?maybe is it the mistake?

the wave generator works good because with one osciloscope i can see the waveform and its period.

0 Kudos
Message 8 of 27
(3,852 Views)

Can you graph the input signal in your LabVIEW code?

0 Kudos
Message 9 of 27
(3,849 Views)

yes,i can and it can read waves all time that i want, so the osciloscope generates waves all time, yes?

 

and there is a extrange thing which i forgot to say you, i have the next cases for differents frequencies:

 

50Hz the counter marks 500

100Hz the counter doesn´t work

200Hz the counter doesn´t work

250Hz the counter marks 500

333Hz the counter marks 333

500Hz is the maximum frequency so the counter doesn´t work for that frequency

 

and it is 100% sure that the counter works well,because i saw it with the highlight execution!

0 Kudos
Message 10 of 27
(3,841 Views)