beautypg.com

B.4.5.2 inputoutputtest1, B-19 – ElmoMC Multi-Axis Motion Controller-Maestro User Manual

Page 271

background image

B.4.5.2 InputOutputTest1

int loop
int iData
int gEvent

function run()
global int loop
global int iData
global int gEvent
int input,tmp,i
int m_input_old,a1_input_old,a2_input_old
int input_num
int input_level
input_num

=

0

input_level

=

0

loop=1
a1.adi=1
a2.adi=1

input = -1

m_input_old = m_din

a1_input_old = a1.IP

a2_input_old = a2.IP

a1_input_old = a1_input_old & 0x3f

a2_input_old = a2_input_old & 0x3f

gEvent = 128


while(loop)

until(gEvent!=128)

switch(gEvent)

case

0

input

=

iData

&

0xff

input_num

=

8

if(input

>

m_input_old)

input_level=1
tmp

=

input

-

m_input_old

else

input_level=0

tmp = m_input_old - input

end

if

m_input_old

=

input

case

a1.aid

input

=

iData

&

0x3f

input_num

=

6

if(input

>

a1_input_old)

input_level=1

tmp = input - a1_input_old

else

input_level=0

tmp = a1_input_old - input

end

if

a1_input_old

=

input

case

a2.aid

input

=

iData

&

0x3f

input_num

=

6

if(input

>

a2_input_old)

input_level=1

tmp = input - a2_input_old

else

input_level=0

tmp = a2_input_old - input

end

if

a2_input_old

=

input

end

switch


for

i=0:input_num

if(tmp&0x0001

==

1)

if(gEvent==0)
switch(i)
case

0

m_dout[0]=input_level
case

1

m_dout[1]=input_level
case

2

m_dout[2]=input_level
case

3

m_dout[3]=input_level
case

4

m_dout[4]=input_level
case

5

m_dout[5]=input_level
case

6

m_dout[6]=input_level
case

7

m_dout[7]=input_level
end

switch

end

if

TRACE( "NodeID %,Input % Input

Level % ",gEvent, i+1,input_level )

end

if

tmp

=

tmp>>1

end

for

gEvent=128

end

while

end function

// Input handler calls then a input event occur.
function @input(int busId, int nodeId, int data)
global int iData,gEvent
iData = data
gEvent = nodeId

end function

Maestro

Software Manual

Appendix B: Sample Programs

MAN-MASSW (Ver. Q)

B-19