Question:
Why does a code in the PLC which is written with the function L_ParWrite via CAN, show an incorrect value for a short term? arum steht in der Codestelle einer PLC, die mit der Funktion L_ParWrite über CAN beschrieben wird, kurzzeitig ein falscher Wert?
Answer:
The system task of the PLC writes data byte by byte to the code. If the system task is interrupted by the user task eg every 2 ms, the unfavourable case may occur that an incorrect value is in the code for one or more program cycles if the code type is larger than one byte. A semaphore can be used if a reaction on a value change in the code is required in the user program. This means that after writing the code an additional auxiliary code is written with the value 1 so that the receiver recognises that new data has arrived. The value of the code itself can now be read without problems and the user sets the value of the auxiliary code to zero.
A scaling routine is an even more elegant solution of the problem. If the value of a code changes, the value of the corresponding variable also changes. A scaling routine created by the user can be started each time a code is written.
Creating a scaling routine:
- In the Modules tab, Object Organizer, highlight the function block to which you want to add a scaling routine.
- Select Add Project Scaling Routine. This opens the dialog Add Scaling Routine.
- In the dialog Add Scaling Routine, select the programming language and the suitable variable. The name of the scaling routine is assigned automatically ('SCAL_' + name of the variable).
- Click the Add button to add the scaling routine or Close to cancel and close the dialog.
The scaling routine is attached below the corresponding function block in the Object Organizer. With a doubleclick, open the scaling routine in the editor when you can do the programming.