Home Products Prices Site Map Order Contact What's New Books Free Files Links FAQ
Dontronics Home PagePICEX RS-232 Serial Port Expansion.
Bottom of Page
11-Mar-98
I no longer support this Picex (software) or Pigmy Board (hardware) as I have moved onto Simmstick and other things, however I am making the source code available for personal use.

PIGMY Boards: Sold out 4-Apr-99

 The source code consists of files for the PIC16C57/XT, and PIC16C84/04. It has been complemented by source from Stewart Montano for PIC to MAX186 ADC routines.

 The original routines lined up with the I/O ports of the Pigmy board, but code changes are required to allow it to work with SimmStick. I have someone having a look at this now. I believe the DT101 Simmstick would make an ideal platform for PICEX.

Subject: PICEX on simmstick
Date: Tue, 16 Jun 1998 10:51:23 +0000
From: Claudio Rachiele IW0DZG 75805312@it.ibm.com
To: dontronics.com

Don, I'm very  sorry for your long waiting.
Hereafter you can find the files you need.
Remember to use Parallax ASM if you want modify and reassemble the
code. I have tested all for a long time and it look like everything
work properly. If you find any problem LMK.

 - SSPCEX57.LST  - SSPCEX57.OBJ  - SSPCEX57.SRC

I have also the schematic in OrCad fmt. If you have OrCad I'll send it
to you with the associated library. Claudio Rachiele IW0DZG
Download sspcex57.zip


The PIC16F84 version remains undone for the DT101 Simmstick. Any takers?? 

The Table of Contents.

What is PICEX?
Disclaimer:
Basic Terminal Driver: Drive it from Basic.
PICEX Commands:
Windows Terminal Program:Drive it from Windows.
Walking LED Basic Program:LED moves along under program Control.
Picex Hardware Assembly

Back to The Table of Contents.

What is PICEX?

This is an Electronics DIY project which allows your PC Serial port to control 18 bits of the outside world.

My PICEX Controller network uses a very simple method of communication. How simple? You can drive it using only a standard RS-232 Serial Port (9600,N,8,1) from any type of PC that is running any PC serial comms program. It uses 6 ASCII Text commands for each data transfer and is byte (8 bits at a time) or single bit addressable. Inexperienced programmers will be able to use the bit mode without any knowledge of Hexadecimal arithmetic. Each PICEX is a small computer that has its own on board Operating System.

The chart below compares my Serial and Parallel kits and features.
Comparison chart. PIPEX compared to PICEX:

PIPEX  (Parallel TTL)               PICEX (Serial RS-232)
Connects to LPTx: 8 wire circuit.   Connects to COMx: 3 wire circuit.
64 bits. 32 bits out, 32 bits in.   16 bits In/Out or any combination.
Fully expandable.                   256 boards or Nodes. (0 to 255)
Requires some programming skills.   Extremely simple communication.
Must address 8-32 bit full word.    Single bit selectable.
2-3 Metres line length from PC.     50-100 Metres from PC or Micro.
Very cost effective.                Dearer per bit count.
PICEX has the ability to program any individual pin as an input or an output. This means that you can have 16 inputs, 16 outputs, or any combination, and they can be programmed on the fly. With careful design, you can write to an LCD display on the same lines as you can read a keyboard matrix on.

A PICEX network in a commercial application may require additional RS-485 hardware fitted if communications over a distance greater than 100 metres is required. RS-485 will drive up to 2000-3000 metres.

PICEX Programming example: There are 3 ports on the PIC16C57 computer chip. Ports B and C are full 8 bit ports. To program port B data bit 0 as an output, then set it high, can be done with the following 2 (6 digit ASCII Text) commands:

00CB00 ;Board 00, Configure Port B with Data bit 0 as output.
       ;Digit 1&2=Board, 3=Command, 4=Port, 5=Data bit, and 6=In/Out.
00OB01 ;Board 00, Output to Port B, with Data bit 0 set High.
       ;Digit 1&2=Board, 3=Command, 4=Port, 5=Data bit, and 6=Level.

The PICEX commands are:         [8 bit]     Read, Write, Program.
                                [1 bit]     Input, Output, Configure.
Plus these General Commands:
'V'ersion, 'L'oopback(test), 'T'est(ID), 'D'irection(I/O Readback), and 'M'aster Reset.

The PICEX Controller RS-232 Serial Network uses my standard PIGMY board, a 4Mhz crystal and a PIC16C57-XT PICEX Chip default Programmed to Board 00.

All orders of PIGMY boards or PICEX chips will include the hardcopy of circuits, etc.

Source code is NOT available for PICEX.
Back to The Table of Contents.

Disclaimer:

Disclaimer:
My PICEX product has been designed over a period of time and should perform as per the instructions given.

I assume no liability for damages either from the direct use of this product or as a consequence of the use/misuse of this product. Hence this product and all information contained within SHOULD BE USED AT ONE'S OWN RISK.

In the case of error reporting in PICEX, most general user input errors are trapped. It is up to the user to understand and minimize these input errors as PICEX has a limited ability in detecting these user generated errors.

This disclaimer is included to absolve me from legal issues brought about by today's litigious society.

Once again, I still accept no responsibility as to the operation of this and any other software that I have ever written.

Any one who has dealt with me in the past knows that I will deal with you on a "One on One" basis. I'm the person that designed this product. If you have a problem, you get to speak to the designer, not an intermediate sales person, or other third party.

Back to The Table of Contents.

Basic Terminal Driver:

Demo to Drive PICEX from a simple Basic program.
10 DEFINT B-Z: COMPORT = &H3F8: REM SET COM PORT
20 GOSUB 1020: REM RESET COM1 UART
30 CLS : CLOSE : LOCATE , , 1: REM TIDY UP, SET CURSOR ON
40 PRINT "VERY BASIC TERMINAL DRIVER FOR PICEX SERIAL NETWORK"
50 PRINT "by Don McKENZIE 25-JUL-94(c)"
60 PRINT "P.O. Box 595 TULLAMARINE 3043 AUSTRALIA": PRINT
70 PRINT "6 BYTE XMIT$ STRING IS USED TO SEND MESSAGE OUT TO PICEX."
80 PRINT "RECD$ = 6 BYTE RECEIVED MESSAGE."
90 PRINT "FULL$ = FULL MSG RETURNED (INCLUDES 'T'est MESSAGE)"
100 PRINT "LENGTH = LENGTH OF FULL$."
110 PRINT "Press space bar to exit..."
120 ON ERROR GOTO 1280
130 COM(1) ON:ON COM(1) GOSUB 790
140 OPEN "COM1:9600,N,8,1,CS10" FOR RANDOM AS #1: REM SET COMMS
150 XMIT$ = "": REM CLEAR TRANSMIT STRING
160 REM
170 REM ******************************************************
180 REM GET 6 CHARACTERS FROM KEYBOARD
190 REM ******************************************************
200 REM
210 PRINT : PRINT "Input 6 Characters: ";
220 FOR X = 1 TO 6: REM SET UP KEYBOARD LOOP OF 6 CHRS
230 B$ = INKEY$: REM GET KEYBOARD CHR
240 IF B$ = "" THEN 230: REM KEY PRESSED?
250 IF B$ = " " THEN CLOSE #1: SYSTEM: REM SPACE WILL STOP PROGRAM
260 PRINT B$; : REM PRINT CHR ON SCREEN
270 XMIT$ = XMIT$ + B$: REM ADD SINGLE CHR TO 6 BYTE STRING
280 NEXT X: REM DO IT 6 TIMES
290 PRINT
300 REM
310 REM ******************************************************
320 REM CALL SUBROUTINE TO SEND SIX CHARACTERS TO COM PORT
330 REM ******************************************************
340 REM
350 F=0:REM DATA RECEIVED FLAG. SET NOT RECEIVED.
360 GOSUB 660: REM TRANSMIT 6 BYTE STRING
370 REM RECEIVE INCOMING STRING VIA ON COM(1) STATEMENT...
380 IF F=0 THEN 550
390 REM
400 REM ******************************************************
410 REM REPORT RESULTS RETURNED
420 REM ******************************************************
430 REM
440 A$ = MID$(FULL$, 2, 2): REM SAVE THE DROP
450 B$ = MID$(FULL$, 4, 1): REM SAVE THE COMMAND
460 C$ = MID$(FULL$, 5, 1): REM SAVE THE PORT
470 D$ = MID$(FULL$, 6, 2): REM SAVE THE DATA
480 PRINT : PRINT "Information returned :"
490 PRINT "   Drop is "; A$
500 PRINT "Command is "; B$
510 PRINT "   Port is "; C$
520 PRINT "   Data is "; D$
530 GOTO 150: REM DO IT ALL AGAIN
540 REM
550 A=A+1:IF A=10000 THEN 560 ELSE 380
560 PRINT :PRINT "PICEX Network gone to sleep..."
570 FOR A = 1 TO 10000: NEXT A: RUN
580 REM ******************************************************
590 REM END OF PROGRAM
600 REM ******************************************************
610 REM
620 REM ******************************************************
630 REM TRANSMIT PROGRAM FOLLOWS
640 REM ******************************************************
650 REM
660 FOR X = 1 TO 6: REM SET UP 6 LOOP
670 B$ = MID$(XMIT$, X, 1): REM GET SINGLE CHR
680 REM A = EOF(1): IF A = 0 THEN xxx: REM TEST OP BUFFER FULL
690 D=INP(COMPORT+5):D=D AND &HDF:IF D=0 THEN 690
700 PRINT #1, B$; : REM TRANSMIT SINGLE CHR TO PICEX
710 PRINT B$;
720 NEXT X: REM GET NEXT CHR
730 RETURN
740 REM
750 REM ******************************************************
760 REM COM 1 RECEIVE SERVICE ROUTINE FOLLOWS
770 REM ******************************************************
780 REM
790 IF LOC(1) = 0 THEN RETURN
800 FULL$ = "": REM CLEAR STRING BUFFER
810 RECD$ = INPUT$(1, #1): REM GET CHRS FROM PICEX
820 FULL$ = FULL$ + RECD$: REM ADD TO FULL STRING BUFFER
830 LAST = ASC(RIGHT$(RECD$, 1)): REM GET VERY LAST CHR
840 IF LAST <> 13 THEN 810: REM IS IT CR?, NO GET MORE
850 LENGTH = LEN(FULL$): REM GET LENGTH OF STRING
860 LENGTH = LENGTH - 2: REM SUBTRACT LAST LF,CR PAIR COUNT
870 FULL$ = LEFT$(FULL$, LENGTH): REM DELETE LAST LF,CR CHRS
880 RECD$ = RIGHT$(FULL$, 6): REM DELETE SPACE. 6 BYTE MSG NOW IN RECD$
890 REM
900 REM ******************************************************
910 REM RECD$ = 6 BYTE MSG. FULL$ = FULL MSG RETURNED
920 REM LENGTH = LENGTH OF FULL$
930 REM ******************************************************
940 REM
950 F=1:REM DATA RECEIVED FLAG
960 PRINT FULL$: REM ADD LF ,CR FOR SCREEN FORMAT ONLY. PRINT FULL STRING
970 RETURN
980 REM ******************************************************
990 REM RESET COM1 UART
1000 REM ******************************************************
1010 REM
1020 REM PROGRAM TO RESET COM1
1030 ADDRESS% = COMPORT
1040 DAT% = INP(ADDRESS% + 3)

1050 DAT% = DAT% AND 127
1060 OUT (ADDRESS% + 3), DAT%
1070 REM
1080 FOR I% = 0 TO 7
1090 DAT% = INP(ADDRESS%)
1100 ADDRESS% = ADDRESS% + 1
1110 NEXT I%
1120 REM
1130 ADDRESS% = COMPORT
1140 DAT% = INP(ADDRESS% + 3)
1150 DAT% = DAT% OR 128
1160 OUT (ADDRESS% + 3), DAT%
1170 REM
1180 REM NOW RE-READ THE REGISTERS WITH THE DLAB=1 TO READ OTHER REGISTERS
1190 FOR I% = 0 TO 7
1200 DAT% = INP(ADDRESS%)
1210 ADDRESS% = ADDRESS% + 1
1220 NEXT I%
1230 RETURN
1240 REM ******************************************************
1250 REM ERROR HANDLER ROUTINE
1260 REM ******************************************************
1270 REM
1280 PRINT:PRINT "ERROR"; ERR
1290 IF ERR = 24 THEN PRINT "PICEX Cable not connected."
1300 IF ERR = 57 THEN PRINT "Device I/O Error."
1310 RESUME 1320
1320 FOR A = 1 TO 10000: NEXT A: RUN
1330 REM
Back to The Table of Contents.

PICEX Commands:

PICEX Operation Summary

The full control of a PICEX network can be achieved using only a terminal program on any PC or a standard VDU that has an RS-232 port. Alternatively, a Basic or other controlling program can be easily written to drive PICEX under full software control. The controlling unit can also be a suitably designed stand alone Micro-controller.

The Comms Port setting for PICEX is 9600 baud, no parity, 8 data bits, and 1 stop bit. (9600,N,8,1).

This can be set from DOS with a MODE COM1: 9600,N,8,1

NODE is the board identification. Also known as the board or drop number.

This Node is burnt into the program of the PIC16C57-XT/P chip. It can't be changed and is usually set by me as "DROP ZERO", however it could be any number between 00 and FFHex. On request, I can make it any number. If multiple boards are ordered together, these drops will all be different.

An internal Watch Do g Timer has been set with a timeout of about 2 seconds. If any unit locks up for any reason, the "WDT" should restart the PIC back to its Power up condition. This includes any "lost" communication signals.

EZ-6 Command Language...

It requires six (ASCII) Upper Case Text characters to write to a serial driven PICEX board. I have called this 6 byte command string the "EZ-6 Command Language". These six bytes represent four fields and in order, are as follows:
  1. Node. 2 bytes
  2. Command. 1 byte
  3. Port. 1 byte
  4. Data. 2 bytes
  1. Node is the board identification. This value can be from 00 to FFHex, (0 to 255 decimal). Board 0 is usually the first board connected to your COM1: serial port. Board 1 is usually the next one and so on, but they don't need to be in order. There can be up to 256 boards on line. A 3 wire circuit hooked up with DB-25 type connectors is all that is required for this simple network.
  2. Command is an upper case letter of the alphabet used to control PICEX. The command summary and examples are given in more detail later.
  3. Port selects a PICEX port. This can be A (4bits), B, or C. Only two bits of port A are accessible to the user. These are bits 2 and 3 as bits 0 and 1 are reserved for the serial communications. B and C are full 8 bit ports.
  4. Data is the data byte sent to PICEX. There are two modes of operation. (a) Byte manipulation. (b) Bit manipulation.
In byte mode, all data transfers are done as 8 bits of data. Bit mode only deals with a single bit. The data format is in Hex, the same as the Node field. In bit format the MSB is port pin 0 to 7, and the LSB is the logic level 0 to 1. 0 is low, 1 is high.

Experienced programmers will use both modes. Novices will find the bit mode very easy as no knowledge of Hex arithmetic is required. Well, not unless you go past board 9.

Command Summary

Byte modes:
R Reads a byte from a port.                               (00 to FFHex.)
W writes a byte to a port.                                (00 to FFHex.)
P will Program a port for input or output direction.        (0=Out/1=In)

Bit modes:
I Inputs a single bit from a port.                        (b7-b0>D0=0/1)
O Outputs to a single port bit.                           (b7-b0>D0=0/1)
C will Configure a port bit for input or output direction.  (O=Out/1=In)
NOTE *** Port A bits 0 and 1 are protected against user programmed direction and level changes as they are reserved for Serial Communications.

Plus these General Commands:

L is a Loopback test between ports B & C and does a bit of LED flashing on the Port A LEDs. Used during initial board assembly level and general testing. Read the PICEX assembly instructions for full loopback wiring details. Also tests an RS-232 string which transmits my "Name-Address Fanfare".

D is I/O Direction readback. The "TRIS" or "Direction" registers in a PIC chip are write only. I have emulated a read function in software so that I/O settings can be read and verified by the user at any time.

M is Master Reset. This returns PICEX to its power up or Reset state.

T will Test all boards and report the total Nodes (boards) on line.

and V will return the PICEX version number. That's it.

I have kept all read and write data transfers as close as possible to the original PIC chip architecture.

STOP.
Please Note. These commands are writtten in the true ASCII mode file and need to be viewed or printed correctly.
--------------------snip------------------------
Download picexcmd.zip (5.8K) to view or print this snipped section:
--------------------snip------------------------
Not only didn't the ASCII look good, the use of 'less than' and 'greater than' symbols in my commands, conflicted greatly with 'html' commands. Sorry!
CONTINUED.

Followed by this response from the active Node:

PICEX Version 1.0 by Don McKenzie
P.O. Box 595 Tullamarine 3043
Australia Phone (03)9-338-6286
Updated 12-Jul-94(c)
A loopback plug of 8 by 10K resistors must be wired up to a dummy female socket or the end of a ribbon cable to either J1 or J2. See the PICEX assembly instructions for full details.

During this test, the RA2 and RA3 LEDs are toggled. The test sequence is as follows:

LED RA2 OFF, LED RA3 OFF. These are cleared on entry to this test.

1 Second delay.
LED RA2 ON, LED RA3 OFF
Test 1. Tests done with Port B as Output, and Port C as Input.

1 Second delay.
LED RA2 ON, LED RA3 ON
Test 2. Tests done with Port B as Input, and Port C as Output.

1 Second delay.
LED RA2 OFF, LED RA3 OFF. This unit passed the Loopback test.

If at any time an error is detected, a 1 second delay is followed by LED RA2 ON, and RA3 ON.

Conclusion:
Good test, both LEDs are turned off.
Bad test, both LEDs remain on.

The LEDs can be cleared very easily with a 'M'aster reset or Reset button.

Any one into PIC design can set up a very simple stand alone tester using a PIGMY board that outputs the 'L'oopback test (6 times 'L') when Reset is pressed and software debounced. Results will be shown on the LEDs of the unit under test.

GARBAGE.....

Clearing garbage on initial RS-232 connection to the network.

ZZZZZZ ZZZZZZ
If you send six Z's to the network, you would expect to get a space then six Z's back followed by a LFCR pair. If you don't, you test for characters returned, wait for a possible return of six, then repeat the procedure until you get the correct data back. This can be done at the start of your controlling program.

In the case of error reporting in PICEX, most general user input errors are trapped. It is up to the user to understand and minimize these input errors as PICEX has a limited ability in detecting these user generated errors.

Back to The Table of Contents.

Windows Terminal Program:

Updated 1-Sep-94
You can use the Terminal program in Windoze 3.1 for quick PICEX testing as follows:

Windoze >> Program Manager >> Accessories >> Terminal >>

Settings >> Terminal Preferences >> Local Echo set to on...
THEN Communications >> 9600, 8 data bits, Parity none, flow control none.

When comms is established with PICEX, you can save the settings to the file "PICEX.TRM".

Back to The Table of Contents.

Walking LED Basic Program:

10 DEFINT B-Z: COMPORT = &H3F8: REM SET COM PORT
20 GOSUB 1690: REM RESET COM1 UART
30 CLS : CLOSE : LOCATE , , 1: REM TIDY UP, SET CURSOR ON
40 PRINT "WALKING LED TEST PROGRAM FOR PICEX SERIAL NETWORK"
50 PRINT "by Don McKENZIE 18-Sep-94(c)"
60 PRINT "P.O. Box 595 TULLAMARINE 3043 AUSTRALIA": PRINT
70 PRINT "This is the same as the PICEX Local Power Up Diagnostics."
80 PRINT "but only uses Port B for this Test."
75 PRINT
90 PRINT "Press space bar to exit..."
100 ON ERROR GOTO 1950
110 COM(1) ON:ON COM(1) GOSUB 1460
120 OPEN "COM1:9600,N,8,1,CS10" FOR RANDOM AS #1: REM SET COMMS
130 XMIT$ = "": REM CLEAR TRANSMIT STRING
140 REM
150 XMIT$="00PA00"
160 GOSUB 1070:PRINT" Program Port A as Output";
170 XMIT$="00PB00"
180 GOSUB 1070:PRINT" Program Port B as Output"
190 XMIT$="00WA00"
200 GOSUB 1070:PRINT" Clear Port A LEDs"
210 GOSUB 1000:PRINT:REM CLEAR Port B LEDS
220 REM
230 REM COUNT = 0 FOLLOWS
240 REM
250 XMIT$="00OB01"
260 GOSUB 1070:PRINT" Set Port B Bit 0 High";
270 GOSUB 950:REM DELAY
280 REM
290 REM COUNT = 1 FOLLOWS
300 REM
310 GOSUB 1000: REM CLEAR Port B LEDS
320 XMIT$="00WA04"
330 GOSUB 1070:PRINT" Set Port A Bit 2 High";
340 XMIT$="00OB11"
350 GOSUB 1070:PRINT" Set Port B Bit 1 High";
360 GOSUB 950:REM DELAY
370 REM
380 REM COUNT = 2 FOLLOWS
390 REM
400 GOSUB 1000:REM CLEAR Port B LEDS
410 XMIT$="00WA08
420 GOSUB 1070:PRINT" Set Port A Bit 3 High";
430 XMIT$="00OB21"
440 GOSUB 1070:PRINT" Set Port B Bit 2 High";
450 GOSUB 950:REM DELAY
460 REM
470 REM COUNT = 3 FOLLOWS
480 REM
490 GOSUB 1000:REM CLEAR Port B LEDS
500 XMIT$="00WA0C"
510 GOSUB 1070:PRINT" Set Port A Bits 2 and 3 High";
520 XMIT$="00OB31"
530 GOSUB 1070:PRINT" Set Port B Bit 3 High";
540 GOSUB 950:REM DELAY
550 REM
560 REM COUNT = 4 FOLLOWS
570 REM
580 GOSUB 1000:REM CLEAR Port B LEDS
590 XMIT$="00WA00"
600 GOSUB 1070:PRINT" Clear Port A LEDs"
610 XMIT$="00OB41"
620 GOSUB 1070:PRINT" Set Port B Bit 4 High";
630 GOSUB 950:REM DELAY
640 REM
650 REM COUNT = 5 FOLLOWS
660 REM
670 GOSUB 1000:REM CLEAR Port B LEDS
680 XMIT$="00WA04"
690 GOSUB 1070:PRINT" Set Port A Bit 2 High";
700 XMIT$="00OB51"
710 GOSUB 1070:PRINT" Set Port B Bit 5 High";
720 GOSUB 950:REM DELAY
730 REM
740 REM COUNT = 6 FOLLOWS
750 REM
760 GOSUB 1000:REM CLEAR Port B LEDS
770 XMIT$="00WA08
780 GOSUB 1070:PRINT" Set Port A Bit 3 High";
790 XMIT$="00OB61"
800 GOSUB 1070:PRINT" Set Port B Bit 6 High";
810 GOSUB 950:REM DELAY
820 REM
830 REM COUNT = 7 FOLLOWS
840 REM
850 GOSUB 1000:REM CLEAR Port B LEDS
860 XMIT$="00WA0C"
870 GOSUB 1070:PRINT" Set Port A Bits 2 and 3 High";
880 XMIT$="00OB71"
890 GOSUB 1070:PRINT" Set Port B Bit 7 High";
900 GOSUB 950:REM DELAY
910 GOTO 190
920 REM
930 REM COUNT FINISHED
940 REM
950 PRINT" and Delay...":FOR A = 1 TO 2000
960 B$ = INKEY$: REM GET KEYBOARD CHR
970 IF B$ = " " THEN CLOSE #1: SYSTEM: REM SPACE WILL STOP PROGRAM
980 NEXT A:REM DELAY
990 PRINT:RETURN
1000 XMIT$="00WB00"
1010 GOSUB 1080:PRINT " Clear all LEDs on Port B";
1020 RETURN
1030 REM ******************************************************
1040 REM CALL SUBROUTINE TO SEND SIX CHARACTERS TO COM PORT
1050 REM ******************************************************
1060 REM
1070 PRINT
1080 B$ = INKEY$: REM GET KEYBOARD CHR
1090 IF B$ = " " THEN CLOSE #1: SYSTEM: REM SPACE WILL STOP PROGRAM
1100 F=0:REM DATA RECEIVED FLAG. SET NOT RECEIVED.
1110 GOSUB 1330: REM TRANSMIT 6 BYTE STRING
1120 REM RECEIVE INCOMING STRING VIA ON COM(1) STATEMENT...
1130 IF F=0 THEN 1250
1140 REM
1150 REM ******************************************************
1160 REM REPORT RESULTS RETURNED
1170 REM ******************************************************
1180 REM
1190 A$ = MID$(FULL$, 2, 2): REM SAVE THE DROP
1200 B$ = MID$(FULL$, 4, 1): REM SAVE THE COMMAND
1210 C$ = MID$(FULL$, 5, 1): REM SAVE THE PORT
1220 D$ = MID$(FULL$, 6, 2): REM SAVE THE DATA
1230 RETURN
1240 REM
1250 A=A+1:IF A=10000 THEN 1260 ELSE 1130
1260 PRINT :PRINT "PICEX Network gone to sleep..."
1270 FOR A = 1 TO 10000: NEXT A: RUN
1280 REM
1290 REM ******************************************************
1300 REM TRANSMIT PROGRAM FOLLOWS
1310 REM ******************************************************
1320 REM
1330 FOR X = 1 TO 6: REM SET UP 6 LOOP
1340 B$ = MID$(XMIT$, X, 1): REM GET SINGLE CHR
1350 REM A = EOF(1): IF A = 0 THEN xxx: REM TEST OP BUFFER FULL
1360 D=INP(COMPORT+5):D=D AND &HDF:IF D=0 THEN 1360
1370 PRINT #1, B$; : REM TRANSMIT SINGLE CHR TO PICEX
1380 PRINT B$;
1390 NEXT X: REM GET NEXT CHR
1400 RETURN
1410 REM
1420 REM ******************************************************
1430 REM COM 1 RECEIVE SERVICE ROUTINE FOLLOWS
1440 REM ******************************************************
1450 REM
1460 IF LOC(1) = 0 THEN RETURN
1470 FULL$ = "": REM CLEAR STRING BUFFER
1480 RECD$ = INPUT$(1, #1): REM GET CHRS FROM PICEX
1490 FULL$ = FULL$ + RECD$: REM ADD TO FULL STRING BUFFER
1500 LAST = ASC(RIGHT$(RECD$, 1)): REM GET VERY LAST CHR
1510 IF LAST <> 13 THEN 1480: REM IS IT CR?, NO GET MORE
1520 LENGTH = LEN(FULL$): REM GET LENGTH OF STRING
1530 LENGTH = LENGTH - 2: REM SUBTRACT LAST LF,CR PAIR COUNT
1540 FULL$ = LEFT$(FULL$, LENGTH): REM DELETE LAST LF,CR CHRS
1550 RECD$ = RIGHT$(FULL$, 6): REM DELETE SPACE. 6 BYTE MSG NOW IN RECD$
1560 REM
1570 REM ******************************************************
1580 REM RECD$ = 6 BYTE MSG. FULL$ = FULL MSG RETURNED
1590 REM LENGTH = LENGTH OF FULL$
1600 REM ******************************************************
1610 REM
1620 F=1:REM DATA RECEIVED FLAG
1630 PRINT FULL$;: REM ADD LF ,CR FOR SCREEN FORMAT ONLY. PRINT FULL STRING
1640 RETURN
1650 REM ******************************************************
1660 REM RESET COM1 UART
1670 REM ******************************************************
1680 REM
1690 REM PROGRAM TO RESET COM1
1700 ADDRESS% = COMPORT
1710 DAT% = INP(ADDRESS% + 3)
1720 DAT% = DAT% AND 127
1730 OUT (ADDRESS% + 3), DAT%
1740 REM
1750 FOR I% = 0 TO 7

1760 DAT% = INP(ADDRESS%)
1770 ADDRESS% = ADDRESS% + 1
1780 NEXT I%
1790 REM
1800 ADDRESS% = COMPORT
1810 DAT% = INP(ADDRESS% + 3)
1820 DAT% = DAT% OR 128
1830 OUT (ADDRESS% + 3), DAT%
1840 REM
1850 REM NOW RE-READ THE REGISTERS WITH THE DLAB=1 TO READ OTHER REGISTERS
1860 FOR I% = 0 TO 7
1870 DAT% = INP(ADDRESS%)
1880 ADDRESS% = ADDRESS% + 1
1890 NEXT I%
1900 RETURN
1910 REM ******************************************************
1920 REM ERROR HANDLER ROUTINE
1930 REM ******************************************************
1940 REM
1950 PRINT:PRINT "ERROR"; ERR
1960 IF ERR = 24 THEN PRINT "PICEX Cable not connected."
1970 IF ERR = 57 THEN PRINT "Device I/O Error."
1980 RESUME 1990
1990 FOR A = 1 TO 10000: NEXT A: RUN
2000 REM
What's Really HOT at Dontronics?
Don's Download Dungeon
Home Products Prices Site Map Order Contact What's New Books Free Files Links FAQ

Dontronics Home Page


Copyright © 1996-99 Dontronics
 
Top of Page