Showing results 1 to 7 of 7

Thread: MODBUS communication status

  1. #1

    Default MODBUS communication status

    Hi,

    I want to access the invalid bit of a variable so that i can assign a particular value to an internal variable based on whether the variable status is valid or not. the VB script i am using is written below: (here DI and Test are analog modbus driver variables and VBA is an internal variable of type UINT)

    Public Sub test()

    Dim i, j, k As Variable
    Dim l As Long

    Set i = thisProject.Variables.Item("DI")
    Set j = thisProject.Variables.Item("Test")
    Set k = thisProject.Variables.Item("VBA")
    l = thisProject.Variables.Item("DI").StatusValue
    'DI1=open and DI2=close
    If (l = H0x00040000) Then
    k.Value = 5
    ElseIf (i.Value = 0 And j.Value = 0) Then
    k.Value = 0
    ElseIf (i.Value = 0 And j.Value = 1) Then
    k.Value = 1
    ElseIf (i.Value = 1 And j.Value = 0) Then 'Set thisProject.Variables.Item("VBA").Value= k.Value

    End If
    End Sub

    But this is not working when the variable is invalid. How can i access the invalid bit of the variable?

  2. #2
    Join Date
    30.05.2007
    Location
    Salzburg
    Posts
    880

    Default AW: MODBUS communication status

    Why do you want to do this via VBA?

    Simply use a Reactionmatrix, watch the Invalid-Bit and link the function "Send value to hardware" to write the desired value to the other variable.

    Regards,
    Herbert

  3. #3

    Default Re: MODBUS communication status

    I can use the reaction matrix in case of different values for one driver variable.Here am using different driver variable for different status of one object. ( eg:- CB open is in one variable, close in another variable) so i need to access it through VBA because the combined element in the Screen changes according to the value of that internal variable. so the red box in the corner which appears when there is a communication error will not appear for the internal variable.

    So i need to pass the invalid bit status of the driver variable to one internal variable.

  4. #4
    Join Date
    18.07.2011
    Posts
    138

    Default Re: MODBUS communication status

    hi

    If you want to pass something from one variable to another you may use the allocations. Use your driver variable as "source variable" and the intern variable as "target variable", this way also the state of the variable is passed on. Check out the zenon help for detailed information on how to create such an allocation.

  5. #5

    Default Re: MODBUS communication status

    In our project we have some five thousand odd objects. Since i am already writing a VB script for assigning the conditions like breaker open, close, intermediate etc it would save a lot of development work for me if i can access the invalid bit through VB.

  6. #6
    Join Date
    30.05.2007
    Location
    Salzburg
    Posts
    880

    Default AW: MODBUS communication status

    use .StatusString() and check for the "Invalid" Status
    -> since a variable can have several variable status you have to search within the status string with VBA function instr()

    Also note, if you want to monitor all those variables (reading the variable status) you have to take care that those variables are advised on the driver (you can check this with the medthod .IsOnline)

    For the Reactionmatrix
    -> you only have to define 1 Rema and you can link this to all the variables you want to monitor...

    Regards,
    Herbert

  7. #7

    Default Re: MODBUS communication status

    thank you....

    It is working now....

Similar Threads

  1. Ethernet IP Communication
    By amolck in forum Engineering Studio Logic & Logic Service (former zenon Logic Workbench & Runtime)
    Replies: 0
    Last Post: 15th March 2010, 06:11
  2. Modbus read input status
    By maurodx in forum Drivers
    Replies: 3
    Last Post: 2nd September 2009, 00:21
  3. communication Error again
    By nahala in forum Engineering Studio Logic & Logic Service (former zenon Logic Workbench & Runtime)
    Replies: 1
    Last Post: 8th May 2009, 11:45
  4. Communication Error!!
    By nahala in forum Engineering Studio Logic & Logic Service (former zenon Logic Workbench & Runtime)
    Replies: 2
    Last Post: 30th April 2009, 09:33
  5. Communication does not work
    By markclemens in forum Drivers
    Replies: 0
    Last Post: 28th August 2007, 13:49

Posting Rules

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