LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Take only one sample every time a counter increments

Hi all,

 

I want to read a bunch of sensors. I am using a rotary encoder as the counter input. What I want to do is for every time the rotary encoder increments by +1 degree, I would like to pull all measurements from the sensors attached. For every degree I want only ONE measurement, which I will then store in an array.

 

My issue is how do I actually go about taking a measurement only ONCE when the counter increments and then waits until the next increment occurs to take another measurement.

0 Kudos
Message 1 of 7
(3,301 Views)

Use a shift register to detect when the encoder changes. You con use the divide with remainder or convert the degrees to an integer. When the current value is not equal that creates your condition to save the samples.

0 Kudos
Message 2 of 7
(3,276 Views)

the encoder outputs a pulse which increments the DAQMx counter input. I have so it is already in integer format. The count would go up to 360 (+1 integer count for every degree turn, 360 degrees in a rotation).

 

What I am having issues with is as follows:
while count is, for example, at "5", then it should take only one reading ONCE from the other sensors. Then when the count reaches "6" it should take another reading, again only ONCE.

 

I am using sample on demand as my "clock" for this system would be the rotary encoder so that if it spins at a varying RPM, the results do not depend on an internal sample clock

0 Kudos
Message 3 of 7
(3,267 Views)

So where is your code?  It is hard to "see the problem" if we can't "see the problem" ...  We could guess, I suppose (try moving the 4th wire from the left ...)

 

Bob Schor

0 Kudos
Message 4 of 7
(3,258 Views)

I will post it in a few days, currently on another PC.

 

It is essentially a physical input that the counter block reads that is in a while(true) loop that runs forever.

I want to figure out how to take a reading when the counter increments.

 

While counting I would like to ouput some logic '1' or '0' value that detects that the counter has incremented so that it can activate a case statement.

0 Kudos
Message 5 of 7
(3,251 Views)

Can you trigger your DAQ device from the encoder signal? Or use the encoder signal as an external acquisition clock? Some DAQ devices have capability to use external signals for clocks or triggers.

 

Lynn

0 Kudos
Message 6 of 7
(3,245 Views)
I'm with Lynn. Set up the DAQ task to use external clocking (with the clock being your encoder output) and call it done.

The only thing you need to be aware of is that the clock inputs are TTL so you need to be sure the signal levels from the encoder are compatible. Likewise you need to be sure the pulses coming from the encoder are clean: no over- or under-shoot, noise or ringing.

Mike...

Certified Professional Instructor
Certified LabVIEW Architect
LabVIEW Champion

"... after all, He's not a tame lion..."

For help with grief and grieving.
0 Kudos
Message 7 of 7
(3,233 Views)