Author Topic: Resistor values with Opto Isolator  (Read 5856 times)

0 Members and 1 Guest are viewing this topic.

Offline BskitterTopic starter

  • Regular Contributor
  • *
  • Posts: 79
  • Country: cz
Resistor values with Opto Isolator
« on: May 19, 2016, 09:09:00 pm »
Hey Guys,

So I made a post a few days ago about some trouble I am having with controlling relays with a 74HC595 shifting register chip, I cant for the life of me figure out where I am going wrong.

I have tried
  • RC snubbers on Relay contacts and the coils + and -
  • Pull up Resistors on DS pin, STCP pin and SHCP pins
  • RC snubber on DS pin (data pin)
  • Different power supplies
  • Different Relays including Arduino Relay Shields

http://hstech.ro/HC595/

This guy had the exact same configuration as me except I only have 8 relays where he has 16 (I think)

I copied that schematic (on the site provided) exactly and still did not fix in my problem  |O

I Have a relay shield with opto iso's , IF is use two separate power supply the interference does not happen.

This is forcing me to now go with an option of running two power supplies in project.

This is the relay design now



I want to change it to something like this



(Please ignore the led and tranistor codes inside the opto iso i just made a look alike since the site I was using did not have an actually icon for one )

I dont know what Resistor values are required here tho, could you guys please recommend what resistors I should use or any changes to this configuration ?

I have an PC817 Opto Iso

Byron
« Last Edit: May 19, 2016, 09:11:35 pm by Bskitter »
 

Offline danadak

  • Super Contributor
  • ***
  • Posts: 1875
  • Country: us
  • Reactor Operator SSN-583, Retired EE
Re: Resistor values with Opto Isolator
« Reply #1 on: May 19, 2016, 09:25:26 pm »
R1 is just to limit base drive to all thats needed to saturate Q2. For that
to occur Ib = Ic / 10 to insure saturation. So R1 = ( V1 - Vcesatcoupler
transistor - Vbeq2 ) / Ib.

R2 is just to limit LED current , so look up that in datasheet, recommended
LED operating current, and R2 = ( Vddcpu - Vohpin - Vled ) / Iled

Regards, Dana.
Love Cypress PSOC, ATTiny, Bit Slice, OpAmps, Oscilloscopes, and Analog Gurus like Pease, Miller, Widlar, Dobkin, obsessed with being an engineer
 

Offline rstofer

  • Super Contributor
  • ***
  • Posts: 9889
  • Country: us
Re: Resistor values with Opto Isolator
« Reply #2 on: May 20, 2016, 03:19:43 am »
R1 is just to limit base drive to all thats needed to saturate Q2. For that
to occur Ib = Ic / 10 to insure saturation. So R1 = ( V1 - Vcesatcoupler
transistor - Vbeq2 ) / Ib.

R2 is just to limit LED current , so look up that in datasheet, recommended
LED operating current, and R2 = ( Vddcpu - Vohpin - Vled ) / Iled

Regards, Dana.

All of which is shorthand for the fact that without a datasheet for the opto, there is no way to give you a numeric answer.  We should also have the relay coil detail so we can figure the 2N2222 collector current and back into the base current.  There needs to be enough base current to saturate the transistor and eliminate excessive heating.

The other 'gotcha' is that the 595 doesn't want to source or sink very much current - on the order of 5 mA for the conditions in the datasheet.  Yes, the MAX is higher than that but realistically, the device isn't designed for driving high current loads.  Which brings us back to the opto:  Can we get the output into saturation with as little as 5 mA of LED current?  Datasheet time...


 

Offline BskitterTopic starter

  • Regular Contributor
  • *
  • Posts: 79
  • Country: cz
Re: Resistor values with Opto Isolator
« Reply #3 on: May 20, 2016, 10:10:08 am »
Datasheet time is here,



Also the coil Specs are

12V

220Ohms

55mA
 

Offline BskitterTopic starter

  • Regular Contributor
  • *
  • Posts: 79
  • Country: cz
Re: Resistor values with Opto Isolator
« Reply #4 on: May 20, 2016, 10:18:25 am »
RCL = (Vcc-VF)/IF
                       =   (5V-1.2V)/0.020 A
                       = 190 ohms (round down to 180 or up to 200 ohms)

But what about the resistor of the base on the n2222 ?

This saturation mode confuses me a bit,

Could some explain the calculation for dummies to me please ?

The most I know is that saturation mode is where the transistor acts as a switch.

 

Offline danadak

  • Super Contributor
  • ***
  • Posts: 1875
  • Country: us
  • Reactor Operator SSN-583, Retired EE
