LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

how to reject pulses

Hi,
This is one project that I am doing for some time using sinar sensor which generates pulse with to measure the distance to object. This sensor is being controlle dby basic stamp2.
My problem is that I am getting signal from the signal out put of the sensor. the same output is used by the basic stamp to switch on the sensor and that time is like 2usec so it acts like pulse the sensor generate long pulse depending upon the distance from the object. SO one short pulse and one long pulse
but I dont want my labview to read this short pulse which is like constant 2Usec,
because I am trying to calculate the velocity out of that range sensor so I onle need pulses which tells me the distance so two consecutive distance pulses in my code will tell me change in distance and the I can convert it into velocity.
But if small pulse I call it triggering pulse is read by the code then it will not be two consecutive distance but will be alternate small large small large

Now I have tried to used the case structure telling it that if time measures is greaterthan this than it is true and process but what happens now is that when it recieves small pulse the case structure repeats the variable like repeat the distance again
see my attachment

How to get rid of this small pulse that it does not go into my while loop
0 Kudos
Message 1 of 4
(2,710 Views)
The cause of the problem is that you were using the case structure to control the data update of the local variable, but you were not using it to control whether the data is processed for a given iteration of the loop. What this meant is that you would process old data during iterations in which you didn't want to process any data. The simple fix is to include all of your processing inside of your case structure. This also allows you to eliminate the use of local variables, which should always be avoided at all costs. The use of that local variable actually created a race condition in your code which could have also contributed to the problem you were having.

I have attached a modified version of your code that implements what I described above. I hope this helps and remember the lesson to learn: use local variables as a last result only!

Kind Regards,
E. Sulzer
Applications Engineer
National Instruments
0 Kudos
Message 2 of 4
(2,692 Views)
hi,

This solved my first problem but it showed me a new one.
Now as the case structure works only once it has the particular pulse but I am also runing a watch inside case structure which also get stops. or you can say that it generates data once case structure runs. Now I am taking delta T so that I can calculate the velocity but now I am getting data every 2nd sec.
The thing is microcontroller reads only the distance but lab view reads both pulses a pulse which initiates the sesnor and once sensor has the distance reading.
My problem could be solve If labview some how dont read the small pulse width which is like 2Usec. can we do that some how

Thanks for help
0 Kudos
Message 3 of 4
(2,684 Views)
There isn't going to be any way "not to read" the smaller pulses because you have to read them in order to know that they're small -- it's a catch 22. Thus, you're only option is to detect whether the pulse is large or small and execute different code accordingly. With the existing case structure in your VI, simply put "large pulse only" code in the TRUE case, "small pulse only" code in the FALSE case, and code that applies to both cases outside the case structure. Following this organization should ensure that all the code is executed at the proper times.

Kind Regards,
E. Sulzer
Applications Engineer
National Instruments
0 Kudos
Message 4 of 4
(2,672 Views)