Assuming that you can measure the pressure X using the analog input #1 and convert it to percentage of fullscale ADC readings:

X = 10000*ADC(1)/4096

X will be in the range of 0 to 10000 representing 0.00% to 100.00% of full scale ADC. This is your process variable.

Now suppose you have a set point pressure S that you want the control system to reach. Whatever unit your pressure is measured you should convert it into the same unit as X using TBASIC. E.g if your ADC returns 0 to 100% of full scale for pressure of 0 to 50.0 psi, and say if you want the set point to be 30 psi, => S = 30*10000/50 = 6000 (60% of fullscale ADC).

The ERROR signal is E = S – X.

The control output Y is controlled by the PWM duty cycle (0 to 10000 representing 0 to 100% duty cycle). The purpose of PID control is to determine the value of Y from E, which is obtained by the following:

1) Use PIDDEF to set the P, I and D term (only do this once during initialization)

2) Use Y = PIDCompute(E) to compute the output Y.

3) SETPWM 1, Y, f ‘ where f is the frequency recommended by your valve supplier.

Note: Fx1616-BA, Fx2424, SmartTILE-Fx and EZWire1616 all support floating point math so P, I and D could be floating point numbers or variables.

However, Since Nano-10 and FMD PLCs do not support floating point, you can get fractional P, I and D term by representing each unit of these term as 0.1. So for a proportional term of 4.0 you will use P =40 and for integral term of 0.3 you will use I = 3. You will need to divide the result from PIDcompute() function by 10 in order to obtain the actual output Y

i.e. Y = PIDcompute(E)/10 ‘ For P, I, and D that are 0.1 per unit

As for the value of P, I and D, this is usually done by experimentation. A starting point may be P = 4 (40 if you use 0.1 per unit). In order to have zero steady state error you must have an Integral term (i.e. non zero I term). You can start with I = 0.1 and D = 0. You can gradually increase/decrease these values to alter the response time of your control system in order to reach the Set Point pressure where E = 0.

Some references regarding how to determine starting P term (proportional gain) can be found here:

http://control.com/thread/1026188392