Showing results 1 to 5 of 5

Thread: AdjustHardwareValue problem

  1. #1
    julienk Gast

    Default AdjustHardwareValue problem

    Hello everybody,

    In october, We have a strange problem with AdjustHardwareValue.
    For instance, I've 5 machines variables (Power kW), before my problem, there was this AdjustHardwareValue for each of them :

    Public Function AdjustHardwareValue_0(obVar As Variable, vValue As Variant) As Double
    
    Dim x As Long
    x = vValue
    AdjustHardwareValue_0 = Int(x)
    If (x > 100) Then
        AdjustHardwareValue_0 = Int(x / 25 + 0.5) * 25
    End If
    End Function

    There was not problem, but one day, we've noticed that our values of variables were "0kW", and if we unselected the case AdjustHardwareValue, it was OK.
    That's why I wonder what kind of thing could have that cause on AdjustHardwareValue.

    For the moment, the case is unselected waiting for solution.

    Thank you.

    Julien.K

  2. #2

    Default Re: AdjustHardwareValue problem

    A better location for this thread (question) would probably have been the VBA forum, but I'll try and answer here anyway

    What are the values that you see, when you disable the adjusthardwarevalue macro?

    Are these values > 100? (is the calculation within the if condition executed)

    Are these values < 1? (e.g. 0.2345) The "int" function that you use in VBA will cut off the decimals and return the value before the decimal character -> that could be "0" in such cases

    What has happened since that "one day"?

    Have the values from the PLC changed?
    Maybe the language / regional settings in the operating system have been changed?

  3. #3
    julienk Gast

    Default Re: AdjustHardwareValue problem

    Sorry for the topic location.

    When I disable the macro, my values are for example 550kW 1300kW 250kW ... They change all the time, whereas I enable the macro my values are 0kW.
    They've never been inferior to 1kW.

    That "one day" there is nothing special action. Maybe an update could caused that problem but I don't know more what happened. That's why I'm searching what cause could interact with AdjustHardwareValue.

    However, in other projects, there are the same thing : Adjusthardware on power variable but They've never had some problem.

    When I try with the same variable on an other independant project, I don't have that problem.

    Thank you for yout helping.

  4. #4

    Default Re: AdjustHardwareValue problem

    I can only imagine that the vValue variant being passed to the AdjustHardwareValue macro is somehow not valid.

    The "int" function is not really required in your function. x is defined as a Long, and by assigning vValue to x, it is implicitely converted to a long, losing the decimals.

    What you can do is write "stop" in the first line, to open the debugger in the runtime when the macro is called, to debug and see what may be wrong.

    If this does not lead to the cause, I think it is best to send a copy of your project to your local COPA-DATA support, for them to take a look at it.

  5. #5
    julienk Gast

    Default Re: AdjustHardwareValue problem

    Hello I've finally solved my problem. There was a line in my VBA code (in thisproject) which caused all macro problem. My line was not in a Sub but in Option explicit ...

    thank you for your helping, now I need some answers about "Attribution" but It is in an other topic.

Similar Threads

  1. User managment Problem, Snapshot relativ Problem
    By jusufs in forum zenon Supervisor
    Replies: 4
    Last Post: 13th September 2010, 23:06

Posting Rules

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