Removing decimal values from number data

  • Hello folks,


    I have a small problem and wonder if anyone has a solution...


    If the robot speed has been reduced from 100% on the flexpendant for whatever reason, I want to send the PLC the current speed in a group output. The code I made works just fine until I tested at 60% speed, at which point it returned a value of 60.000004!


    I've tried converting to a string, back to a value etc., but am now a bit stuck as to which way to overcome this problem.


    The code is:


    PROC speed_check()
    !
    flexpendspeed:=CSpeedOverride();
    !
    IF flexpendspeed<100 THEN
    !
    SetGO go_SpeedValue,flexpendspeed;
    TPErase;
    TPShow TP_LATEST;
    UIMsgBox " Robot system speed is not 100%"\MsgLine2:=""\MsgLine3:=" Robot rendszer sebességét nem 100%"\Buttons:=btnNone\Icon:=iconInfo\MaxTime:=2\BreakFlag:=spderr;
    ELSEIF flexpendspeed=100 THEN
    SetGO go_SpeedValue,100;
    ENDIF
    !
    ENDPROC


    Thanks in advance!

Advertising from our partners