Capture Events and ...
 
Notifications
Clear all

Capture Events and make decisions based on existing conditions:

3 Posts
1 Users
0 Reactions
28.4 K Views
(@Animatics)
Posts: 1
New Member Guest
Topic starter
 

Use Port G interrupt available in the “PLS” and “PS2”
version firmware (available in all products except SM2315 and RTC series). In the latest firmware, you can assign Port G to call C2 subroutine on interrupt.

In doing so, any time Port G is grounded, it will call C2
withing 250 to 500useconds. Then the CPU will process code sequentially from C2 down until it reaches “RETURNI” which stands for “Return-Input”.

The C2 code will be called and executed regardless of what
the motor was doing at the time. It will not effect any motion (unless the code in C2 is written to do so).

Example:

UAI 'make PortA an input
UBI 'make PortB an input
UCI 'make PortC an input
UGI 'make PortG an input
ZS 'clear all errors
F=64 'setup PortG to call C2
END

C2
x=@P 'Capture position
y=CLK 'Capture clock
z=@PE 'Capture Position Error
i=U&7 'capture Ports A, B and C as a 3-bit masked value.
PRINT( Port G was grounded! “,#13)

SWITCH i 'make decision based on input status.
CASE 0 'do what ever BREAK
CASE 1 'do what ever BREAK
CASE 2 'do what ever BREAK
CASE 3 'do what ever BREAK
CASE 4 'do what ever BREAK
CASE 5 'do what ever BREAK
CASE 6 'do what ever BREAK
CASE 7 'do what ever BREAK
ENDS

RETURNI

In so writing the code in this method, you can have a motor
not actually running any code at all until Port G is grounded.

 
Posted : 13/01/2010 12:03 am
(@juhlik)
Posts: 1
New Member Guest
 

Will this code work with a 23165DT motor?

 
Posted : 23/12/2010 6:56 am
(@csearcy)
Posts: 316
Reputable Member Guest
 

The previous example is only for Class4 motors with -PLS or -PLS2 firmware.
The SM23165DT is a Class5 motor.

Class5 Example:

EIGN(0) 'make PortA an input
EIGN(1) 'make PortB an input
EIGN(2) 'make PortC an input
EIGN(6) 'make PortG an input
ZS 'clear all errors

ITR(0,16,6,0,2) 'setup interrupt 0 to call C2 when PortG goes low
EITR(0) 'enable interrupt 0
ITRE 'enable all interrupts
PAUSE 'keep the program from ending
END

C2
DITR(0) 'disable interrupt 0 (to prevent it from being called twice)
PRINT("PortG was grounded!",#13)
x=PA 'Capture position
y=CLK 'Capture clock
z=EA 'Capture Position Error
'Capture Ports A, B and C as a 3-bit value.
i=7-(IN(0)+(IN(1)*2)+(IN(2)*4))

SWITCH i 'make decision based on input status.
CASE 0 'do what ever BREAK
CASE 1 'do what ever BREAK
CASE 2 'do what ever BREAK
CASE 3 'do what ever BREAK
CASE 4 'do what ever BREAK
CASE 5 'do what ever BREAK
CASE 6 'do what ever BREAK
CASE 7 'do what ever BREAK
ENDS

WAIT=50 'delay 50msec
EITR(0) 'enable interrupt 0
RETURNI 'return from interrupt

 
Posted : 23/12/2010 4:39 pm
Share: