Showing results 1 to 6 of 6

Thread: Decoding the INT tag bit By Bit

  1. #1
    Join Date

    Frage Decoding the INT tag bit By Bit

    Dear sir,
    i'm having a integer Tag, which is bit encoded values. Now i have to do is to decode it by bit by bit. and store the bit values in individual bool tags. how could we do it VBA or other method?
    Kindly check and do the needfull.

  2. #2
    Join Date

    Lächeln Re: Decoding the INT tag bit By Bit

    i found the solution for the above, by using the MOD 2/ Bit masking method.
    now i have the problem is, how to detect which variable has triggered the function. basically i want to do is generate the alarms based on the integer tag value.

    i can use withevents onlinevariable, but this events are fired for all the online variable change. for me the Online Alarm group variable value has any change then this event to be triggered.

    how do i can complete my task. Kindly any one can help me.

  3. #3

    Default Re: Decoding the INT tag bit By Bit

    Hi Paruvathakumar,

    You need to know, that there can be only one active alarm per variable in zenon. So if you can guarantee that only one of the alarmbits in the INT is active at the same time, you can use a reaction matrix to define alarms for each of the single alarm bits.

    If each of the bits represent individual alarms, you either need to create the variables in zenon as 16 single boolean variables, split them in the PLC, or use the zenon logic to split the variables into single boolean variables, in order to have individual alarms.

    Best regards,

  4. #4
    Join Date

    Lächeln Re: Decoding the INT tag bit By Bit

    Hi Mark..
    Thanks For the reply...
    my intentions is your Second option...
    My PLC Encode the alarm bits to INT, in HMI i have to Decode it to individual Bool Bits.
    i'm using the following codes to detect the alarms.
    if i use variablechange, this event calls for all the online variable change.
    i can make a online container for only alarm. and in only that container variable has any change then decode function will call.
    (i'm worried, if i execute this function for all the variables, my application should not get hang/slow)

    Private Sub OLV_Change_VariableChange(ByVal obVar As Variable)
        If InStr(obVar.Name, "_AlarmStatus") > 0 Then
        Dim Ret
            Ret = Alarms.fnAlm_Decode(obVar.Name)
        End If
    End Sub
    Public Function fnAlm_Decode(ByVal VarName As String) As Boolean
    Dim InVal, TmpVal, WordNo, i As Integer
    Dim AlmStart As Integer
    Dim EncodeVar As Variable
    Dim DecodeVar As Variable
    Dim Out_Var, CPU As String
    Dim Ret, Sp
    On Error GoTo Err
        Ret = usrFunctions.SetOnlineVar(VarName)
        If InStr(VarName, "_AlarmStatus_") > 0 Then
            Sp = Split(VarName, "_AlarmStatus_")
            CPU = Sp(0)
            WordNo = Sp(1)
            GoTo Err
        End If
        Set EncodeVar = thisProject.Variables.Item(VarName)
        InVal = EncodeVar.Value
        AlmStart = WordNo * 32
        For i = 0 To 31
            Out_Var = CPU & "_AlarmTag_" & (AlmStart + i)
            Ret = usrFunctions.SetOnlineVar(Out_Var)
            TmpVal = 0
            InVal = EncodeVar.Value
            TmpVal = InVal Mod 2
            InVal = (InVal - TmpVal) / 2
            Set DecodeVar = thisProject.Variables.Item(Out_Var)
            If TmpVal = 1 Then
                DecodeVar.Value = 1
                DecodeVar.Value = 0
            End If
        Next i
        fnAlm_Decode = True
        GoTo Ok
        fnAlm_Decode = False
    End Function

  5. #5

    Default Re: Decoding the INT tag bit By Bit


    Have a look at the zenon logic (straton). Splitting one or more INT variables into single bits can be done fairly easy here, and the zenon logic runtime runs as a separate process.


  6. #6
    Join Date

    Default Re: Decoding the INT tag bit By Bit


    I'm having a problem related with this!!!!
    I just programmed a DINT split into Booleans through Zenon Logic. Everything is working fine EXCEPT that the timestamp in the AML is wrong. All the alarms configured through Logic have the same time for received and cleared, and both of those times are incorrect.

    Any idea why that can be happening?

    **I programmed it by copying the data into an array of bolleans by:


    Is there a better way to do it?

Similar Threads

  1. Bit Toggle
    By allmendinger in forum zenon Service Engine Supervisor
    Replies: 3
    Last Post: 8th November 2011, 23:30
  2. Bit Alarmierung
    By hicom in forum zenon Service Engine Supervisor
    Replies: 1
    Last Post: 3rd August 2011, 23:40
  3. i-bit in report
    By roberto1978 in forum zenon Service Engine Supervisor
    Replies: 1
    Last Post: 12th May 2010, 14:22
  4. convert anything to bit
    By brandt in forum Engineering Studio Logic & Logic Service (former zenon Logic Workbench & Runtime)
    Replies: 0
    Last Post: 7th February 2008, 13:04

Posting Rules

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts