From 04:00 PM CDT – 08:00 PM CDT (09:00 PM UTC – 01:00 AM UTC) Tuesday, April 16, ni.com will undergo system upgrades that may result in temporary service interruption.

We appreciate your patience as we improve our online experience.

LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Quad Encoder output in Labview Help

Hello All,

I am having some trouble setting up an encoder in labview and getting an output.  My labview skills are weak at best.  I have a PCI-6259 and a quad encoder wired into the counter 0 terminals of the SCB.  I set up some Boolean indicators on the channels to make sure I am getting my pulses (which I am).  I tried using the DAQmx VIs like I saw in some examples but kept getting errors.  I tried using the DAQ Assistant to set it for angular postion but I wasn't getting any output when I ran it.

Download All
0 Kudos
Message 1 of 9
(3,819 Views)

I'm not sure, that this is the problem source, but you have Acquisition Mode set to 1 Sample. Try to change it to multisampling...

0 Kudos
Message 2 of 9
(3,772 Views)

I did try that, but it errors out because it needs some sort of clock input to use as a reference.  I tried to create one but I couldn't get that to function properly.

0 Kudos
Message 3 of 9
(3,768 Views)

Try to read very basics of DAQmx, try to open LabVIEW examples (search quadrature encoder). 

Right now you are saying "my program gives some errors. I have tried some examples, they do not work".

By a screenshot of the block diagram with express VIs I can only say that you are probably trying to read from the same lines simultaneously and getting conflict.

PS. If you use ALT+ printscreen, it will capture only one window. If you use command Edit -> Create VI snippet from selection on blockdiagram, we will be able to open this snippet and see how everything is configured. Guess what is more informative? 

0 Kudos
Message 4 of 9
(3,752 Views)

I had to work on some other projects, but I am back on this now.

I managed to get the encoder setup and reading correctly. 

The only thing I can't figure out now is how to reset the counter to zero with the software.

Using the z-channel would not work for my application.

It seems like I am going to have to stop and then re-start that portion of the program unless there is another way?

encoder screenshot.png

0 Kudos
Message 5 of 9
(3,694 Views)

Josh@bpe wrote:

I managed to get the encoder setup and reading correctly. 

The only thing I can't figure out now is how to reset the counter to zero with the software.

Using the z-channel would not work for my application.


Why won't the z-channel work? Do you mean you can't get LabVIEW to recognise it, or that the z-channel is unsuitable for some physical reason? (As a possible side note, are you sure X1 is the right decoding type?)

 


It seems like I am going to have to stop and then re-start that portion of the program unless there is another way?


It seems extremely unlikely that that will be your only choice. LabVIEW is pretty flexible (sometimes too much, and encoders seem to be a pain...)

 


GCentral
0 Kudos
Message 6 of 9
(3,674 Views)

Channel Z works fine.  When I enable it, the encoder will reset to zero when it passes that point.  However, the application I am using it for has technicians installing it onto various valves to measure the opening angles.  Using the Z channel would not be practical for this application.  But I was able to solve my dilemma yesterday.  Here is a pic of the code.  I basically use a couple local variables, one to store the position of the encoder when the reset button is pressed and one of the position of the encoder and then subtract the 2 values.

Encoder Reset ScreenShot1.png

0 Kudos
Message 7 of 9
(3,664 Views)

Hi Josh,

 

I basically use a couple local variables, one to store the position of the encoder when the reset button is pressed and one of the position of the encoder and then subtract the 2 values.

Why don't you use a shift register to store the position (on reset button)?

Why don't you get rid of the other one and use a simple wire instead?

THINK DATAFLOW!

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
0 Kudos
Message 8 of 9
(3,662 Views)

The thought had crossed my mind but I don't have much experience with shift registers and don't have a lot of time to 'play' with Labview at the moment.  I will look into it more when I get some time free'd up.  Thanks.

0 Kudos
Message 9 of 9
(3,659 Views)