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

From SoftMC-Wiki
Jump to: navigation, search
(minor edit)
(Added some content)
 
(8 intermediate revisions by the same user not shown)
Line 1: Line 1:
{{Languages|Program_Examples:Path-PLS}}  
+
{{Languages|Program_Examples:Path-PLS}}/!\ Under construction /!\
78
+
== [[Program_Examples:1.1_Feature_introduction|1.1 Feature introduction]] ==
 +
 
 +
----
 +
 
 +
This feature is used for laser application or any device that need a drive output to be toggled as fast as possible depends on the motor drive position.<br/> The idea is to trigger the FAST output 7/8 of the CDHD2 as fast as possible depending on the position feedback.<br/> In point of view of drive without master it’s easy.<br/> But in our case, we want the master to trigger to outputs and the master can provide data depending on the cycle time and in most of case the cycle time is to long so it a problem.<br/> That why thanks to this feature the drive can trigger the output even if it is not on a cycle times, we will se how to parameter this feature from the master (mc) in the next chapter
 +
 
 +
== [[Program_Examples:1.2_Scenarios|1.2 Scenarios]] ==
 +
 
 +
----
 +
 
 +
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
 +
 
 +
dim actualpfb as long
 +
 
 +
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;
 +
 
 +
== [[Program_Examples:1.2.2_Before_running_the_code|1.5&nbsp; The results]] ==
 +
 
 +
[[File:FastplsResults.png|650x500px|FastplsResults.png]]
 +
 
 +
In red the cycle times (4ms)<br/> In blue the output 7
 +
 
 +
As we can see the output is triggered even if it is not on the cycle time
 +
 
 +
&nbsp;

Latest revision as of 15:21, 13 February 2023

Language: English  • 中文(简体)‎
/!\ Under construction /!\

1.1 Feature introduction


This feature is used for laser application or any device that need a drive output to be toggled as fast as possible depends on the motor drive position.
The idea is to trigger the FAST output 7/8 of the CDHD2 as fast as possible depending on the position feedback.
In point of view of drive without master it’s easy.
But in our case, we want the master to trigger to outputs and the master can provide data depending on the cycle time and in most of case the cycle time is to long so it a problem.
That why thanks to this feature the drive can trigger the output even if it is not on a cycle times, we will se how to parameter this feature from the master (mc) in the next chapter

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