Re: Resistor values with Opto Isolator
« Reply #5 on: May 20, 2016, 10:49:11 am »
In order to drive a bipolar T into saturation one has to drive enough
base current to force the collector junction into forward bias. This occurs
when the beta drops sufficiently, and the industry rule of thumb is 10,
so Ib = Ic / 10.


http://www-inst.eecs.berkeley.edu/~ee105/sp08/lectures/lecture5_2.pdf

http://www.ittc.ku.edu/~jstiles/312/handouts/Example%20A%20BJT%20Circuit%20in%20Saturation.pdf


Regards, Dana.
« Last Edit: May 20, 2016, 11:01:11 am by danadak »
Love Cypress PSOC, ATTiny, Bit Slice, OpAmps, Oscilloscopes, and Analog Gurus like Pease, Miller, Widlar, Dobkin, obsessed with being an engineer
 

Offline Cervisia

  • Regular Contributor
  • *
  • Posts: 83
  • Country: 00
Re: Resistor values with Opto Isolator
« Reply #6 on: May 20, 2016, 10:51:05 am »
You don't need 20 mA through the LED.

First, determine how much current you need through the relay. Is that 55 mA the minimum needed to close the relay, or the Absolute Maximum rating (i.e., the current at which it can explode)?

Assuming that you actually need 55 mA, and that the transistor is to be saturated, we force Ic/Ib = 10, so the needed base current is 5.5 mA.

Now use the current transfer ratio of the PC817 to determine the required LED current. If your chip isn't labeled A/B/C/D, its worst-case CTR is about 50 %, so the required LED current would be 11 mA. If your shift register cannot supply that, use a separate transistor to amplify the current for the LED, or measure the optocoupler's actual CTR (and then choose a better one, if needed).
« Last Edit: May 20, 2016, 10:53:14 am by Cervisia »
 

Online Zero999

  • Super Contributor
  • ***
  • Posts: 19491
  • Country: gb
  • 0999
Re: Resistor values with Opto Isolator
« Reply #7 on: May 20, 2016, 12:27:49 pm »
Hey Guys,

So I made a post a few days ago about some trouble I am having with controlling relays with a 74HC595 shifting register chip, I cant for the life of me figure out where I am going wrong.

I have tried
  • RC snubbers on Relay contacts and the coils + and -
  • Pull up Resistors on DS pin, STCP pin and SHCP pins
  • RC snubber on DS pin (data pin)
  • Different power supplies
  • Different Relays including Arduino Relay Shields

http://hstech.ro/HC595/

This guy had the exact same configuration as me except I only have 8 relays where he has 16 (I think)

I copied that schematic (on the site provided) exactly and still did not fix in my problem  |O

I Have a relay shield with opto iso's , IF is use two separate power supply the interference does not happen.

This is forcing me to now go with an option of running two power supplies in project.

This is the relay design now



I want to change it to something like this



(Please ignore the led and tranistor codes inside the opto iso i just made a look alike since the site I was using did not have an actually icon for one )

I dont know what Resistor values are required here tho, could you guys please recommend what resistors I should use or any changes to this configuration ?

I have an PC817 Opto Iso

Byron
Why are you using both an opto-coupler and a relay?

The 74HC595 is more than capable of directly driving a transistor and a relay provides galvanic isolation. There is no need to have an opto-coupler, as well as a relay.
 

Offline danadak

  • Super Contributor
  • ***
  • Posts: 1875
  • Country: us
  • Reactor Operator SSN-583, Retired EE
Re: Resistor values with Opto Isolator
« Reply #8 on: May 20, 2016, 12:41:39 pm »
Transistor saturation, attached.


Regards, Dana.
Love Cypress PSOC, ATTiny, Bit Slice, OpAmps, Oscilloscopes, and Analog Gurus like Pease, Miller, Widlar, Dobkin, obsessed with being an engineer
 

Offline rstofer

  • Super Contributor
  • ***
  • Posts: 9889
  • Country: us
Re: Resistor values with Opto Isolator
« Reply #9 on: May 20, 2016, 02:20:13 pm »
The single transistor scheme should work.  The video is interesting but I'm not clear on what voltage is being applied and where.
Your decoupling caps (0.1 ufd ceramic) need to be as close as possible to the Vcc and Gnd pins at each chip.  Right at the chip.
I would be looking at the power supply with a scope.  There's something wrong if the supply is so wimpy that it drops out when switching relays.  OTOH, switching all 8 at the same time might be an issue.

I have used the 2N2222A for driving relays many times with no issues.  There is something wrong with your power scheme.  It's unfortunate but without using an opto, the ground between the logic and relays must be common.  It can be two separate ground planes connected together at a single port but they must be connected.

