Difference between revisions of "Program Examples:fast-PLS"

From SoftMC-Wiki
Jump to: navigation, search
(created)
 
 
(10 intermediate revisions by one other user not shown)
Line 1: Line 1:
 
{{Languages|Program_Examples:Path-PLS}}  
 
{{Languages|Program_Examples:Path-PLS}}  
here is an example of using path PLS with PUMA robot
+
== [[Program_Examples:1.1_Feature_introduction|1.1 Feature introduction]] ==
  
PLStest.PRG:
+
----
<syntaxhighlight lang="vb">
 
'------------------------------------------------------------------------------
 
' File:        PLStest.PRG
 
' Purpose:    generating puma motion with PLS: PLSlengh and PlsPercentage
 
' Version:    1.00
 
' Author:      Eran Korkidi
 
' History:    08.DEC.2015 - created
 
'------------------------------------------------------------------------------
 
  
dim shared loc1 as location of xyzypr = #{500.0 , -920.0 , -50.0 , 50.0 , 180 , 0}
+
This feature is used for laser applications or any other application that needs a drive's digital output to be toggled as fast as possible, depending on the motor position.<br/> In this example the FAST digital output 7/8 of the CDHD2 is triggered as fast as possible depending on the position feedback.<br/> Instead of using the drive's position-based PCOM feature, we will use the softMC's fast PLS feature together with the drive's time-based PCOM feature, to trigger the digital output. The fast PLS feature allows us to trigger the drive's output even between EtherCAT cycles.
dim shared loc2 as location of xyzypr = #{-500.0 , -920.0 , -50.0 , 50.0 , 180 , 0}
 
  
common shared P1 as pls PUMA Sys.Dout.101
+
== [[Program_Examples:1.2_Scenarios|1.2 Scenarios]] ==
common shared P2 as pls PUMA Sys.Dout.102
+
 
common shared P3 as pls PUMA Sys.Dout.103
+
----
 +
 
 +
I will explain the MC controller code that I wrote line by line<br/> The idea is to perform a homing process (home type 35) then to send motion to 400 degrees<br/> Meanwhile the motor is moving the user should see that the output 7 is toggled on 5 points: 150,175,200,220,360 degrees
 +
 
 +
== [[Program_Examples:1.2_Scenarios|1.2 HW connection]] ==
 +
 
 +
----
 +
 
 +
C2 connection&nbsp;:&nbsp;<br/> [[File:Hwconnectionfastpls2.png|600x400px|Hwconnectionfastpls2.png]]
 +
 
 +
In other word:<br/> [[File:Hwconnectionfastpls.png|350x300px|Hwconnectionfastpls.png]]
 +
 
 +
&nbsp;
 +
 
 +
== [[Program_Examples:1.2.2_Before_running_the_code|1.3&nbsp;Before running the code]] ==
 +
 
 +
----
 +
 
 +
Fast PLS output functionality need to be set on the drive (on out 7 or out 8)<br/> On the configurator in control studio two new objects need to be mapped on pdo4&nbsp;: 2191h and 2205h
 +
 
 +
[[File:configfastpls.png|500x400px|configfastpls.png]]
 +
 
 +
&nbsp;
 +
 
 +
== [[Program_Examples:1.2.2_Before_running_the_code|1.4 The&nbsp;code]] ==
 +
 
 +
----
 +
 
 +
<span style="color:#00b050">'------------------------------------------------------------------------------</span>
 +
 
 +
<span style="color:#00b050">' File:&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <MyTask>.prg</span>
 +
 
 +
<span style="color:#00b050">' Purpose:&nbsp;&nbsp;&nbsp;&nbsp; Just an example of a module header</span>
 +
 
 +
<span style="color:#00b050">' Version:&nbsp;&nbsp;&nbsp;&nbsp; 1.00</span>
 +
 
 +
<span style="color:#00b050">' Author:&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <Elliot Serfaty></span>
 +
 
 +
<span style="color:#00b050">' Description:</span>
 +
 
 +
<span style="color:#00b050">' History:&nbsp;&nbsp;&nbsp;&nbsp; YYYY-MM-DD&nbsp; <MyShortCut>&nbsp; V1.00</span>
 +
 
 +
