Simple PC – PLC Communications Part IV - Evaluation Code Sample

. Thursday, November 6, 2008

In this post, I would like to give a simple pseudo code for managing time intervals, how to switch them between. Remember that following code is belong to 'Evaluate' function which is stated in second post and executing in a continious loop:

Global TimeInterval

Function Evaluate()

Select Case TimeInterval

Case "T1"

If PLC_Read.Request = True

TimeInterval = "T2"

End If

Case "T2"


TimeInterval = "T3"

PLC_Write.Response = True

Case "T3"

If PLC_Read.Request = False Then

TimeInterval = "T4"

End If

Case "T4"

TimeInterval = "T1"

PLC_Write.Response = False

End Select

End Function

However, it is just a sample, it is possible to simplify this code into less steps. For example it is possible to insert into database and then switch into last step according to read data from PLC.

For next post, we are going to give some tips about managing steps and increasing immunity against deadlocks may be caused by power loss and operators unwanted, unexpected behaviours.


Post a Comment


Search This Blog


About Me

My photo
Automation engineer especially working on PC software development. Formerly I was coding on PLC, but now I am using mostly Visual Basic on PC.