Counter/Timer

cancel
Showing results for 
Search instead for 
Did you mean: 

Counting edges within a period

Solved!
Go to solution

Hello,

 

I'm still fairly new to labview and so I could use some help on something I'm working on.

 

I need to measure two things from an encoder, the RPM, which I can easily do via the index; and the number of edges on the A channel between two index pulses.

 

I would like to use the index to trigger the counter to begin counting edges on the A channel, and then the next index to end the counting. This program will essentially verify the RPM of the encoder given a base speed, and it will verify the correct resolution of the encoder.

 

I am using an NI6602 counter card and I need to be able to configure multiple encoders onto it which is why I'm only using the index and channel A.

 

Thank you,

Jason

0 Kudos
Message 1 of 12
(9,273 Views)

Take at the LabVIEW Examples. In LabVIEW go to Help->Find Examples. Then select Hardware Input and Output. Then DAQmx->Counter Input. Take a look at these examples especially the Counter Read Encoder. I hope these help. Have a good day. 

Alex D
Systems Engineer
Academic Research
National Instruments
0 Kudos
Message 2 of 12
(9,248 Views)

I've spent significant time taking apart these examples with no luck.

 

Let me try to reexplain my goal as I don't think I did a good job of it the first time around.

 

I would like to use 1 counter to measure two things...the period between index pulses, and the number of pulses on the 'A' channel between those index pulses. 

 

The examples in the library for reading encoders abstracts all of the information away and so what I'm left with is an angular position reading...but what method does it use for calculating that position? I would like access to the information used in the calculation so that I can use it to verify velocity, and number of quadrature pulses per revolution.

0 Kudos
Message 3 of 12
(9,244 Views)

You could hook up multiple channels to the same counter and get the data you want. The exact details of how to do that I'll leave up to you but you should be able to do that. Just configure each channel for the different data that you want. Have a good day. 

Alex D
Systems Engineer
Academic Research
National Instruments
0 Kudos
Message 4 of 12
(9,226 Views)

Alex,


That is my entire question. How do I go about hooking up more than one channel to a counter and how to I read that information?

0 Kudos
Message 5 of 12
(9,224 Views)

What you will need to do is to connect the encoder to two separate counter inputs and set up two channels one for the Period and one for the Edge Count. That should give you the data you need to find out the information you want. Also remember to set up digital triggering for the measurement using the counter input port so that you can take the measurements when you rotate the encoder. 

Alex D
Systems Engineer
Academic Research
National Instruments
0 Kudos
Message 6 of 12
(9,212 Views)

Let me propose an alternate solution to this.

 

Currently I have a labview program (written by someone far more qualified than myself) that reads in an entire port, P0, and samples that data and recreates it into a waveform graph. The result is a mapping of the A, B, and index signals of an encoder. It then does operations to truncate that data down into one revolution and it verifies the resolution and indicates the velocity. This is all done with the NI6251 counter card that I know uses hardware timing. 

 

Is it possible to do this same sort of thing with the NI6602 card that I also have even though it uses software timing? I need to be able to read in the 'A' channel and index of 5 encoders so in my mind that would mean 5 counters. Does the NI6602 have enough ports to do this sort of thing? Could I do it all on the NI6251 with 2 counters and 2 ports?

0 Kudos
Message 7 of 12
(9,185 Views)

The 6251 has 2 counters and 8 hardware-timed digtial input lines (port 0 only).

 

The 6602 has 8 counters and 0 hardware-timed digital input lines.

 

 

It sounds like you need to make two measurements:

 

1.  RPM of the encoder

2.  Number of pulses on the A channel of the encoder per revolution.

 

Each of these measurements would take up a resource (counter OR hardware-timed digital I/O) if they had to occur simultaneously.  Using a counter for either measurement is more ideal though (less data transfer, can accomodate shorter pulses, more measurement precision).

 

Technically, you could probably get something working on the 6251 for 5 encoders at a time by using an odd mix of counters and hardware-timed digital inputs.  The 6602 could measure up to 4 encoders simultaneously using counters only, but doesn't have any additional hardware-timed lines.

 

Perhaps you could measure the number of A pulses per revolution on the very first revolution, and then measure the RPM of the encoder?  You could re-use the counters and could then measure up to 8 encoders simultaneously (you wouldn't really be making the two measurements for each counter simultaneously, but you could switch between the two measurement modes without any wiring changes).

 

 

Best Regards,

John Passiak
0 Kudos
Message 8 of 12
(9,169 Views)

John, thank you for your insight. Your last paragraph seems idea. If I can measure those two things back to back there would be no issue. 

 

How would I be able to count the number of A pulses within that first revolution though? Is there a way to trigger the counter to go only once it has seen an index pulse, and then to stop right after it sees it again?  The encoders will be constantly running at about 3000 RPM and I wont be able to stop them, and slowly rotate them once; I need to be able to take a fast sample of the data.

0 Kudos
Message 9 of 12
(9,127 Views)
Solution
Accepted by topic author jasonkelly214

You could either:

 

 

Configure the task as a "period" measurement (measure the period of the Z index using the A channel as the timebase):

 

PeriodEncoderMeasurement.png

 

 

 

OR

 

Configure the task as an "edge count" measurement (count edges of the A signal using the Z index as the sample clock):

 

EdgeCountEncoderPeriodMeasure.png

 

 

 

OR

 

Configure the task as an "encoder" measurement (measure the change in position in terms of A/B ticks using the Z index as the sample clock):

 

EncoderTaskPeriodEncoderMeasurement.png

 

 

 

In all but the encoder example you'll probably want to configure digital filtering for each of the inputs as encoder signals are often quite noisy (sometimes the noise is detected as extra edges which would throw off your meausurement).  In the encoder example it's probably not necessary since the counter will only increment once per cycle of A and B although you still need to watch out for noise on the Z index signal.

 

 

Best Regards,

John Passiak
Message 10 of 12
(9,123 Views)