Remote-processing BASIC 52 Uživatelský manuál Strana 94

  • Stažení
  • Přidat do mých příruček
  • Tisk
  • Strana
    / 163
  • Tabulka s obsahem
  • KNIHY
  • Hodnocené. / 5. Na základě hodnocení zákazníků
Zobrazit stránku 93
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 123. Line num ber range is card dependent.
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: RUN
Use: ON LINE 3,7,5000 Executes a subroutine at line 5000 when line 7 changes.
Cards: RPC-320, RPC-330
DESCRIPTION
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 later.
An ON LINE interrupt is turned off by specifying number only. ON LINE interrupts can be turned off any
time in a program.
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 change, 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
interrupt. ON LINE ON resumes interrupts. When this command is executed, any changed lines cause an
interrupt. To cancel or clear interrupts, use the CLEAR parameter shown above. All line change flags are
reset and no interrupts are generated until a line changes state.
When two lines chang e betw een th e 5 ms sampling time, th e high er num bered interrupt 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 of the following scenarios happen: Sinc e lines are sam pled e very 5 ms, a p ulsed signal can be m issed.
Use one of the ONITR interrupts to capture this kind of signal. The second scenario is more of a problem.
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 upon other control structures currently running. 30 levels is a reasonable number. However, 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.
Zobrazit stránku 93
1 2 ... 89 90 91 92 93 94 95 96 97 98 99 ... 162 163

Komentáře k této Příručce

Žádné komentáře