[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Big Apple Users Group 12.1.97
James OReilly (joreilly@smtp.dorsai.org) wrote:
: Neil Wotherspoon has written a process control program to run an elevator.
: I'm helping him translate it from QBasic, a PC programming language, to
: Applesoft Basic, an Apple II programming language. A process control
: program controls some mechanism in the real world. This program makes an
: elevator go the floor you select. Since Polly has ruled that we can't
: connect the computer to her building elevator, I guess Neil will have to
: bring the 2 foot tall model elevator from his office. Come see Neil show
: us that an Apple II can actually control events in the real physical
: world.
:
: Skip this paragraph if you aren't interested in the gory programming
: details. The program addresses the elevator thru the printer slot and
: passes the character equivalent of the floor no. to the elevator. When we
: connected the computer to a printer to test the program, the program
: stopped when it tried to send the elevator to the 4th floor. We found
: that this happened because the character equivalent of 4 also means end of
: transmission to an Apple II. Neil is rewiring the elevator to accept
: different signals and we'll have the demo ready for the meeting.
: I can show how I used Program Writer to write the program in Applesoft
: Basic. Hank Levinson, if asked, could discuss ways of avoiding the end of
: transmission problem, which he thinks might be circumvented by "error
: trapping" procedures.
I can't make the meeting (wrong part of the world), but I think I can tell
you what the problem is.
You are asking the elevator to go to a particular floor by sending it a
signal through the parallel port. But to tell the elevator to go to the
fourth floor, you do not send it a $34, which is the ASCII code for the
numeral 4, but instead you send it a $04, which is the ASCII code for a
Control-D.
I can understand why you do it this way...it becomes dead easy because all
you have to do is run a set of lines from the parallel port to a decoder,
and the decoder will then send the signal to the elevator control. If
there are fewer than seventeen floors, you can use an 8-->16 line decoder
to do the job.
The problem is, you are bumping into a problem, not with the Apple's
architecture, but rather its operating system. When you print a ^D from
an Applesoft program, the character gets intercepted by either DOS 3.3 or
BASIC.SYSTEM (depending on whether you are using DOS 3.3 or ProDOS), and
the OS tries to interpret the remainder of the line as a DOS command.