Rpbasic-52 programming guide, On line – Remote Processing BASIC 52 User Manual
Page 94
RPBASIC-52 PROGRAMMING GUIDE
2-75
ON LINE
Syntax:
ON LINE number,I/O line,subroutine line
ON LINE number
ON LINE ON/OFF [,CLEAR]
Where: number = 0 to 7, is the interrupt reference number
I/O line = 0 to 7 or 100 to 12 3. Line num ber range is card d ependent.
subroutine line = program subroutine to execute on line change
ON/OFF = enable / suspend ON LINE checking
CLEAR = clears all line change flags
Function:
Branches to a service subroutine when an I/O line changes state.
Mode:
R U N
Use:
ON LINE 3,7,5000
Executes a subroutine at line 5000 wh en line 7 changes.
Cards:
RPC-320, RPC-330
D E S C R IP T I ON
Up to 8 digital I/O lines can be monitored for changes in state. Lines are monitored by the operating system
every 5 ms. When a line changed from the last monitored state, a flag is set. This flag is checked at the end
of the current Basic statement. Thus, an interrupt is generated when a line goes low or high. Unless an
ONTICK or ONITR subroutine is currently executing, the subroutine line is then executed.
number is from 0 to 7. It acts, to some extent, as a priority arbitrator. It does not have any relationship to I/O
line or subroutine line except to num ber interrupts. More information late r.
An ON LIN E interrupt is turned off by specifying number only. ON LINE interrupts can be turned off any
t im e in a pr og ra m .
I/O line numbers 100-123 correspond to opto rack positions. Use the table in the DIGIT AL I/O chapter to
make the correspondence between an opto position and actual digital I/O line. Lines 0-7 are designated L0-
L7 on the card.
ON LINE ON/OFF enables/suspends line interrupts. Lines are still checked every 5 ms by the operating
system . If a line d id cha nge, it is flagge d. ON LINE OFF suspends interrupts while ON LINE ON resumes
this type of interrupt. Use ON LINE OFF when an I/O line interrupt cannot be preempted by any other line
interru pt. ON LINE ON resumes interrupts. When this command is executed, any changed lines cause an
interrupt. To cancel or clear interrupts, use the CLEAR paramete r shown abo ve. All line chan ge flags are
reset and no interrupts are generated until a line changes state.
Wh en tw o lines chang e betw een th e 5 m s sam pling ti me, th e high er num bered interrup t takes priority .
However, if the same or another line changes in the next sample period, its subroutine will take priority.
For an interrupt to occur, a line must be stable for at least 5 ms. When a line changes faster than this, one or
both o f the foll owin g scen arios h appe n: Sinc e lines are sam pled e very 5 ms, a p ulsed s ignal c an be m issed.
U s e o n e o f t he O N IT R i nt e rr up ts to c ap tu re th is k in d of si gn a l. T he s ec o nd s ce n ar io is m o re o f a p ro b le m .
ON LINE generates subroutines. When a line change is detected, a subroutine is generated. When the
subroutine is long and a line change quick enough, these routines become nested. When too many routines
are stacked, program execution is terminated and a control-stack error is returned. Maximum nesting level
depends up on other control struc tures currently running . 30 levels is a reasona ble numb er. Howev er, if a
number of FOR-NEX T loops are running, this number is diminished.
There are two ways to take care of this program. First, make the service routine very short - less than 3
commands. Second, is to execute the ON LINE OFF com mand. This shuts off all ON LINE execution.