<span style="color:#00b050">'&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Created</span>
 +
 
 +
<span style="color:#00b050">'------------------------------------------------------------------------------</span>
 +
 
 +
<span style="color:#00b050">' module global "constants"</span>
 +
 
 +
&nbsp;
 +
 
 +
<span style="color:#00b050">'common shared FASTPLS1 as PLS a1 sys.DOut.1008</span>
 +
 
 +
&nbsp;
 +
 
 +
&nbsp;
 +
 
 +
<span style="color:#00b050">'Laser should be</span>
 +
 
 +
<span style="color:#00b050">'On when pfb =>&nbsp; 150 &nbsp;deg</span>
 +
 
 +
<span style="color:#00b050">'Off when pfb => 175 &nbsp;&nbsp;deg</span>
 +
 
 +
<span style="color:#00b050">'On when pfb =>&nbsp; 200 &nbsp;deg</span>
 +
 
 +
<span style="color:#00b050">'Off when pfb => 220 &nbsp;&nbsp;deg</span>
 +
 
 +
<span style="color:#00b050">'On when pfb =>&nbsp; 360&nbsp;&nbsp; deg</span>
 +
 
 +
&nbsp;
 +
 
 +
&nbsp;
  
 
program
 
program
  
CreatePLSdata 4 P1
+
dim actualpfb as long
'CreatePLSdata P2 2
+
 
'CreatePLSdata P3 2
+
dim tol as long = 0.1
 +
 
 +
dim i as long
 +
 
 +
&nbsp;
 +
 
 +
attach a1
 +
 
 +
Print "------FastPLS V1.0--------"
 +
 
 +
Print "/!\Home proccess/!\"
 +
 
 +
call EC_SLAVE_SET_HOMING_PARAMETERS(a1,HOMING_METHOD,35) <span style="color:#00b050">&nbsp;‘Hometype = 35</span>
 +
 
 +
call EC_SLAVE_HOME_DS402(a1, 5000)&nbsp;&nbsp; <span style="color:#00b050">‘Enable the home process</span>
 +
 
 +
if a1.PFb < tol and a1.PFac > - tol then
 +
 
 +
Print "Homing&nbsp;: DONE ,Pfb = " + str$ (a1.PFb)
 +
 
 +
else
 +
 
 +
Print "->Homing&nbsp;: FAIL ,Pfb = " + str$ (a1.PFb)
 +
 
 +
end if
 +
 
 +
&nbsp;
 +
 
 +
&nbsp;
 +
 
 +
print "/!\ Init the Fast-PLS /!\ "
 +
 
 +
sys.dout.1008=0&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span style="color:#00b050">'Turn off the output 1008 is pointing to DOUT 7 of the drive</span>
 +
 
 +
&nbsp;
 +
 
 +
FASTPLS1.PlsEnable = OFF&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;<span style="color:#00b050">' Disable the FastPLS</span>
 +
 
 +
sys.dout.sim[1008]=0&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span style="color:#00b050">' set output as real</span>
 +
 
 +
FASTPLS1.hwassistance=2&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <span style="color:#00b050">' PLS as Fast PLS</span>
 +
 
 +
CreatePlsData 5 FASTPLS1&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;<span style="color:#00b050">' Create 5 points</span>
 +
 
 +
FASTPLS1.PlsPosition[1] =&nbsp; 150&nbsp;&nbsp;
 +
 
 +
FASTPLS1.PlsPosition[2] =&nbsp; 175
 +
 
 +
FASTPLS1.PlsPosition[3] =&nbsp; 200
 +
 
 +
FASTPLS1.PlsPosition[4] =&nbsp; 220
 +
 
 +
FASTPLS1.PlsPosition[5] =&nbsp; 360
 +
 
 +
for i=1 to 5
 +
 
 +
&nbsp;Print "PLS position number: " + str$(i)+ "= "; FASTPLS1.PlsPosition[i]
 +
 
 +
next
 +
 
 +
FASTPLS1.PlsSource = A1.Pcmd&nbsp;&nbsp; <span style="color:#00b050">‘source of the PCOM</span>
 +
 
 +
FASTPLS1.PLSPropagationDelay=0
 +
 
 +
