Close or Esc Key

Arduino Projects   |   Raspberry Pi   |   Electronic Circuits   |   AVR   |   PIC   |   8051   |   Electronic Projects

how to make 8051 to recognise i/p only greater than a specified voltage?

3 posts / 0 new
Last post
Greeshma N D
Greeshma N D's picture
Offline
Last seen: 2 years 3 weeks ago
Joined: 20/01/2016 - 21:33
how to make 8051 to recognise i/p only greater than a specified voltage?

My project is on blood leakage monitoring system.It uses TCST110 photointerrupter. Curently in proteus i've used pc817d and some resistors instead of tcst110.i can make 8051 detect the photointerrupter's on condition, but unable to make it to respond only when photointerruprt's o/p is above specified vlg(.03V ).what changes should i make in the code.

code is as follows:

#include "REG51.h"
#include <stdio.h>
#define buz P1
sbit LED_pin = P2^0; //Defining LED PIN
sbit sensor_pin = P0^0; //Defining output of sensor  PIN
void Delay(int); //Function prototype declaration
void main (void)
{ buz=0x00;  //buzzer off
  sensor_pin = 1; // if sensor is low 
  LED_pin=0; //LED off 
  while(1) //infinite loop
  {
    if(sensor_pin == 0 ) //If sensor is high 
    {
      LED_pin = 1; //LED ON
buz=0x01;      // ON Buzzer
Delay(6000); //Delay
buz=0x00; // OFF Buzzer
      LED_pin = 0; //LED OFF
 Delay(6000);
    }}}
 void Delay(int k)
{ int j;
  int i;
  for(i=0;i<k;i++)
  {
    for(j=0;j<100;j++)
    { } }
}
 
GANEEV SINGH
GANEEV SINGH's picture
Offline
Last seen: 1 week 5 days ago
Joined: 22/07/2013 - 16:08
HiFor comparing voltages, you

Hi

For comparing voltages, you should either use a comparator chip or an ADC IC

Ashutosh Bhatt
Ashutosh Bhatt's picture
Offline
Last seen: 3 days 3 hours ago
Joined: 21/12/2010 - 15:59
better you use 89C4051 or

better you use 89C4051 or 89C2051 that has analog comparator in built

it can be used to compare input voltage with set threshold voltage and give internal output on P3.7