Programs: Difference between revisions

From Industrial Robotics & Automation - Fanuc Teach Pendant Programming
Content added Content deleted
No edit summary
 
(10 intermediate revisions by the same user not shown)
Line 1: 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.]]
Program structure for Fanuc robots is top down. That is, the instructions will run in order. Jumps will continue right after their destination LBL, CALLs will run from top to bottom and continue once they reach the called program's END with the line after the original CALL.
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.
==== 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.
Examples:


'''PR[5]=PR[2:Zero]'''


<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 singularity.


== Setup Section ==
'''J P[1:Home] 20% FINE'''
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 just happen to be using PR[10] in this program, 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.
<br />


Examples:
====Inputs ====


'''PR[10]=PR[10]-PR[10]'''
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.


<br />
IF DI[101] = ON JMP LBL[4]

IF DI[102] = ON JMP LBL[5]
== Intro Motion ==
IF DI[103] = ON JMP LBL[6]
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].
IF DI[104] = ON JMP LBL[7]

JMP LBL[8]
'''J P[1:Home] 20% FINE'''


<br />
<br />
[[File:Start button.jpg|thumb]]


==Loop ==
==== Configuration ====


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]
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.


'''LBL [4]
'''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.
'''PR[10,3] = 5'''


'''R[12] = R [12] + 1'''
'''WAIT DI[104:START] = ON'''


== Configuration ==
'''LBL [5]'''
[[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. We multiply by negative 1 so that it subtracts that z height from our motion instructions later.


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] = 7'''


'''R[12] = R [12] + 2'''
'''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 />
'''LBL [6]'''
== Motion ==


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.
'''PR[10,3] = 25'''


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.
'''R[12] = R [12] + 1'''


'''LBL [7]'''
'''J P[1] 100% Fine'''


'''PR[10,3] = 33'''
'''L P[2] 222mm/s Fine OFFSET PR[10]'''


'''R[12] = R [12] + 2'''
'''L P[5] 100mm/s Fine OFFSET PR[10]'''


'''L P[3] 222mm/s Fine OFFSET PR[10]'''
<br />
==== Motion ====


'''C P[8] OFFSET PR[10]'''
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.


'''J P[1] 100% Fine OFFSET PR[10]'''
'''... P[6] 222mm/s Fine OFFSET PR[10]'''


'''L P[2] 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].
'''L P[5] R[11] Fine OFFSET PR[10]'''


'''L P[3] 222mm/s Fine OFFSET PR[10]'''
'''JMP LBL [1]'''


<br />
'''C P[8] 222mm/s Fine OFFSET PR[10] ...P[6] R[11] Fine OFFSET PR[10]'''
== Results ==
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.

Latest revision as of 13:00, 27 July 2019

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.



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 just happen to be using PR[10] in this program, 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[10]=PR[10]-PR[10]


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 singularity.

J P[1:Home] 20% FINE


Loop

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]

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

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. We multiply by negative 1 so that it subtracts that z height from our motion instructions later.

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] * -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.

Motion

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

L P[2] 222mm/s Fine OFFSET PR[10]

L P[5] 100mm/s Fine OFFSET PR[10]

L P[3] 222mm/s Fine OFFSET PR[10]

C P[8] OFFSET PR[10]

... P[6] 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]


Results

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.