B.4 callbacks functions, B.4.1 perrorcallback, B.4.2 emcycallback – ElmoMC Multi-Axis Motion Controller-Maestro User Manual

Page 267: B.4.3 heartbeatcallback, B-15

Advertising
background image

B.4 Callbacks Functions

B.4.1

PerrorCallBack

int dev
// Entry point of the application.
function run()

global int dev //default value - 0

int

n

TRACE( "Dev value %", dev )

n = 100 / dev

TRACE( "Program OK" )

end function

// Error handler calls then a runtime program
// error occur.
function @perror(int error)

global int dev

//send user message to desktop computer

messagex( 0, dev, error )

//set

global

var

dev

=

2

//view error code

TRACE( "Program error value %", error )

//reset

program

reset
end function

B.4.2

EmcyCallback

// This function is used to choose a response to specific CANopen emergency messages
function run()
a1.mo=0
wait(10)
a1.px=0
a1.um=5
a1.sp=10000
a1.mo=1
wait(10)
a1.pa=0
a1.bg
a1.pa=10000
a1.bg
end function

function
@emcy(int busId, int nodeId, int first4bytes, int last4bytes)

TRACE (" Bus id is: % Node id is % ", busId, nodeId)

//if the first 4 bytes of an emergency message is " Can message lost"

if(first4bytes==0xff118110)

TRACE(" Can message lost") //then print an error message in the debug window

else

if

(first4bytes==0xff118200)

TRACE("Protocol

error")

end

if

end function

B.4.3

HeartbeatCallBack

int work

// Entry point of the application.
function run()
global

int

work

work = 0

hbperiod(0,

200)

sync(0,

20)

TRACE( "Start" )

until( work == -127 )

Maestro

Software Manual

Appendix B: Sample Programs

MAN-MASSW (Ver. Q)

B-15

Advertising