LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Problem Getting PID implemented in FPGA

Hello Ladies and Gentlemen,

 

I am trying to control 2 motors use a NI cRio 9022 and NI 9401. I have written code that works to generate PWM signals for both the motors as well as obtain Quadrature Encoder readings for both the motors, all of this done in a single-cycled timed loop in the FPGA. I now wish to implement two PID controllers in the FPGA as well to control both these motors separately. At the moment, I have gotten down to writing code for the PID for only one of the motors. I am using the quadrature encoder reading as my process variable and stipulating a position via user input as my setpoint and using the PWM high time period as the output of the PID controller.

 

The problem I am facing is that when I run the code, to test if the PID implementation works, and give it a position value, the PID controller is not sending any signal to the motor.

 

Would some kind soul help me out and tell me what I am doing wrong. Also, would it be possible to put two PID blocks in the same while loop(please look at attached VI to see what I mean).

 

Thank You

Ven

0 Kudos
Message 1 of 2
(2,142 Views)

What have you done so far to debug this?  Have you tried running in simulation so you can use the standard LabVIEW debugging tools?  It's not immediately obvious to me what's wrong, but the code looks like it's more complicated than necessary.  For example, you should never have a select where the true input is a false constant and the false input is a true constant - that's just a logical NOT.  Of course, since the selector input is >=0, you could just replace it with a <0 and avoid the NOT.

 

To run your VI in FPGA emulation mode, see the document Testing an FPGA VI Called by a Real-Time VI Running in Emulation Mode.

0 Kudos
Message 2 of 2
(2,138 Views)