Author Topic: AVR ISP Programmer Optoisolator Circuit  (Read 4522 times)

0 Members and 1 Guest are viewing this topic.

Offline KerryTopic starter

  • Jr. Member
  • **
  • Posts: 30
  • Helpful? 0
AVR ISP Programmer Optoisolator Circuit
« on: November 08, 2009, 08:22:00 PM »
Hello,

I want to create a circuit to go in-between my AVR ISP mkII and whatever AVR-containing circuit I want to program such that the programmer is isolated from the circuit and the MCU.  I've created the attached schematic, but I'm unsure how to finish it (or if what I've got so far is correct).  These are my thoughts:

These pins are for data going in the direction Programmer -> MCU
RST (pin 5)
MOSI (pin 4)
SCK (pin 3)
EDIT:  Correct pin#s

MISO (pin 1) is for data going MCU -> Programmer

GND and VTG are for reference and don't actually need to be coupled.

I assumed this was going to be pretty basic - if the signal on the input side of the isolator is at +5V relative to the input side ground, the output should be 5V above the output side ground.  If the input signal is at 0V, the output side should follow.  The schematic shows four pull-down resistors so the output from the optoisolators is at 0V, unless the optoisolator output is high, then it pulls the signal high.  The collector is always at VCC (or VTG, +5V).

I'm getting stuck on what to do with the negative side of the LEDs (circles in red).  My first guess was just to ground them, and my second guess was that they needed to be grounded through a resistor (not sure why I thought that would help), but some quick tests on a breadboard showed that I was unable to get the output side to react as I intended, regardless of my connection to that pin.  So... am I completely missing the boat on this one, or am I close?

Note:  I'm actually using 4N27 isolators, not 4N25's - it's the same datasheet, so I believe the functionality is the same.  The CAD software I'm using has a 4N25 but no 4N27, so that's what I show in the schematic.

Thanks for the help!

-Kerry
« Last Edit: November 08, 2009, 08:23:43 PM by Kerry »

Offline KerryTopic starter

  • Jr. Member
  • **
  • Posts: 30
  • Helpful? 0
Re: AVR ISP Programmer Optoisolator Circuit
« Reply #1 on: November 08, 2009, 08:42:34 PM »
Rather than edit my first post - here's an update:

Turns out the optoisolator I was using was fried - I swapped it out and it's behaving as I expected.  I'm using a resistor between the negative LED lead and ground (and afraid to try anything different in case this fried the first one).  I also removed the pull-down resistor from the 4N27 pin 6 (the emitter) and I'm getting high and low output as expected, even without the pull-down resistor.  I realize this could just be coincidence, but I'm doubting the necessity of the pull-down resistor on the emitter now.  Thoughts on this?

Datasheet for the 4N27:  http://www.vishay.com/docs/83725/4n25.pdf

Thanks!

-Kerry

Offline Soeren

  • Supreme Robot
  • *****
  • Posts: 4,672
  • Helpful? 227
  • Mind Reading: 0.0
Re: AVR ISP Programmer Optoisolator Circuit
« Reply #2 on: November 09, 2009, 11:17:24 AM »
Hi,

You need a resistor in series with each LED. It doesn't matter on which side of the LED it is placed.

Assuming 5V logic and 1.5V for the LED, a resistor of 3.5/0.01 = 350  use 330 Ohm.
Whether your logic can drive 10mA is quite another matter though.
Regards,
Søren

A rather fast and fairly heavy robot with quite large wheels needs what? A lot of power?
Please remember...
Engineering is based on numbers - not adjectives

Offline KerryTopic starter

  • Jr. Member
  • **
  • Posts: 30
  • Helpful? 0
Re: AVR ISP Programmer Optoisolator Circuit
« Reply #3 on: November 09, 2009, 03:15:38 PM »
Is 10 mA a typical value for an LED?  The datasheet shows the LED current going as low as 0.5 mA, although I don't see a recommended value called out anywhere.  I suppose I could try a 3k3 Ohm resistor to drop the current down to something more reasonable for logic?  Is my approach reasonable?  I feel like I'm guessing...

Thanks for the help!

-Kerry

Offline SmAsH

  • Supreme Robot
  • *****
  • Posts: 3,959
  • Helpful? 75
  • SoR's Locale Electronics Nut.
Re: AVR ISP Programmer Optoisolator Circuit
« Reply #4 on: November 09, 2009, 03:47:46 PM »
Yes, 10-20mA is normal for an led.
Howdy

Offline Soeren

  • Supreme Robot
  • *****
  • Posts: 4,672
  • Helpful? 227
  • Mind Reading: 0.0
Re: AVR ISP Programmer Optoisolator Circuit
« Reply #5 on: November 09, 2009, 05:36:54 PM »
Hi,

Is 10 mA a typical value for an LED?  The datasheet shows the LED current going as low as 0.5 mA, although I don't see a recommended value called out anywhere.
We're looking at a specific LED here, namely the one in the 4N27.
The DC Current Transfer Ratio for this (IR) LED is 30% (typ), 10% (min).
That means, that for 10mA in, you can draw 3mA (typ), 1mA (min).
For 0.5mA the values would be 150µA and 50µA respectively.

I don't know what currents you need out of the 4N27, but a potential 50µA is probably less than what you need.

You shouldn't go over 10mA though.


I suppose I could try a 3k3 Ohm resistor to drop the current down to something more reasonable for logic?  Is my approach reasonable?  I feel like I'm guessing...
You could use a transistor like BC337 or 2N2222 to drive each LED, or... You could connect it up directly.
Regards,
Søren

A rather fast and fairly heavy robot with quite large wheels needs what? A lot of power?
Please remember...
Engineering is based on numbers - not adjectives

 

SMF spam blocked by CleanTalk