Showing results for 
Search instead for 
Did you mean: 

pid loop in fpga vi output is always zero

Hello, I have 2 pid loops to control a 3 stage servovalve, the scheme of the control for this devices is that you conect 2 pid loops, the output of the first pid loop is the setpoint for the second one, the process variable for the first pid loop is the position of the valve, and the process variable for the second loop is the position of a spool, so when you want to move the valve, the first pid loop tells the second pid loop to move the spool so the whole servovalve moves to the desired position. I already did it with a code, which I modified to work with 3 of these devices, but right now the output of the first pid loop is always zero it doesn't matter if I change the gains or do something else, I already checked the code several times and  the wirings and everything seems fine, I will attach the code to see if someone can help me with that

0 Kudos
Message 1 of 5

here is a picture of the implementation of the pid loops. the channel index is set by a counter which reaches number 2 and then resets to 0program.jpg

0 Kudos
Message 2 of 5



It seems interesting to me that only one of the PID functions is outputting 0. Does the other PID function output 0 as well? If not then it might be best to directly compare what differences are happening between the two PID functions. If that is the case, could you send me the inputs that are coming into each function in a screenshot?


If the second function is not working, then can you still let me know what you are inputting into the input as well as the configuration for each one of the PID functions, and then we can see what is happening to cause the 0 output.


In addition, I recommend not coercing (the red dot) the input of the PID, and directly converting it beforehand to the correct type of single fixed point.




Shamik C

Applications Engineer

National Instruments

0 Kudos
Message 3 of 5

Hello Shamik,


I finally made it work the way I needed, I changed the way the channel index was chaninging, the counter and reset were outside the flat sequence sructure and I think that the contoller channel wasn't updating as fast as the case structure for the outputs or inputs (that is the first thing that comes to my mind) but still, I keep believeing that if that was the problem, the ouput of any channel of the first pid loop would be different from zero, they would be in the wong order but still different from zero. 

The output of the second pid loop was fine, it always tried to reach the setpoint of that loop which was zero.


The inputs are decided in a case structure where depending on which actuator and what mode the user wants, se we have the east actuator, corresponds to channel 0, center actuator: channel1, west actuator: channel 2. And the mode is position: true, or force: false, for each option I set different setpoint and pid gains.





0 Kudos
Message 4 of 5

hello again,


apparently I made it work again, but the thing is I cannot make some changes to the program or the pid loop will stop working, for the fisrt pid loop one of the options is a force control loop, and the sensor is a loadcell, I am using a ni 9237 module to read the loadcell, and this gives me small voltages from the loadcell, at full scale I will see .0022 v, so I need to be able to scale this number in order to have a better resolution in terms of applying the control loop, I tried to rescale the input of the module directly in the fpga vi just by using a multiplication function, I even tried to send the reading to the real time module and le it do the math and send back to the fpga the scaled number, but every time happens the same thing the output of this pid loop is zero, any Ideas?



0 Kudos
Message 5 of 5