Thursday, December 8, 2011

Design & Implementation of Data Acquisition System (DAQ)

Analog-to-digital converters are among the most widely used devices for data acquisition. Digital computers use binary values, but in physical world everything is analog. Therefore, we need an analog-to-digital converter to translate these analog signals to digital signals.
DAQ (Data Acquisition System) is a device that gathers useful measurement data (8-Channels) for characterization, monitoring, or control. No matter what the specific application, all DAQ systems either measure a physical parameter (like temperature, pressure, flow, etc.) or take a specific action (sound an alarm, turn on a light, etc.) based on the data received.
Circuit: 



Video: 




Source Code:

//Code for Data Acquisition System (DAQ)
#include <reg51.h>
sbit start=P3^3; // Preparing Pin's For Microconroller
sbit end=P3^4;
sbit oe=P3^5;
sbit ale=P3^6;
sbit clock=P3^2;

unsigned char sensor=0;

void delay() //Simple Delay
{
 int k,l;
 for(k=0;k<30;k++)
  for(l=0;l<80;l++);
}
void initSerial() //Initialize the MCU
{
 TMOD=0x22;
 TH1=0xFD;
 SCON=0x50;
 TR1=1;
 EA=1;
 ES=1;
}
void usDelay(int a) //Initialize Clock for ADC0808 that work with 10kHz
{
 TH0=256-(a/1.085);
 TR0=1;
 ET0=1;
}
void timerRoutine() interrupt 1
{
 clock=~clock;
}
void sendChar(unsigned char ch) // For sending Data
{
 SBUF=ch;
 while(!TI);
 TI=0;
}

void sendReading(unsigned char val) // Sending reading of ADC (1-Character at atime) & ','
{
 sendChar(val);
 sendChar(',');
}
void latch() // Latch the Address of ADC
{
 ale=0;
 delay();
 ale=1;

}
void startConv() // Start Convertion
{
 delay();
 start=0;
 delay();
 start=1;
}
void wait() //Wait the interrupt (end of convertion (EOC))
{
 while(end==1);
}
void get() // to get data from ADC
{
 delay();
 oe=0;
 delay();
 oe=1;
}
void main() // the main Program
{

 unsigned char reading;
 P1=0;
 initSerial();
 usDelay(50);
 while(1)
 {
  if(sensor==8) // sensor for 8-channel
   sensor=0;
  if(sensor==0)
   sendChar('N'); //Evry 8-Reading send 'N' Character
  P1=(P1&0xf8)+sensor;
  latch();
  startConv();
  wait();
  get();
  reading=P2;
  sendReading(reading);
  sensor++;

 }
} 

No comments:

Post a Comment