Counter/Timer

cancel
Showing results for 
Search instead for 
Did you mean: 

Proper approach to gather buffered encoder counts on sensor transition?

I have a 6224 M-Series card.  I would like to have a triggered/buffered encoder count when a sensor changes state.   I have an incremental quadrature encoder connected to a motor on a conveyor belt.  I have a sensor on the belt.   I want the encoder to be continually counting (in other words configured and counting quadrature--but outside of my code having to "look" at the counts), then when the sensor changes state from off to on, I want to "get" the encoder count.  When it then transitions from on to off, I want the encoder count at that point.  So, for every "pulse" on the sensor (the length and timing of the pulse will vary--it is not periodic and the time the pulse will be on will vary ), I want to get two and only two encoder counts.  It is a length measurement application.  Very simple.    I can see many different ways to approach this.  I need to know that one encoder counts comes from the sensor going from off to on and the other comes from the sensor transitioning from on to off.    I need hardware accuracy so I am assuming I need a buffered or triggered approach.  My problem is that I don't see how to do that with the .NET measu.studio task architecture or it is so full of different options and configurations that I am unsure as to the proper approach.  Can I do it from one task, or do I need two?---with one sample clock set to respond to the rising edge and other to the falling edge?  Can I "or" those together (there are only the two options in the enumeration)? Do I need to physically connect the sensor to the sample/source input of the counter or can I use any of the PFI pins for that functionality? 
 
Any pointers would be greatly appreciated.   The encoder is connected and we can get counts using the direct method---and buffered methods, but they just work on the rising (or falling--but not both) edge ( started from samples included in measurement studio)?
0 Kudos
Message 1 of 2
(3,189 Views)

I only use LabVIEW so I can't address any of the .net syntax at all.  I can only comment on the hardware capability.

Unfortunately, no, you cannot set up a single encoder acquisition task to buffer on either Rising OR Falling edge.  You should be able to set up 2 separate tasks though, with one set to acquire on Rising and the other set to acquire on Falling edge.  However, if you do it that way, you'll have used up both counters and you probably won't be able to "peek" at the instantaneous count while waiting for those sensor transitions.

The other way that may work is to perform a Digital Input on the sensor signal using "Change Detection" rather than a regular sampling clock.  Change detection can be set up to respond to either type of transition, and it started being available for M-series boards in DAQmx 8.0   You will also need to figure out how to use the Change Detection Event/Pulse as the sampling clock for your buffered encoder task.

What you can then have is 3 tasks -- 1 unbuffered encoder task that you can "peek" at anytime, 1 buffered Digital Input task that captures your sensor state whenever it changes, 1 buffered encoder task that captures position at the change detection instant when your sensor changes state.  The buffered digital data will correlate to your buffered encoder data so you can know for sure which type of sensor transition corresponds to each captured position.

As to the .net stuff, sorry but I've got no experience at all.  Just wanted to give you a rough roadmap for the things that ought to be possible so you'll know it's worth pursuing the details.

-Kevin P.

ALERT! LabVIEW's subscription-only policy came to an end (finally!). Unfortunately, pricing favors the captured and committed over new adopters -- so tread carefully.
0 Kudos
Message 2 of 2
(3,185 Views)