Hello all,I am trying to program a timer on a UR10. Since our cycle uses two robots, I would like to program the timer only in the second robot (close to the end of the cycle) to the same point one cycle later, as the program will be running in a continuous loop.I have already set a cycle counter by using the following code:In the BeforeStart, I have the following:count=0addcount:=FalseIn the robot program I've got:addcount:=False...addcount:=TrueWait=0.01addcount:=False..And then I created a thread with the following code:If addcount:=True count:=count+1Wait=0.01For now it seems to be working correctly. Is there any way I could use something similar for a timer? Maybe instead of time:=time+1 it would be something like 0.01 or 0.008?Thanks!
I was thinking something like this but I am not sure (I am unable to test it right now).BeforeStarttimer:=0stoptimer==trueRobotProgram..timer:=0Wait=0.01stoptimer==false..Thread2While stoptimer==false timer:=timer+.008sync()
Do you need the two robots communicating with each other to know when to run the timer or are you simply wanting to only have a cycle timer on the second robot?The approach that you have works, we run lots of cycle timers in the backgrounds on all of our robots, we do it slightly different as far as triggers but the premise is the same.The only issue that I see in your psuedo-code is that you need a sync() inside the while loop or you will throw errors, you also need a sync() where you have it to handle the case where stoptimer is true
Hello Matthew,Exactly. The idea is to only have a cycle timer on the second robot (current, previous, and average). It works perfectly now.Thank you for your help!
Hi there,I was needing some help with programming my timer. I have a sensor that tells the robot when to go to get the object and when the sensor is LOW then the robot waits. I want the timer to only record when the robot is moving basically timer running as long as the sensor is high. For the most part it is always high, but in case our coworkers take a break or fall behind I want to receive real time to base off of how productive the robot is and not based on the entire day.I was thinking about using an IF statementIf Sensor=lo Stop timerElse Sensor HI Start timerI obviously start the timer when I start the program. I just don't want the "start timer" in the else to restart the timer.
Why not just have a thread in the background like this:global time = 0 thread collectUseTime(): if (get_standard_digital_in(port)): #Where port is the DI port your sensor is connected to, if not DI then you can use the command for CI get_configurable_digital_in(port) time = time + get_steptime() (function returns the time of the controller 0.008 for CB3 and 0.002 for E-Series) end sync() (consumes either 0.002 or 0.008 seconds depending on robot model) end Write that as script code and place in your before start section, then add a line to the before start section that saysrun collectUsetime()Then as soon as the input goes high you would collect time when the input goes low time collection would stop.You could also add that same code to a thread in Polyscope, obviously you would just use the Input name in the if condition.
Ok so what I have isglobal time=0thread collectUseTime(): if(get_standard_digital_in(7)) time = time + get_steptime() end sync()endIt is having an error code that pops up referring to line 4should it say global time? Also please forgive me and all the simple questions I am still a newby.I couldn't fully understand the part in parenthesis about the function part. And I am working with an E-series
Need a colon at the end of the if statementglobal time=0 thread collectUseTime(): if(get_standard_digital_in(7)): <- That colon is very important, at the end of def, thread, if, while, elif, else, etc. time = time + get_steptime() end sync() end
Hello all,
I am trying to program a timer on a UR10. Since our cycle uses two robots, I would like to program the timer only in the second robot (close to the end of the cycle) to the same point one cycle later, as the program will be running in a continuous loop.
I have already set a cycle counter by using the following code:
In the BeforeStart, I have the following:
count=0
addcount:=False
In the robot program I've got:
addcount:=False
.
.
.
addcount:=True
Wait=0.01
addcount:=False
.
.
And then I created a thread with the following code:
If addcount:=True
count:=count+1
Wait=0.01
For now it seems to be working correctly. Is there any way I could use something similar for a timer? Maybe instead of time:=time+1 it would be something like 0.01 or 0.008?
Thanks!