Hi panic mode,
Thanks for all your help. I really appreciate the way you tried to explain the concepts and now the code is working for me as expected.
Thanks once again!!
Hi panic mode,
Thanks for all your help. I really appreciate the way you tried to explain the concepts and now the code is working for me as expected.
Thanks once again!!
But how the example in book is working?
I got one more thing which says that I should define the TestArray or any value which I am saving in interrupt in Cofig file.
I have saved both my TestArray and ENDPROBE in Config file. Then also I am not able to get the value out of interrupt.
Hey panic mode,
Thanks for all your help!
Actually I try to make multiple codes as I am in school and I get the KUKA just 2 times a week to test the code. I have used you code and tried to modify the code as per my requirement.
I have make one more code using the code given in document as well. I tested that but it's not working as per expectation. Can you let me know how can I make that work as well. I know the problem is in the interrupt where the value is runtime variable and it's not coming out of interrupt.
In the code attached when I am doing LIN {TestArray[1]}, LIN{TestArray[2]}
The values getting stored in the test array are ENDPROBE values from the search function and not from interrupt. I want if the interrupt is not called then it should save the ENDPROBE value from the search function and if the interrupt is called it should save value from the interrupt function's $POS_INT value.
E6POS ENDPROBE
E6POS STARTPROBE
INT NProbe
E6POS TestArray[10]
NProbe = 0
INTERRUPT DECL 10 WHEN $IN[1]==TRUE DO STOREOFFSET()
LIN{Y 0}
STARTPOINT = $POS_ACT
SEARCH($POS_ACT, ENDPROBE, NProbe)
TestArray[NProbe] = ENDPROBE
LIN STARTPOINT
LIN {Y 50}
STARTPOINT = $POS_ACT
SEARCH($POS_ACT, ENDPROBE, NProbe)
TestArray[NProbe] = ENDPROBE
LIN STARTPOINT
LIN{TESTARRAY[1]}
LIN{TESTARRAY[2]}
END
;----------------------------------------------------------------
DEF SEARCH(STARTPROBE:IN, ENDPROBE:OUT, NProbe:OUT)
E6POS STARTPROBE
E6POS ENDPROBE
INT NProbe
NProbe = NProbe+1
;Enable the Interrupt
INTERRUPT ON 10
;Calculate Max Probe loc, ":" is geometric operator
ENDPROBE = STARTPROBE : {X 0, Y 0, Z -100, A 0, B 0, C 0}
;Move to max probe location
LIN ENDPROBE
WAIT SEC 0
;Return to start
INTERRUPT OFF 10
END
;------------------------------------------------------
DEF STOREOFFSET(ENDPROBE:OUT)
E6POS ENDPROBE
;Disable the the interrupt so it doesn't get stuck in loop
INTERRUPT OFF 10
ENDPROBE = $Pos_INT
;Stop the robot
BRAKE
;Resume the main program after being interrupted
RESUME
END
Display More
Display Moreimpossible... your program is not working and you cannot use saved value. you just got part "1" resolved, though you don't understand how and why.
you are jumping the gun. using RESUME also involves some safety concerns and you are pushing forward without mastering basics.
so be warned and ... just be careful... and go back and re-evaluate all feedback you got... you skipped some important info.
Here is small part of it:
declaration syntax may look the same BUT .... it is not. and not all declarations are equal. depending on WHERE and HOW variable is declared and initialized will affect many things. for example how and when it can be accessed, how and when it can be monitored, if and how long value is retained etc.
each place of declaration has very specific limitations.
if variable is not declared in a DAT file, it is a RUNTIME variable and it is just not suitable for what you are trying to do.
runtime means that random block of memory is reserved for the variable when the program is started, and it is lost immediately when program ends. if this declaration is in some subprogram, there is a good chance that every time subprogram is called, assigned memory is a different RAM location. further more, such variables are ONLY usable within ONE routine where they are defined - that's it. which makes it great for temporary variables so you are not constantly tying up memory. you take it, use it and give it back. very economical.... but at a cost of life and scope and ability to monitor when debugging - to monitor it program must be selected, started and PAUSED.
so.... you may pause program when in ISR and see that value is copied from $POS_INT to your variable but this is completely and utterly useless - as soon as the ISR is done, that memory location is lost and you no longer have saved value. and no other routine could access it anyway because it is a runtime variable.
variable declared in a DAT file is STATIC. it means as soon as DAT file is linked (used) first time, memory location is reserved to the variable. you may still not monitor it all the time (access is blocked if program is deselected) but same memory is used and it STILL retains value... even if you cancel program and select it again.... and see the previous value. memory is reserved until power down.
guess what happens if you have many programs with DAT files if you keep selecting one after another (does not matter if they run, as long as they got selected or - linked). yup, each time you select one program module, all variables in corresponding DAT file get PERMANENT hold of memory - even if you never run the program. and if you keep selecting more and more programs, more and more memory gets allocated - PERMANENTLY (well, until reboot). so you get less and less free RAM every time you select program that was not selected before. this is one of the reasons why programs exported from CAD/CAM are only SRC files.
to make STATIC variable RETENTIVE, it need to be both declared and initialized in a DAT file. then as soon as variable is changed SOMEHOW, it's declaration is also updated and DAT file is saved. this means that variable will have value to be initialized with after reboot.
to make STATIC variable GLOBAL, it need to be declared either in $CONFIG.DAT.
alternatively it can also be declared in some DAT file if that file is PUBLIC and particular declaration contains keyword GLOBAL.
also note that local STATIC variables (declared in local DAT file), can be accessed by all local routines (SRC file with same name as the DAT file).
Hi Panic mode,
Thanks for all your help. I really appreciate you took time and you want me to learn the basics first.
Actually I read the KUKA document and there I didn't get much understanding on Advance run thing.
So I tried without that.
Regarding the Array saving thing, I want the array data in this program only and I don't want to use it later. I saw this one code in documentation and tried it but its not working, I know it should not work as I have not defined the array. But how it's working on the document. Can you help me with this.
Hi SkyeFire I got my interrupt working by adding WAIT SEC 0 . Thanks!!
That was very helpful.
Is there any way by which I can define an array in the program and not in the dat file and populate the values in the array and can use in the program if needed.
Hi, I am programming for the Kuka and trying to store the external probe values in an array.
I am facing 2 problems.
1. The program which i have mentioned below is getting stuck at Resume and its not coming back to main programming. If I am not giving interrupt then its working fine but once I gave some external interrupt then it get stuck at Resume.
2. The points in the interrupt that is the $POS_INT values need to store in an array which is accessible outside the interrupt program.
INTERRUPT DECL 10 WHEN $IN[1]==TRUE DO STOREOFFSET()
LIN{Y 0}
STARTPOINT = $POS_ACT
SEARCH($POS_ACT)
LIN STARTPOINT
LIN {Y 50}
STARTPOINT = $POS_ACT
SEARCH($POS_ACT)
LIN STARTPOINT
;----------------------------------------------------------------
DEF SEARCH(STARTPROBE:IN)
E6POS STARTPROBE
;Enable the Interrupt
INTERRUPT ON 10
;Calculate Max Probe loc, ":" is geometric operator
ENDPROBE = STARTPROBE : {X 0, Y 0, Z -100, A 0, B 0, C 0}
;Move to max probe location
LIN ENDPROBE
;Return to start
INTERRUPT OFF 10
END
;------------------------------------------------------
DEF STOREOFFSET()
E6POS PROBEPTS
;Disable the the interrupt so it doesn't get stuck in loop
INTERRUPT OFF 10
PROBEPTS = $Pos_INT
;Stop the robot
BRAKE
;Resume the main program after being interrupted
RESUME
END
Display More
Hi,
I am new to KRL. I want to save the $POS_ACT values which gives the current position of the robot in an array.
I tried this but its not working.
NProbe = 0
LOOP
LIN{Y 0}
SEARCH($POS_ACT, TestArray[], NProbe)
LIN{Y 50}
SEARCH($POS_ACT, TestArray[], NProbe)
LIN{Y -50}
SEARCH($POS_ACT, TestArray[], NProbe)
ENDLOOP
DEF SEARCH(STARTPROBE:IN, TestArray:OUT, NProbe:OUT)
E6POS STARTPROBE
E6POS ENDPROBE
E6POS TestArray[]
INT NProbe
NProbe = NProbe + 1
;Enable the Interrupt
INTERRUPT ON 10
; ":" is geometric operator
ENDPROBE = STARTPROBE : {X 0, Y 0, Z -100, A 0, B 0, C 0}
;Move to max probe location
LIN ENDPROBE
TestArray[NProbe] = ENDPROBE
END
Display More