some tags are not refreshing on DskDevice IO Device

Hi All,

I cant figure out why some tags doesnt refresh.

I am reading an ION meter via modbus tcp, and Total Power data is coming on 2 registers. So, in variable tags i have one for High Value Register and other tag for the Low Value register. and via cicode i make the calculation formula Value=High Value * 65536 + Low Value. I have other variable tag on DskDevice L15 named Value. but this isnot refreshing while on runtime. also if i make other text with the same expression tag "Value=High Value * 65536 + Low Value".

could someone help me please

Parents
  • Hi Pavel,

    Are you certain that your main function is running? Do you start it on startup of your application?
    You can configure a startup function in the Computer Setup Wizard.
    I suggest that you run these functions on the I/O server, because if you run them on the client you HAVE to be logged in to Citect to be able to write to the disk tag (security restriction on the client process).

    This might be the main problem now: not being logged in in Citect.

    Also, you should remove a WHILE 1 loop from one of your functions.
    Your main function is already running in an endless loop so it will start a new calculation function every 100ms.
    If you leave the WHILE 1 in your calculation function it will also never stop and thus every 100ms a new instance of this function will run in parallel of the existing one, creating a memory leak and other unpredictable behaviour.

    I suggest adjusting your functions like this:

    FUNCTION MTR1_KW_C()
    ErrSet(1); // Disable error checking, e.g.: divide by Zero
    MTR1_KW_CALC = MTR1_KW_H * 65536 + MTR1_KW_L;
    ErrSet(0); // Re-enable error checking.
    END

    FUNCTION MTR1_MAIN_C()
    ErrSet(1); // Disable error checking
    WHILE TRUE DO
    TaskNew("MTR1_KW_C", "", 8); // Call this function as a new task, but only if it does not run already
    SleepMS(100);
    END
    ErrSet(0); // Re-enable error checking.
    END

    Calling your calculation function with TaskNew() prevents running more than 1 instance of it, for example when your calculation takes longer than 100ms.

    Regards,
    Patrick
Reply
  • Hi Pavel,

    Are you certain that your main function is running? Do you start it on startup of your application?
    You can configure a startup function in the Computer Setup Wizard.
    I suggest that you run these functions on the I/O server, because if you run them on the client you HAVE to be logged in to Citect to be able to write to the disk tag (security restriction on the client process).

    This might be the main problem now: not being logged in in Citect.

    Also, you should remove a WHILE 1 loop from one of your functions.
    Your main function is already running in an endless loop so it will start a new calculation function every 100ms.
    If you leave the WHILE 1 in your calculation function it will also never stop and thus every 100ms a new instance of this function will run in parallel of the existing one, creating a memory leak and other unpredictable behaviour.

    I suggest adjusting your functions like this:

    FUNCTION MTR1_KW_C()
    ErrSet(1); // Disable error checking, e.g.: divide by Zero
    MTR1_KW_CALC = MTR1_KW_H * 65536 + MTR1_KW_L;
    ErrSet(0); // Re-enable error checking.
    END

    FUNCTION MTR1_MAIN_C()
    ErrSet(1); // Disable error checking
    WHILE TRUE DO
    TaskNew("MTR1_KW_C", "", 8); // Call this function as a new task, but only if it does not run already
    SleepMS(100);
    END
    ErrSet(0); // Re-enable error checking.
    END

    Calling your calculation function with TaskNew() prevents running more than 1 instance of it, for example when your calculation takes longer than 100ms.

    Regards,
    Patrick
Children
No Data