Home› Programming
Discussion
Back to discussions page
Jstewart
Posts: 62 Apprentice
Way to keep value of variable after program is stopped |
105 views
|
Answered | |
/ Most recent by Jstewart
in Programming
|
8 comments |

in Programming
Im doing some testing with a UR5, and i am having a pop-up show at the start of the program asking the operator to input a number anywhere from 1 - 6. when the operator selects 1 or 2, that will instruct the robot to move to pick up either a green (1) or red (2) marker then im using switch cases to step through the rest of the program. After it picks up the marker, i have a variable called "TOOL_SELECT" and which ever marker is selected is the value. However whenever i stop and then restart the program, the value goes back to 0 then when i call the switch case to return whichever marker, it moves back to the home position instead of returning the marker. ( i have it returning home if the TOOL_SELECT variable had a 0) is there a way to keep the current marker selected? or is it always going to return to 0 after a stop?
Best Answer
-
matthewd92 Founding Pro, Tactile Sensor Beta Testers Posts: 1,267 Handy
There are two ways to accomplish this.
If all you want to do is keep the variable state run to run, but not when power is lost, then add an Init Variables to the program and then you can choose the variable you want and tell it to keep its value from the last run.
The permanent way to do this is to add an installation variable. This variable will be available to any program that uses that installation file and would be persisted even after a power loss event such as powering down the robot. Only recommend these when its a variable that you do not ever want to lose its state regardless of power and it doesn't hurt to be available in other programs.
Comments
-
mkardasinski Posts: 41 Handy
Power loss and powering down have me a bit confused. Is an installation variable saved immediately after being updated? So in the event of a power outage & power to the robot is abruptly cut while running, the variable contents are current after power-up?0 · TwitterFacebook -
Jstewart Posts: 62 Apprentice
@matthewd92 thats exactly what i was looking for. thanks.0 · TwitterFacebook -
matthewd92 Founding Pro, Tactile Sensor Beta Testers Posts: 1,267 Handy
I’m not sure if the value changed right before power was abruptly lost it would be current but yes, the values are persisted to disk to prevent loss whenever the robot is powered off. Not sure how often the writes to disk occur but we’ve lost power before and still had our variables.0 · TwitterFacebook -
Jstewart Posts: 62 Apprentice
@matthewd92 why are my variables not showing in the drop down of the initial variable values page?0 · TwitterFacebook -
matthewd92 Founding Pro, Tactile Sensor Beta Testers Posts: 1,267 Handy
How are they defined? If they are defined in script they will not show there, if they are installation variables they will not show there.0 · TwitterFacebook -
Jstewart Posts: 62 Apprentice
I tried defining in the installation and in the before program section. Where are you supposed to define them at?0 · TwitterFacebook -
Jstewart Posts: 62 Apprentice
@matthewd92 Forget my last post, i ended up figuring it out. Thanks for the help!0 · TwitterFacebook