PID algorithm for PLC of twincat

garchev

Member
Join Date
Aug 2005
Location
rousse
Posts
2
Hi everybody,
I have to design PID controlled regulator(position and velocity) of Beckhoff TwinCat SoftPLC controller. I need your help to write the PID algorithm. I am looking for any information(code) about PID algorithms for PLCs, not especially for TwinCat.

Building of programming modules for standard and modified PID algorithms. Building the human-machine interface (HMI) of a PC for visualizing of the parameters of the developed PID algorithms. Investigate the parameters influence of the PID regulator over its characteristics. Investigating of the processes of a PID regulator system.

That's my diplom. my mail is [email protected]
 
Hi garchev,



I don't know much of Beckhoff but they sell motion software. This software is running on a PC or a CX1000 from Beckhoff as far as I know. It is better to use that than writing it.



Best regards,

Henry
 
Garchev,
Henry is correct the NC Controller that is part of the Beckhoff TwinCAT software has the functions for position and velocity corrections built into it as a standard. Also by using that you are able to take advantage of the PLC Open motion control Function Blocks when writing your control program.

also the algorithm that your trying to create is going to vary depending on the scan time you have set in your controller.

As to the HMI question what are you using for your HMI software and which drivers have you chosen to use? these are things that we need to know to be able to help.
 
a

Building of programming modules for standard and modified PID algorithms. Building the human-machine interface (HMI) of a PC for visualizing of the parameters of the developed PID algorithms. Investigate the parameters influence of the PID regulator over its characteristics. Investigating of the processes of a PID regulator system.

my work is:Building of programming modules(codes)(instruction list or stuctured text) of TwinCAT PLC soft.
-standard position pid algorithm
-standard velocity pid algorithm
- modified position pid algorithm
- modified velocity pid algorithm

AND Investigate the parameters influence of the PID regulator over its characteristics.
 
Garchev,
I understand the code part of what you are asking. I still do not know what you are using for your visualization i.e. Visual basic.net, wonderware, indusoft...etc. that's my first question as to the code I am trying to understand if you are intentionally trying to re-invent the wheel here?

the function blocks that are predefined in the PLC Open library meet most all of the requirements for doing industrial projects and in considering that someday there will be somebody else maintaining the machine they will be more easily recognizable by them.

If as it appears that you do not wish to use them then the first order of business that you will have to address is to create custom data types to handle the passing of the axis information similar to the ones that are in the NC control provided. shown here:

TYPE NCTOPLC_AXLESTRUCT
STRUCT
nStateDWord : DWORD; (* Status double word *)
nErrorCode : DWORD; (* Axis error code *)
nAxisState : DWORD; (* Axis moving status *)
nAxisModeCon : DWORD; (* Axis mode (feedback from NC) *)
nCalibrationState : DWORD; (* State of axis calibration (homing) *)
nCoupleState : DWORD; (* Axis coupling state *)
nSvbEntries : DWORD; (* SVB entries/orders (SVB = Set preparation task) *)
nSafEntries : DWORD; (* SAF entries/orders (SAF = Set execution task *)
nAxisId : DWORD; (* Axis ID *)
nOpModeDWord : DWORD; (* Current operation mode *)
nCtrlLoopIndex : DWORD; (* Axis control loop index ( old variable: nReserved2_HIDDEN : DWORD )*)
fPosIst : LREAL; (* Current position (absolut value from NC) *)
fModuloPosIst : LREAL; (* Current position as modulo value (e.g. in degrees) *)
nModuloTurns : DINT; (* Modulo turns *)
fVeloIst : LREAL; (* Current velocity (optional) *)
fPosDiff : LREAL; (* Position difference (lag distance) *)
fPosSoll : LREAL; (* Setpoint position *)
fVeloSoll : LREAL; (* Setpoint velocity *)
fAccSoll : LREAL; (* Setpoint acceleration ( old variable: fReserve1_HIDDEN : LREAL ) *)
fReserve2_HIDDEN : LREAL; (* reserved *)
fReserve3_HIDDEN : LREAL; (* reserved *)
fReserve4_HIDDEN : LREAL; (* reserved *)
END_STRUCT
END_TYPE

and here:

TYPE PLCTONC_AXLESTRUCT
STRUCT
nDeCtrlDWord : DWORD; (* Control double word *)
nOverride : DWORD; (* Velocity override *)
nAxisModeReq : DWORD; (* Axis operating mode (PLC request) *)
nAxisModeDWord : DWORD; (* *)
fAxisModeLReal : LREAL; (* *)
fActPosCorrection : LREAL; (* Correction value for current position *)
nReserved_HIDDEN : ARRAY [32..127] OF BYTE;
END_STRUCT
END_TYPE

then you will need to set the scan time of your plc in such a way that the information is passed to the PLC as soon as there is new information available which will require you to know your network update time and re-act accordingly.

Then you will need to begin writing move blocks with your PIDs integrated into them to do your corrections on the fly no mean feat in and of itself especially when they have been done in advance for you as shown here:

MC_MoveAbsolute(
Execute:= ,
Position:= ,
Velocity:= ,
Acceleration:= ,
Deceleration:= ,
Jerk:= ,
Axis:= ,
Done=> ,
CommandAborted=> ,
Error=> ,
ErrorID=> );

or

MC_MoveAbsoluteOrRestart(
Execute:= ,
Position:= ,
Velocity:= ,
Acceleration:= ,
Deceleration:= ,
Jerk:= ,
Axis:= ,
Done=> ,
CommandAborted=> ,
Error=> ,
ErrorID=> );

These blocks are defined for all controllers not just TwinCAT which means that everyone following behind you will be able to read them and understand what your trying to do.

If you still want to follow this course set up the structures and I will try to help as I am able as long as you understand that this is no small project.

good luck

Keeper
 

Similar Topics

Hello I have plc s7-1200 and want to control 4 outputs with 3 inputs by PID algorithm . any outputs is dependent. I could do this?
Replies
13
Views
5,226
Hi just wondering if anyone can help me out with the type of algorithm Omron PLCs use? Ideal, Series, or Parallel? I'm running through a tuning...
Replies
4
Views
1,922
Hi all! In Siemens help PID controller is K(1+1/Tis+Tds). I did in matlab some model with object described Transfer Function and this PID form...
Replies
8
Views
8,066
Hi i want to make PID code by using MLX1000, I dont want to use PID instruction and real type data format. is possible, if yes please help me...
Replies
9
Views
2,967
Hi, I am using low cost Delta PLC DVP 14SS, I want to use a PID loop, as per PID instruction, during testing of the program, I found that on...
Replies
2
Views
3,132
Back
Top Bottom