Programs: Difference between revisions

No edit summary
Line 6:
 
== Setup Section ==
The first lines of a program should be your setup instructions. This often means zeroing registers and setting constants to be used later. It's also a good idea to set all your outputs to ideal conditions. We canjust dohappen thisto quicklybe using aPR[10] singlein registerthis instructionprogram, but you may not know what you're going to use until you reach it. You can always insert lines at the beginning of your program to setup the registers later on when you know which registers you will use.
 
We can zero entire position registers easily using a single register instruction.
 
Examples:
 
'''PR[510]=PR[510]-PR[510]'''
 
<br />
 
== Intro Motion ==
It can be useful to include motion instructions that take your robot to a known position, in case of power failure or a prior program leaving off in a weird place. Use a Joint move to ensure you don't enter [https://www.universal-robots.com/how-tos-and-faqs/faq/ur-faq/what-is-a-singularity-42311/ singularity].
 
'''J P[1:Home] 20% FINE'''
 
<br />
[[File:Start button.jpg|thumb]]
 
==InputsLoop ==
 
Since when looping, you aren't likely to want it to go home every single time and don't want to zero your registers each time, we will begin our loop here. We will jump to this label later in the program, with JMP LBL[1]
While inputs can be read anywhere in your program, it can be helpful to organize them into a small section that can be run through at points where it really matters. In this example, we have 4 inputs waiting to go ON. These could represent 4 different conveyors coming to the robot.
 
'''IF DI[101] = ON JMP LBL[41]'''
 
Everything inside the loop will occur over and over. In this example, we only want it to repeat when we press a "Start" button.
'''IF DI[102] = ON JMP LBL[5]'''
 
'''IFWAIT DI[103104] = ON JMP LBL[6]'''
 
'''IF DI[104] = ON JMP LBL[7]'''
 
'''JMP LBL[8]'''
 
<br />
 
== Configuration ==
[[File:Knob.jpg|thumb]]
Depending on program state, input values, counts, times, and other variables - you can set up configuration data to match. This lets you run short, efficient motion instructions with few or no special sections. In this example, an analog input, AI[1] is read and applied to the Z element (element 3) of our position register. Note that this part isn't reached until someone presses that "Start" button above, so the technician will set the analog value with a knob and THEN press start.
 
'''PR[10, 3] = 5AI[1]'''
Depending on program state, input values, counts, times, and other variables - you can set up configuration data to match. This lets you run short, efficient motion instructions with few or no special sections.
 
Any changes to the knob after starting won't affect the motion until the next loop, so the technician could actually begin entering the next value on the knob immediately.<br />
'''LBL [4]
 
'''PR[10,3] = 5'''
 
'''R[12] = R [12] + 1'''
 
'''LBL [5]'''
 
'''PR[10,3] = 7'''
 
'''R[12] = R [12] + 2'''
 
'''LBL [6]'''
 
'''PR[10,3] = 25'''
 
'''R[12] = R [12] + 1'''
 
'''LBL [7]'''
 
'''PR[10,3] = 33'''
 
'''R[12] = R [12] + 2'''
 
<br />
== Motion ==