Go Down

Topic: Control other circuit with a transistor. (Read 393 times) previous topic - next topic

Rubid

Hi guys,
maybe a stupid question - please don't bite :)

I want to control the optocoupler circuit with a transistor, but there are few other things that messes the whole situation.

If the switch is released:
a) the LED should be turned OFF.
b) the logical state on PD2 should be HIGH.
c) the optocoupler should be connected with ground.

How to achieve the third thing by not spoiling the other two?

See attached schema.

majenko

The problem with this is current will flow from the base to the emitter of the transistor causing the LED to illuminate.

If you replace the transistor with a MOSFET then current doesn't flow.

Try this out: Click Here (requires Java)
Get 10% off all 4D Systems TFT screens this month: use discount code MAJENKO10

MarkT

#2
Feb 23, 2013, 10:25 pm Last Edit: Feb 23, 2013, 10:27 pm by MarkT Reason: 1
Connect the optocoupler like the LED - so long as the total current is below 40mA (lets say 10mA for LED, 20mA for
optocoupler), then it will work as you want.

The transistor isn't necessary for a normal opto coupler which wants 10 to 20mA or so.

If a transistor was wanted then you'd need a PNP transistor doing high-side switching of the opto coupler, but
just driving it direct from the pin seems simpler here.

[edit:  doh, what was I thinking, the current flows through the push-button, no need to limit to 40mA, just choose
the right series resistor for 5V and the intended current.  (don't try to share it with the LED's series resistor).]
[ I won't respond to messages, use the forum please ]

Rubid

#3
Feb 23, 2013, 10:40 pm Last Edit: Feb 23, 2013, 10:44 pm by Rubid Reason: 1
Thanks majenko, I'll check that out.

MarkT, do we understand each other correctly? The PD2 is in INPUT mode... I can't control anything with that pin...

The optocoupler is used to control the motor movement. If the switch is pressed, I want to light up the LED and stop the motor movement.

Go Up