Programs: Difference between revisions

1,255 bytes added ,  4 years ago
no edit summary
No edit summary
 
(2 intermediate revisions by the same user not shown)
Line 1:
[[File:Milling.gif|thumb|The example used on this page is for a milling program, where a technician sets a cutting depth, then starts the process with a START button.]]
Teach pendant programs are generally simplistic, following much of the same structure as other programming languages.
 
It's a good idea to break your program into sections as listed below, to help organize your code.
 
This is an example program that you may see in the field. A technician can set a cutting depth on a knob, and then press a START button to begin cutting the product.
 
 
 
Line 30 ⟶ 34:
'''LBL[1]'''
 
Everything inside the loop will occur over and over. In this example, we only want it to repeat when we press a "Start" button. We can also open up the digital input 104 in the IO screen and comment it with the word START.
 
'''WAIT DI[104:START] = ON'''
 
== 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. NoteWe thatmultiply thisby partnegative isn't1 reachedso untilthat someoneit pressessubtracts that "Start" button above, so the technician will set the analog value withz aheight knobfrom andour THENmotion pressinstructions startlater.
 
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] = AI[1]'''
 
'''PR[10, 3] = AI[1] * -1'''
 
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 />
Line 44 ⟶ 50:
 
Your motion lines should be efficient and minimalist. Anything that can be done with a new tool frame, user frame, offset, and registers should be, instead of having lots of similar motion lines.
 
In this example, each of the lines uses the offset of PR[10] so whatever negative value was on the knob when START was pushed, will be applied to the motion instructions.
 
'''J P[1] 100% Fine'''
Line 49 ⟶ 57:
'''L P[2] 222mm/s Fine OFFSET PR[10]'''
 
'''L P[5] R[11] 100mm/s Fine OFFSET PR[10]'''
 
'''L P[3] 222mm/s Fine OFFSET PR[10]'''
Line 55 ⟶ 63:
'''C P[8] OFFSET PR[10]'''
 
'''... P[6] R[11] 222mm/s Fine OFFSET PR[10]'''
 
'''L P[1] 100mm/s FINE OFFSET PR[10]'''
 
Since we don't want this program to end, instead just waiting to begin again when the button is pushed again, we will add a jump instruction up to LBL[1].
 
'''JMP LBL [1]'''
== Notes ==
 
The program listed above could have been done much more simply with a group input and a SELECT instruction. It was left as IF statements for simplicity in understanding.
<br />
== NotesResults ==
The program sets everything up (zeroing the position register), goes home, and then waits for input. The technician configures the knob to whatever depth they wanted to perform the tasks at, and then presses START. The program will set the value of the knob (as a negative number) to the position register, and then the robot performs its motion tasks, at the newly offset height. Once it has finished, it will jump back up and wait for the technician to set a new height and press START again.