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.

Academic Hardware Products (myDAQ, myRIO)

cancel
Showing results for 
Search instead for 
Did you mean: 

Using more than 4 quadrature encoder input for MyRIO

Solved!
Go to solution

Hello,

 

I am doing a project where I need to drive 6 motors, each with quadrature encoder feedback to control position. 

 

Currently, I've been using the MyRIO Encoder VI's, but there's a limit to 4 encoders. What is the best way of reading 6 encoders simultaneously with the MyRIO?

 

Thanks,

 

Timothy

0 Kudos
Message 1 of 33
(16,133 Views)

Hey Timothy,

 

Out of the box myRIO supports up to 3 Quadrature encoders.  All three encoders are implemented in LabVIEW FPGA, so it is possible for you to create a custom FPGA personality with more QE inputs by copy and pasting the existing QE blocks and mapping the channels to physical myRIO pins (you'll have to remove other myRIO peripherals).  If you modify the FPGA personality you'll no longer be able to use the myRIO Express VIs or Advanced IO VIs.  Instead you can use the FPGA Read / Write node to directly read and write the FPGA register that control the QE blocks.  

 

This is a more advanced approach but gives you a huge amount of flexibility.

 

If you know that your QE signals will be relatively slow (<~20KHz) you could possibly use the default personality and use digital inputs in a timed loop to create a software QE implementation.

 

Let us know if you have questions about any of this.

 

Thanks!

 

 

-Sam K

LabVIEW Hacker

Join / Follow the LabVIEW Hacker Group on google+

Message 2 of 33
(16,110 Views)

We decided to implement software encoders using a timed loop. We can count the edges from each signal (A,B), but I am unsure how to implement a way of detecting which signal is leading. Any ideas?

0 Kudos
Message 3 of 33
(16,094 Views)

Ideally you'd want to catch them in different iterations of the timed loop.  I'd probably use a while loop running as fast as it can (no need for a timed loop really) and keep a state for each DI channel and an overall state.  The channel state lets you determine if you have a rising or falling edge, the overall state would let you determine if A leads B or B leads A.  Then just let that grind one CPU core at 100% if you can.  What's the rest of your application doing?  Would something like that work for you?

 

-Sam K

LabVIEW Hacker

Join / Follow the LabVIEW Hacker Group on google+

0 Kudos
Message 4 of 33
(16,090 Views)

Thanks for your help - we got the encoder working, but we haven't tested it integrated into everything else. We are using these 6 motors to control the position of a platform suspended by 6 cables.  Input is desired (x,y,z) coordinate, kinematic equations are performed to determine what the necessary cable lengths are to move the platform to the new position. That's the general idea of it, at least. I have a screenshot of the code necesarry for 1 of the motors, if that helps.

 

I will let you know if just putting the encoder inputer inside a while loop works or not.

 

 

0 Kudos
Message 5 of 33
(16,078 Views)

The software version was too slow. We want to use the FPGA interface, but had a few questions. If we used the FPGA interface would ALL of the express VI's not work for RIO or would it just be the encoder VI's? Because we still want to use PID control and PWM and mathscript.

0 Kudos
Message 6 of 33
(16,061 Views)
Solution
Accepted by topic author dess1088

If you need to modify the myRIO FPGA personality you have a few options.

 

The best option is to start with the myRIO FPGA sample project, add and remove components as needed and then build your bitfile.  Any registers (LV FPGA controls / indicators) you don't modify will still work with the Advanced IO VIs and Express VIs.  In order to use the new bitfile (FPGA Personality) you'll need to update the Open FPGA VI Reference in myRIO v1.1 Open.vi (LabVIEW 2013\vi.lib\myRIO\Common\Instrument Driver Framework\myRIO v1.0\myRIO v1.1 Open.vi).

 

After doing this any time you use a myRIO Express VI or Advanced IO VI it will use your custom bitfile.  Any peripheral channels you've left in place will continue to work.  Any channels you've removed will still show up in the VIs, but will not work (they will probably throw errors at runtime) and any new channels you added will not show up in the VIs.  For new channels you'll need to use the FPGA Read / Write nodes to read and write the configuration and data register you created in the FPGA personality.  These changes will persist on that computer until you change the Open FPGA VI Reference back to the original bitfile.

 

0.PNG

 

Let us know if you have questions about any of this.

 

Thanks!

 

-Sam K

LabVIEW Hacker

Join / Follow the LabVIEW Hacker Group on google+

Message 7 of 33
(16,052 Views)

Hi, I saw your post about myRIO and Quad Encoders. In this moment I'm designing a control system for a University project. Then I need to control four Motors, and I will use Quad Encoders to close the control loop.

I have a big Question::::

 

Can I read four Quad encoders with myRIO? I have checked the PDF Manual, and I noticed that only have 2 Inputs for encoders.

 

Thanks four your help.

0 Kudos
Message 8 of 33
(16,002 Views)

Hey Javimeloc,

 

As discussed in this thread myRIO supports up to 3 QEs using the default FPGA personality.  Each provides two inputs, channel A and channel B which can be used for Step and Direction, or Quadrate Encoder inputs (A and B).

 

If you need to use more than 3 encoders you'll need to modify the myRIO FPGA personality as described above.

 

If you have any questions please create a new thread and link to this one.

 

Thanks!

 

-Sam K

LabVIEW Hacker

Join / Follow the LabVIEW Hacker Group on google+

0 Kudos
Message 9 of 33
(15,989 Views)

Thank you for your help! 🙂

0 Kudos
Message 10 of 33
(15,980 Views)