B.4.6 motion completed callback samples, B.4.6.1 mcompletecallback, B-21 – ElmoMC Multi-Axis Motion Controller-Maestro User Manual

Page 273

Advertising
background image

B.4.6

Motion Completed Callback Samples

B.4.6.1 MCompleteCallback

// AxisMotionComplete

function
run()
global int motionStatus
motionStatus=0
InitAxis(a3)
InitAxis(a4)

sync(0, 10)

//send sync signal to CANbus0 every 10ms

wait(10)
axisHoming(a3,

0)

axisHoming(a4,

0)

end function

function InitAxis(AXIS axis)

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

// the interpreter command or by

//

the

user

program.

axis.mo

=

0

wait(10)

axis.sf = 0

axis.um = 5

axis.tr[1]=100
axis.tr[2]=1
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

axis.amc = 1

end function

function axisHoming(AXIS axis, int home_pos)
global int motionStatus

TRACE( "homing axis %", axis.aid)

axis.px = home_pos

axis.mo

=

1

axis.pa = home_pos + 10000

axis.bg

//wait until axis has stopped

until(motionStatus==axis.aid)
motionStatus=0
TRACE("finish

homing")

end function

// Motion Completed handler calls then a target position
reached.
function @motioncompleted(int busId, int objId)
global int motionStatus
switch(objId)
case

a3.aid

motionStatus=a3.aid
case

a4.aid

motionStatus=a4.aid
end

switch

TRACE( "Motion completed for object %", objId )

end function

// VectorMotionComplete

int motionStatus

function run()
global int motionStatus
motionStatus=0

sync(0, 10)

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

wait(10)
g1.detach()
v1.attach()
InitVector(v1)
setWorkMode(v1)
vectorHoming(v1,0,0)
//draw

line

v1.vsp=70000

//

max

velocity

v1.vse=0

/*

end

velocity*/

TRACE("start

line")

v1.line(70000, 100000)

//go to( 7000,10000)

v1.bg

//action!

//wait until vector has stopped

until(motionStatus==1)
motionStatus=0
TRACE("finish

line")

end function

function InitVector(VECTOR vector)
global int motionStatus
int i

vector.rm = 0 //The reference is generated by

the interpreter command or by the user program.
vector.mo

=

0

wait(10)

vector.sf = 0

vector.um = 5

vector.tr[1]=100
vector.tr[2]=1

vector.ll[2] = -833333

vector.hl[2] = 833333

vector.VH[2] = 750000

vector.VL[2] = -750000

vector.ll[3] = -1000000000

vector.hl[3] = 1000000000

vector.VL[3] = -999999990

vector.VH[3] = 999999990

vector.vmc=1
end function

function setWorkMode(VECTOR vector)
vector.vum=1

//build trajectory in max. velocity mode

vector.vsc=1

//smooth intersection with max. velocity

vector.vtm=1 //enable PVT motion initialization

vector.vac = 28000000 //max acceleration

vector.vdc = 28000000 //max deceleration

vector.sd

=

100000000

end function

Maestro

Software Manual

Appendix B: Sample Programs

MAN-MASSW (Ver. Q)

B-21

Advertising