Difference between revisions of "CPRog Examples"

From Wiki
(Replaced link to command reference with SW documentation, fixed some wording)
(28 intermediate revisions by 2 users not shown)
Line 1: Line 1:
This page shows some example programs for the CPRog software. Please get in contact if you application is not covered...
+
This page shows an example program for the CPRog software v980-10-XXX
  
----
+
==Demo - First Program==
[[File:CPRogMatrix.JPG|500px|thumb|left|The matrix motion in CPRog]]
+
{{#evt:
 +
service=youtube
 +
|id=https://youtu.be/9LWbj4UqOnw
 +
|alignment=left
 +
}}
 +
 
 +
In this video we demonstrate the programming and control of a robolink DCi robot. The DCi is a compact robot with integrated electronics and a linux single board computer, so that once the program is written in CPRog on an external PC, the DCi can operate and run a program without any connection to an external PC: [https://youtu.be/9LWbj4UqOnw Robolink DCi Programming in CPRog]. Programming of other robolink robots is identical but requires the external PC to remain connected during execution of the program.
 +
 
 +
<br clear=all>
 +
 
 +
== Structured programming using Sub-Programs and Matrix Motion ==
 +
The article [[Structured_Programming]] gives a short introduction on how to use sub-programs and the matrix command. A pick-and-place example can be downloaded there as well.
  
 
== Matrix Motion ==
 
== Matrix Motion ==
  
In order to grip work pieces form a rectangular tray it one has to control the robot so that it moves a new position and then operates the gripper. The motions have to be carried out multiple times for multiple items on the matrix. To simplify setting up such a motion, CPRog can handle ''loops and subprograms''. In this case once would program two loops: one that increment the x and y of the target position and a second loop that controls the gripping motion. Here some example code that accomplishes this task:
 
  
===Program Files:===
+
[[File:CPRogMatrix.JPG|500px|thumb|left|The matrix motion in CPRog]]
Download the following xml files (right click, save as):
+
''''' This example shows the manual approach of handling matrices using loop commands, please refer to the previous section for the integrated matrix command! '''''
* The main program [http://www.cpr-robots.com/download/CPRogExamples/Matrix/testMatrix.xml testMatrix.xml]
+
 
<syntaxhighlight lang=xml>
+
In order to grip work pieces form a rectangular tray one has to control the robot so that it moves a new position and then operates the gripper. The motions have to be carried out multiple times for multiple items on the matrix. To simplify setting up such a motion, CPRog can handle ''loops and subprograms''. In this case once would program two loops: one that increment the x and y of the target position and a second loop that controls the gripping motion. Here some example code that accomplishes this task:
<?xml version="1.0" encoding="utf-8"?>
+
<br clear="all"/>
<!-- values in mm and degree -->
+
===Program Files===
<Program>
+
#Download the following xml files (right click, save as) and save both of them in the directory <code>C:\CPRog\Data\Programs</code>.
  <Header ProgramName ="CPRog recording" Author="nn" SetUpDate="" LastChangeDate="" Kinematic="CPRFour"/>
+
#* The main program [http://www.cpr-robots.com/download/CPRogExamples/Matrix/testMatrix.xml testMatrix.xml]
  <Joint Nr="0" a1="0" a2="10.86" a3="6.14" a4="72.69" a5="0" a6="0" e1="0" e2="0" e3="0" velPercent="50" acc="40" smooth="50" AbortCondition="false" Descr="Start position" />
+
#* The gripping sub program [http://www.cpr-robots.com/download/CPRogExamples/Matrix/sub_matrixGrip.xml sub_matrixGrip.xml]
  <Output Nr="1" Channel="DOut21" State="False" Descr="Open gripper at first" />
+
#Load the <code>test.matrix.xml</code> program in CPRog by clicking on the folder symbol in the menu ribbon at the top right.
  <Store Nr="2" Type="number" Name="xvalue" Value="240" Descr="matrix x Posiiton" />
 
  <Store Nr="3" Type="number" Name="yvalue" Value="-60" Descr="matrix y Position" />
 
  <Store Nr="4" Type="position" Name="target" Value="current" Descr="Final matrix position" />
 
  <Loop Nr="5" Mode="Count" Times="3" Descr="x loops" />
 
      <MathOperator Nr="6" Function="Set" FirstOperand="yvalue" SecondOperand="0" Descr="" />
 
      <MathOperator Nr="7" Function="Add" FirstOperand="xvalue" SecondOperand="20" Descr="add 20 mm for every y loop" />
 
      <Loop Nr="8" Mode="Count" Times="3" Descr="y loops" />
 
        <MathOperator Nr="9" Function="Add" FirstOperand="yvalue" SecondOperand="40" Descr="add 40 mm for every x loop" />
 
        <MathOperator Nr="10" Function="Set" FirstOperand="target.x" SecondOperand="xvalue" Descr="set the values to the target variable" />
 
        <MathOperator Nr="11" Function="Set" FirstOperand="target.y" SecondOperand="yvalue" Descr="" />
 
        <Linear Nr="12" Source="Variable" VariableName="target" vel="100" acc="40" smooth="50" AbortCondition="false" Descr="go to the target" />
 
        <Sub Nr="13" File="sub_matrixGrip.xml" Descr="sub program for gripping" />
 
        <Joint Nr="14" a1="-9.28" a2="13.67" a3="-4.92" a4="80.74" a5="21.8" a6="0" e1="0" e2="0" e3="0" velPercent="50" acc="40" smooth="50" AbortCondition="false" Descr="drop position" />
 
        <Output Nr="15" Channel="DOut21" State="False" Descr="drop the part" />
 
      <EndLoop />
 
  <EndLoop />
 
  <Joint Nr="16" a1="0" a2="10.86" a3="6.14" a4="72.69" a5="0" a6="0" e1="0" e2="0" e3="0" velPercent="50" acc="40" smooth="50" AbortCondition="false" Descr="back to start position" />
 
</Program>
 
</syntaxhighlight>
 
* The gripping sub program [http://www.cpr-robots.com/download/CPRogExamples/Matrix/sub_matrixGrip.xml sub_matrixGrip.xml]
 
<syntaxhighlight lang=xml>
 
<?xml version="1.0" encoding="utf-8"?>
 
<!-- values in mm and degree -->
 
<Program>
 
  <Header ProgramName ="CPRog recording" Author="nn" SetUpDate="" LastChangeDate="" Kinematic="CPRFour"/>
 
  <Relative Nr="0" MoType="CartBase" x="0.0" y="0.0" z="-50.0" a="0.0" b="0.0" c="0.0" vel="100" acc="40.0" smooth="50" AbortCondition="false" Descr="" />
 
  <Wait Nr="1"  Type="Time" Seconds="0.3" Descr="" />
 
  <Output Nr="2" Channel="DOut21" State="true" Descr="" />
 
  <Relative Nr="3" MoType="CartBase" x="0.0" y="0.0" z="50.0" a="0.0" b="0.0" c="0.0" vel="100" acc="40.0" smooth="50" AbortCondition="false" Descr="" />
 
</Program>
 
</syntaxhighlight>
 
Please save both files in the <code>C:\CPRog\Data\Programs</code> folder.
 
  
 
[[file:Caution.png|frameless|50px]]''Always first test any program in a simulation, i.e. with the robot disconnected in software. The starting positions of the example code may have to be adapted to your specific set up!''
 
[[file:Caution.png|frameless|50px]]''Always first test any program in a simulation, i.e. with the robot disconnected in software. The starting positions of the example code may have to be adapted to your specific set up!''
  
Please refer to the command reference for further information on the commands and variables: [http://www.cpr-robots.com/download/CPRog/CPR_CommandReference.pdf Command Reference]
+
Please refer to the [[Software Updates|CPRog/iRC documentation]] for further information on the commands and variables.
  
===Troubleshooting:===
+
===Troubleshooting===
 
* If the robot does not perform the complete pattern, please check if the motion might exceed the '''motion limits'''. This is shown in the log messages tab on the bottom of CPRog.
 
* If the robot does not perform the complete pattern, please check if the motion might exceed the '''motion limits'''. This is shown in the log messages tab on the bottom of CPRog.
 
* Take a look at the variables in the "variables" tab on the bottom of CPRog. This often helps to find problems.
 
* Take a look at the variables in the "variables" tab on the bottom of CPRog. This often helps to find problems.
 
* Precision: If the real robot approaches the positions with offsets it might be necessary to perform a fine calibration. Please have a look at the according page [[Define the zero position offsets]] or get in contact!
 
* Precision: If the real robot approaches the positions with offsets it might be necessary to perform a fine calibration. Please have a look at the according page [[Define the zero position offsets]] or get in contact!
  
 
+
== Support ==
 
 
 
For questions please [[Support Routes|get in contact]]
 
For questions please [[Support Routes|get in contact]]
  
 
----
 
----
[[Category:CPRog]][[Category:Downloads]][[Category:Support]]
+
[[Category:CPRog]][[Category:Downloads]][[Category:Support]][[Category:CPRog v980-10-XXX]]

Revision as of 11:35, 30 April 2021

This page shows an example program for the CPRog software v980-10-XXX

Demo - First Program

In this video we demonstrate the programming and control of a robolink DCi robot. The DCi is a compact robot with integrated electronics and a linux single board computer, so that once the program is written in CPRog on an external PC, the DCi can operate and run a program without any connection to an external PC: Robolink DCi Programming in CPRog. Programming of other robolink robots is identical but requires the external PC to remain connected during execution of the program.


Structured programming using Sub-Programs and Matrix Motion

The article Structured_Programming gives a short introduction on how to use sub-programs and the matrix command. A pick-and-place example can be downloaded there as well.

Matrix Motion

The matrix motion in CPRog

This example shows the manual approach of handling matrices using loop commands, please refer to the previous section for the integrated matrix command!

In order to grip work pieces form a rectangular tray one has to control the robot so that it moves a new position and then operates the gripper. The motions have to be carried out multiple times for multiple items on the matrix. To simplify setting up such a motion, CPRog can handle loops and subprograms. In this case once would program two loops: one that increment the x and y of the target position and a second loop that controls the gripping motion. Here some example code that accomplishes this task:

Program Files

  1. Download the following xml files (right click, save as) and save both of them in the directory C:\CPRog\Data\Programs.
  2. Load the test.matrix.xml program in CPRog by clicking on the folder symbol in the menu ribbon at the top right.

Caution.pngAlways first test any program in a simulation, i.e. with the robot disconnected in software. The starting positions of the example code may have to be adapted to your specific set up!

Please refer to the CPRog/iRC documentation for further information on the commands and variables.

Troubleshooting

  • If the robot does not perform the complete pattern, please check if the motion might exceed the motion limits. This is shown in the log messages tab on the bottom of CPRog.
  • Take a look at the variables in the "variables" tab on the bottom of CPRog. This often helps to find problems.
  • Precision: If the real robot approaches the positions with offsets it might be necessary to perform a fine calibration. Please have a look at the according page Define the zero position offsets or get in contact!

Support

For questions please get in contact