LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Quad Encoder Decode for FPGA

Quad Encoders are commonly used position feedback devices.  I'm exploring the possibility of using a Scancon 2RMHF with cRIO or sbRIO, it's has 500cpt on AB, plus a once per rev pulse.  A quick search on the internet shows there are many dedicated ICs that will convert the Quad AB signals to position, e.g. HTLC-2032 or LS7366.

 

My question is, if I use cRIO or sbRIO, do NI have ready-to-use FPGA code that will perform the same function as the ICs ?   I have searched ni.com for "quad encoder" but with limited results.

0 Kudos
Message 1 of 6
(6,858 Views)

You can use the onboard FPGA on CompactRIO or Single-Board RIO with Digital I/O to read from most quadrature encoders directly.  You just need to ensure you use a DIO module that is fast enough to capture all the digital edges of your quad encoder signal at the fastest rotational rate of your encoder (500cpt * the number of turns/sec).  The faster the I/O module you use relative to the speed of the encoder pulses, the better accuracy you will acheive with the FPGA.

 

To get started with the FPGA programming you can reference this developer zone article on Quadrature Encoders, which I found referenced from ni.com/ipnet, your one-stop-shop for finding NI FPGA example programs and reference IP.

 

I also like to use the handy functions generated by the FPGA wizard manually in my FPGA applications.  You can find the Quad Encoder functions here on your hard drive after you install LabVIEW FPGA:   C:\Program Files\National Instruments\LabVIEW 2009\FPGAWizard\PlugIns\Function\niRIOQuadCtr\Templates\Fpga

 

I would recommend copying any VIs you use from this folder into your own "user VIs" folder so you have the ability to update or modify them if you see fit without affecting the functionality of the original FPGA Wizard.

 

Hope this helps,

 

 

Spex
National Instruments

To the pessimist, the glass is half empty; to the optimist, the glass is half full; to the engineer, the glass is twice as big as it needs to be has a 2x safety factor...
Message 2 of 6
(6,849 Views)

I found the article you reference, the code functions when decoding simulated encoder data, but when decoding a real encoder signal, it's susceptible to noise, and also jitter at low speed and when stationary.  The dedicated ICs will use state machines and digital filters to solve the decode problem.  I could develop decode IP for a NI FPGA target, but would that be reinventing the wheel.  There must be millions of incremental encoders spinning round as we speak.

 

Has anyone on this forum created a LabVIEW FPGA implementation for incrementals ?

Message Edited by bmann2000 on 12-09-2009 09:15 AM
0 Kudos
Message 3 of 6
(6,815 Views)

I have built encoder functionality into my process.  I am only using the A and B signals as I do not need the index pulse.  I have no issues with noise at low speed, but there will always be some jitter or dither, with an encoder at zero speed as it is never perfectly still, at least in my experience.  I am measuring absolute position and velocity of an 8192 PPR quadrature encoder using the NI 9411 module.

 

Unfortunately I cannot divulge my code as it is intellectual property.  I can, however, say that I monitored one channel to do the counting and used the edge-ness, rising or falling, of the other channel to decide whether to increment or decrement.

0 Kudos
Message 4 of 6
(6,804 Views)

Can i have that fpga vi to get the encoder signal it would be very helpful for me. im doing a project now. thaks. pls...

0 Kudos
Message 5 of 6
(6,355 Views)

Hi Tom,

 

As mentioned in my previous post.. A quadrature encoder VI is included with every copy of LabVIEW FPGA.  Copy the quadrature encoder VI from the FPGA wizard folder into your source code folder or the user VIs folder for future use.  Here is the path to the Wizard version, but be careful that you don't edit/save over that version.

 

"C:\Program Files\National Instruments\LabVIEW 2009\FPGAWizard\PlugIns\Function\niRIOQuadCtr\Templates\Fpga\QuadratureCtr_X4.vi"

 

Regards,

Spex
National Instruments

To the pessimist, the glass is half empty; to the optimist, the glass is half full; to the engineer, the glass is twice as big as it needs to be has a 2x safety factor...
0 Kudos
Message 6 of 6
(6,344 Views)