Email: Password: Remember Me | Create Account (Free)

Back to Subject List

Old thread has been locked -- no new posts accepted in this thread
???
03/10/08 14:17
Read: times


 
#152089 - Gas Sensor with ATMEL89C52
Hi everybody, I'm a amateur programmer and I wanna to make a small project which described above:

Project Details:
I have to make a gas sensor that detects the LPG if exists, with ATMEL89C52.
To read the data from gas sensor I have to use a ADC0808 and connect it to the Port0 of microcontroller. I also have a buzzer that should connect to a pin of 3rd port of the microcontroller. (Ports 0 and 2 will use to communicate with external EPROM 27C64 and a RAM6264 - these RAM and ROM are required for the project). There will be no code in the 89C52 and the program will read from external ROM. The voltage level that run the buzzer is about 3V.
I have some works on the project in simulation. They works however in the experiment they won't.

Could you please send me a suggestion to overcome this problem? Thanks...

P.S. I'm sending the Keil C code:

/* Adding header files */

#include <89c51rd2.H>
#include <stdio.h>

/* Defining the ports and pins */
#define DATAS P1
#define START P3_2
#define EOC P3_3
#define OE P3_4
#define openalarm P3_1

/* Setting types of variables */
float alert;
float step;

/* Main function of the program */
void main(void)
{
/* The step value of the output of the ADC is calculated */
step=(float)5/256;

/* Defining the port 1 as input port */
DATAS=0xFF;

/* Infinite loop */
while(1)
{
/* Starting conversion and taking 1 ADC sample */
START=1;
START=0;
while(!EOC);

/* During the conversion, setting the ADC output to 1 */
OE=1;

/* Calculating the alert sequence */
alert=DATAS*step;

/* Giving alert parameter to the assigned pin */
if (alert>2)
openalarm=1;
else if (alert<=2)
openalarm=0;
OE=0;
}
}


No replies in thread

Back to Subject List