LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Rotary motion sensor on NI myDAQ

Hey I'm trying to set up a rotary motion sensor to work with my NI myDAQ. So the way the sensor works is if you turn it clockwise it sends small pulses (digital) on one wire and I should count up each pulse and when you turn it counter clock wise it sends pulses on a different wire and you should count down for each pulse.

 

As it stands if I spin my sensor at a medium to high speed it stops reading any counts. Is there a way I can get a higher resolution and read the correct amount of ticks?

 

 

Here is my simple VI

0 Kudos
Message 1 of 18
(4,535 Views)

You probably have a sample rate issue. You need to sample at a rate at least twice as fast as your encoder output pulses so that you see both the highs and the lows of the pulses.

 

Your DAQ Assistant is set to 1 Sample, so you are only going to be reading at the rate of your clock. Change the Acquisition mode to Continuous and set the sample rate to 1kHz and see if that helps. You will need to alter your code to understand the array of booleans that come out and convert those to a pulse count.

Cheers


--------,       Unofficial Forum Rules and Guidelines                                           ,--------

          '---   >The shortest distance between two nodes is a straight wire>   ---'


0 Kudos
Message 2 of 18
(4,527 Views)

Alright so after I have changed my acquistion mode I have my data come out as a 1D array of Digital Waveform. How can I covert that into somthing that I can compare to check if I have a rising edge?

0 Kudos
Message 3 of 18
(4,522 Views)

I recall a thread a while ago with some fancy array operations to make this faster, but you can do something like this:

Boolean Array To Encoder.png

Cheers


--------,       Unofficial Forum Rules and Guidelines                                           ,--------

          '---   >The shortest distance between two nodes is a straight wire>   ---'


0 Kudos
Message 4 of 18
(4,513 Views)

Hmmm even with the fancy array operatons it looks like I'm still skipping counts.

0 Kudos
Message 5 of 18
(4,510 Views)

Would there be any way to use the counter input: edge counter and have only one assistant use the clock at a time and switch which one is using it when a rising edge is deteced on the other wire?

0 Kudos
Message 6 of 18
(4,508 Views)

You should be able to sample from both encoder signals at the same time using the same clock, you just aren't able to have differing sample rates.

 

The DAQ Assistant will allow you to configure your channels as counters instead of digital inputs, which should prove helpful.

Cheers


--------,       Unofficial Forum Rules and Guidelines                                           ,--------

          '---   >The shortest distance between two nodes is a straight wire>   ---'


0 Kudos
Message 7 of 18
(4,494 Views)

Right so when I try sampling from both lines and using my clock I get this error.

 

Error -50103 occurred at DAQmx Start Task.vi:7220006

Possible reason(s):

The specified resource is reserved. The operation could not be completed as specified.

 

Am I setting this up wrong?

0 Kudos
Message 8 of 18
(4,483 Views)

Try using a single DAQ Assistant and adding the second channel to that task by pressing the Plus sign at the top. I'm not super familiar with the DAQ Assistant, but I belive it is trying to create two separate tasks the way you have it now.

Cheers


--------,       Unofficial Forum Rules and Guidelines                                           ,--------

          '---   >The shortest distance between two nodes is a straight wire>   ---'


0 Kudos
Message 9 of 18
(4,479 Views)

New error

Requested multiple virtual channels that correspond to the same physical channel within a task. A task cannot contain multiple physical channels of a specified type.

Use different physical channels for each virtual channel.

 

Channel Name: CountEdges
Physical Channel: ctr0
Channel Name: CountEdges_0
Physical Channel: ctr0

0 Kudos
Message 10 of 18
(4,464 Views)