Knowledge Base

PID control: SPLat programming

We’re in the home straight now, at least as far as the PID control part of your application is concerned. You have interfaced your process to the SPLat and you have all the settings to make the PID control work. You’ve probably had a few false starts along the way, that’s perfectly normal, but if you’ve paid enough attention to the detail you are now staring a great solution in the face.

All that remains for the PID function is to generate the production PID code and integrate it into the rest of your SPLat program.

PIDassist has a built in code generator. Use the .pid settings you determined in the previous chapter. They will provide most of the information the code generator needs. The only other decision you need to make are:

RAM Addr

This setting lets you decide where the code generator locates the RAM variables it needs. The number of RAM bytes required will depend on the parameters chosen.

Self Timed

If you check this box, the PID code generated will include the use of timer 7 to generate sampling intervals. It is then up to you to call (GoSub) the PID_Calc subroutine frequently to give it a chance to do its sums at the appropriate times. If you do not check this box then you must take responsibility for calling PID_calc exactly every sample time.

In practice there are inevitable delays in detecting that a timer has timed out, so you will end up calling PID_Calc at a slower rate than intended. Dialect 12 of the SPLat language will contain a new timing mechanism that can mitigate this effect.

Fixed SP

Checking this box will result in code that contains the setpoint value from the Controller pane hard-coded.

The setpoint is always interpreted as the input (usually voltage) actually presented to the SPLat board, irrespective of inversion.

Once you have all the setting the way you want them, click the “Generate SPLat code” button. You can then copy and paste the resulting code into your own SPLat program and add your own code to link it into your application. The generated code is not designed to interact with PIDassist.

The generated code can vary quite a bit, depending on your settings.