The Arduino Relay Shield uses a similar scheme except that they use PNP transistors.  Here is the schematic:
https://www.bing.com/images/search?q=arduino+relay+shield+schematic&view=detailv2&&id=A0A2FE751FBE845150C292F6E99B997B4C8DF0A0&selectedIndex=3
 

Offline danadak

  • Super Contributor
  • ***
  • Posts: 1875
  • Country: us
  • Reactor Operator SSN-583, Retired EE
Re: Resistor values with Opto Isolator
« Reply #10 on: May 21, 2016, 12:20:53 am »
Keep in mind from the basic C equation you can get a rough idea of
C size needed to prevent droop.

Q = C x V, I = C x dV / dT

So look up transient response time of the reg, that becomes dT. You know the total I
from relay specs (total of all 8, that's worst case). Now stipulate dV you will tolerate,
and compute C = ( I x dT ) / dV. Amps, Volts, Farads are units used in eqns.

This is an oversimplification, loop dynamics a little more complicated, but a gross way of getting to
size of C. Its also oversimplified as C is a f( V across cap).

Regards, Dana.
« Last Edit: May 21, 2016, 12:23:51 am by danadak »
Love Cypress PSOC, ATTiny, Bit Slice, OpAmps, Oscilloscopes, and Analog Gurus like Pease, Miller, Widlar, Dobkin, obsessed with being an engineer
 

Online Zero999

  • Super Contributor
  • ***
  • Posts: 19491
  • Country: gb
  • 0999
Re: Resistor values with Opto Isolator
« Reply #11 on: May 21, 2016, 01:31:35 pm »
Have you tried this.
 

Offline BskitterTopic starter

  • Regular Contributor
  • *
  • Posts: 79
  • Country: cz
Re: Resistor values with Opto Isolator
« Reply #12 on: May 21, 2016, 02:33:26 pm »
Hi All !

Thank you for all the feedback !

@Hero999

I have not tried that configuration, But I will when I get home later.


Also the opto coupler will be used to separate the power from the relays and the logic part of the project,

I have a feeling the power supply part of my project could have the problem,

So the two problems that arise when I apply 230VAC through the relay

  • The 595 Chip somehow gets effect and loses the data in its register, I have probed every possible input on that chip and have seen nothing.
  • The Arduino USB controller disconnnects as well, this tells me that there could be dip or spike in power.

Now I have not explained How I am powering my project.

I have a meanwell switching power supply

http://www.gmelectronic.com/switching-power-supply-mean-well-lrs-35-12-p332-892

This one to be exact

well its Very basic, 1st here is a photo of the power supply board I have built



it consists of two LM2575 switch regulators, and one LM7805 linear voltage regulator





(On the picture of my board it does look different but this is before I made the change)

And I have followed these schematics.

Could a sudden spike in the system cause the switching regulators to do something strange ?

I also noticed that if the relays are closer to the power supply and Arduino the Problem is a lot more apparent !

Any idea guys ?l

 

 

Online Zero999

  • Super Contributor
  • ***
  • Posts: 19491
  • Country: gb
  • 0999
Re: Resistor values with Opto Isolator
« Reply #13 on: May 21, 2016, 05:02:20 pm »
Hi All !

Thank you for all the feedback !

@Hero999

I have not tried that configuration, But I will when I get home later.


Also the opto coupler will be used to separate the power from the relays and the logic part of the project,
As the 5V supply to the logic is provided by an unisolated voltage regulator, it can't be separate from the power used for the relays and there's no point in using an opto isolator.

Another possibility is using a relay which can be driven directly by the 5V signal from the 74HC595.

Quote
I have a feeling the power supply part of my project could have the problem,

So the two problems that arise when I apply 230VAC through the relay

  • The 595 Chip somehow gets effect and loses the data in its register, I have probed every possible input on that chip and have seen nothing.
  • The Arduino USB controller disconnnects as well, this tells me that there could be dip or spike in power.
Do you only get those problems when 230VAC is applied to the relays? If so, what are you switching with the relays?
 

Offline BskitterTopic starter

  • Regular Contributor
  • *
  • Posts: 79
  • Country: cz
Re: Resistor values with Opto Isolator
« Reply #14 on: May 21, 2016, 06:07:56 pm »
@Hero999

I use the N2222 tranistor controlled by the 595 which is the controlled by the Arduino.

I have probed everywhere with a scope and can so NOTHING, no interference at all :/

This spike somehow creeps around in the Ground.

 

Offline danadak

  • Super Contributor
  • ***
  • Posts: 1875
  • Country: us
  • Reactor Operator SSN-583, Retired EE
Re: Resistor values with Opto Isolator
« Reply #15 on: May 21, 2016, 06:32:40 pm »
If you have a DSO you can try two things to catch a spike -

1) Set scope on infinite persistence, and over a few seconds see if anything
shows up outside supply rails.

