Difference between revisions of "CPRog Examples"

From Wiki
 
(53 intermediate revisions by 3 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|400px|thumb|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 ==
  
E.g. to grip work pieces form an rectangular tray it is not necessary to program all singele positions. CPRog can handle two loops that increment the x and y parts of the target position. The gripping motion is inside a sub program.
 
  
'''Program Files:'''
+
[[File:CPRogMatrix.JPG|500px|thumb|left|The matrix motion in CPRog]]
* The main program [http://www.cpr-robots.com/download/CPRogExamples/Matrix/testMatrix.xml testMatrix.xml]
+
''''' This example shows the manual approach of handling matrices using loop commands, please refer to the previous section for the integrated matrix command! '''''
* The gripping sub program [http://www.cpr-robots.com/download/CPRogExamples/Matrix/sub_matrixGrip.xml sub_matrixGrip.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:
 +
<br clear="all"/>
 +
===Program Files===
 +
#Download the following xml files (right click, save as) and save both of them in the directory <code>C:\CPRog\Data\Programs</code>.
 +
#* The main program [http://www.cpr-robots.com/download/CPRogExamples/Matrix/testMatrix.xml testMatrix.xml]
 +
#* The gripping sub program [http://www.cpr-robots.com/download/CPRogExamples/Matrix/sub_matrixGrip.xml sub_matrixGrip.xml]
 +
#Load the <code>test.matrix.xml</code> program in CPRog by clicking on the folder symbol in the menu ribbon at the top right.
 +
 
 +
[[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 [[Software Updates|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!
 +
 
 +
 
 +
== Glue Application ==
 +
 
 +
''''' This example shows how to use logic programs to set a DO during a motion. This is helpful e.g. for a gluing application. '''''
 +
 
 +
Further examples and advice can be found in article [[Dispensing Applications]].
 +
 
 +
''''' Example 1 '''''
 +
 
 +
In the following picture you can see finished mainprogram. The xml programm files can be downloaded here: https://wiki.cpr-robots.com/images/f/f3/GlueingExamples.zip . The goal of this example is that the robot makes 3 parallel lines of glue.  First, we program the motion of the robot. 
 +
 
 +
[[File:GlueExampleLine_1.PNG|800px|thumb|center|GlueLine]]
 +
 
 +
 
 +
# (Instruction 1): drive to start position.
 +
# (Instruction 2): drive to X and Z value of start position for the gluing. The y value should be smaller than the value you want to start with your glue.
 +
# (Instruction 4): move robot in y value, choose a higher value than your glue should be
 +
# (Instruction 6 + 7): move to start point for the next line of glue, y value must be smaller than the value you want to start your glue.
 +
# (Instruction 9): move robot for second glue line.
 +
# (Instruction 11+12): move to start point for the third line of glue like in step 4
 +
# (Instruction 14): move robot for third line of glue.
 +
# (Instruction 13): move robot to start position.
 +
After defining the motion of the robot, we need to define the logic of DOut of glue. If you don't know how to use logic programms see the wiki article https://wiki.cpr-robots.com/index.php/Logic_Program.
 +
In the following picture you can see the logic program of this application. You can download the xml file here.
 +
 
 +
The DOUT for glue in this example is DOut27. The glue should be added, if the y-position of the robot is between 50 and 125. If the robot is out of this range, DOut27 should be disabled. 
 +
[[File:GlueExampleLine.PNG|800px|thumb|center|GlueLineLogik]]
 +
# (Instruction 1 to 11):  create a loop whit false as condition, so this program will never end. You need this loop, because programs have a minimum execution time of 500ms. Shorter programs, for example fast running logic programs, may be delayed during the automatic restart.
 +
# (Instruction 3 to 8): you need a if-else condition to check whether the y-position of the robot is in range for gluing.
 +
# (Instruction 5 +7): set and reset DOut 27
 +
If you will start the program now, the DOut 27 will be activated every time the y-value is in the defined range. This also means for example if you move the robot manually. To stop that you need a global signal which defines weather the robot is allowed to start glue. This global signal (GSig1 in our case) is set before every motion of glue. This is done in instruction 3,8 and 13. After motion with glue activated the glue DOut must be deactivated. This is done in instruction 5,10 and 15. This GSig1 has now be added in the logic program. Only if GSig1 is activated the DOut 27 can be set (Instruction 3).
 +
 
 +
 
 +
Here is a video of the complete motion.
 +
[[File:GlueLineVideo.MP4|800px|15.45MB|thumb|center|GlueLine]]
 +
 
 +
'''''Example 2 '''''
 +
 
 +
Another opportunity to define the area of glue is to define a start area where the DOut is activated and an end area where the DOut is deactivated. This allows you to do any motions between the start and end area without changing the DOut. In the following picture you can see the main program of such an application.  The xml programm files can be downloaded here: https://wiki.cpr-robots.com/images/f/f3/GlueingExamples.zip
 +
 
 +
[[File:GlueExampleArea.png|800px|thumb|center|GlueLineLogik]]
  
Please save both files in the c:\CPRog\Data\Programs folder.
 
  
Please test this program in simulations, not with the real robot. E.g. starting positions etc have to be adapted to your specific set up!
+
Like in the example above, in the main program the motion of the robot is defined. The variable GSig1 needs to be set to control if the robot is in the program part, where the Dout should be set.
 +
The logic program is shown in the picture below.
  
Please refer to the commands specification for further information on the variable commands: [http://www.cpr-robots.com/download/CPRog/CPR_CommandReference.pdf Command Reference]
+
[[File:GlueExampleAreaLogik.png|800px|thumb|center|GlueLineLogik]]
  
'''Troubleshooting:'''
+
The difference between the if condition in this logic program and the logic program above is that in this case the x and y value is checked. If the robot is in the start area the DOut is set. If the robot is in the end area the DOut will be disabled. If the robot is eighter in the start area nor in the end area, the DOut will not be changed, if GSig1 is activated. If the GSig1 is deactivated the DOut will be deactivated as well.
* 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
+
You can see a video of this application below.
* Take a look at the variables in the variables tab on the bottom of CPRog. This helps to find problem
 
* Precision: If the real robot approaches the positions with offsets it might be necessary to perfom a fine calibration. Please have a look at the according page [[Define the zero position offsets]] or get in contact!
 
  
 +
[[File:GlueExample2Area.MP4|800px|15.45MB|thumb|center|GlueLine]]
  
 +
== Definition of a DXF file in SolidWorks ==
 +
The 'Path' command allows to load and replay dxf files, e.g. for glueing applications. DXF files can be genereted with lots of programs, an example workflow for SolidWorks is described here: [[Definition of a DXF file in SolidWorks]]
  
For questions please get in contact: support(at)cpr-robots.com
+
== Support ==
 +
For questions please [[Support Routes|get in contact]]
  
 
----
 
----
[[Category:CPRog]][[Category:Downloads]]
+
[[Category:CPRog]][[Category:Downloads]][[Category:Robot Programming]][[Category:Support]][[Category:CPRog v980-10-XXX]]

Latest revision as of 12:32, 28 August 2024

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!


Glue Application

This example shows how to use logic programs to set a DO during a motion. This is helpful e.g. for a gluing application.

Further examples and advice can be found in article Dispensing Applications.

Example 1

In the following picture you can see finished mainprogram. The xml programm files can be downloaded here: https://wiki.cpr-robots.com/images/f/f3/GlueingExamples.zip . The goal of this example is that the robot makes 3 parallel lines of glue. First, we program the motion of the robot.

GlueLine


  1. (Instruction 1): drive to start position.
  2. (Instruction 2): drive to X and Z value of start position for the gluing. The y value should be smaller than the value you want to start with your glue.
  3. (Instruction 4): move robot in y value, choose a higher value than your glue should be
  4. (Instruction 6 + 7): move to start point for the next line of glue, y value must be smaller than the value you want to start your glue.
  5. (Instruction 9): move robot for second glue line.
  6. (Instruction 11+12): move to start point for the third line of glue like in step 4
  7. (Instruction 14): move robot for third line of glue.
  8. (Instruction 13): move robot to start position.

After defining the motion of the robot, we need to define the logic of DOut of glue. If you don't know how to use logic programms see the wiki article https://wiki.cpr-robots.com/index.php/Logic_Program. In the following picture you can see the logic program of this application. You can download the xml file here.

The DOUT for glue in this example is DOut27. The glue should be added, if the y-position of the robot is between 50 and 125. If the robot is out of this range, DOut27 should be disabled.

GlueLineLogik
  1. (Instruction 1 to 11): create a loop whit false as condition, so this program will never end. You need this loop, because programs have a minimum execution time of 500ms. Shorter programs, for example fast running logic programs, may be delayed during the automatic restart.
  2. (Instruction 3 to 8): you need a if-else condition to check whether the y-position of the robot is in range for gluing.
  3. (Instruction 5 +7): set and reset DOut 27

If you will start the program now, the DOut 27 will be activated every time the y-value is in the defined range. This also means for example if you move the robot manually. To stop that you need a global signal which defines weather the robot is allowed to start glue. This global signal (GSig1 in our case) is set before every motion of glue. This is done in instruction 3,8 and 13. After motion with glue activated the glue DOut must be deactivated. This is done in instruction 5,10 and 15. This GSig1 has now be added in the logic program. Only if GSig1 is activated the DOut 27 can be set (Instruction 3).


Here is a video of the complete motion.

Example 2

Another opportunity to define the area of glue is to define a start area where the DOut is activated and an end area where the DOut is deactivated. This allows you to do any motions between the start and end area without changing the DOut. In the following picture you can see the main program of such an application. The xml programm files can be downloaded here: https://wiki.cpr-robots.com/images/f/f3/GlueingExamples.zip

GlueLineLogik


Like in the example above, in the main program the motion of the robot is defined. The variable GSig1 needs to be set to control if the robot is in the program part, where the Dout should be set. The logic program is shown in the picture below.

GlueLineLogik

The difference between the if condition in this logic program and the logic program above is that in this case the x and y value is checked. If the robot is in the start area the DOut is set. If the robot is in the end area the DOut will be disabled. If the robot is eighter in the start area nor in the end area, the DOut will not be changed, if GSig1 is activated. If the GSig1 is deactivated the DOut will be deactivated as well. You can see a video of this application below.

Definition of a DXF file in SolidWorks

The 'Path' command allows to load and replay dxf files, e.g. for glueing applications. DXF files can be genereted with lots of programs, an example workflow for SolidWorks is described here: Definition of a DXF file in SolidWorks

Support

For questions please get in contact