Guide to Sensor Interfacing

Thread Starter

@vajra

Joined May 2, 2018
154
I have Photoelectric sensors and I want to interface it with mcu AT89C51. Sensor work with I have looked at datasheet But I don't have idea.

I'm attaching datasheet of the sensor. A sensor is working between 12v DC to 30V DC

There are four output pin's of sensor. How to interface sensor to AT89C51
 

Attachments

ericgibbs

Joined Jan 29, 2010
18,865
hi v,
Its a PNP output which means a Pull Down resistor is required, between pins 4 and 3.
The pull up resistor will have to be voltage divider.
What voltage are you powering the sensor with and what voltage does the AT expect as an input./
E

AA1 02-Dec-18 10.53.gif
 

Thread Starter

@vajra

Joined May 2, 2018
154
hi v,
Its a PNP output which means a Pull Down resistor is required, between pins 4 and 3.
The pull up resistor will have to be voltage divider.
What voltage are you powering the sensor with and what voltage does the AT expect as an input./
E

View attachment 164852
I'm using 24v Dc supply for sensor

AT89c51 work with 5V DC input voltage

What's the range of resister's need to make a divider circuits ?

What's the use of control pin, You haven't connected it anywhere ?
 

ericgibbs

Joined Jan 29, 2010
18,865
hi,
R1=15k and R2 = 3k9.
From a 24Vdc output that will give 4.9v at the junction of R1 and R2
E

I do not see reference to the Control pin in the data.???
Will look on the web.
 

ericgibbs

Joined Jan 29, 2010
18,865
hi,
I have been on the Baumer web page, I would suggest that you use their 'contact us' option on that website and ask about the Control pin.
E
 

ericgibbs

Joined Jan 29, 2010
18,865
hi,
If you cannot find any information ref the Control, I would either connect to 0v or leave it it disconnected.
I would expect it has an internal pull up on the Control pin, leaving it open or connecting it to 0v will Enable the sensor.
A little trial and error.:rolleyes:

E
 

Thread Starter

@vajra

Joined May 2, 2018
154
hi,
If you cannot find any information ref the Control, I would either connect to 0v or leave it it disconnected.
I would expect it has an internal pull up on the Control pin, leaving it open or connecting it to 0v will Enable the sensor.
A little trial and error.:rolleyes:

E
Hello ericgibbs,

Manually I have tested sensor with divider circuit and Buzzer. It's all working together

I have AT89S52 Microcontroller

This is a program for checking the sensor

if the sensor detecting object, buzzer should ring else buzzer should be turn OFF

Problem is that if the sensor is not detecting still the buzzer is ringing but It shouldn't ring because there is no object

I think the problem is with a program because manually it's working fine . Can you help me to solve the problem ?

C:
#include <REG51.h>
                 
sbit sensor     = P0^1;    //sensor connected to P0.1
sbit Buzzer    = P2^0;    // Buzzer connected to p2.0
#define  ON    1
#define  OFF   0
void main (void)
{
    
        while(1)
       {
             if(sensor == ON)      //If sensor  is activated
                {
                  Buzzer = ON;     // Turn ON Buzzer
                }
              else
               {
                    Buzzer = OFF;    // Turn OFF Buzzer
               }
      }
}
 

ericgibbs

Joined Jan 29, 2010
18,865
hi v,
When the project is all connected to the 'AT' have you checked with a voltmeter, the voltage on the P0 pin, when the program is running.?
It should be 5V or 0V depending on the activation state of the opto detector.
Let me know what you measure.
E
 

Thread Starter

@vajra

Joined May 2, 2018
154
hi v,
When the project is all connected to the 'AT' have you checked with a voltmeter, the voltage on the P0 pin, when the program is running.?
It should be 5V or 0V depending on the activation state of the opto detector.
Let me know what you measure.
E
If the sensor is high or low, P0 pin is always High

I measured voltage with multimeter It has 4.8 V DC
 

ericgibbs

Joined Jan 29, 2010
18,865
hi,
So thats a hardware problem.
Could you post a sketch and/or a photo of the project, it would help

BTW: I don't use 'C', is Pin P0 set as an Input.??

E
 

Thread Starter

@vajra

Joined May 2, 2018
154
hi,
So thats a hardware problem.
Could you post a sketch and/or a photo of the project, it would help

BTW: I don't use 'C', is Pin P0 set as an Input.??

E
I don't think there is fault in hardware If It had fault in hardware It wouldn't work manually

This is wiring connection
upload_2018-12-3_15-40-49.png
 
Last edited by a moderator:

ericgibbs

Joined Jan 29, 2010
18,865
hi Les, & V
I think is one of those cases where a photo image of the project would have avoided all the hassle.
E

EDIT:

For the record, how did you connect the Control pin on the Opto, it may help other users to know.
 
Last edited:

Thread Starter

@vajra

Joined May 2, 2018
154
hi Les, & V
For the record, how did you connect the Control pin on the Opto, it may help other users to know.
I did the all wiring on breadboard and it looks very messy. that's why I didn't post image before, I'll post a clean image of connection
 
Top