Download Print this page

Atari CX70 Operator's Manual page 62

Light pen

Advertisement

ATARI Light Pen Operator's Manual
such as in a menu seIection> this number should be higher. A value of
9 is usually sufficient for a highly accurate determination of pen
position.
The sorting of the X and Y pen coordinates is done by a method known
as an insert-sort. A storage table is defined to hold the total
number <max='69) of values to be sorted; 69 is the maximum because this
is the maximum area of memory available to be allocated for the sort
table. An error will occur if you try to use a greater number of
readings. The sampling number is stored at decimal 205.
As each of the values is read< the table of previous values is
examined one item at a time.
If the new value is less than a value
previously received^ that previous value is moved to an array location
with a subscript one number higher than the one previously occupied.
In other wordSi if you had previously processed six values* these
could be represented as VAL(l) through VAL<6). These previous values
would already be ordered from lowest value VAL(l) to highest value
VAL<6>. Now when the new one is read* it is compared to VAL(6). If the
new value is lower than VAL(6)* then VAL(7) is set equal to VAL(6)*
having the effect of moving the highest value into the next position
in order to make a slot for the new value. Now a comparison is made to
VAL(5). If lower* then VAL(5> is moved into the position formerly
occupied by VAL(6)* and so forth*
until the correct slot is found.
This continues for all new values until each one has found a slot.
Then the center value in the table is the median of the sort. This
will be the value that occurs most often and will be the most likely
true position of the pen. Random noise readings will have been pushed
out to the outer ends of the table and will not affect the correct
location of the median. The advantage of using an insert-sort is that
the sort can be done as each data item is read. If you use a batch
sort*
you will have to wait while the data is sorted following all the
readings. The insert-sort requires no wait because it sorts while
read ing.
The number stored at decimal 205*
used to establish the number of
reads* should be odd (1* 3* 5* . . . 65* 67* 69) to provide a true middle
point to the sort table. The diagram below represents a typical
sorting sequence for the seventh value in a 7-value insert sort.
Description of PENBUF Operation - 58

Advertisement

loading