LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

how to measure angular position of two encoders using NI 6216

Solved!
Go to solution

Hi, I need your help. I want to connect two encoders independent of each other to measure angular position using the NI USB-6216 counters, but I can't get both counters to work simultaneously without depending on each other.

I am using two-pulse decoders

I am generating a clock signal with a dummy analog output for both counters, but I can't get them to work independently, they can start counting together but I need them to stop at different times.

0 Kudos
Message 1 of 11
(1,431 Views)

 

To connect and use two encoders independently with the NI USB-6216 counters, you can follow these steps:

  1. Hardware Connections: Ensure that each encoder is properly connected to its respective counter input channels on the NI USB-6216. Connect the encoder outputs to the counter inputs, making sure that the wiring is correct and secure.

  2. Counter Configuration: Configure the counters in your software environment (such as LabVIEW or Measurement & Automation Explorer) to set the appropriate counter mode and parameters for each encoder. Ensure that the counter settings for each encoder are independent of each other.

  3. Clock Signal Generation: Instead of using a single dummy analog output for both counters, you should generate separate clock signals for each counter. You can use two independent analog output channels on the NI USB-6216 to generate the clock signals. Configure the output channels to produce the desired clock frequency and waveform for each encoder.

  4. Start and Stop Control: In your software code, implement separate start and stop controls for each counter. This allows you to control the counting process independently for each encoder. You can use digital triggers, software commands, or external signals to initiate the start and stop operations for each counter.

  5. Synchronization: If synchronization between the two encoders is required, ensure that any necessary synchronization signals or methods are implemented correctly. This ensures that the measurements from both encoders are aligned properly.

By following these steps, you should be able to connect and use two encoders independently with the NI USB-6216 counters. Make sure to consult the documentation and resources provided by National Instruments for detailed information on using the USB-6216 and the specific software environment you are using.

0 Kudos
Message 2 of 11
(1,400 Views)

What you describe should be possible.  Please post your code and describe your physical wiring connections.

 

Note: before posting the code, it's helpful to:

1. Set all front panel controls to typical values then choose "Edit->Make Current Values Default"

2. Back-save several versions using "File->Save For Previous Version...".  Many of the people offering help around here work in older versions and won't be able to open vi's saved in a newer version.   I for one work mainly in LV 2020, but I'd recommend saving even farther back.

 

 

-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 3 of 11
(1,387 Views)

I share the VI for a better help, what I am looking for is that both counters start counting once their respective motors are activated and stop at different times, I still succeed. I would only have to generate a different clock signal for each counter as I wish explain the previous comment

0 Kudos
Message 4 of 11
(1,378 Views)

gives this error

yoliveraus_1-1684954735398.png

 

0 Kudos
Message 5 of 11
(1,337 Views)

Where does that error occur?   Which task causes it?   Is there more error text to describe which specific resource is reserved?

 

The counter configs look generally ok to me, though some wire-tidying would help.  But you also have several DAQ Assistants inside your main loop - I'm more suspicious about those.

 

 

-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 6 of 11
(1,287 Views)

Just like this, the two counters do not work at the same time, for ctr1 to work I must physically disconnect on the ctr0 card and it is not what I am looking for, what I want to achieve is that each counter gives me the position of its associated encoder, one independent from the other. Otherwise when I add the other dummy analog output to generate the independent clock signals for each of the counters, I get that reserved resource error.

Help me please

0 Kudos
Message 7 of 11
(1,239 Views)

I don't understand what the exact problem is.

 

I took your code, did a little wiring cleanup, and ran with a simulated 6216 device without producing any resource conflict error.  I *did* get a warning about you using an AO sample rate that exceeds the boards specs and I also quickly got the buffer overflow error -200279 because you were reading too few samples per loop iteration.  (A good general rule of thumb is to read 1/10 sec worth per iteration.  If you use the max spec'ed AO sample rate of 250 kHz, you'd read 25000 samples per iteration.)

 

I also don't understand what kind of "not working" behavior you see from the counters that requires you to physically disconnect one of them to make the other one "work".  That sounds like a problem in your wiring hookups, perhaps a failure to establish a shared common (-) among the DAQ device and the encoders?

 

 

-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 8 of 11
(1,229 Views)

Thank you so much
Regarding the physical connections, what is connected are the direct encoders (A and B) to the ports PFI8(A), PFI10(B) for the CTR0 counter and PFI3(A), PFI11(B) for the CTR1 counter respectively. , and even then it continues giving me the same problem both counters together do not work correctly, it is as if their internal operation depended on each other. Or am I doing something wrong in the code that gives me this problem. It's like a counter works as a clock for the other.
I've tried two pairs of encoders with different resolutions and it still gives me the same problem.

0 Kudos
Message 9 of 11
(1,207 Views)
Solution
Accepted by topic author yoliveraus

Still unsure what the *exact* problem is.  Please describe your observations and symptoms in much more detail.

 

Also, with regard to the physical wiring, you've described the signal (+) side of the wiring but not the return/common (-) side.  Do the encoders, their power supply, *and* your DAQ all share the same common (-)?

 

 

-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.
Message 10 of 11
(1,180 Views)