Configuration in zenon
|Show all Hide all|
The following globalvariables have to be declared in zenon and have to be defined as 'externally visible'. As driver the Internal driver is used:
Watchdog_IN : DINT
Watchdog_OUT : DINT
In addition these assignments must be set up:
1. COPA-DATA or COPALP do not guarantee that the code which is mentioned here is correct. This code is only an Example.
2. We recommend that you do not adopt the Redundancy switching from this example. This can cause problems when using zenon sub projects!
If the straton Runtime is missing, the zenon Runtime should be closed!
You can copy the VBA script in the zenon VBA Editor (Zenrt32Objekte/thisProject) and edit it there accordingly.
Public WithEvents zOLV As OnlineVariable
Public lTime As Long
Public bSTRATON_Lost As Boolean
Private Declare Function GetTickCount Lib "kernel32" () As Long
Private Sub Project_Active()
If zOLV Is Nothing Then
Set zOLV = thisProject.OnlineVariables.CreateOnlineVariables("OLV")
If Not zOLV Is Nothing Then
lTime = GetTickCount 'lTime initialisieren
bSTRATON_Lost = False
'Is activated on each change of the variable <Watchdog_OUT>
Private Sub zOLV_VariableChange(ByVal obVar As IVariable)
lTime = GetTickCount 'Time stamp in ms
bSTRATON_Lost = False
'is executed every 5 seconds using time control (execute VBA Macro) ...
Public Sub Timer ()
Dim obFuncRed As RtFunction
Dim obFuncTerm As RtFunction
Set obFuncRed =thisProject.RtFunctions.Item("funcRed") 'Redundancy switching
Set obFuncTerm =thisProject.RtFunctions.Item("funcTerm") 'Exit program
than 15 s passed since the variable has changed
'This is only true for a cycle time of more than 100 ms. This value must be adjusted
'proportional to the cycle time.
If lTime < GetTickCount - 15000 Then
'Stops the switching between the two RTs.
'If straton is no longer available, it is switched to the other RT,
'because here straton is not running anymore and switched this RT back to here,
'is only switched back if in the mean time a straton
'RT has been running. Otherwise zenon is closed
If bSTRATON_Lost Then
If Not obFuncTerm Is Nothing Then
bSTRATON_Lost = True
lTime = GetTickCount 'reset lTime
If Not obFuncRed Is Nothing Then
'execute zenon function 'funcRed' (Redundancy switching)
Private Sub Project_SbToServer()
lTime = GetTickCount 'initialize lTime
'Online variables container is deactivated and released..
Private Sub Project_Inactive()
If Not zOLV Is Nothing Then zOLV.Undefine
Set zOLV = Nothing
As described in the VBA script, in zenon functions funcRed, funcTerm and VBA_Call must be created:
The function VBA_Call must be executed by the time control in zenon: