;******************************************************** ;* * ;* COM's Optoisolation unit * ;* * ;* * ;* AirBorn Electronics * ;* Steven Murray * ;******************************************************** $TITLE (* AirBorn Electronics COM's Optoisolation unit) USING 0 ;Using reg bank 0|title should end here ^ ;TARGET: This code is intended for the 87C751 microprocessor, which has ;2 kilobytes of EPROM, 64 bytes of RAM, and an 8051 instruction set minus two ;instructions: Ljmp and Lcall, which are not a lot of use with only 2k of code. ;Commands follow to allow for 87C751 regs, The file "C751REGS.obj" must be ;linked in also EXTRN data (RTH, RTL, I2CON, I2DAT, I2CFG, I2STA) EXTRN bit (I2CON_0,I2CON_1,I2CON_2,I2CON_3,I2CON_4) EXTRN bit (I2CON_5,I2CON_6,I2CON_7) EXTRN bit (I2CFG_0,I2CFG_1,I2CFG_2,I2CFG_3,I2CFG_4) EXTRN bit (I2CFG_5,I2CFG_6,I2CFG_7) EXTRN bit (I2STA_0,I2STA_1,I2STA_2,I2STA_3,I2STA_4) EXTRN bit (I2STA_5,I2STA_6,I2STA_7) ;Interrupt vector addresses remain as with the 8051, with the timer on the ;87C751 using the 8051 timer 0 location (00Bh), Timer I using the 8051 timer 1 ;vector (01Bh) and i2c serial using the 8051 serial vector (023h). ; ; !!!!! WARNING !!!!! Before downloading OPTOISOL.HEX or TOTAL.HEX down to ;EPROM, for the final target software, fill the EPROM programmers memory with ;FFh, so that the unused memory area may be used in the future for an alternate ;application. Failure to do this will render One-time-programmable 87C751 ;microprocessors (the vast majority of them) nearly useless if there is even ;a small bug in the program, or if a different application is desired !!!!! ;As part of this concept of being able to do small modifications and additions ;to already programmed 'one time programmable' microprocessors, 'Pad' and ;'mov R7, A' are placed at strategic locations in code - see 'Modifications' ; Crystal equ 1 ;Crystal frequency: 0 = 11.0592 Mhz, 1 = 12Mhz Pad equ 0FFh ;Value used for padding space in EPROM, used in ; unexecuted space. 'Mov R7, A' is used in executed ; code, but has the same value - 0FFh. R7 is junked. BrkBits equ 33 ;Number of bit-times a break condition will be ; transmitted for - longer than this, and it is cut. ; ;R0 loc 00h see below ;R1 loc 01h spare ;R2 loc 02h General use register ;R3 loc 03h General use register ;R4 loc 04h Number of bits to receive, bit timer for break ;R5 loc 05h see below ;R6 loc 06h spare ;R7 loc 07h ;Junked by pad instruction: mov R7, A ; RMASK equ R0 ;Receive mask - a 1 in a bit indicates receive pin DIPSWDAT equ R5 ;Assembled dip-switch data - a closed switch is a 1 TEMP equ 08h ;Temporary variable IDLEDAT equ 09h ;Idle data, the comparison byte used to see a 1 to 0 ; transition on an input - a start bit ; loc 0Ah - 2Fh spare STACKBAS equ 30h ;Stack from 30h up ; ; ; CSEG AT 0h SYSRESET: nop ;Leave this NOP here - it defeats one of the early mask ; 80C31 bugs, just in case this code is used on one. ajmp APPLTEST ; CSEG AT 3h EXTINT0: db Pad, Pad, Pad, Pad, Pad, Pad, Pad, Pad ;No Interrupt vectors are used in the optoisol code, ; so this area filled with Pad bytes. CSEG AT 0Bh T0INT: db Pad, Pad, Pad, Pad, Pad, Pad, Pad, Pad ; CSEG AT 13h EXTINT1: db Pad, Pad, Pad, Pad, Pad, Pad, Pad, Pad ; CSEG AT 1Bh TIMERI: db Pad, Pad, Pad, Pad, Pad, Pad, Pad, Pad ; CSEG AT 23h I2CINT: db Pad, Pad, Pad, Pad, Pad, Pad, Pad, Pad ; CSEG AT 2Bh APPLTEST: mov R7, A ;Overwriteable padding (see 'Modifications') mov R7, A mov A, P0 ;Get Port 0 - the TxData port on OPTOISOL anl A, #7 ;Just look at the TxData bits jz TSTP01 ;Test if 3 bits are all zero xrl A, #7 ;Test if 3 bits are all one jnz ALTAPPL ;Bits are different - run alternate application TSTP01: mov P0, #5 ;Set P0.1 low - other bits left high mov R7, A ;Delay to let signals stabilize mov A, P0 ;Get the TxData bits back mov P0, #7 ;(Set P0.1 high again) anl A, #7 ;Mask out all but the TxData bits jnz ALTAPPL ;If P0.0 and P0.2 have NOT followed P0.1, then ; they are not tied together, this cannot be ; a OPTO-ISOL board, run alternate application ajmp OPTOISOL ; ;*** Alternative application may be placed here. *** ;The only constraints on the alternative application is that P0.0-P0.2 may not ;be tied together, and P0.1 will be pulse low for 3us after reset (being SDA ;this shouldn't matter). Alternative application may use any interrupt vectors ;it requires. With optoisol.asm April 1990 there is 1.5k avail for Alt appl. ; ALTAPPL: ajmp OPTOISOL ;If not using alt application, do only optoisol ;When fitting alternative application, place two ;NOPs at the start, which will overwrite this ;jump. CSEG AT 6A0h OPTOISOL: mov R7, A ;Overwriteable padding (see 'Modifications') mov R7, A mov P1, #0E0h ;Turn off all Tx Enables mov SP, #STACKBAS ;Initialize the stack pointer mov R2, #255 ;Number of initial watchdog pumps PONLOOP: mov R3, #50 ;Delay time in each cycle PONLOOP2: djnz R3, PONLOOP2 ;Do the delay xrl P0, #7 ;Complement the TxData lines djnz R2, PONLOOP ;Loop until entire delay finished ;Delay is 106*255 mach cycles, (27ms @ 12 Mhz) acall READDS ;Go read the dipswitch ; TxOFF: mov R7, A ;Overwriteable padding (see 'Modifications') mov R7, A mov P1, #0E0h ;Turn off all Tx Enables mov IDLEDAT, P3 ;Get reference levels from receive port ;***1 TIME CRITICAL SECTION ;Code should take very nearly 9 cyc to (***2) IDLEWAIT: ; clr A ;Debug code to run watchdog -Proto only ; movx @R0, A ;Pulse TxOut low -Proto only ; mov A, #0FFh ; -Proto only ; movx @R0, A ;Pulse TxOut high again -Proto only mov A, P3 ;Get the receive inputs orl IDLEDAT, A ;If any inputs are high, set IDLEDAT bits cpl A ;Make Rx inputs at 0 into set bits in A anl A, IDLEDAT ;AND - any 1 to 0 transition now a set bit in A anl A, #1Fh ;Just look at valid Rx inputs xrl P0, #7 ;Pulse TxData lines - keep WDOG off jz IDLEWAIT ;Loop until we see a start bit ;***2 TIME CRITICAL SECTION ;Code should be around 20+(n*4) cyc to (***3) mov RMASK, A ;Save the receive mask mov R7, A ;Padding to get time delay right START: mov R7, A mov R7, A acall HALFDEL ;Do a half bit delay, to get us to the middle ; of the start bit jnz TxOff ;Abort if we see a false start bit ;***3 TIME CRITICAL SECTION ;Code should be around 48+(n*4) cyc to (***4) acall TxDat0 ;Set TxData lines low (output START bit) mov A, RMASK ;Get the receive mask cpl A ;The receive channel becomes a 0 bit anl A, P3 ;Any Rx channel at space becomes a 0 bit orl A, #0E0h ;Mask off all but valid Tx Outputs mov P1, A ;Put to Tx Enables mov A, DIPSWDAT ;Get the dipswitch data anl A, #38h ;Look at the number-of-bits switches rr A ;Shift switches until in bits 0-2 rr A rr A add A, #(NBITTAB-OFF5) ;Offset to address lookup table movc A, @A+PC ;Get the number of bits corresponding to the OFF5: ; dipswitch setting mov R4,A ;Save the number of bits to receive in R4 mov R7, A ;8 cycle delay for correct execution time mov R7, A mov R7, A mov R7, A mov R7, A mov R7, A mov R7, A mov R7, A ANOTHBIT: mov R7, A ;2 cycle delay for correct execution time mov R7, A acall BITDEL ;Go delay for a bit time jnz RECVD1 ;Jump if we have received a 1 bit ;***4 TIME CRITICAL SECTION ;Code should be around 48+(n*4) cyc in loop ; back to (***4), and 48+(n*4) cyc to (***5) RECVD0: acall TxDat0 ;Set Tx Data lines low (A 0 data bit) ajmp TSTBITS RECVD1: acall TxDat1 ;Set Tx Data lines high (A 1 data bit) ajmp TSTBITS ;This unnecessary jump equalizes exec times TSTBITS: mov R2, A ;Save A, A being the received serial data acall READDS ;Go sample the dipswitch djnz R4, ANOTHBIT ;Loop until a whole character is received mov A, R2 ;Restore A to do test for valid stop bit DOSTOP: jnz STOPDEL ;If we have a valid stop bit, do the delay ;***5 TIME CRITICAL SECTION (thru STOPDEL) ;Code should be approx 48+(n*6) cyc to (TxOff) ;We have a framing error, Break or line locked ; low mov R4, #BrkBits ;Load a break count in to R4 ajmp BRKDEL ;Keep outputting the low condition for up to ; 33 more bit times, or until the line goes ; high, whichever is sooner. This will give ; better performance during those times when ; the COM's opto-isolator is not properly ; sync'ed into the data stream. ; READDS: ;Read dipswitch, make closed (ON) dipswitch ; bits into ones, save in DIPSWDAT mov TEMP, P3 ;Get upper bits of dipswitch data anl TEMP, #0E0h ;Keep just the dipswitch data mov A, P1 ;Get the lower bits of the dipswitch data anl A, #0E0h ;Mask out floss rr A ;Move bits so dipswitch data is in bits 2-4 rr A rr A orl A, TEMP ;OR in the upper bits of the dipswitch rr A ;Rotate so the dipswitch data is in bits 0-5 rr A xrl A, #3Fh ;Invert the dipswitch data - ON's now 1's. mov DIPSWDAT, A ;Put the dipswitch data in memory for other ; routines to use ret ;All done, taken 16 cycles, plus call ; HALFDEL: ;Delay for half a bit time. Time critical. mov A, DIPSWDAT ;Get the dipswitch data anl A, #7 ;Look at just the baud rate selection bits add A, #((RATTAB1-OFF1)+(8*Crystal)) ;Offset to address lookup tab movc A, @A+PC ;Get delay value corresponding to baud rate OFF1: mov R2, A ;Put delay value to register for DJNZ loop DELOOP1: mov A, P3 ;Get the receive pins anl A, RMASK ;Mask to see the current receive pin djnz R2, DELOOP1 ;Loop until the delay is complete ret ;All done, taken 12+(4*n) cycles, plus call ; BITDEL: ;Delay for a bit time. Time critical mov A, DIPSWDAT ;Get the dipswitch data anl A, #7 ;Look at just the baud rate selection bits add A, #((RATTAB2-OFF2)+(8*Crystal)) ;Offset to address lookup tab movc A, @A+PC ;Get delay value corresponding to baud rate OFF2: mov R2, A ;Put delay value to register for DJNZ loop DELOOP2: mov A, P3 ;Get the receive pins anl A, RMASK ;Mask to see the current receive pin djnz R2, DELOOP2 ;Loop until the delay is complete ret ;All done, taken 12+(4*n) cycles, plus call ; STOPDEL: ;A Special version of BITDEL that tests for a ; new start bit transition and is jumped to ; rather than called. Time critical. mov R7, A ;Overwriteable padding (see 'Modifications') mov R7, A mov A, DIPSWDAT ;Get the dipswitch data anl A, #7 ;Look at just the baud rate selection bits add A, #((RATTAB3-OFF3)+(8*Crystal)) ;Offset to address lookup tab movc A, @A+PC ;Get delay value corresponding to the baud rate OFF3: mov R2, A ;Put the delay value to R2 for djnz loop DELOOP3: mov A, P3 ;Get the receive pins anl A, RMASK ;Mask with the receive mask jz NEWSTART ;Jump out if the start bit is seen djnz R2, DELOOP3 ;Loop until delay complete ajmp TxOFF ;Done, leave, taken 14+(6*n) cycles, plus call ; NEWSTART: mov R7, A ;Overwriteable padding (see 'Modifications') mov R7, A ajmp START ; BRKDEL: ;A Special version of BITDEL (Similar to ; STOPDEL) that looks for transition to mark. mov R7, A ;Overwriteable padding (see 'Modifications') mov R7, A mov A, DIPSWDAT ;Get the dipswitch data anl A, #7 ;Look at just the baud rate selection bits add A, #((RATTAB3-OFF4)+(8*Crystal)) ;Offset to address lookup tab movc A, @A+PC ;Get delay value corresponding to the baud rate OFF4: mov R2, A ;Put the delay value to R2 for djnz loop DELOOP4: mov A, P3 ;Get the receive pins anl A, RMASK ;Mask with the receive mask jnz BOUT ;Jump out if mark condition is seen djnz R2, DELOOP4 ;Loop until delay complete djnz R4, DELOOP4 ;Loop until bit-times for break is finished BOUT: acall HalfDel ;Delay for half a bit time acall TxDat1 ;Go set the output to MARK ajmp TxOFF ;Done, leave, taken 16+(6*n) cycles, plus call ; ;*** Table of Baud rate values ;Formula: Period=(1000,000 / baud_rate) us ; Cycles=Period * (Crystal / 12) ; Halftab=( ((Cycles/2)-24) /4) +1 ; Fulltab= (( Cycles - 48 ) /4) +1 ; Stoptab= (( Cycles - 16 ) /6) +1 RATTAB1: ;Crystal= 11.0592 Mhz, halftable db 1 ;Dipswitch=000, Baud rate 19,200 db 7 ;Dipswitch=001, Baud rate 9,600 db 11 ;Dipswitch=010, Baud rate 7,200 db 19 ;Dipswitch=011, Baud rate 4,800 db 43 ;Dipswitch=100, Baud rate 2,400 db 91 ;Dipswitch=101, Baud rate 1,200 db 91 ;Dipswitch=110, Baud rate 1,200 db 91 ;Dipswitch=111, Baud rate 1,200 ; ;Crystal= 12 Mhz, halftable db 1 ;Dipswitch=000, Baud rate 19,200 db 8 ;Dipswitch=001, Baud rate 9,600 db 12 ;Dipswitch=010, Baud rate 7,200 db 21 ;Dipswitch=011, Baud rate 4,800 db 47 ;Dipswitch=100, Baud rate 2,400 db 99 ;Dipswitch=101, Baud rate 1,200 db 99 ;Dipswitch=110, Baud rate 1,200 db 99 ;Dipswitch=111, Baud rate 1,200 ; RATTAB2: ;Crystal= 11.0592 Mhz, fulltable db 1 ;Dipswitch=000, Baud rate 19,200 db 13 ;Dipswitch=001, Baud rate 9,600 db 21 ;Dipswitch=010, Baud rate 7,200 db 37 ;Dipswitch=011, Baud rate 4,800 db 85 ;Dipswitch=100, Baud rate 2,400 db 181 ;Dipswitch=101, Baud rate 1,200 db 181 ;Dipswitch=110, Baud rate 1,200 db 181 ;Dipswitch=111, Baud rate 1,200 ; ;Crystal= 12 Mhz, fulltable db 2 ;Dipswitch=000, Baud rate 19,200 db 15 ;Dipswitch=001, Baud rate 9,600 db 24 ;Dipswitch=010, Baud rate 7,200, 0.7% error db 41 ;Dipswitch=011, Baud rate 4,800 db 93 ;Dipswitch=100, Baud rate 2,400, 0.25% error db 197 ;Dipswitch=101, Baud rate 1,200, 0.12% error db 197 ;Dipswitch=110, Baud rate 1,200 db 197 ;Dipswitch=111, Baud rate 1,200 ; RATTAB3: ;Crystal= 11.0592 Mhz, stoptable db 6 ;Dipswitch=000, Baud rate 19,200 db 14 ;Dipswitch=001, Baud rate 9,600 db 20 ;Dipswitch=010, Baud rate 7,200 db 30 ;Dipswitch=011, Baud rate 4,800 db 62 ;Dipswitch=100, Baud rate 2,400 db 126 ;Dipswitch=101, Baud rate 1,200 db 126 ;Dipswitch=110, Baud rate 1,200 db 126 ;Dipswitch=111, Baud rate 1,200 ; ;Crystal= 12 Mhz, stoptable db 7 ;Dipswitch=000, Baud rate 19,200 db 16 ;Dipswitch=001, Baud rate 9,600 db 21 ;Dipswitch=010, Baud rate 7,200 db 33 ;Dipswitch=011, Baud rate 4,800 db 68 ;Dipswitch=100, Baud rate 2,400 db 137 ;Dipswitch=101, Baud rate 1,200 db 137 ;Dipswitch=110, Baud rate 1,200 db 137 ;Dipswitch=111, Baud rate 1,200 ; NBITTAB: ;Table of number of bits in character ;Number is data+stop+parity, without start db 8 ;Dipswitch=000, 7 bits, no parity, 1 stop db 9 ;Dipswitch=001, 7 bits, no parity,2 stop db 9 ;Dipswitch=010, 7 bits, 1 parity, 1 stop db 10 ;Dipswitch=011, 7 bits, 1 parity, 2 stop db 9 ;Dipswitch=100, 8 bits, no parity, 1 stop db 10 ;Dipswitch=101, 8 bits, no parity, 2 stop db 10 ;Dipswitch=110, 8 bits, 1 parity, 1 stop db 11 ;Dipswitch=111, 8 bits, 1 parity, 2 stop ; db 'Coms Optoisol' db '(C) 1994 AirBorn' ; db Pad, Pad, Pad, Pad, Pad, Pad, Pad, Pad ;Spare for mods db Pad, Pad, Pad, Pad, Pad, Pad, Pad, Pad db Pad, Pad, Pad, Pad, Pad, Pad, Pad, Pad db Pad, Pad, Pad, Pad, Pad, Pad, Pad, Pad db Pad, Pad, Pad, Pad, Pad, Pad, Pad, Pad db Pad, Pad, Pad, Pad, Pad, Pad, Pad, Pad TxDat0: mov P0, #0 ;Set TxData to 0 - rem out for prototype clr A ;Clear accumulator -Proto only ;movX @R0, A ;Output 0 to external latch - rem out for prod. ret ;All done, takes 5 cycles, plus call TxDat1: mov P0, #7 ;Set TxData to 1 - rem out for prototype mov A, #0FFh ;Set accumulator to 0FFh -Proto only ;movX @R0, A ;Output 0FFh to external latch ; - rem out for prod ret ;All done, takes 5 cycles, plus call ; Debug: ; mov R4, #0FFh ;Start with port 4 =FFh - LED's off ; mov R3, #20h ;Do 20 flashes (Port will end up = FFh) ; mov R2, #0 Delay1: ; mov R1, #40h ;Delay to get a 16Hz LED flash rate Delay2: ; djnz R1, Delay2 ; djnz R2, Delay1 ; mov A, R4 ;Get the current port status ; cpl A ;Complement ; mov R4, A ;Save the current port status ; movX @R0, A ;Put the data to the LED's ; djnz R3, Delay1 ;Loop until all flashes done ; mov R3, #15 ;2 second delay with LED's off Delay3: ; djnz R1, Delay3 ; djnz R2, Delay3 ; djnz R3, Delay3 ; ajmp SYSRESET ; ; ;AirBorn Electronics COM's Opto-isolation unit ; ;This device is intended to optically isolate a spur of RS485 channels on a ;COM's link. This optical isolation can prevent the propagation of faults and ;excessive voltage from one group of COM's devices (eg Peripherals) to another. ;This unit is provided with 5 inputs - any number of which could be optically ;isolated without change to software, but with only one intended to be isolat- ;ed at this stage. ; ;OPERATION ; ;On power up the opto-isolation unit tests pins P0.0-P0.2 to see if they are ;commoned together. In the finished opto-isolation unit they must be commoned ;together for increased drive to opto-isolators. If they are not wired together ;the program vectors to ALTAPPL: which can be another application for the same ;programmed chip. After this test the program disables all the TxEnable ;outputs and starts pulsing TxData. TxData may be used as the input signal for ;a watchdog reset circuit, and these initial pulses are to ensure that the ;watchdog is well and truly "fed" at power on. This also acts as a short power ;on delay. The program then proceeds to normal operation. ; ;The 5 receive inputs are monitored for a falling edge transition - a start bit ;on one of the RS485 serial channels. If one of the channels is continuously ;low, it is ignored until such time as it goes high then low again. Upon seeing ;a proper falling edge on one of the RS485 channels, that channel is nominated ;as the receiving channel by setting a bit in the RMASK byte that corresponds ;to its bit position on the port. The program then proceeds to time out a half ;bit delay, at the baud rate selected on the dipswitch, and then it resamples ;the receive line. If the RS485 line has returned high, then the operation is ;discarded as an invalid start bit, and the program returns to waiting for a ;high to low transition. If the RS485 line is still low, then the program ;proceeds to enabling the remaining RS485 lines for transmission. ; ;The program will transmit out all the lines except the line it is receiving ;from and any lines which are monitored as a continuous low, as here the data ;would be in obvious conflict and there is no sense in transmitting. The ;program will continue sampling the RxData line and transmitting the ;information out on the other RS485 lines until the stop bit in the character ;is reached. ; ;If a valid (high) stop bit is seen, then the program will wait, with its RS485 ;drivers enabled, a further bit delay time - watching for a new start bit. If ;a new start bit is seen in this time then transmission of the next byte will ;resume with no disabling of the buffers. Otherwise the RS485 buffers are all ;disabled until a new start-bit is detected on any one of the lines, whereupon ;the whole cycle begins again. If a new start bit is detected ; ;If an invalid (low) stop bit is seen, then the program keeps transmitting the ;data (- this gives slightly more reliable operation in those situations where ;the com's isolation device has actually lost sync with the incoming data) ;but starts a timer - around 33 bit times. As soon as the line returns high ;the program disables transmission and returns to looking for a valid start ;bit. If the timer should finish, the program disables transmission and ;returns to looking for a valid start bit anyway, ignoring that channel until ;such time as it goes high again. ; ;During normal operation the watchdog reset, if fitted, will be using the ;TxData signal as the monitor signal. This signal might change with a period ;as long and slow as twelve times the baud rate - ie if the lowest used baud ;rate is to be 1200 baud, a 100Hz signal should be capable of reliably holding ;off the watchdog from firing. During those periods when there is no serial ;data being transferred, the program will disable the transmitter outputs and ;will send pulses to the TxData output to feed the watchdog, at 102/111 Khz, ;for crystal frequencies of 11.0592Mhz and 12 Mhz respectively ; ; ;MODIFICATION OF CODE ; ;This product is based around the 87C751 microprocessor, which is an OTP ;product. This means it can never be erased. If modification or correction of ;a bug is required in such a chip, it is normal to throw away the device, but ;this is a little expensive for us. To this end we are following an approach, ;which if followed carefully will allow modification of the product without ;throwing away all the chips. Any location which is programmed to the value ;0FFh can be overwritten at a later time, as long as the security bit on the ;microprocessor has not been blown. To this end, we place a lot of 'mov R7, A' ;instructions (opcode 0FFh) in strategic places. You may alter code by ;replacing these with jump instructions to 'patches' or 'fixes'. You will have ;manage this very carefully on a printout listing first, to ensure the number ;of bytes exactly matches. You should save the before and after .ASM files ;seperately, and keep a careful track of the revision number, using the decimal ;portion for modifications that can be 'Reprogrammed' in OTP chips - eg number ;in sequence V1.0, V1.1, V1.2. Make sure you obey the warning at the front of ;this program listing concerning filling the EPROM programmer memory with FF's ;before you download the file. There is also sufficient room in the EPROM for ;an entirely seperate application, and the trap for it already. ; ; ;HARDWARE ; ;Reference to the circuit diagram of the normal implementation of the COM's ;Opto-isolator would be useful in understanding the hardware. It is important ;to note that while the current unit has five channels, with one optically ;isolated, any number of channels may be optically isolated, and less than ;five channels may ofcourse be fitted merely by ensuring the unused Rx input ;port pins on the microprocessor stay at one stable level or are disconnected. ; ;The microprocessor has 19 I/O pins, all of which are used, although 3 are ;commoned up and could be seperated if an extra buffer was available, leaving ;two spare pins. ; ; ;PINS ON THE 87C751 ; ;Dip-Switch - Positions 1 to 6: P1.5, P1.6, P1.7, P3.7, P3.6, P3.5 (pins 18-23). ; The Dip-Switch should be 6 switches to ground, pullups are inside the micro. ;Receive Inputs, Transmit Outputs, Transmit Enable outputs ; Each of the five channels needs one Receive input and one transmit enable ; output, but they can all share the same Transmit output. These lines are ; TTL compatible, but due to limited sink current when driving optoisolators, ; there are three transmit outputs wired in parallel. ;Receive inputs, 1 to 5: P3.0, P3.1, P3.2, P3.3, P3.4 (pins 5,4,3,2,1). ; Space (=Start) condition is low, Mark (=idle) condition is high ;Transmit enab outputs, 1 to 5: P1.0, P1.1, P1.2, P1.3, P1.4, P1.5 (pins 13-17). ; Receive condition is low, Transmit condition is high ;Transmit outputs, 3 pins in parallel: P0.0, P0.1, P0.2 (pins 6,7,8). ; Space (=Start) condition is low, Mark (=idle) condition is high ;Reset input (RST), active high. Pulse high on power on. If implementing ; watchdog circuit, pulse high if pulses stop of Transmit output for 20ms. ;X1, X2. Crystal connections (11.0592 Mhz or 12 Mhz). Vcc, Gnd. +5v, 0v. ; ; ; Dip-Switch settings for the AirBorn Electronics COM's Optoisolator ; ; Switch postions 1,2,3 set BAUD-RATE, positions 4,5,6 set NUMBER-OF-BITS ; ; Sw1 Sw2 Sw3 ; Off Off Off 19200 Baud ; Off Off On 9600 Baud ; Off On Off 7200 Baud ; Off On On 4800 Baud ; On Off Off 2400 Baud ; On Off On 1200 Baud ; ; Sw4 Sw5 Sw6 ; Off Off Off 7 Bits, no parity, 1 stop (rare) ; Off Off On 7 Bits, no parity, 2 stop ; Off On Off 7 Bits, 1 parity, 1 stop (Sometimes used) ; Off On On 7 Bits, 1 parity, 2 stop ; On Off Off 8 Bits, no parity, 1 stop (Indust standard) ; On Off On 8 Bits, no parity, 2 stop ; On On Off 8 Bits, 1 parity, 1 stop (Often used) ; On On On 8 Bits, 1 parity, 2 stop (rare) ; ; ENSURE PROPER DIPSWITCH SETTING!!! IMPROPER SETTING OF THE ; DIPSWITCHES WILL CAUSE (SOMETIMES INTERMITTENT) PROBLEMS !! ; ; ; Wiring of the AirBorn Electronics COM's Optoisolator ; ; Connectors are clearly labelled on unit, a filtered DC Source of approx ; +12v is required, plus connections to the COM's devices. Each RS-422 ; COM's connection is three wires - COMS+, COMS-, Gnd. These wires go ; to COMs+, COMS-, and Gnd of the connected device - eg PC or peripheral. ; Sometimes only a two wire cable is used, and the ground connection is ; the shield. ; The RS-232 connection, if used, is TxD (Data out of the optoisolator), ; RxD (Data into the optoisolator), Gnd, and occasionally RTS (Direction). ; These wires go to TxD_of_optoisolator --> RxD_of_other_unit, ; RxD_of_optoisolator --> TxD_of_other_unit, Gnd to Gnd. (IE swop over). ; If the RS-232 connection is unused it may be left disconnected only if ; less than half a metre of cable is left connected - much more and you ; will get random noise pickup. ; If any RS-422 connection is unused, it may be left disconnected with up ; to around 50 metres of cable connected, as it is more noise-immune. ; It is rare that you should have to isolate grounds on RS-422 lines - ; if you do, you should be using the opto-isolated port, and connecting ; the ground anyway. If connecting the ground causes a problem, ; disconnecting it is likely to cause more problems in the long run. ; ; END