2) Set triggering up for a runt pulse, try 100 uS for a trail run, see if scope
triggers.


Regards, Dana.
Love Cypress PSOC, ATTiny, Bit Slice, OpAmps, Oscilloscopes, and Analog Gurus like Pease, Miller, Widlar, Dobkin, obsessed with being an engineer
 

Offline BskitterTopic starter

  • Regular Contributor
  • *
  • Posts: 79
  • Country: cz
Re: Resistor values with Opto Isolator
« Reply #16 on: May 21, 2016, 06:52:23 pm »
@Dana

So I am probing around again !

and now I see a -5 dip as soon as the relays shutdows I saw this dip between ground and Vcc of the 595 register chip !

Now before I continue please note i have this scope !

http://www.ebay.com/itm/DSO138-2-4-TFT-LCD-Digital-Oscilloscope-DIY-Kit-1Msps-200KHz-Bandwidth-W-Probe-/191827754952?hash=item2ca9d33fc8:g:eRgAAOSwyjBW5opl

I know its not the best but it is all I have for now.

How do I get rid of this dip.

My Idea is to just put a large cap between gnd and vcc of the chip ?

Any suggestions
 

Offline BskitterTopic starter

  • Regular Contributor
  • *
  • Posts: 79
  • Country: cz
Re: Resistor values with Opto Isolator
« Reply #17 on: May 21, 2016, 06:55:59 pm »
Note the gnd of the osciliscope is connected to the collector of the 2n2222 !
 

Offline BskitterTopic starter

  • Regular Contributor
  • *
  • Posts: 79
  • Country: cz
Re: Resistor values with Opto Isolator
« Reply #18 on: May 21, 2016, 07:00:02 pm »
NOW I AM CONFUSED

I just put a dioide (n4007) between ground of the supply and ground of the 595 and the realy now does not shut down. WTF ?

Please could someone explain this ??
 

Online Zero999

  • Super Contributor
  • ***
  • Posts: 19491
  • Country: gb
  • 0999
Re: Resistor values with Opto Isolator
« Reply #19 on: May 21, 2016, 07:23:09 pm »
It's not possible to tell you what's wrong, without a complete schematic.
 

Offline BskitterTopic starter

  • Regular Contributor
  • *
  • Posts: 79
  • Country: cz
Re: Resistor values with Opto Isolator
« Reply #20 on: May 21, 2016, 07:55:49 pm »
Hey Hero999

Ill get to posting a full schematic soon, just tried to draw it on this site and then they asked me to pay and it lost my sketch  |O |O |O

Ill draw it somehow (in paint)

but the problem goes away if i put a diode on vcc and gnd of the 595, the coil has a bit of a buzz to it tho !

I suspect the flyback diode is not doing the job it is meant to be doing !
 

Offline BskitterTopic starter

  • Regular Contributor
  • *
  • Posts: 79
  • Country: cz
Re: Resistor values with Opto Isolator
« Reply #21 on: May 21, 2016, 09:20:01 pm »




Here they are Sorry for the quailty if you can recommend a good free circuit drawing site I could put it in there.

 

Offline danadak

  • Super Contributor
  • ***
  • Posts: 1875
  • Country: us
  • Reactor Operator SSN-583, Retired EE
Re: Resistor values with Opto Isolator
« Reply #22 on: May 21, 2016, 10:49:31 pm »
For drawing schematics use the free spice tools like -


http://www.ti.com/tool/tina-ti

http://www.analog.com/en/design-center/interactive-design-tools/adisimpe.html

http://www.linear.com/designtools/software/     LTC Spice

They have a schematic capture front end.

In your schematic do not separate grounds with a diode. All grounds should meet at
the supply.

Your scope is simply too slow to capture fast transients like you are experiencing. When the
time comes and you can upgrade consider a scope of 100 Mhz or better.

http://cp.literature.agilent.com/litweb/pdf/5989-5733EN.pdf


Regards, Dana.
« Last Edit: May 21, 2016, 10:55:09 pm by danadak »
Love Cypress PSOC, ATTiny, Bit Slice, OpAmps, Oscilloscopes, and Analog Gurus like Pease, Miller, Widlar, Dobkin, obsessed with being an engineer
 


Share me

Digg  Facebook  SlashDot  Delicious  Technorati  Twitter  Google  Yahoo
Smf