Difference between revisions of "Program Examples:Defining a Cartesian Group"

From SoftMC-Wiki
Jump to: navigation, search
(Created page with "The following example demonstrate how to setup a cartesian group. It will configure basic setup of an XYZ orthogonal system. The setup will be done in SETUp.PRG task. First o...")
 
 
(3 intermediate revisions by 2 users not shown)
Line 1: Line 1:
The following example demonstrate how to setup a cartesian group. It will configure basic setup of an XYZ orthogonal system. The setup will be done in SETUp.PRG task.
+
{{Languages|Program_Examples:Defining_a_Cartesian_Group}}
 
+
== Introduction ==
First of all a crtesian group must be defined in CONFIG.PRG file:
+
The following example demonstrates how to setup a cartesian group. It will configure basic setup of an XYZ orthogonal system. The setup will be done in SETUP.PRG task.
  
 +
== Configuration ==
 +
First of all, a cartesian group must be defined in CONFIG.PRG file:
 
<pre>
 
<pre>
 
common shared gXYZ  as group Axnm = a1 Axnm = a2 Axnm = a3 model=1  of xyz
 
common shared gXYZ  as group Axnm = a1 Axnm = a2 Axnm = a3 model=1  of xyz
 
</pre>
 
</pre>
  
Then in the SETUP.PRG task define subroutine for setting up a linear axis :
+
== Axis Definition==
{{Note| We assume there is a global integer array '''pos_units[]''' defined in the system. It holds position resolution of each axes, e.g. howm any counts there is in one full revolution of the motor.}}
+
Next, in the SETUP.PRG task, define subroutine for setting up a linear axis :
{{Note| In this example we assume there is no gear between the linear screw and the motor, and the pitch of the screw is 5mm per revolution }}
+
{{Note| It is assumed there is a global integer array '''pos_units[]''' defined in the system. It holds the position resolution of each axes; e.g., the number of counts in one full revolution of the motor.}}
 +
{{Note| In this example it is assumed there is no gear between the linear screw and the motor, and the pitch of the screw is 5 mm per revolution }}
  
 
<pre>
 
<pre>
Line 17: Line 20:
 
       en = 0
 
       en = 0
 
       sleep 10
 
       sleep 10
      simulated = 0
+
'      simulated = 0
 
        
 
        
 
       pfac = pos_units[elementid]/5 'For 5mm pitch  
 
       pfac = pos_units[elementid]/5 'For 5mm pitch  
Line 43: Line 46:
 
       abs = 1
 
       abs = 1
 
       positionrolloverenable = 0
 
       positionrolloverenable = 0
      simulated = 1
+
'      simulated = 1
 
       Print "axis ";elementname;" set."
 
       Print "axis ";elementname;" set."
 
     detach
 
     detach
 
   end with
 
   end with
 
end sub
 
end sub
 +
</pre>
  
</pre>
+
== Group Setup ==
 +
Now define a group setup routine for setting up the common group parameters.
 +
{{Note| It is assumed that the working range of the robot for every axis is between 0 mm and +300 mm}}
  
Now define a group setup routine setting up the common group parameters.
 
{{Note| here we assume that the working range of the robot for every axis between 0 and +300mm}}
 
 
<pre>
 
<pre>
 
sub SetGroup(gr as generic group)
 
sub SetGroup(gr as generic group)
Line 137: Line 141:
 
</pre>
 
</pre>
  
At the end we need the main program block of the SETUP.PRG:
+
== Complete Task ==
 
+
Lastly, the main program block of the SETUP.PRG:
 
<pre>
 
<pre>
 
dim shared profile as long = -1' 2 - Acceleration Trapeze Profile, -1-Sine Acceleration
 
dim shared profile as long = -1' 2 - Acceleration Trapeze Profile, -1-Sine Acceleration

Latest revision as of 05:55, 17 July 2017

Language: English  • 中文(简体)‎

Introduction

