From Friday, April 19th (11:00 PM CDT) through Saturday, April 20th (2:00 PM CDT), 2024, ni.com will undergo system upgrades that may result in temporary service interruption.

We appreciate your patience as we improve our online experience.

Multifunction DAQ

cancel
Showing results for 
Search instead for 
Did you mean: 

NI 6221 PCI encoder hardware connection

Hello,

 

I would like to consult possibility of connection DFS60B-S1MA10000 incremental encoder (https://www.sick.com/de/en/encoders/incremental-encoders/dfs60/dfs60b-s1ma10000/p/p293367) to PCI 6221 acquisition board.

From what I understood is, that if encoder will be set to TTL output mode, it should be possible to connect A and B canal signal directly to proper board PFI's?

 

Thanks for response in advance.

 

Best Regards,

Pawel

0 Kudos
Message 1 of 10
(5,297 Views)

Yes, no problem with this. Just consult the datasheets of both (encoder and DAQ card) to find out the proper pins that you need to connect. Then you can use LV daqmx to directly read out the position, or as you wish - just use the counter functionalities of daqmx. Some info about this is here:

 

http://www.ni.com/tutorial/4623/en/

http://www.ni.com/tutorial/7109/en/

http://www.ni.com/getting-started/set-up-hardware/data-acquisition/quadrature-encoders

 

 

Good luck with your project!

Jozef Lipták
0 Kudos
Message 2 of 10
(5,281 Views)

Hello,

 

Thank you for your advice, its already connected and wired.

 

Is it possible to trigger possible to trigger one sample acquisition from analog input every time counter to which encoder is connected increases its value? The purpose is to get one sample for the same angle position during rotation.

 

Thank you for your help in advance.

 

Best regards!

0 Kudos
Message 3 of 10
(5,274 Views)

 

Depends of type of your application - you can choose between more approaches. Have a look here:

http://www.ni.com/product-documentation/4322/en/

 

in the section

  1. Synchronization Beyond Analog

 

are described some approaches.

 

You can trigger acquisition according to counter internal output, trigger immediately and use this counter output as sample clock for the measurement, etc...

 

Play around with the functions, if you have the hardvare, or you can use even in MAX simulated hardware for testing. I also highly recommend the example finder in LabVIEW – here you can find ready to go solutions for many problems (ni.com/examples).

Jozef Lipták
0 Kudos
Message 4 of 10
(5,271 Views)

Hello,

 

I analyzed possibilities and compared them with my application.

I think the best solution would be to use Finite Samples aquisition (I know that I will get around 2500 encoder pulses during one revolution, so I would demand for example 2450 samples), with timing controlled by PFI to which encoder is connected.

BUT I assume that this would require to start and stop the task every time that I want to perform the measure - and it is not possible, because everytime I try to use DAQmx Stop for Analog Input task, it freezes for few seconds, which is unacceptable.

 

So considering that, I will probably need continous acquisition, but during the time when encoder is not rotating, I will get an error, because the samples are not read.

 

Any suggestions?

0 Kudos
Message 5 of 10
(5,263 Views)

The acquisitions VI has a timeout terminal. If you set to this -1 it will wait for indefinite time. You probably got timeout error, because you request finite number of samples, set the sampling clock to this counter out, and there are no pulses whitin the timeout interval.

Jozef Lipták
0 Kudos
Message 6 of 10
(5,258 Views)

Hello,

 

OK, so what I used example Voltage - Continous Inputs.vi, set timeout to -1 and Sample Clock Source to PFI8 (to which is connected singal A from encoder).

I didn't work at all - either there was no data read at all, sometimes it was reading some data at the same beggining of the rotation.

 

Is it possible that because of the speed of the rotation, card is not able to aquire enough samples from analogic input? It is around 2500 samples per second from two channels - if yes, I wouldn't suspect that.

 

Best Regards

0 Kudos
Message 7 of 10
(5,230 Views)

Hello,

 

I noticed also a funny thing. Please look ath the code below:

aq.png

 

When I start the VI, number of samples based on encoder's changing signal is very good at the begginning (around 5000). But every rotation further it decreases, reaching for example 1500 samples per revolution.

Its very strange to me, because it is not time dependent - you can start the VI, leave it running for 10 mins and it will still calculate 5000 samples during first rotation.

 

Any idea why it behaves like that?

 

BR

0 Kudos
Message 8 of 10
(5,224 Views)

I am not really sure what you want to accomplish by this code. The problem is, that the while loop iterates almost as fast as possible, the wait time 1ms means practically nothing. each sample you read from the AI and the counter is "on demand" - software timed. You also dynamically build-up an array with samples. This I think is the reason of the slow down - after it reaches some size, it slows down the iteration of the while loop. The wait function means, that it will wait for so long, that the timer reaches the next ms multiple. If the functions called within the loop takes longer, it will wait this "longer time" and then add additional time to reach the next ms multiple you specified. And when the builded-up array becomes larger, it takes a longer time to add a new element to this array - the read measurement functions take probably still the same time (more or less - because it is still software triggered - so it can depend on the current OS load).

Jozef Lipták
0 Kudos
Message 9 of 10
(5,157 Views)

Thanks for reply. I posted this code because I didn't understand why there was less and less samples - thanks for clarification.

 

Anyway I managed to trigger sampling with encoder singal, it was pretty easy but didn't work well with NI examples - I had to play around with my own code.

Message 10 of 10
(5,154 Views)