sps.sub user PLC section

  • The working code for analogical robot speed control in Automatic Mode with an external potentiometer ( analogical input), to be added in sps.sub is fallowing :


    ;FOLD USER DECL

    ;please insert user defined declarations

    DECL REAL nPLCSpeed

    SIGNAL iPLCSpeed $ANIN[1] ; robot speed control from external potentiometer

    ;ENDFOLD (USER DECL)

    ;ENDFOLD (DECLARATIONS)

    .

    .

    .

    LOOP

    WAIT FOR NOT($POWER_FAIL)

    TORQUE_MONITORING()

    ;FOLD USER PLC

    ;Make your modifications here


    IF $AUT THEN : only apply PLC speed in Automatic Mode

    nPLCSpeed = iPLCSpeed ; transcribe input byte to integer


    IF nPLCSpeed<0 THEN

    nPLCSpeed=0 ; avoid negative values

    ENDIF

    IF nPLCSpeed>0 THEN

    nPLCSpeed=100 ; OV_PRO only accepts integers between 0 and 100

    ENDIF


    $OV_PRO=100.0*$ANIN[1] ; write speed to $OV_PRO

    ENDIF

    ENDLOOP


    Note that underlined code line will give you when edit in WV a warning message that should be ignored not supressed with ;

    The message is:

    "When using a value of type 'REAL' for a parameter of type 'INT' some values may not be initialized correctly"

    If you supress the message, just to have a clean syntax in Work Visual, will not function.

    Important is to have no error, warnings are just warnings, do not block.


    I also awarn that use of potentiometer in robot speed control should be done by end user with maximum attention, because is very easy to hit the button and instead 10% suddenly to reach 100%.

    Is more safe digital control with +/- from smartpad or external digital button if needed.


    Thank you Skyfire,PanicMode,Herman for your sugestions that lead me to solve this request.

  • Just some remarks on your code. So you can write following code and have the same behaviour:

  • Yes nPLCSspeed is declared as real, if try to define as integer , iPLCSpeed becomes red, not accepted.

    Your code simplified I think is better since potentiometer is 0-10V, and couldn't give for nPLCSpeed negative values or higher than 100.

    I will try it, if works will be adopted.

    Thank you !

  • Therefore, still testing today robot behaviour, Submit Works fine, do not stop anymore.

    Running a simple src programm, in T1 os ok, in AUT is ok too a while, Robot Speed can be setted from potentiometer, but appear an error and stop, not in the same line , randomly saying

    "OVM invalid value"

    originator R1/nonname.src....my testing program

    I think it happen when I try to vary robot speed while running.

    When fix a speed from potentiometer and run in auto keeping it unchanged, run all program ok.

    Maybe I am wrong, but what about refer OVM value?

    It is linked by OV_PRO?

    I don't think is a problem with the program since in T1 is running well.

  • I found some line reffering to OVM in tm bib.src


    I think is linked by OV_PRO when torque monitor.

    Or collision detection.


    Vary on OV_PRO from potentiometer while runing, change torque values and maybe robot could interpret this as a collision and stop movement.


    Should I deactivate collision detection?

Advertising from our partners