FASTPLS1.PLSPropagationEnableDelay = 0
 +
 
 +
FASTPLS1.PlsPolarity = ON &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span style="color:#00b050">'low to high polarity</span>
 +
 
 +
FASTPLS1.PlsEnable&nbsp;&nbsp; = ON&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span style="color:#00b050">‘Enable the fastpls</span>
 +
 
 +
print "FastPLS Active "
 +
 
 +
print" "
 +
 
 +
Print"Motion activated"
 +
 
 +
a1.En=1
 +
 
 +
<span style="color:#00b050">'record FASTPLS1.rec 50000 recdata = a1.PositionCommandHistory[1],a1.pcmd, 50*sys.dout[1008] ,ec_pdo_read(1,0x2191,0),a1.vcmd,((ec_pdo_read(1,0x2205,1) shl 4) shr 4), a1.PositionCommandHistory[1]+a1.vcmd*((ec_pdo_read(1,0x2205,1) shl 4) shr 4)/10/1e6</span>
 +
 
 +
<span style="color:#00b050">'record FASTPLS1.rec 10000 Gap=1 Recdata = a1.PCmd , 50*sys.dout[1008], ec_pdo_read(1,0x2191,0) , ec_pdo_read(1,0x2205,1)</span>
 +
 
 +
<span style="color:#00b050">'recordon</span>
 +
 
 +
move a1 400 abs=1 vcruise=720
 +
 
 +
waitformotion a1
 +
 
 +
Print"Drive disable"
 +
 
 +
a1.En=0
 +
 
 +
FASTPLS1.PlsEnable&nbsp;&nbsp; = OFF
 +
 
 +
FASTPLS1.PlsPolarity = OFF
 +
 
 +
Print"Test is done"
 +
 
 +
'recordclose
 +
 
 +
detach a1
 +
 
 +
End Program
 +
 
 +
&nbsp;
  
P1.plsposition[1] = 10
+
== [[Program_Examples:1.2.2_Before_running_the_code|1.5&nbsp; The results]] ==
P1.plsposition[2] = 20
 
P1.plsposition[3] = 80
 
P1.plsposition[4] = 90
 
  
Attach Puma
+
[[File:FastplsResults.png|650x500px|FastplsResults.png]]
Puma.PLSsource = Puma.PathLength
 
Puma.en = 1
 
P1.PlsEnable = TRUE
 
Move Puma loc1 Vcruise=10
 
while Puma.IsMoving
 
Sleep 1
 
end while
 
Record Motion.rec 3000 Gap = 1 RecData = Sys.Dout.101 * 100, Puma.Setpoint{1}
 
RecordOn
 
MOVES Puma loc2 WithPLS = P1
 
while Puma.IsMoving
 
Sleep 1
 
end while
 
RecordClose
 
  
P1.PlsEnable = FALSE
+
In red the cycle times (4ms)<br/> In blue the output 7
Puma.PLSsource = Puma.PATHPERCENTAGE
 
Puma.en = 1
 
P1.PlsEnable = TRUE
 
Move Puma loc1 Vcruise=10
 
while Puma.IsMoving
 
Sleep 1
 
end while
 
Record Motion1.rec 3000 Gap = 1 RecData = Sys.Dout.101 * 100, Puma.Setpoint{1}
 
RecordOn
 
MOVES Puma loc2 WithPLS = P1
 
while Puma.IsMoving
 
Sleep 1
 
end while
 
RecordClose
 
Detach Puma
 
  
end program ' <MyTask>.prg
+
As we can see the output is triggered even if it is not on the cycle time
  
</syntaxhighlight>
+
&nbsp;

Latest revision as of 12:11, 15 June 2026

Language: English  • 中文(简体)‎

1.1 Feature introduction


This feature is used for laser applications or any other application that needs a drive's digital output to be toggled as fast as possible, depending on the motor position.
In this example the FAST digital output 7/8 of the CDHD2 is triggered as fast as possible depending on the position feedback.
Instead of using the drive's position-based PCOM feature, we will use the softMC's fast PLS feature together with the drive's time-based PCOM feature, to trigger the digital output. The fast PLS feature allows us to trigger the drive's output even between EtherCAT cycles.

1.2 Scenarios


