Dear all.
In a simple case, I have done the palletizing with kuka kr5 krc4.
Everything runs well. But my customer want an output during the program running.
They want an heart beats (1 rise up / sec.)when the robot is running my program.
How can I do that? I mean I do not know how to write the code.
How to add a heart beat in the sps
-
plustandard -
July 13, 2019 at 4:09 AM -
Thread is Resolved
-
-
get your hands on programming manual for system integrators and system variables manual. check variables like $TIMER, $PRO_IP, $PRO_STATE etc. i would suggest creating own expert module and test it in robot interpreter. once everything works, just link it with Submit.
-
Hello,
You can make a logic like:
If ($pro_act==true and ($date.sec-($date.sec/2)*2==0)) then
Beat=true
else
Beat=false
endif$pro_act --This output is set whenever a process is active at robot level
($date.sec-(-$date.sec/2)*2==0) is $date.sec modulo 2==0, read the clock and for 1 sec you will have a beat.Maybe you will have to modify the modulo syntax but is a tip.
-
do they need to know if some program is running or they want info on specific program?
-
Hello,
You can make a logic like:
If ($pro_act==true and ($date.sec-($date.sec/2)*2==0)) then
Beat=true
else
Beat=false
endif$pro_act --This output is set whenever a process is active at robot level
($date.sec-(-$date.sec/2)*2==0) is $date.sec modulo 2==0, read the clock and for 1 sec you will have a beat.Maybe you will have to modify the modulo syntax but is a tip.
Thanks Casius
I try your code this morning, I found that the $date.sec is error. Seems there is no system Variables named $date.sec
Can you tell me more.
Sorry I do not make a systematic study of kuka program. Just study how to make code by reading others. -
do they need to know if some program is running(I will use a msgnotify ("") for this function) or they want info on specific program?Thanks your help Panic mode
I followed the tips from you and Casius.
Yes,I need to know which program is running, and what is the current status of the robot.I make some code like this.
Code
Display MoreIF ($MODE_OP==#AUT) And ($pro_state==#P_Active) and THEN ;make sure the program is running, then start the heart beat $timer[3]=0 $TIMER_STOP[3]=FALSE IF $TIMER[3]>1000 THEN ;the time can not use "=="to check the current data, I can only make sure it is more then 1000ms $out[3]=TRUE ENDIF IF $TIMER[3]>2000 THEN $out[3]=FALSE $TIMER[3]=0 ENDIF ENDIF
But I meet a new problem. I put the code in sps. The kuka rise up a error "sps is read protect only"
What's wrong on my code?? -
those are two separate questions
I put the code in sps. The kuka rise up a error "sps is read protect only"this has nothing to do with code. simply file is protected. if you want to edit it, you need to remove write protection.
this usually means checking and changing file attributes.
in case of KSS8.3 with installed MultiSubmit, SPS tasks must be cancelled manually before editing.
What's wrong on my code??few things, both logic and syntax
-
those are two separate questionsthis has nothing to do with code. simply file is protected. if you want to edit it, you need to remove write protection.
this usually means checking and changing file attributes.
in case of KSS8.3 with installed MultiSubmit, SPS tasks must be cancelled manually before editing.few things, both logic and syntax
Hello Panic mode.
Finally, I want to share my solution.
For the sps. I modified it in workvisual(actully,modified the sps in expert mode is ok).
And I found that can not use some system variables. like:$mode_op and $pro_start etc.
But we can do it like this: -
I can offer a slightly more compact method of making a heartbeat, just for the heck of it:
Code
Display More$TIMER[1] = -1000 $TIMER_STOP[1] = FALSE ; these lines go in the INI section of the SPS LOOP ; the built-in Loop section of the SPS ; add this to the User section of the SPS loop IF $TIMER_FLAG[1] THEN ; True whenever Timer>=0 $OUT[1] = NOT $OUT[1] ; invert signal state $TIMER[1] = -1000 ENDIF ENDLOOP
-
And I found that can not use some system variables. like:$mode_op and $pro_start etc.All variables can be used. That is the whole point to have them.
If that was not possible, they have no reason to exist.
you actually use $MODE_OP in your own example.there may be limitations in terms of scope or access type but ALL variables can be used.
-
I can offer a slightly more compact method of making a heartbeat, just for the heck of it:Code
Display More$TIMER[1] = -1000 $TIMER_STOP[1] = FALSE ; these lines go in the INI section of the SPS LOOP ; the built-in Loop section of the SPS ; add this to the User section of the SPS loop IF $TIMER_FLAG[1] THEN ; True whenever Timer>=0 $OUT[1] = NOT $OUT[1] ; invert signal state $TIMER[1] = -1000 ENDIF ENDLOOP
Or in 1 line in the sps
$out[100]= ($date.sec-($date.sec/2)*2==0) AND $PRO_ACT AND $EXT
-
nice but still it only tells that some program is running, not a specific one.
-
nice but still it only tells that some program is running, not a specific one.True he would need to a variable maybe to his module but i liked the one line
-
Or in 1 line in the sps
$out[100]= ($date.sec-($date.sec/2)*2==0) AND $PRO_ACT AND $EXT
Yabbut, that only works for a 0.5Hz waveform. Which, I admit, is what the OP asked for, so... you win. -
Thanks
-
really? how is 0.5Hz equal to "1 rise per second"?
0.5Hz<>1Hz -
nice but still it only tells that some program is running, not a specific one.Hm. I once did something along those lines using $PRO_IP.SI0x.NAME[], where the 'x' represents the level of the call stack. Depending on whether the program the OP wants to identify is reliably at a known level (SI02, SI05, etc), it might be necessary to create a subroutine that can search through the stack looking for a string match.
-
really? how is 0.5Hz equal to "1 rise per second"?
0.5Hz<>1HzUnless I'm missing something, as written, the output only goes True when the $DATE.SEC value is an even number. That would generate one positive edge every 2sec, for 0.5Hz.
-
that is correct but OP stated rise once per second so - 1Hz was expected but 0.5Hz was demonstrated.
just being stickler ...