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.