Academic Hardware Products (myDAQ, myRIO)

cancel
Showing results for 
Search instead for 
Did you mean: 

Quad encoder VI doesn't work after programming FPGA

Solved!
Go to solution

I am rather new to the MyRIO, and I am working on controlling a stepper motor from the MyRIO and read in a quadrature encoder at the same time. Individually programmed, the two pieces work beautifully, but once I combine them and attempt to program, the stepper control signals work, but the encoder reader does not. I am using the Express VI for the quad encoder reader from LabVIEW, and I produce the four stepper signals using the FPGA. 

 

It seems as if the encoder is disabled when I program the FPGA with my code, because if I have two parallel loops, one for the encoder reader and one for the stepper control, if I stop the stepper loop, the encoder immediately works.

 

Is there something simple I am missing?  Any suggestions would be greatly appreciated!

 

Thank you,

 

Enan

0 Kudos
Message 1 of 10
(9,046 Views)

Good day Enan,

 

Since the encoder and motor control sections work well individually sounds like there are dependencies that force somehow a sequential execution on your code after combining the code but, would not be able to tell without the code.

 

Try checking the IO resources used for these 2 operations and make sure they are not reusing the same ports.

Alejandro C. | National Instruments
0 Kudos
Message 2 of 10
(9,026 Views)

Thank you for the response.

 

I looked over the IO ports thinking that that could be the simple solution to my problem, but they (the ports) appear to be completely separate, and there is little chance interfere with each other. Using ENC0 on digital port C, and producing the signals on DIO4:7 of digital port C. I moved the four stepper signals to A just to see if there was a difference, and there was no change in the result.

 

I've also used a sequence structure to try to have them initialize at separate times (opening the FPGA reference once the encoder had started), but this did nothing to resolve the problem.

 

I feel like it has something to do with the encoder actually functioning on the FPGA level even though I program the VI at the processor level.

 

My code has since become quite disorganized. I will post it when I have a layout that could be understood.

 

Thank you again,

 

Enan

0 Kudos
Message 3 of 10
(9,007 Views)

Here is the code I have.

Download All
0 Kudos
Message 4 of 10
(8,986 Views)

So the code that you sent does not have any relation to each other which could be the problem. On the RT your calling an FPGA VI called ‘quadencoderwithdrive2.vi’. In theory the ‘DigitalStepperDrive(WORKS).vi ‘ should be inside the ‘quadencoderwithdrive2.vi’. When you compile custom FPGA code everything is supposed to fit into a single bitfile.

 

Try merging the FPGA VIs and recompile. You know you are on the right direction if you see all the controls and indicators from the FPGA on the Read/Write control from the RT.

Alejandro C. | National Instruments
0 Kudos
Message 5 of 10
(8,981 Views)

That was a mistake on my part. I apologize!  Here is what I should have posted. It calls the 'DigitalStepperDrive(WORKS).vi'.

 

Sorry again for my mistake, the other program was for something else.

 

Thank you for your help!

 

Enan

0 Kudos
Message 6 of 10
(8,974 Views)

Hi there,

 

No worries, and sorry for the late reply. So…same answer as before. You are calling 2 separate codes than needs to merge into a single FPGA VI.

 

Unfortunately you can’t run more than one bitfile on the FPGA. The myRIO Express VI’s use a different bitfile than the one you generate for the custom stepper control (see pictures).

 

Again, I recommend creating and compiling a single FPGA VI with both functionalities or stick to the express VIs and build the functionality on the Real Time side.

 

Regards,

Alejandro C. | National Instruments
0 Kudos
Message 7 of 10
(8,944 Views)

Thank you very much for you help. The multiple bitfile error is what I was assuming was the issue, but I thought there might be a work-around for that problem.  I have created a single FPGA VI with both functionalities that works and it functions well for what I need, just without some of the features the VI has.

 

Thank you again,

 

Enan

0 Kudos
Message 8 of 10
(8,939 Views)
Solution
Accepted by topic author ezelinski

I now realize that my last response might have been confusing and not helpful to anyone else that may come across the same problems later. 

 

Here is how I fixed the problem I was having:

 

I had to derive the boolean expressions for a quadrature encoder (basically creating my own), and then used the outputs (UP, DOWN) to increment/decrement a counter using conditionals. I then stored the direction value in a flip flop implemented using two T/F conditionals in series and connected to a shift register on the edge of the loop.

 

This was all able to be implemented in a Single-cycle Timed Loop, and then I was able to place that in the same loop that I was using to control the stepper motor.

 

In this way I was able to have a VI that compiled in one Bitfile and could be programmed to the FPGA.

 

Hope this is more clear!

 

Enan

0 Kudos
Message 9 of 10
(8,718 Views)

Could you be so kind to upload your project for more reference?, please

0 Kudos
Message 10 of 10
(4,654 Views)