Make your own free website on Tripod.com
Home

Radio interfacing to the IBM-PC Parallel Printer Port

The original IBM-PC's Parallel Printer Port had a total of 12 digital outputsand 5 digital inputsaccessed via 3 consecutive 8-bit ports in the processor's I/O space.

 Pinout Diagram


Pin assignments:

Signal nameRegister bitD-SUBCentronics
PinPin
Data bit 0D022
Data bit 1D133
Data bit 2D244
Data bit 3D355
Data bit 4D466
Data bit 5D577
Data bit 6D688
Data bit 7D799
nError (nFault)S31532
Select S41313
PaperEnd S51212
nAck S61010
Busy S71111
nStrobe C011
nAutoLF C11414
nInit C21631
nSelectIn C31736
Ground GND18-2519-30

Inputs and Outputs

Port address:
The most parallel ports are located at a base address of 378h, 278h, or 3BCh. To find the base address of a parallel port in Windows 95, open the "Control panel", then click on "System", "Device manager", "Ports", select an LPT port, then click the "Resources" tab. The addresses of installed parallel ports are also displayed in the CMOS setup screens that you can access when you boot your computer.

The following is typical.


       Printer         Data Port        Status          Control
	LPT1            0x03bc          0x03bd          0x03be      
	LPT2            0x0378          0x0379          0x037a      
	LPT3            0x0278          0x0279          0x027a 


Visual Basic
examples

Visual Basic:
In Visual Basic you have to use a DLL to access the ports. Jan Axelson programmed two DLLs which allow you to use the Visual basic 16-bit and 32-bit . You can download the DLLs at Inpout16.DLL and Inpout32.DLL.
Although the program code to call the Inp and Out routines.

You can also download our examples PrinterPort for Visual Basic 3.0: PRINT16.ZIP
You can also download our examples PrinterPort for Visual Basic 5.0: PRINT32.ZIP

Instructions to read and write to the port:

read instruction:xx=INP(address)
write insruction:OUT(address),xx

You can write to the data port(D0-D7) at the base address. D0 is the least significant bit and D7 is the most significant bit. For example "OUT(889),85" writes 01010101(=85 decimal)to the port address 378h (= 889 decimal).

You can read the status port(S3-S7) at the base address+1. At Bit 7(S7) you will read the inverted signal of the connector. S0 - S2 are usually not in use and read as low signals. When all signals are high you will read 78h (01111000 = 120decimal = 78h).

You can write to the control port(C0-C3) at base address+2. The bits 0,1 and 3 are inverted so if you write 04h (00000100), all four bits will be going high and when you write 0Bh (00001011) all four bits will be going low.



Visual Basic Example for progamming LMX1501A Serial prorammable PLL

AN-935: Upgrading from the MB150X to the National LMX1501A

Functional Description
LMX1501A Block Diagram
The simplified block diagram below shows the 19-bit data register, the 14-bit R Counter and the S Latch, and the 18-bit N Counter (intermediate latches are not shown). The data stream is clocked (on the rising edge) into the DATA input, MSB first. If the Control Bit (last bit input) is HIGH, the DATA is transferred into the R Counter (programmable reference divider) and the S Latch (prescaler select: 64/65 or 128/129). If the Control Bit (LSB) is LOW, the DATA is transferred into the N Counter (programmable divider).

Serial Data Input Timing
Serial Data Input Timing
Notes: Parenthesis data indicates programmable reference divider data.
Data shifted into register on clock rising edge.
Data is shifted in MSB first.



Divide Ratio of Reference Divider
Serial Data to Reference Divider
PROGRAMMABLE REFERENCE DIVIDER (R COUNTER)
AND PRESCALER SELECT (S LATCH)
If the Control Bit (last bit shifted into the Data Register) is HIGH, data is transferred from the 19-bit shift register into a 14-bit latch (which sets the 14-bit R Counter) and the 1-bit S Latch (S15, which sets the prescaler: 64/65 or 128/129).


