Value scaling

Forum Home Forums Uncategorized Issues Value scaling


Viewing 7 posts - 1 through 7 (of 7 total)
  • Author
  • #3484

    I have an input 0 – 255.
    This value needs to be scaled to 0 – 50.0.

    I tried Scaler(Val(23),0,255,0,50.0) but this just crashes the server and it becomes unavailable. Am I using the formula right.

    double Scaler (double input, double in_min, double in_max, double out_min, double out_max)
    double out1 = 0;
    double out2 = 0;
    double output = 0;
    double diff = in_max - in_min;
    if (diff != 0)
    if (input > in_max) out1 = in_max;
    else out1 = input;
    if (in_min > out1) out2 = in_min;
    else out2 = out1;
    output = (out_max - out_min) / diff * (out2 - in_min) + out_min;
    return output;

    This site automatically changes the minus sign on the dash. Try to rewrite the formula from the code or correct hands.

    The entry of the formula seems correct


    this just crashes the server

    To fix it, you need to read and understand a message in the server log file.


    Thank you manjey73. That is the exact formula i added.

    It does not crash completely. I just do not get any information from it.
    Input channel 23 is my modbus register that contains the byte value.

    When I add the input channel to say 203, then I add the formula on 203 to look at 23 to scale the value. The value gets scaled correctly but it never updates again. Some other values in the same scheme is working, but the scaled value is frozen.
    Also in the communicator screen the 23 gets changed to 203.


    Can you catch and fix a screenshot ? Just online translation I do not understand what you mean ?


    I have watched the videos on youtube carefully.
    I will start from scratch using only the one register value. Might be something conflicting.


    I found the problems.
    Communicator had two modbus lines looking at the same device. Thats issue one.
    Second. I used the same signal number in my calculated value as in my main channel number. That caused the communicator to change to that signal which never updates again.

Viewing 7 posts - 1 through 7 (of 7 total)
  • You must be logged in to reply to this topic.