Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

driving optocoupler 4n35 using 8051

Status
Not open for further replies.

100k

Member level 1
Joined
Jun 16, 2012
Messages
37
Helped
1
Reputation
2
Reaction score
1
Trophy points
1,288
Activity points
1,607
Hi
I m working on a circuit which need to drive an optocoupler(4n35) using a micro controller. The problem is when i connect the uc with the optocoupler the low logic pin of the controller rise upto say 2.26V. I have checked the datasheet of the at89s52(micro contoller i m using) it says the pin can sink a max of 10 mA so i added resistance of 330E on the emmiter side of the optocoupler. So, the net current sinked by the optocoupler is (4.80-1.18)/330=10.9mA.
4.98V= Vcc, 1.18V= Vf of optocoupler. But still the problem persists, anyone please let me know why this happens or how to drive optocoupler using microcontroller.

Thanx
 

have you connected any resistor in series with the input of opto coupler?
and make opto led on with low level in port pin.

the emitter resistor do not have any effect on the port current.
if you post your present circuit , the problem can be identified.
 

I have connected 2nd pin of 4n35 with controller o/p the 1st is connected with the supply 5V(actually 7805 is giving 4.8V) via a 330E res. The current flowing through the emitter should be (4.80-1.18)/330=10.9mA , I suppose.

Further, when I disconnected the 10k res between the base and emitter of the 4n35 the circuit worked properly. The datasheet shows having high values of base emitter increase CTR but in my case it has been increased by removing the base emitter. Now, a new question poped out if the emitter and detector are isolated then why this happen? Although now my problem has been solved but the reason why it occurred and how it solved i can't explain.

If you know any good quality resource on optocouplers please share.
 
Last edited:

you can find whether the observation is due to port pin loading , by driving the opto with a pnp transistor and connecting the base of pnp transistor to port pin.(other resistors should be as appropriate)
 

how the port can be loaded when it is sinking current which is under its capacity.

Please explain the role of base resistance in the optocouplers.
 

how the port can be loaded when it is sinking current which is under its capacity.

Please explain the role of base resistance in the optocouplers.

are the lo voltage level indicated is a static one or dynamic one?

base resistance in opto coupler increases the switching speed.
and at the same time it reduces the CTR.

you have removed the base resistor , which means increasing base res to infinity and hence its ctr is as in data sheet.
 

The low voltage was 3.26 volts and high was 4.32V. The high is acceptable because it was driving the optocoupler but low wasn't. The low voltage was always 3.26 V hence, static.
I'm still wondering why I got 3.26V as low.

My circuit connection was like
pin 1: Vcc(5V) via a 100E res.
pin 2: to microcontroller.
pin 3: Not connected.
pin 4: ground.
pin 5: connected to Vs(12V)via a 10k res.
pin 6: a 10k res.

from this configuration the base current should be 38.2mA. And CTR as per datasheet is above 80% for 20mA of If(emitter current),so definitely it should be over 80%. I'm driving MOSFET from optocouplers so current shouldn't be an issue 'cos MOSFETs are voltage controlled. But this configuration wasn't working. And I'm amazed why.

If possible please share a method for calculating parameters for optocoupler like how to determine the values of base resistance, emitter resistance, etc.
Thanx for the enlightening on optocoupler.
 

before correcting optocoupler , make sure that your port pin is giving proper logic values.

remove optocoupler and measure the lo and hi voltage on port pin.
which port pin are u using?

are you sending any pulse waveform ? its frequency? duty cycle?

just test with a port pin as high and then as lo(no pulsed).only 1 and zero for a long time in pin.

observe the waveform or mesure the voltage in portpin.
 
  • Like
Reactions: 100k

    100k

    Points: 2
    Helpful Answer Positive Rating
I am sending a pulsed signal the logic levels were correct just before connecting the contoller to the optocoupler. Amazingly, when I connected some pins to optocoupler and left other pins away I could see that the logic level were false on the pins which were connected to the optocoupler and not on pins which were not connected. I 've reprogrammed the controller so that when I trigger it then only it will change its logic levels.

So, it seems the problem is with the optocouplers only, and why this problem solved when I removed the base resistor?

I used port 3 at 50Hz 50% duty cycle.
 

I Amazingly, when I connected some pins to optocoupler and left other pins away I could see that the logic level were false on the pins which were connected to the optocoupler and not on pins which were not connected.

without optocoupler , connect a separate LED to port pin , with your original 5v led supply and its series resitor with same value.

connect LED cathode to port pin and drive a 1 and then a 0.

if you observe the same problematic voltage , then it is a port pin problem.(mostly driving capability).
 

Yes I did that and it was working fine. But if it is a port pin problem then why and how it is solved by removing the base resistor of the optocoupler
 

My circuit connection was like
pin 1: Vcc(5V) via a 100E res.
pin 2: to microcontroller.
pin 3: Not connected.
pin 4: ground.
pin 5: connected to Vs(12V)via a 10k res.
pin 6: a 10k res.

in 4n35 pin number 6 no need any resistor and at pin number 5 10 k is so high try use with 1k resistor.


pin 1: Vcc(5V) via a 1k res.
pin 2: to microcontroller.
pin 3: Not connected.
pin 4: ground.
pin 5: connected to Vs(12V)via a 1k res.
pin 6: n/c

try this circuit its worked for me many times and if you using PORT 0 of 89c52 try check your pull up value.
 

Status
Not open for further replies.

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top