Help choosing optocoupler/switch for microcontroller project

In summary, the user is looking for a slotted photoswitch to count rotations of an anometer. They are finding information difficult to interpret and are confused about the voltages and currents involved. They have found a solution using a resistor and uController pull-up resistor.
  • #1
phlegmy
120
0
Hey guys
i'm putting together a shopping list for my first microcontroller project.
One thing i need is a slotted photoswitch (to count rotations of an anometer)

The project will be powered by a 9v battery, regulated to 5v.

The photoswitch has an led on one "post" and the other post has a photo transistor to detect the light from the led.

The switch I'm looking at has a this data sheet
http://www.farnell.com/datasheets/9111.pdf
and the product is here:
http://ie.farnell.com/optek-technology/opb610/opto-switch-slotted/dp/1497899

I'm finding some info a bit difficult to interperut
On page 2, it says the reverse input voltage is 3v (drop across the led on input post?)
with a forward dc current of 50mA
This means i need a resistor in series of (5-3)/.05 = 40ohms? for the input led

CONFUSION:
It also says that the collector-emmiter voltage is 24V with a collector-emitter current of
30mA,
this is what confuses me. i have no idea if i can just hook up the collector to the 5v supply and connect the emmiter to ground through a resistor, and measure the output on the switch side of the resistor?i suppose i could just buy one and see if it will work, but words of wisdom at this stage would save me some troubel and potentially some €'s!
 
Last edited by a moderator:
Engineering news on Phys.org
  • #2
phlegmy,

Typically you would connect pin 3 to a pull up resistor and the other side of the resistor to the uController's Vcc, in this case likely 1k to 10k for a 5ma to 0.5ma drain @ Vcc = 5V. You would also connect your uController "sensor pin" to both pin 3 and the resistor where they are connected together. When the space between the slot is "blocked" the "sensor pin" will go "High", in this case 5V. When the space between the slot is "Open", the "sensor pin" will go "low", 0V.

The LED source current sounds high to me. In general something in the 10mA to 20mA range is what I have run across in optical switches I have used in the past, so you may want to consider sourcing something with lower power consumption if you plan on operating it for any length of time on a 9V battery.

uControllers like the AVR family have I/O pins with built-in pull-up resistors, so you could use this in place of the external resistor on the transistor side, and you could also power the LED with another I/O pin. This would allow you to disable both for a considerable period of time between pulses.

If you have only one "opening" or "closing" per revolution, then it is fairly easy to calculate the maximum acceleration/deceleration in any given revolution and turn both the LED and the Sensor "Off" for the entire period greater than or less than the min/max, thus saving a tremendous amount of power over days/weeks/months. You might also choose to only power the sensor on every few seconds or minutes if you are not interested in the instantaneous readings.

You might also consider using a hall effect sensor & a magnet, this will use considerably less power.

Fish
 
  • #3
THanks so much for the REply fish!

Thats a much better way of hooking up the switch,
switching the photoswitches collector and thus controllers input to ground through a resistor,
rather than trying to get a high signal from the emitter.

I;ll look into a hall effect sensor,
Thanks again for your help!
JAmes
 
  • #4
Just to report that i have all but finished my anomometer but for calibration and a few tweeks to the microcontrollers code.
I ended up using the optocoupler configured as described by Fish4Fun, Thanks again.
 

1. What is an optocoupler and why is it important in a microcontroller project?

An optocoupler is an electronic component that is used to isolate electrical signals between two circuits. It consists of a light-emitting diode (LED) and a light-sensitive transistor, allowing for the transfer of electrical signals through light. In a microcontroller project, optocouplers are important for protecting the microcontroller from damage due to high voltage or current, and for providing electrical isolation between different components or circuits.

2. How do I choose the right optocoupler for my microcontroller project?

When choosing an optocoupler for your microcontroller project, there are several factors to consider such as the voltage and current requirements, the speed and switching frequency, and the type of isolation needed (e.g. optical, capacitive, or magnetic). It is important to carefully read the datasheet of the optocoupler to ensure it meets the requirements of your project.

3. Can I use any optocoupler for my microcontroller project?

No, not all optocouplers are suitable for use in microcontroller projects. Some optocouplers may have different voltage or current ratings, or may be designed for specific applications. It is important to choose an optocoupler that is compatible with your microcontroller and meets the requirements of your project.

4. What is the difference between an optocoupler and a switch in a microcontroller project?

An optocoupler is an electronic component that provides electrical isolation between two circuits, while a switch is used to control the flow of current in a circuit. In a microcontroller project, an optocoupler is typically used for isolation and protection, while a switch is used to turn components on or off or to select different signals or inputs.

5. Are there any precautions I should take when using an optocoupler in my microcontroller project?

Yes, there are several precautions to keep in mind when using an optocoupler in a microcontroller project. It is important to properly calculate the voltage and current requirements, and to ensure the optocoupler is correctly connected and installed. It is also recommended to use optocouplers with built-in protection features, and to regularly test and monitor their performance to ensure they are functioning properly.

Similar threads

Replies
6
Views
6K
  • Electrical Engineering
Replies
22
Views
7K
  • Electrical Engineering
Replies
13
Views
6K
Back
Top