Interfacing optoelectric proximity sensor with arduino

Hi,
Have you got current limit resistors on the LEDs?

It would be easier for you to hand draw your circuit and photograph it.
Can you post a pic of the sensor?

Thanks.. Tom.. :slight_smile:

TomGeorge:
Hi,
Have you got current limit resistors on the LEDs?

It would be easier for you to hand draw your circuit and photograph it.
Can you post a pic of the sensor?

Thanks.. Tom.. :slight_smile:

Hi Tom,
I have already posted the circuit diagram along with the code. It is the exact circuit that I have described. Let me know if I have not uploaded it correctly.

Hi,
OP Diagram.


So you have NO current limit resistors, you need current limit resisitors
Can you tell us your electronics, programming, arduino, hardware experience?

Tom... :slight_smile:

TomGeorge:
Hi,
OP Diagram.


So you have NO current limit resistors, you need current limit resisitors
Can you tell us your electronics, programming, arduino, hardware experience?

Tom... :slight_smile:

I have experience in programming and arduino of over a year now. But I am pretty new to electronics.

Hi,
Is this how your circuit is constructed?

If so, unplug the USB port and do not use it until you know about current limit resistors for LEDs, and I am worried about the 24V supply for the sensor yet direct connection to the arduino input.
Tom... :slight_smile:

sheel:
I have experience in programming and arduino of over a year now. But I am pretty new to electronics.

TomGeorge:
Hi,
OP Diagram.


So you have NO current limit resistors, you need current limit resisitors
Can you tell us your electronics, programming, arduino, hardware experience?

Tom... :slight_smile:

Just to verify the circuit, when I replaced the sensor with a limit switch, the problem remained.
But when I added a delay of 100 milliseconds, the program worked with limit switch.
But it still fails with sensor.

TomGeorge:
Hi,
Is this how your circuit is constructed?

If so, unplug the USB port and do not use it until you know about current limit resistors for LEDs, and I am worried about the 24V supply for the sensor yet direct connection to the arduino input.
Tom... :slight_smile:

TomGeorge:
Hi,
Is this how your circuit is constructed?

If so, unplug the USB port and do not use it until you know about current limit resistors for LEDs, and I am worried about the 24V supply for the sensor yet direct connection to the arduino input.
Tom... :slight_smile:

Just to verify the circuit, when I replaced the sensor with a limit switch, the problem remained.
But when I added a delay of 100 milliseconds at the end of the loop(), the program worked with limit switch.
But it still fails with sensor.

Hi,
Can you just connect the sensor up to your 24V supply on its own, no arduino connected, and measure the output volts when the sensor is detecting and not detecting please.
A picture of the sensor would be a help.

Tom.... :slight_smile:

Hi,

Is this how your circuit is constructed?

Tom.... :slight_smile:

TomGeorge:
Hi,
Can you just connect the sensor up to your 24V supply on its own, no arduino connected, and measure the output volts when the sensor is detecting and not detecting please.
A picture of the sensor would be a help.

Tom.... :slight_smile:

Thanks Tom,
The output voltage was the difference. Using the limiting resistors helped. Thanks again.

Hi, good.
So how does you circuit look now?

Tom.. :slight_smile:

TomGeorge:
Hi, good.
So how does you circuit look now?

Tom.. :slight_smile:

HI Tom,
Here is the new circuit.

c3.jpg

Hi,
What are your LEDs, please show a link to where you got them, are they like this?


If so you need to place resistors in series with each LED.
I find it hard to see how LED1 is lighting because the input current to the arduino input is very low.
We need to see a picture of your project please..

Tom.. :slight_smile:

Hi,

Tom... :slight_smile:

TomGeorge:
Hi,
What are your LEDs, please show a link to where you got them, are they like this?


If so you need to place resistors in series with each LED.
I find it hard to see how LED1 is lighting because the input current to the arduino input is very low.
We need to see a picture of your project please..

Tom.. :slight_smile:

I am using the first LED, in your picture, everywhere. I got them from the local hardware store. It needs just 3V to light up. Sorry I can't show you a picture of the exact project. I am bound by my company rules.

Looks to me like the sensor is probably outputting 24V which is then pulled down by LED1 and pin 3 protection diode in parallel to some unknown, unstable voltage. Until that is fixed your circuit is not going to work as you expect. also you need current limiting resistors (330 Ohm)on LED 2 & 3 and pulldown resistors (10k) on pins 5 & 6.

Hi,

I am using the first LED, in your picture, everywhere. I got them from the local hardware store. It needs just 3V to light up. Sorry I can't show you a picture of the exact project. I am bound by my company rules.

You don't have anyone experienced in electronics at your work place?

outsider's circuit is what I was leading you, too.

A step at a time so you would understand and learn what is going on.
You haven't answered post #15 yet, to really establish if the output is 24V high output.
Please read the references I have posted so you understand how to drive LEDs.

Tom... :slight_smile:

TomGeorge:
Hi,You don't have anyone experienced in electronics at your work place?

outsider's circuit is what I was leading you, too.

A step at a time so you would understand and learn what is going on.
You haven't answered post #15 yet, to really establish if the output is 24V high output.
Please read the references I have posted so you understand how to drive LEDs.

Tom... :slight_smile:

Hi. Looking at outsider's circuit and reading the link posted by you, I now understand my mistake.

Regarding post #15, the output voltage was indeed 24V as guessed by outsider. So, with whatever knowledge I had in electronics, I just kept on adding 10K resistors in series to bring the voltage down to the range of arduino.

I thought I would learn basic electronics while working with arduino. But, it seems as if I had a completely wrong approach. I think I should go through basic electronics first before moving anywhere ahead with the arduino, or I might damage the arduino or my laptop or even worse myself.

Thank you Tom and outsider.

If your circuit is as drawn then of course it can't work properly. The LED is clamping the voltage to the input pin to only a few volts(depending on the LED colour) so the input pin will not go to logic high However, it is almost certainly saving your arduino from destruction.
Step back to basics. Forget the arduino for a moment.

If your LED does respond to sensor activity as wired, then the sensor is likely to be a source/sink driven output. These have a built in current limit and that probably why you have not yet destroyed it or the LED.
You must add a resistor in series the LED (470 to 1k ohms or so-its not critical) to limit the current.
Now the sensor and the LED are happy. But you will destroy the arduino if you connect it to the sensor output. (oops 24V on the arduino. Very bad).
Solution: 4.7V zener diode between arduino input and ground.(stripe to the input) Then resistor (2k to 5k is ok for a small zener) from arduino input to sensor output. This will clamp the voltage appearing on the arduino input to a safe value. Sorry I can't be bothered drawing a diagram. Wire this up without the arduino and check voltages first. if ok then connect to arduino and work on the code. Good luck.
Crawl around a bit before standing up - more chance of success.