Looks like you are not calling the function. Call function SetHz() in sps.sub. You can call it inside the loop statement.
mapping
-
Martin84 -
July 6, 2016 at 10:12 PM -
Thread is marked as Resolved.
-
-
Exactly how to give it sps.sub it gets:
-
Paste your sps.sub code here.
-
The reason it doesn't work is because the function isn't declared as global.
-
Quote
&ACCESS RVEO
&REL 40
&COMMENT PLC on control
DEF SPS ( )
;FOLD DECLARATIONS
;FOLD BASISTECH DECL
;Automatik extern
DECL STATE_T STAT
DECL MODUS_T MODE
;ENDFOLD (BASISTECH DECL)
;FOLD USER DECL
; Please insert user defined declarations;ENDFOLD (USER DECL)
;ENDFOLD (DECLARATIONS)
;FOLD INI
;FOLD DEFAULT MSG_T
$MSG_T={MSG_T: VALID FALSE,RELEASE FALSE,TYP #NOTIFY,MODUL[] " ",KEY[] " ",PARAM_TYP #VALUE,PARAM[] " ",DLG_FORMAT[] " ",ANSWER 0}
;ENDFOLD (DEFAULT MSG_T)
;FOLD AUTOEXT INIT
INTERRUPT DECL 91 WHEN $PRO_STATE1==#P_FREE DO RESET_OUT ()
INTERRUPT ON 91
$LOOP_MSG[]=" "
MODE=#SYNC
$H_POS=$H_POS
;Automatik extern
IF $MODE_OP==#EX THEN
CWRITE($CMD,STAT,MODE,"RUN /R1/CELL()")
ENDIF
;ENDFOLD (AUTOEXT INIT)
;FOLD USER INIT
; Please insert user defined initialization commands;ENDFOLD (USER INIT)
;ENDFOLD (INI)LOOP
WAIT FOR NOT($POWER_FAIL)
;FOLD USER PLC
;Make your modifications here;ENDFOLD (USER PLC)
IF $PERI_RDY THEN
P03()
ENDIF
IF $PERI_RDY THEN
P04()
ENDIF
SetHz()
ENDLOOP
;FOLD ;%{H}
;FOLD
END
;ENDFOLDDEF RESET_OUT ( )
INT N
$LOOP_MSG[]=" "
IF REFLECT_PROG_NR == 1 THEN
FOR N = 0 TO PGNO_LENGTH - 1
$OUT[PGNO_FBIT_REFL + N] = FALSE
ENDFOR
ENDIF
IF (PGNO_REQ>0) THEN
$OUT[PGNO_REQ]=FALSE
ELSE
IF (PGNO_REQ<0) THEN
$OUT[-PGNO_REQ]=TRUE
ENDIF
ENDIF
END;FOLD USER SUBROUTINE
; Integrate your user defined subroutines;ENDFOLD (USER SUBROUTINE)
;ENDFOLD -
You can explain how? SPL
-
You have called the function in the loop statement but the submit does not recognize the subroutine as a external subroutine. You will have to declare it as an external subroutine in the declaration section of sps. See in Blue.
I hope it will work. If not then you can simply write this function as an internal subroutine inside the function inside the FOLD saying User Subroutine.
Thanks
-
I typed in $ config file: EXT Set Hz ()
but it does not work.
will do now your method.
Thanks -
-
There is a difference between sub and function. Function returns value and sub doesn't. When calling function you must have something that receives the result. Value transfer is done using equal sign which you did not use. Also you did not put any value into SetHz. If testing function in ļa single variable monitor use equal sign like I did. If using function in a program declare variable or use result of function to pass value directly to a ByVar parameter.
-
Now I am confused.
I have to give in sps.sub ext sethz ()?
what you are to be in the sps .sub?
in sethz I see only the rest is hidden. -
There is a difference between sub and function. Function returns value and sub doesn't. When calling function you must have so thing that receives the result. Value transfer is done using equal sign which you did not use. Also you did not put any value into SetHz. If testing function in ļa single variable monitor use equal sign like I did. If using function in a program declare variable or use result of function to pass value directly to a ByVar parameter.Thanks Panic. Sorry, I didn't realise this.
Martin, you may have to go with second option in my previous explanation. Write this function in sps.sub under FOLD USER Subroutines.
-
Quote
ok so function is ok....
you can test it in variable monitor, just type=SetHZ(1)
or
SetHZ(30)
to see the result.
message you have now tells you that 'whatever' is not of correct type. it need to be REAL (or at least INT) to receive result from SetHz
Starting from scratch.
What and where to enter in this place? -
add something to sps.sub?
Quote&ACCESS RVEO
&REL 40
&COMMENT PLC on control
DEF SPS ( )
;FOLD DECLARATIONS
;FOLD BASISTECH DECL
;Automatik extern
DECL STATE_T STAT
DECL MODUS_T MODE
;ENDFOLD (BASISTECH DECL)
;FOLD USER DECL
; Please insert user defined declarations;ENDFOLD (USER DECL)
;ENDFOLD (DECLARATIONS)
;FOLD INI
;FOLD DEFAULT MSG_T
$MSG_T={MSG_T: VALID FALSE,RELEASE FALSE,TYP #NOTIFY,MODUL[] " ",KEY[] " ",PARAM_TYP #VALUE,PARAM[] " ",DLG_FORMAT[] " ",ANSWER 0}
;ENDFOLD (DEFAULT MSG_T)
;FOLD AUTOEXT INIT
INTERRUPT DECL 91 WHEN $PRO_STATE1==#P_FREE DO RESET_OUT ()
INTERRUPT ON 91
$LOOP_MSG[]=" "
MODE=#SYNC
$H_POS=$H_POS
;Automatik extern
IF $MODE_OP==#EX THEN
CWRITE($CMD,STAT,MODE,"RUN /R1/CELL()")
ENDIF
;ENDFOLD (AUTOEXT INIT)
;FOLD USER INIT
; Please insert user defined initialization commands;ENDFOLD (USER INIT)
;ENDFOLD (INI)LOOP
WAIT FOR NOT($POWER_FAIL)
;FOLD USER PLC
;Make your modifications here;ENDFOLD (USER PLC)
IF $PERI_RDY THEN
P03()
ENDIF
IF $PERI_RDY THEN
P04()
ENDIF
SetHz()
ENDLOOP
;FOLD ;%{H}
;FOLD
END
;ENDFOLDDEF RESET_OUT ( )
INT N
$LOOP_MSG[]=" "
IF REFLECT_PROG_NR == 1 THEN
FOR N = 0 TO PGNO_LENGTH - 1
$OUT[PGNO_FBIT_REFL + N] = FALSE
ENDFOR
ENDIF
IF (PGNO_REQ>0) THEN
$OUT[PGNO_REQ]=FALSE
ELSE
IF (PGNO_REQ<0) THEN
$OUT[-PGNO_REQ]=TRUE
ENDIF
ENDIF
END;FOLD USER SUBROUTINE
; Integrate your user defined subroutines;ENDFOLD (USER SUBROUTINE)
;ENDFOLD
,
Excuse me with such detail to ask , but poorly with the language and certain things do not understand , as you write the language computing. -
2247 Message text BOTH SIDES OF THE VALUE ASSIGNMENT ARE NOT
COMPATIBLE -
I bet you haven't declared the variable 'whatever'.
-
Yeah I do not know how to do it.
Or rather, where it add? -
Yeah I do not know how to do it.
Or rather, where it add?I can give you one precious suggestion....
Go for KUKA training or read manuals (download them from Manual Section of this forum and read expert programming manual in full)....
About variable declaration, you can declare it in $Config.dat or the .dat file (same name as your src file) linked to your src file. You can also declare them locally in your src file in the declaration section. All this have been explained in detail in Programming manuals.
Thanks
-
Hey
I found some time and I began to view the programming instructions.I do not know if I understand it, how you want it:
QuoteDECL POS P1
INT A1,A2
REAL VEL[7],ACC[7],B
DECL S_PAR_TYPE S_PAR[3] -
We also don't understand how do you want it. I read the complete post twice to recall everything.
Please explain your question. I do not understand the code in your post as you have included new information.
-