The following example demonstrates how to setup a cartesian group. It will configure basic setup of an XYZ orthogonal system. The setup will be done in SETUP.PRG task.

Configuration

First of all, a cartesian group must be defined in CONFIG.PRG file:

common shared gXYZ   as group Axnm = a1 Axnm = a2 Axnm = a3 model=1  of xyz

Axis Definition

Next, in the SETUP.PRG task, define subroutine for setting up a linear axis :

NOTE-Info.svgNOTE
It is assumed there is a global integer array pos_units[] defined in the system. It holds the position resolution of each axes; e.g., the number of counts in one full revolution of the motor.
NOTE-Info.svgNOTE
In this example it is assumed there is no gear between the linear screw and the motor, and the pitch of the screw is 5 mm per revolution
sub SetAxis(ax as generic axis, byval vvv as double)
  with ax
    attach
      en = 0
      sleep 10
'      simulated = 0
      
      pfac = pos_units[elementid]/5 'For 5mm pitch 
      
      vfac = pfac/1000 ' mm /sec
      afac = vfac/1000 ' mm /sec^2
      jfac = afac/1000 ' mm / sec^3
      vmax = vvv
      amax = 1500
      dmax = 1500
      jmax = omega*amax ' Fast reacting
      vcruise = vmax
      acc = amax
      dec = dmax
      jerk = jmax
      prftype = profile
      smooth = -1
      vospd               = 2*vmax 
      velocitysafetylimit = 100*vmax
      positionerrorsettle = 5
      pemax  = 1
      pmaxen = 1
      pminen = 1
      disp = 0
      abs = 1
      positionrolloverenable = 0
'      simulated = 1
      Print "axis ";elementname;" set."
    detach
  end with
end sub

Group Setup

Now define a group setup routine for setting up the common group parameters.

NOTE-Info.svgNOTE
It is assumed that the working range of the robot for every axis is between 0 mm and +300 mm
sub SetGroup(gr as generic group)
  dim i as long
  with gr
    attach
      en = 0
      sleep 10
      vfac = 1/1000
      afac = vfac/1000
      jfac = afac/1000
      positionerrorsettle = 2
      pemax  = 1
      abs = 1

      a1.axistype = 0
      a2.axistype = 0
      a3.axistype = 0

      configgroup

      vmax = 1000 '  mm/sec
      amax = 1500 '  1500 mm/sec^2
      dmax = 1500 '  1500 mm/sec^2
      jmax = omega*amax  
      vcruise = vmax
      acc = amax
      dec = dmax
      jerk = jmax

      vmtran = vmax
      amtran = amax
      jmtran = jmax
      vtran = vmtran
      atran = amtran
      dtran = amtran
      jtran = jmtran

      vmrot = vmax
      amrot = amax
      jmrot = jmax
      vrot = vmrot
      arot = amrot
      drot = amrot
      jrot = jmrot

      xmax = 300
      xmin = 0

      ymax = 300
      ymin = 0

      zmax =  300
      zmin =  0

      rmin = 0
      rmax = 4000

      smooth = -1
      prftype = profile

      j1.pmin = 0
      a1.pmin = 0
      
      j2.pmin = 0
      a2.pmin = 0
      
      j3.pmin = 0
      a3.pmin = 0
      
      j1.pmax = 300
      a1.pmax = 300
      
      j2.pmax = 300
      a2.pmax = 300
      
      j3.pmax = 300
      a3.pmax = 300
      
      Print "group ";elementname;" set."
      detach
  end with
end sub

Complete Task

Lastly, the main program block of the SETUP.PRG:

dim shared profile as long = -1' 2 - Acceleration Trapeze Profile, -1-Sine Acceleration
dim shared omega as double = 15
program
    call Setaxis(a1,1000) ' X max speed 1000mm/sec
    call Setaxis(a2,1000) ' Y max speed 1000mm/sec
    call Setaxis(a3,1000)   ' Z max speed 1000mm/sec
    call SetGroup(GXYZ)   
end program