I will explain the MC controller code that I wrote line by line
The idea is to perform a homing process (home type 35) then to send motion to 400 degrees
Meanwhile the motor is moving the user should see that the output 7 is toggled on 5 points: 150,175,200,220,360 degrees

1.2 HW connection


C2 connection : 
Hwconnectionfastpls2.png

In other word:
Hwconnectionfastpls.png

 

1.3 Before running the code


Fast PLS output functionality need to be set on the drive (on out 7 or out 8)
On the configurator in control studio two new objects need to be mapped on pdo4 : 2191h and 2205h

configfastpls.png

 

1.4 The code


'------------------------------------------------------------------------------

' File:        <MyTask>.prg

' Purpose:     Just an example of a module header

' Version:     1.00

' Author:      <Elliot Serfaty>

' Description:

' History:     YYYY-MM-DD  <MyShortCut>  V1.00

'              Created

'------------------------------------------------------------------------------

' module global "constants"

 

'common shared FASTPLS1 as PLS a1 sys.DOut.1008

 

 

'Laser should be

'On when pfb =>  150  deg

'Off when pfb => 175   deg

'On when pfb =>  200  deg

'Off when pfb => 220   deg

'On when pfb =>  360   deg

 

 

program

dim actualpfb as long

dim tol as long = 0.1

dim i as long

 

attach a1

Print "------FastPLS V1.0--------"

Print "/!\Home proccess/!\"

call EC_SLAVE_SET_HOMING_PARAMETERS(a1,HOMING_METHOD,35)  ‘Hometype = 35

call EC_SLAVE_HOME_DS402(a1, 5000)   ‘Enable the home process

if a1.PFb < tol and a1.PFac > - tol then

Print "Homing : DONE ,Pfb = " + str$ (a1.PFb)

else

Print "->Homing : FAIL ,Pfb = " + str$ (a1.PFb)

end if

 

 

print "/!\ Init the Fast-PLS /!\ "

sys.dout.1008=0              'Turn off the output 1008 is pointing to DOUT 7 of the drive

 

FASTPLS1.PlsEnable = OFF        ' Disable the FastPLS

sys.dout.sim[1008]=0                ' set output as real

FASTPLS1.hwassistance=2        ' PLS as Fast PLS

CreatePlsData 5 FASTPLS1        ' Create 5 points

FASTPLS1.PlsPosition[1] =  150  

FASTPLS1.PlsPosition[2] =  175

FASTPLS1.PlsPosition[3] =  200

FASTPLS1.PlsPosition[4] =  220

FASTPLS1.PlsPosition[5] =  360

for i=1 to 5

 Print "PLS position number: " + str$(i)+ "= "; FASTPLS1.PlsPosition[i]

next

FASTPLS1.PlsSource = A1.Pcmd   ‘source of the PCOM

FASTPLS1.PLSPropagationDelay=0

FASTPLS1.PLSPropagationEnableDelay = 0

FASTPLS1.PlsPolarity = ON             'low to high polarity

FASTPLS1.PlsEnable   = ON             ‘Enable the fastpls

print "FastPLS Active "

print" "

Print"Motion activated"

a1.En=1

'record FASTPLS1.rec 50000 recdata = a1.PositionCommandHistory[1],a1.pcmd, 50*sys.dout[1008] ,ec_pdo_read(1,0x2191,0),a1.vcmd,((ec_pdo_read(1,0x2205,1) shl 4) shr 4), a1.PositionCommandHistory[1]+a1.vcmd*((ec_pdo_read(1,0x2205,1) shl 4) shr 4)/10/1e6

'record FASTPLS1.rec 10000 Gap=1 Recdata = a1.PCmd , 50*sys.dout[1008], ec_pdo_read(1,0x2191,0) , ec_pdo_read(1,0x2205,1)

'recordon

move a1 400 abs=1 vcruise=720

waitformotion a1

Print"Drive disable"

a1.En=0

FASTPLS1.PlsEnable   = OFF

FASTPLS1.PlsPolarity = OFF

Print"Test is done"

'recordclose

detach a1

End Program

 

1.5  The results

FastplsResults.png

In red the cycle times (4ms)
In blue the output 7

As we can see the output is triggered even if it is not on the cycle time