Divide Ratio of Programmable Divider
Serial Data to Programmable Divider
PROGRAMMABLE DIVIDER (N COUNTER)
The N counter consists of the 7-bit swallow counter (A counter) and the 11-bit programmable counter (B counter). If the Control Bit (last bit shifted into the Data Register) is LOW, data is transferred from the 19-bit shift register into a 7-bit latch (which sets the 7-bit Swallow (A) Counter) and an 11-bit latch (which sets the 11-bit programmable (B) Counter).



Connection to LMX1501A
PinPrinterPort               Usage          
2Data 0 Out to printerPLL Clock
3Data 1 Out to printerPLL Data
4Data 2 Out to printerPLL Enable
18GroundGround
25-Pin Printer Connector
Connection to the computer`s printer port.


To program LMX15001A for 320MHz with 5kHz frequency step and 10,240MHz reference X-tal:

RDivider = Reference frequency : Frequency step = 10240000 : 5000 = 2048
NDivider = (VCOFrequency : Swallow Counter) : Frequency step = (320000000 : 64) : 5000 = 1000
Prescaler = 64 (Prescaler Control-bit = 1)


Sub cmdProgram_Click ()
OutPort = &H378
InPort = &H379
RValue = 2048
PValue = 1
SValue = 64
NValue = 1000
UpdateRDivider
UpdateNDivider
End Sub


BAS-file:
Option Explicit
Declare Function Inp Lib "inpout16.Dll" Alias "Inp16" (ByVal InPort As Integer) As Integer
Declare Sub Out Lib "inpout16.Dll" Alias "Out16" (ByVal OutPort As Integer, ByVal Value As Integer)
Global OutPort'&H378, &H278 or &H3BC
Global InPort'&H379, &H279 or &H3BD
Global RValue'Decimal value for Reference Divider
Global RDivider'Binary value for Reference Divider
Global SValue'Desimal value for Swallow Counter
Global SDivider'Binary value for Swallow Counter
Global NValue'Decimal value for Frequency Divider
Global NDivider'Binary value for Frequency Divider
Global PValue'0 = 128/129 and 1 = 64/65
 
 
 
Sub UpdateNDivider()
'Used to calculate Binary value
Dim Digit'Number of Binary digit to S and N divider
Dim BinValue'Binary value
Dim TempValue
Dim DecValue'Decimal value
 
'Calculate Binary value for Swallow Counter
DecValue = Val(SValue)
BinValue = ""
Do
TempValue = DecValue Mod 2
BinValue = CStr(TempValue) + BinValue
DecValue = DecValue \ 2
Loop Until DecValue = 0
SDivider = BinValue
 
'Calculate Binary value for NDivider
DecValue = Val(NValue)
BinValue = ""
Do
TempValue = DecValue Mod 2
BinValue = CStr(TempValue) + BinValue
DecValue = DecValue \ 2
Loop Until DecValue = 0
NDivider = BinValue
 
'Used to transmit Swallow Counter digit to PLL
Dim c As Integer
Dim d As Integer
'Used to transmit NCounter digit to PLL
Dim e As Integer
Dim f As Integer
 
'Send NDivider value to PLLBit 8 to 18
For e = 1 To (11   Len(NDivider))'If number of Binary <11 digit
Out (OutPort), 0'Set Data Low.
Out (OutPort), 1'Set Clock High.
Out (OutPort), 0'Set Clock and Data Low.
Next e
 
For f = 1 To Len(NDivider)
Digit = Mid$(NDivider, f, 1)
If Digit = 0 Then Out (OutPort), 0'Set Data Low.
If Digit = 0 Then Out (OutPort), 1'Set Clock High.
If Digit = 0 Then Out (OutPort), 0'Set Clock and Data Low.
 
If Digit = 1 Then Out (OutPort), 2'Set Data High.
If Digit = 1 Then Out (OutPort), 3'Set Clock High.
If Digit = 1 Then Out (OutPort), 0'Set Clock and Data Low.
Next f
 
'Send SCounter value to PLLBit 1 to 7
For c = 1 To (7   Len(PDivider))'If number of Binary <7 digit
Out (OutPort), 0'Set Data Low.
Out (OutPort), 1'Set Clock High.
Out (OutPort), 0'Set Clock and Data Low.
Next c
 
For d = 1 To Len(SDivider)
Digit = Mid$(SDivider, d, 1)
If Digit = 0 Then Out (OutPort), 0'Set Data Low.
If Digit = 0 Then Out (OutPort), 1'Set Clock High.
If Digit = 0 Then Out (OutPort), 0'Set Clock and Data Low.
 
If Digit = 1 Then Out (OutPort), 2'Set Data High.
If Digit = 1 Then Out (OutPort), 3'Set Clock High.
If Digit = 1 Then Out (OutPort), 0'Set Clock and Data Low.
Next d
 
'Send Control-bit LSBControl-bit = 0
Out (OutPort), 0'Set Data Low
Out (OutPort), 2'Set Clock High
Out (OutPort), 0'Set all bit Low
 
'Send LE
Out (OutPort), 4'Set EN High
Out (OutPort), 0'Set all bit Low
 
End Sub
 
 
 
Sub UpdateRDivider()
'Used to calculate Binary value
Dim Digit'Number of Binary digit to R divider
Dim BinValue'Binary value
Dim TempValue
Dim DecValue'Decimal value
 
'Calculate Binary value
DecValue = Val(RValue)
BinValue = ""
Do
TempValue = DecValue Mod 2
BinValue = CStr(TempValue) + BinValue
DecValue = DecValue \ 2
Loop Until DecValue = 0
RDivider = BinValue
 
'Send Prescaler Control bit to R-dividerBit 15
Out (OutPort), 2'Set Data High (ControlBit = 1).
Out (OutPort), 3'Set Clock High.
Out (OutPort), 0'Set all bit Low
 
'Used to transmit digit to PLL
Dim i As Integer
Dim j As Integer
 
'Send Reference Divider value to PLLBit 1 to 14
For j = 1 To (14   Len(RDivider))'If number of Binary <14 digit
Out (OutPort), 0'Set Data Low.
Out (OutPort), 1'Set Clock High.
Out (OutPort), 0'Set Clock and Data Low.
Next j
 
For i = 1 To Len(RDivider)
Digit = Mid$(RDivider, i, 1)
If Digit = 0 Then Out (OutPort), 0'Set Data Low.
If Digit = 0 Then Out (OutPort), 1'Set Clock High.
If Digit = 0 Then Out (OutPort), 0'Set Clock and Data Low.
 
If Digit = 1 Then Out (OutPort), 2'Set Data High.
If Digit = 1 Then Out (OutPort), 3'Set Clock High.
If Digit = 1 Then Out (OutPort), 0'Set Clock and DataLow.
Next i
 
If SValue = 128 Then Out (OutPort), 0'Set Data Low.
If SValue = 128 Then Out (OutPort), 1'Set Clock High.
If SValue = 128 Then Out (OutPort), 0'Set Clock and Data Low.
 
If SValue = 64 Then Out (OutPort), 2'Set Data High.
If SValue = 64 Then Out (OutPort), 3'Set Clock High.
If SValue = 64 Then Out (OutPort), 0'Set Clock and DataLow.
 
'Send Control-bit LSBControl-bit = 1
Out (OutPort), 1'Set Data High
Out (OutPort), 3'Set Clock High
Out (OutPort), 0'Set all bit Low
 
'Send LE
Out (OutPort), 4'Set EN High
Out (OutPort), 0'Set all bit Low
End Sub


Take a loock at sites Phase Locked Loops Programmer and WINScanner Software.




E-Mail: cbradio@wintransceiver.com