beautypg.com

B.8.5 vectoraxismove, B-33 – ElmoMC Multi-Axis Motion Controller-Maestro User Manual

Page 285

background image

B.8.5

VectorAxisMove

int trjPointsArr[10,2]
int ind
function run()
global int trjPointsArr[]
global int ind
ind=1
InitAxis(a1)
InitAxis(a3)
sync(0,

10)

//send a sync signal to CAN bus 0 every 10ms

trjPointsArr[0,0]= 0 //set coor. x0

trjPointsArr[1,0]= 10000 //set coor. x1

trjPointsArr[2,0]= 0 //set coor. x2

trjPointsArr[3,0]= 15000 //set coor. x3

trjPointsArr[4,0]= 0 //set coor. x4

trjPointsArr[5,0]= 20000 //set coor. x5

trjPointsArr[6,0]= 0 //set coor. x6

trjPointsArr[7,0]= 30000 //set coor. x7

trjPointsArr[8,0]= 0 //set coor. x8

trjPointsArr[9,0]= 40000 //set coor. x9

trjPointsArr[0,1]= 0 //set coor. y0

trjPointsArr[1,1]= 10000 //set coor. y1

trjPointsArr[2,1]= 0 //set coor. y2

trjPointsArr[3,1]= 15000 //set coor. y3

trjPointsArr[4,1]= 0 //set coor. y4

trjPointsArr[5,1]= 20000 //set coor. y5

trjPointsArr[6,1]= 0 //set coor. y6

trjPointsArr[7,1]= 30000 //set coor. y7

trjPointsArr[8,1]= 0 //set coor. y8

trjPointsArr[9,1]= 40000 //set coor. y9

homing(a1,

trjPointsArr[0,0]) //set coor. x to 0

homing(a3,

trjPointsArr[0,1]) //set coor. y to 0

setWorkMode()
drawTrj()

//wait until both axes have stopped

while

((a1.ms==2)||(a3.ms==2))

wait(1)
end

while

end function

function InitAxis(AXIS axis)
axis.mo

=

0

axis.rm = 0 //The reference is generated by the

// interpreter command or by the user program.

wait(10)

axis.sf = 0

axis.um = 5 //set unit mode

axis.sd

=

1000000000

// set velocity and position limits

axis.ll[2]

=

-833333

axis.hl[2] = 833333

axis.VH[2] = 750000

axis.VL[2]

=

-750000


axis.ll[3]

=

-1000000000

axis.hl[3] = 1000000000

axis.VL[3]

=

-999999990

axis.VH[3] = 999999990

end function

function setWorkMode()

v1.vum=1 //build trajectory in max. velocity mode

v1.vsc=0

v1.vtm=1 //enable PVT motion initialization

v1.vac

=

1000000000

v1.vdc

=

1000000000

end function

function homing(AXIS axis, int home_pos)

axis.px = home_pos

axis.mo

=

1

wait(10)

axis.pa = home_pos

axis.bg
end function

function drawTrj()
global int trjPointsArr[]
int i
v1.starts()

//

begin

trj

v1.vsp = 100000

//max. velocity

v1.vse

=

0

//end

velocity

for

i=1:(trjPointsArr.size[0]-1)

v1.addline(trjPointsArr[i,0],trjPointsArr[i,1])

//create line from current point to coordinate

v1.adddwell(700)
end

for

v1.ends()

//

end

trj

a1.ui[1]=trjPointsArr[1,0]

v1.bg

end function

function misha()
global int trjPointsArr[]
int i
v1.vsp

=

30000

//max.

velocity

v1.vse

=

0

//end

velocity

v1.line(10000,10000)

v1.bg

end function

// Emergency handler calls then a CANopen
emergency message appears on the bus.
function @emcy(int busId, int nodeId, int
first4bytes, int last4bytes)
global int ind
global int trjPointsArr[]
ind++
if(ind>trjPointsArr.size[0]-1)
ind=1
else
a1.ui[1]=trjPointsArr[ind,0]
end

if

//TRACE( "Emergency: bus %, node %",

busId, nodeId )
end function

Maestro

Software Manual

Appendix B: Sample Programs

MAN-MASSW (Ver. Q)

B-33