[AVR] Atmega8 Digital input using 4n35 optocoupler

Status
Not open for further replies.

asking

Full Member level 5
Joined
Sep 21, 2010
Messages
279
Helped
6
Reputation
12
Reaction score
6
Trophy points
1,298
Visit site
Activity points
3,377


I want to take the field Digital inputs using opto-coupler 4n35 as i have show in the above schmatic. But such arrangement is not working with Atmega8 in the Real hardware. I don't know the reason...actually when i check with multimeter. when the led source is on the PIN5 reads 60mv and when the led source of 4n35 is off it reads 5.0V. but when i connect this 5v as show in the schmatic to atmega8 it's not detecting...

so any other circuit idea of reading field digital inputs via 4n35 (optical isolation)?

Thanks...
 

Hi,

Set the port to input by writing a "0" to the corresponding "ddrb" bit.

Read in by using "pinb".
You will see a low, when optocouplercis active.

Hope this helps
Klaus

Added: ..and be sure that your programmer does not overwrit the mosi pin.
 
Reactions: asking

    asking

    Points: 2
    Helpful Answer Positive Rating
Hi,

I found the problem. It was DDRB bit which was set to be in output direction. DDRB = 0xFF; but still i was able to use external push button with no issues. That's strange. But as soon as i made it DDRB = 0x00; i am able to detect the opto-coupler signal and now my circuit is optically isolated.

Thanks
 

Status
Not open for further replies.

Similar threads

Cookies are required to use this site. You must accept them to continue using the site. Learn more…