Pages: [1]   Go Down
Author Topic: Control other circuit with a transistor.  (Read 343 times)
0 Members and 1 Guest are viewing this topic.
Poland
Offline Offline
Newbie
*
Karma: 0
Posts: 28
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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

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.


* forum.png (2.69 KB, 322x215 - viewed 24 times.)
Logged

UK
Offline Offline
Faraday Member
**
Karma: 99
Posts: 4153
Where is your SSCCE?!?!
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

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)
Logged

Get 10% off all 4D Systems TFT screens this month: use discount code MAJENKO10

0
Offline Offline
Shannon Member
****
Karma: 199
Posts: 11671
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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).]
« Last Edit: February 23, 2013, 04:27:47 pm by MarkT » Logged

[ I won't respond to messages, use the forum please ]

Poland
Offline Offline
Newbie
*
Karma: 0
Posts: 28
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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.
« Last Edit: February 23, 2013, 04:44:58 pm by Rubid » Logged

Pages: [1]   Go Up
Jump to: