🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: sci.electronics
Article #8048

Re: Microcomputer controlled AC interface

#8048
From: Brian Catlin
Date: Tue, 30 Oct 1990 21:30
89 lines
5189 bytes
In article <wwf1.657054401@ra> wwf1@ra.MsState.Edu (Bill Ford) writes:
>Did anyone read the article in the latest issue of "Modern Electronics" about
>the interface to allow you to switch AC equipment on and off via your PC's
>parellel port?  What I want to know is what in the software allows you to
>raise the logic values of your parellel port hi and lo.  I don't know much
>about the BASIC routine the author used.
>
>It looks like a good project.
>
>-- 
>"Look out, droogie, don't crash here...There's only room for one, and
> here she comes, here she comes..."  David Bowie, "Suffragette City"


In line 10 of PSWITCH.BAS DEC is set to zero.  Then
the program outputs the value of dec to port 888
using the OUT 888, DEC command.
In this program, the value of DEC is changed according
to which lines you want to go high.  Lines 240 through
380 find the values for DEC.
The first line is  forced high by setting DEC to a value
of 1.  The second line is forced high by setting DEC to
2, third line by 4, etc.  If you want more than one line
to go high then the values are added together  (eg. for
all lines to go high, DEC = 1+2+4+8+16+32+64+128 = 255,
for the first seven lines, DEC = 1+2+4+8+16+32+64 = 127)
This value is again sent to the CPU by the command OUT 888, DEC.
The 888 in both commands tells the CPU that the value
of DEC is to be sent to the parallel port.  DEC 
tells the computer what to do with the port's lines.

Note also that the ends of several lines have been cut off. 
Following is the way that the program should appear:

10 CLEAR: CLOSE: KEY OFF: CLS: DEC = 0: OUT 888, DEC
20 BYTE$ = " 0   0   0   0   0   0   0   0"
30 LOCATE 1, 21: PRINT "ZDDDDDDDDDDDDDDDDDDDDDDDDDDDDDD?"
40 LOCATE 2, 21: PRINT "3  PARALLEL INTERFACE PROGRAM  3"
50 LOCATE 3, 21: PRINT "@DDDDDDDDDDDDDDDDDDDDDDDDDDDDDDY"
60 LOCATE 10, 15: PRINT "BIT NUMBER    7   6   5   4   3   2   1   0 "
70 LOCATE 11, 15: PRINT "DDDDDDDDDDDDDDEDDDEDDDEDDDEDDDEDDDEDDDEDDD4 "
80 LOCATE 12, 29: PRINT "3   3   3   3   3   3   3   3 "
90 LOCATE 13, 29: PRINT "A   A   A   A   A   A   A   A "
100 LOCATE 14, 15: PRINT "   VALUE     "; BYTE$
110 LOCATE 21, 16: PRINT "COPYRIGHT,  GEORGE F. STOCKMAN, IV,  1989"
120 DELAY = TIMER + 5: WHILE DELAY > TIMER: WEND
130 LOCATE 21, 16: PRINT STRING$(41, 32)
140 LOCATE 21, 11: PRINT "BIT NUMBER TO TOGGLE / [CR] TO RESET / [ESC] TO QUIT"
150 A$ = INKEY$: IF A$ = "" THEN 150
160 IF A$ = "0" THEN 240 ELSE IF A$ = "1" THEN 260 ELSE IF A$ = "2" THEN 280
170 IF A$ = "3" THEN 300 ELSE IF A$ = "4" THEN 320 ELSE IF A$ = "5" THEN 340
180 IF A$ = "6" THEN 360 ELSE IF A$ = "7" THEN 380
190 IF A$ <> CHR$(13) THEN 230
200 BYTE$ = " 0   0   0   0   0   0   0   0"
210 DEC = 0: BIT0 = 0: BIT1 = 0:BIT2 = 0: BIT3 = 0
220 BIT4 = 0: BIT5 = 0: BIT6 = 0: BIT7 = 0: GOTO 430
230 IF A$ = CHR$(27) THEN CLS: SYSTEM ELSE BEEP: GOTO 150
240 IF BIT0 = 0 THEN BIT0 = 1: DEC = DEC + 1 ELSE BIT0 = 0: DEC = DEC - 1
250 GOTO 390
260 IF BIT1 = 0 THEN BIT1 = 1: DEC = DEC + 2 ELSE BIT1 = 0: DEC = DEC - 2
270 GOTO 390
280 IF BIT2 = 0 THEN BIT2 = 1: DEC = DEC + 4 ELSE BIT2 = 0: DEC = DEC - 4
290 GOTO 390
300 IF BIT3 = 0 THEN BIT3 = 1: DEC = DEC + 8 ELSE BIT3 = 0: DEC = DEC - 8
310 GOTO 390
320 IF BIT4 = 0 THEN BIT4 = 1: DEC = DEC + 16 ELSE BIT4 = 0: DEC = DEC - 16
330 GOTO 390
340 IF BIT5 = 0 THEN BIT5 = 1: DEC = DEC + 32 ELSE BIT5 = 0: DEC = DEC - 32
350 GOTO 390
360 IF BIT6 = 0 THEN BIT6 = 1: DEC = DEC + 64 ELSE BIT6 = 0: DEC = DEC - 64
370 GOTO 390
380 IF BIT7 = 0 THEN BIT7 = 1: DEC = DEC + 128 ELSE BIT7 = 0: DEC = DEC - 128
390 BYTE$ = "": BYTE$ = BYTE$ + STR$(BIT7) + "  " + STR$(BIT6) + "  "
400 BYTE$ = BYTE$ + STR$(BIT5) + "  " + STR$(BIT4) + "  "
410 BYTE$ = BYTE$ + STR$(BIT3) + "  " + STR$(BIT2) + "  "
420 BYTE$ = BYTE$ + STR$(BIT1) + "  " + STR$(BIT0) + "  "
430 OUT 888, DEC: LOCATE 14, 28: PRINT BYTE$;: GOTO 150
This is my own interpretation of the program and it should
work.  The author's correct version will probably come
out in one of the next few issues.
This is a very interesting project and I plan on building
it also. 
\*********************************************************************\
 \  Brian Catlin          Electrical Engineering                       \
  \  email: bc338569@longs.lance.colostate.edu                          \
   \  "Here's a battery and a wire--go light up the world!"              \
    \                                         -- Mom and Dad              \
     \*********************************************************************\
     
Technical Details
Message-ID: <10720@ccncsu.ColoState.EDU>
Path: arc1-ca.pugleaf.net!utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!sun-barr!lll-winken!elroy.jpl.nasa.gov!ncar!boulder!ccncsu!longs.LANCE.ColoState.Edu!bc338569
References: <wwf1.657054401@ra>

Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!sun-barr!lll-winken!elroy.jpl.nasa.gov!ncar!boulder!ccncsu!longs.LANCE.ColoState.Edu!bc338569
From: bc338569@longs.LANCE.ColoState.Edu (Brian Catlin)
Newsgroups: sci.electronics
Subject: Re: Microcomputer controlled AC interface
Message-ID: <10720@ccncsu.ColoState.EDU>
Date: 30 Oct 90 21:30:36 GMT
References: <wwf1.657054401@ra>
Sender: news@ccncsu.ColoState.EDU
Reply-To: bc338569@longs.LANCE.ColoState.Edu (Brian Catlin)
Distribution: sci
Organization: Colorado State University, Fort Collins, CO  80523
Lines: 89