02-29-2012 10:44 AM - edited 02-29-2012 10:53 AM
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
Solved! Go to Solution.
02-29-2012 12:18 PM
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.
02-29-2012 12:25 PM
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 =.
02-29-2012 12:32 PM
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?
02-29-2012 12:41 PM
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.
02-29-2012 12:48 PM
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?
02-29-2012 01:16 PM
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?
02-29-2012 01:22 PM - edited 02-29-2012 01:22 PM
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.
02-29-2012 01:25 PM
Can you graph the input signal in your LabVIEW code?
02-29-2012 01:40 PM - edited 02-29-2012 01:42 PM
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!