ANALOG TO DIGITAL CONVERTER INTERFACING WITH PARALLEL PORT This tutorial is taken from the book
MY EXPERIENCE IN PARALLEL PORT INTERFACING.
you can download it free from the files
section(file:-parallelport(3 files) of
yahoo group-booksbybibinhttp://groups.yahoo.com/group/booksbybibin/
comments about this book on
www.booksbybibin.blogspot.comANALOG TO DIGITAL CONVERTER
#include"bparlib.c"
#define ChipSelect Clear_ControlPort_bit(0) // to clear RD' and CS'
int Read_adc(void);
void main()
{
float a=1,b;
b=Read_adc();
printf("\nadc output:%f\n",b);
a= b*5/255; //conversion supply voltage is 5V
printf("the input voltage is %f",a);
getch();
}
int Read_adc(void)
{
ChipSelect; //to select the chip, enabled
delay(1);
Clear_ControlPort_bit(1);
delay(1);
Set_ControlPort_bit(1);
delay(1);
return(Read_DataPort());
}
Here I used Vref=Vcc=5V. This voltage may change depending on load. You can use
any other Vref using a potentiometer at the Vref/2 pin. See datasheet for the
maximum value of Vref. Digital and analog grounds are short circuited. Here the 10K
and 150pF determines the speed of conversion. The normal speed is 100uSec. You can
change this. If you increase the speed, then it is called overclocking. I used 222pF
instead of 150pF. So if you don't get 150 pF then u can use other values but the speed
of conversion will vary. Here I am using the free running mode of operation for
easiness. Mainly used mode is interrupt mode. In free running mode ADC will never
end the conversion. Some power is wasted in this case compared to interrupt mode.
First we have to Enable Write pin then disable it after some time. This time will be in
milliseconds because the conversion time of ADC is in terms of milliseconds(.1ms). So
the conversion time of ADC in our program is 2ms. i.e, you can get 500 conversions in
a second. Most of the application this much speed is enough, especially when we used
sensors in robotics. You can try for a better speed. Here the voltage is calculated using
the formula
V=ouput of ADC/(2^8-1)*Vref. Here Vcc=5V and output of ADC is of 8 bit so we
divide it by 255. See the least count of ADC = 5/255=1/51=.02V . You can see that if
you decrease Vref, then we can get a better accuracy.
#include"bparlib.c"
#define ChipSelect Set_ControlPort_bit(0) // to clear RD' and CS'
void main()
{
int a;
ChipSelect; //to select the chip, enabled
Clear_ControlPort_bit(1);
delay(1);
Set_ControlPort_bit(1);
printf("output %d",Read_DataPort());
getch();
}
This program is used to check what is the output of the ADC when chip select and
read are not enabled. The output will be 0xff not Z(high impedance). In most of the
cases you have to see it if you use it with some multiplexed bus. Suppose if you want
to expand parallel port and by using control signals we disable ADC but still a voltage
of HIGH remains at the output. So be careful about multiplexing ADC with any bus.
Use a buffer to the output of the ADC to enable the chip reading when you are using
multiplexed bus.
megaby30- 11-10-2006
hello! we're working on a project which include ADC circuit interfacing with parallel port. We're still having a hard time since we're beginners. Could could give us a big favor. Could send us a complete detail on your experience in parallel port interfacing with the ADC circuit. It will be really a great help for us. Thanks!
yogi- 11-24-2006
hi megaby30
download my book from yahoo group-booksbybibin, if you have any doubts put the problem in this forum. I have given troubleshooting tips in that book, see it thoroughly.
bibin john
www.bibinjohn.tk
krishsandeep- 09-12-2007
I am doing a project on robotics which uses C++ as an interface language. I need a circuit to use it as an pheripheral interface and a programming technique for the control. Can i get it..... ?
I can use serial port or Parallel port. I want the programming codes and the circuit which links the motors and the computer.
yogi- 09-19-2007
read my parallel port from the files section of yahoo group-booksbybibin, then u will understand the basics
Forumer™ is Voted #1 Free Forum Hosting provider
Build your own community today with the largest message board hosting company.