8-CHANNEL ADC(ANALOG MUX) 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.com8-CHANNEL ADC(USING ANALOG MUX)
Figure shows analog mux is used to multiplex 8 analog voltages to the ADC. Here we
are using an analog mux MC14051 or CD4051. The selection pins of the analog mux is
connected to the output of the control port.INH is disabled. Thus by selecting proper
inputs we can get different channel outputs. Analog mux can work as a digital mux
while digital mux can't.
#include"bparlib.c"
float Read_adc(void);
void main()
{
clrscr();
//selecting 0 the value
Clear_ControlPort_bit(1);
Clear_ControlPort_bit(2);
Clear_ControlPort_bit(3);
printf("\nvalue of ADMUX 0 is %f",Read_adc());
//selecting channel-1 the value
Set_ControlPort_bit(1);
Clear_ControlPort_bit(2);
Clear_ControlPort_bit(3);
printf("\nvalue of ADMUX 1 is %f",Read_adc());
//selecting channel-2 the value
Clear_ControlPort_bit(1);
Set_ControlPort_bit(2);
Clear_ControlPort_bit(3);
printf("\nvalue of ADMUX 2 is %f",Read_adc());
//selecting channel-3 the value
Set_ControlPort_bit(1);
Set_ControlPort_bit(2);
Clear_ControlPort_bit(3);
printf("\nvalue of ADMUX 3 is %f",Read_adc());
//selecting channel-4 the value
Clear_ControlPort_bit(1);
Clear_ControlPort_bit(2);
Set_ControlPort_bit(3);
printf("\nvalue of ADMUX 4 is %f",Read_adc());
//selecting channel-5 the value
Set_ControlPort_bit(1);
Clear_ControlPort_bit(2);
Set_ControlPort_bit(3);
printf("\nvalue of ADMUX 5 is %f",Read_adc());
//selecting channel-6 the value
Clear_ControlPort_bit(1);
Set_ControlPort_bit(2);
Set_ControlPort_bit(3);
printf("\nvalue of ADMUX 6 is %f",Read_adc());
//selecting channel-7 the value
Set_ControlPort_bit(1);
Set_ControlPort_bit(2);
Set_ControlPort_bit(3);
printf("\nvalue of ADMUX 7 is %f",Read_adc());
getch();
}
float Read_adc(void)
{
float b;
delay(1);
Clear_ControlPort_bit(0);
delay(1);
Set_ControlPort_bit(0);
delay(1);
b=Read_DataPort();
b=b*5/255;
return(b);
}
Forumer™ is Voted #1 Free Forum Hosting provider
Build your own community today with the largest message board hosting company.