Program Examples:fast-PLS

From SoftMC-Wiki
Jump to: navigation, search
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