Interface LTC1298 with Standard Parallel Port

Wichit Sirichote, wichit.sirichote@gmail.com

Build a simple ADC board that interfaces standard PC parallel port.

I got the idea to build the analog-to-digital converter board after using Pacific compiler for dos. I thought I can use old 486 PC with minimum resource. The homemade converter board can tie to the available standard PC printer port. There are many pages describe how to use such printer port for homemade projects. I recommend you to visit the nice page written by Craig Peacock, "Interfacing the Standard Parallel Port". Since the LTC1298, a 12-bit ADC has serial interface, so we can use only four signals from printer port and write the software for controlling the ADC easily. You may develop your code to make the old PC to be data logger. The logged data can be saved in ASCII text format to the hardrive. The prototype shown in Figure 1 can tie to printer port directly.

Figure 1: The prototype of ADC Board.

 

 

 

 

 

 

 

 

 

 

 

 

 

 

Hardware Schematic

The LTC1298 is micropower ADC chip. It draws power only 250uA. I have tried using logic high from D7 to supply the chip. It worked fine, but the problem is the LTC1298 has voltage reference tied the the same VDD pin 8. I have the +5.0V reference voltage reference LM336-5.0V to supply the chip. For some application that finds means to calibrate the ADC, we can use D7 with logic high to be power supply. We see that the chip needs four signals to interface. Three of them are output only from printer port, DIN, CLK and CS. The arrows show signal direction. DIN receives configuration command. CLK is shift clock signal and CS is for start conversion and shutdown. The chip draws only 1nA when shutdown (CS = 1). I used data bit from printer port with software control to produce such signals. The converted 12-bit digital data was sent out from DOUT pin to PAPER END (PE) input bit.

Figure 2: Complete schematic of ADC board

 

 

 

 

 

 

 

 

 

 

Software

The source code was written in c language and the exe file was compiled with Pacific c compiler. If you use another c compiler you can modify some statement easily. I tested the code old PC, 486 machine the timing for delay function was fine. If you use faster PC, you may need to modify it.


#include <stdio.h>
#include <conio.h>
#include <stdlib.h>
#include <dos.h>
#define LPT 0x378
#define status 0x379
#define control 0x37A
#define DIN 1
#define DOUT 0x20
#define CLK 2
#define CS 4
char port_data;

void delay(int n)
               {
               int j;
               for(j=0; j<n; j++)
               continue;
               } 
void delay_us(unsigned int n)
               {
               unsigned int j;
               for(j=0; j<n; j++)
               delay(100);
               }

void init_ADC(void)
               {
               outp(LPT,port_data|=CS); // make CS to logic high
               }
               
int read_ADC(char n)
               {
               int k;
               char i,channel;
               k=0;
               outp(LPT,port_data&=~CS); // make CS low
               delay(10);
               
               if(n==0) channel= 0x0d;
               else channel= 0x0f;
// send config nibble 
               for(i=0; i<4; i++)
               {
               outp(LPT,port_data&=~CLK); // make clk low
               delay_us(10);
               
               if(channel&0x8) outp(LPT,port_data|=DIN);
               else outp(LPT,port_data&=~DIN);
               
               outp(LPT,port_data|=CLK); // make clk high
               delay_us(10);
               
               channel <<=1;
               
               }
 
               outp(LPT,port_data&=~CLK); // make clk low
               delay(100);
               // now read 12-bit data
               for(i=0; i<12; i++)
               {
               k<<=1;
               outp(LPT,port_data|=CLK); // make clk high
               delay_us(10);
               outp(LPT,port_data&=~CLK); // make clk low
               delay_us(10);
               
               if(inp(status)&DOUT) k |=1;
               else k &= ~1;
               
               }
             outp(LPT,port_data|=CS);                // make CS high
               
             return k&=0xfff ;
}

void main(void)
{ 
               port_data = 0x80;
               init_ADC();
               
               while(read_ADC(0) <4090)
               {
               printf("\n ADC0 = %d ADC(1) = %d",read_ADC(0), read_ADC(1));
               delay(1000);
               }
}
             


 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

The main code reads ADC for both channel and prints them to PC screen while the value of channel 0 is less than 4090. Here is the sample running printout. I have LM336-2.5V tied to channel 1.

ADC0 = 2496 ADC(1) = 2024
ADC0 = 2498 ADC(1) = 2024
ADC0 = 2497 ADC(1) = 2024
ADC0 = 2497 ADC(1) = 2024
ADC0 = 2497 ADC(1) = 2024
ADC0 = 2497 ADC(1) = 2024
ADC0 = 2497 ADC(1) = 2024
ADC0 = 2497 ADC(1) = 2024
ADC0 = 2497 ADC(1) = 2024
ADC0 = 2498 ADC(1) = 2024
ADC0 = 2496 ADC(1) = 2024
ADC0 = 2497 ADC(1) = 2024
ADC0 = 2498 ADC(1) = 2024
ADC0 = 2497 ADC(1) = 2024
ADC0 = 2497 ADC(1) = 2024
ADC0 = 2497 ADC(1) = 2024
ADC0 = 2497 ADC(1) = 2024
ADC0 = 2496 ADC(1) = 2024

 

 

 

 

 

 

 

 

 

Download

 

Schematic adc.pdf
source code and dos executable file adc.c Adc.exe

 



<

5 December 2004

Recovered 17 December 2015