Shop OBEX P1 Docs P2 Docs Learn Events
Electronics basics: limiting resistors & optocouplers — Parallax Forums

Electronics basics: limiting resistors & optocouplers

EMHmark7EMHmark7 Posts: 93
edited 2013-12-23 21:09 in General Discussion
Hi,

I apologize for such dummy question (before I burn something).

1) With the Propeller (or any MCU) do I need always put a resistor on the I/Os?
(I connected the Parallax 4x20 LCD transmit wire without any resistor and it works).

2) I want to use an optocoupler, maybe the 4N25 (the most simple I have seen)
Any advice on using an optocoupler?
First, on the driven side, the ICs has a transistor Base pin (beside the optical "base"). Do we need to use it?

Second, my understanding is that some % current is "transmitted" from one side to the other.
But I suppose in fact it comes from the driven side, so cannot be bigger than the driven side source.

For my project, I want to drive a camera shutter switch by shorting the connector's switch.
About 3V., 0.2mA. On the other hand, I use a QuickStart Propeller.

Thanks.

Comments

  • Mike GreenMike Green Posts: 23,101
    edited 2012-08-29 09:19
    1) No. The resistor is to protect the I/O pin from voltages greater than the 3.3V maximum allowed, like from 5V sensors. It's also to prevent damage from accidentally connecting the I/O pin to voltages greater than 3.3V. Something like 3.3K is a reasonable value for this sort of thing for voltages up to about 5V.

    2) Most optocouplers, like the 4N25, look like LEDs to the Propeller (because that's what they are inside). Like any LED, you need a current limiting resistor to prevent damage to the optocoupler and the I/O pin. The exact value for the resistor depends on the amount of current needed for the optocoupler's LED. The 4N25's datasheet gives 10mA as a typical forward current. A 150 Ohm resistor should provide that.

    The output transistor of the 4N25 is controlled by the amount of light provided by the LED (all internal to the optocoupler). The datasheet gives the typical transfer current as 50%. If you run the LED at 10mA, that means that the output transistor will provide about 5mA through it.

    It's usually more reliable to use a reed relay driven by the Propeller. There are some reed relays that have a 3V coil and require less than 20mA of current to activate. These can be directly driven by a Propeller I/O pin although you need a reverse connected diode (like a 1N914 or 1N4001) across the relay coil. The relay contacts have nearly zero resistance when closed ... perfect for substituting for a pushbutton or other switch closure.
  • EMHmark7EMHmark7 Posts: 93
    edited 2012-08-29 13:14
    Thanks for fast reply.

    2) About optocoupler, I was more concerned by the camera side. I do not want to supply anything else than what the camera supplies itself in the remote switch connector. So, about using a 4N25, do you think I do not need to use the Base pin?

    2.1) Why do you say a 150Ohm resistor should provide 10mA, if 3.3V / (10/1000A)=330 Ohms?

    2.2) "typical transfer current as 50%. If you run the LED at 10mA, that means that the output transistor will provide about 5mA through it."
    But if it is the driven side that provides it, it should not have a current more than that, in my case, the camera supplies .2mA, no?

    Why do you say relay is more reliable? (I do not need fast stuff, I just program a delay if needed) But do you mean the optocoupler solution has its drawbacks?

    Thanks for providing a nice working solution with part#. I appreciate!



    But I will give a try with your suggestion of a relay. Specs say Mechanical endurance 10exp8 operations!
  • skylightskylight Posts: 1,915
    edited 2012-08-29 13:22
    EMHmark7 wrote: »
    About optocoupler, I was more concerned by the camera side. I do not want to supply anything else than what the camera supplies itself in the remote switch connector.!
    That's why Mikes solution is the best as the relay contacts are volt free and will not damage your camera
  • EMHmark7EMHmark7 Posts: 93
    edited 2012-08-29 13:22
    "These can be directly driven by a Propeller I/O"

    Using a relay such as 4N25, I suppose we need to limit current in the coil with a resistor?
  • skylightskylight Posts: 1,915
    edited 2012-08-29 13:38
    EMHmark7 wrote: »
    "These can be directly driven by a Propeller I/O"

    Using a relay such as 4N25, I suppose we need to limit current in the coil with a resistor?
    the coil has resistance and without a resistor will draw less than 20ma as Mike stated from the I/O pin
    The important thing is the reverse diode to stop Back EMF
  • RDL2004RDL2004 Posts: 2,554
    edited 2012-08-29 14:04
    However, the 4N25 is an optocoupler, not a relay and does need a current limiting resistor.
    The calculation is:
    R = V - VLED / ILED
    R = 3.3 - 1.8 / 0.010
    R = 150 Ω

    Just as Mike said before.
  • skylightskylight Posts: 1,915
    edited 2012-08-29 14:12
    sorry I should have removed the reference to 4N25 when I replied as I was on about the reed relays that Mike suggested.
  • Mike GreenMike Green Posts: 23,101
    edited 2012-08-29 14:18
    Part of the advantage of a relay over an optocoupler is that we don't really know what the camera shutter circuit requires in terms of voltage or current. A relay provides a contact closure which is the same electrically as a pushbutton. A transistor, like the output of the optocoupler, has a voltage drop across it and may only provide a limited amount of current.

    What RDL2004 showed as Vled is a combination of the voltage drop across the LED (about 1.4V) plus the typical voltage drop across the output transistor of the Propeller's output transistor (about 0.3V). 150 Ohms is a close standard value for the calculated resistance.
  • EMHmark7EMHmark7 Posts: 93
    edited 2012-08-29 15:52
    Thanks everyone (fast replies is so great when we really need it)! I'll try the IM01TS.
  • EMHmark7EMHmark7 Posts: 93
    edited 2012-09-12 08:07
    (Using a 3v (Up to 7.5v capable) driven relay (the IM01TS), should I put a limiting resistor for the amount of reverse current. I do not know if we can expect a reverse current higher than 3.3v?
    Or just the diode is enough?

    I mean, should I also drive it with an inverter (74LS05) or I can directly use the I/O as the 3.3v source?
  • Mike GreenMike Green Posts: 23,101
    edited 2012-09-12 09:00
    The diode is enough. What it does is clamp (limit) the voltage produced to 0.6V as the magnetic field collapses and turns the coil into a generator. The actual amount of current involved is low.

    The relay you picked (IM01TS) draws about 3 times as much current (47mA) as the one I mentioned (17mA) and definitely more than a Propeller I/O pin is designed for (40mA). You'll need to use a switching transistor to drive it as shown in Nuts and Volts Column #6. The N & V Column is written for the 5V Stamps and you'll need to use a smaller base resistor with the Propeller, something like 220 Ohms.
  • Mark_TMark_T Posts: 1,981
    edited 2012-09-12 09:49
    For driving a relay directly from CMOS logic a schottky diode might be preferred to prevent the output voltage rising above Vdd+0.5V. Schottky diodes have forward voltage ratings lower than normal pn-junction diodes and are inherently fast to respond. Failing a schottky a fast switching diode is better I reckon than the sluggish 1N4001 (1N4148 would do nicely for instance).

    Normally when using a diode to protect an external NPN transistor switch from inductive spikes we don't care about a few volts of spike getting past the diode due to its slow switching. When driving from CMOS microcontroller the input protection diodes have to be protected from over-voltage/over-current, and there is only about 0.5V of voltage swing permissable. The Prop input protection diodes may be able to take the current pulses, but its not clear from the published data what pulses they can take - the continuous current limit is 0.5mA though, so I would be very wary of 10mA pulses getting to them.
  • EMHmark7EMHmark7 Posts: 93
    edited 2012-09-12 10:57
    A chance you were there! My prop says I owe you my life!

    It was not clear and overloocked it in the specs sheets. When I divide Coil resistance from Rated voltage (3V) I see the current values you said.

    1) But I do not catch "The diode is enough. What it does is clamp (limit) the voltage produced to 0.6V " on how it limits voltage to 0.6V.

    2) And about a diode for protecting battery source before the VIN on the Quickstart board, does it need to be schottky?

    3) So, about a possible overvoltage induction swing, I am not shure what protection would be for shure a good practice. (talking about the relays)

    Thanks again,
  • EMHmark7EMHmark7 Posts: 93
    edited 2012-11-14 10:14
    Mark_T wrote: »
    ...When driving from CMOS microcontroller the input protection diodes have to be protected from over-voltage/over-current, and there is only about 0.5V of voltage swing permissable. The Prop input protection diodes may be able to take the current pulses, but its not clear from the published data what pulses they can take - the continuous current limit is 0.5mA though, so I would be very wary of 10mA pulses getting to them.

    Back in the project after a 2 months out of the country.

    I am obviously not an expert in electronics.
    I know we need to put a reversed diode parallel to a relay's coil.
    I imagine that as the diode has a lower resistance than the coil, reverse current will not go through the coil but through the diode.

    Q1) However, do we need to put a resistor in series with that diode in order to limit the spiking current?

    Q2) I found a shottky diode: http://www.digikey.com/product-detail/en/1N5819-T/1N5819DICT-ND/190960
    Current - Average Rectified (Io): 1A

    I do not know the meaning of this spec (if it is a max or other meaning)
    Anybody can tell me if it is a good choice for driving this 17mA relay (http://www.digikey.com/product-detail/en/IM21TS/PB1167-ND/1828439)
    from a Propeller I/O?

    Q3) By the way, what is the right/best way to use those prototyping boards in which the hole is large enough only for a through hole pin? (So in order to connect 2 or more things together at that node)

    Thanks again,
    Marc
  • Mike GreenMike Green Posts: 23,101
    edited 2012-11-14 10:38
    There's not a lot of current produced by the coil's magnetic field collapsing and the diode limits the voltage produced to about 0.7V (less for a Schottky diode). The danger from the field collapsing is that, if there's no protective diode, the voltage can get quite high (tens of volts at least) and that can damage low voltage ICs even with only a few microAmps of current.

    The Schottky diode and relay you showed should work fine with a Propeller I/O pin. I've used cheap 1N914A diodes and a SPST reed relay with similar coil characteristics ... works fine.

    With prototyping boards, I use two adjacent holes and bend the lead across from one hole to the other and create a solder bridge between the two
  • kwinnkwinn Posts: 8,697
    edited 2012-11-14 11:06
    That diode should be fine, and no resistor is required.
  • EMHmark7EMHmark7 Posts: 93
    edited 2012-11-14 11:17
    I confess I do not catch well the process involved. The coil itself has only its own resistance and the reverse diode has its own, I suppose hopfully lower than the coil. So I do not catch well how putting a diode limits the voltage. (Nobody needs to respond to that has it is just a theoric value).

    But, it is not clear if Q1) However, do we need to put a resistor in series with that diode in order to limit the spiking current?
    or do we need to put the resistor between the I/O and the Coil-Diode couple ?

    Thanks.
  • kwinnkwinn Posts: 8,697
    edited 2012-11-14 11:33
    The schottky diode has a forward voltage of about 0.3V so when the magnetic field on the coil collapses the voltage will only be that high. The coil has enough resistance that it limits the current to a level the diode can handle. The peak current through the diode will be high for a very brief time, but not high enough for a long enough time to damage the diode.
  • EMHmark7EMHmark7 Posts: 93
    edited 2012-11-25 07:45
    Another basic electronics question that I did not find answer elsewhere:

    I need to make a reference voltage. What is the difference between a Potentiometer used with the 3 connectors, compared to using it with only 2 connectors?
    Both will give a dfferent voltage. Does the 3-connector method have an advantage?

    Thanks.
  • kwinnkwinn Posts: 8,697
    edited 2012-11-25 11:27
    EMHmark7 wrote: »
    Another basic electronics question that I did not find answer elsewhere:

    I need to make a reference voltage. What is the difference between a Potentiometer used with the 3 connectors, compared to using it with only 2 connectors?
    Both will give a dfferent voltage. Does the 3-connector method have an advantage?

    Thanks.

    It depends on the circuit you are connecting it to. Lets say you have a 5V input reference voltage and you want to be able to adjust your output reference voltage from 0 to 5V. In that case you would use the 3 connection circuit with one end connected to ground, the other end to the +5V reference, and the output would come from the potentiometer wiper.

    If you were using a 3 terminal regulator to make an adjustable regulator you would have a fixed resistor (typically 120 ohms) between the output pin and the "adj" pin, and a potentiometer between the "adj" pin and ground. That potentiometer would use the 2 connection circuit.

    In the first case you are using the potentiometer to output the desired voltage. In the second case you are using the potentiometer to provide the desired resistance between the "adj" pin and ground.
  • EMHmark7EMHmark7 Posts: 93
    edited 2012-11-25 12:04
    I think you described the 2 options I am facing with. I did some experiments ans say that my understanding was wrong on potentiometers

    (due to childhood experiments where I could turn of a device when at max resistance. Maybe it was a feature of that potentiometers or because the resistance was lowering the current just enough to stall the motor o light).

    Now I see that with 2 pins, I can just lower a bit the voltage, rather than really getting full range down to zero by benefiting from the GND too.

    Thanks for your reply, my question was very preschool but helped my to catch other things and modify my design.

    Marc
  • EMHmark7EMHmark7 Posts: 93
    edited 2012-12-06 07:31
    Another basic electronics,
    Somebody whom knows more in that field told me that about putting tu power switch and fuse, it is normally put on + side of power source.
    (Even if as I did, he knows that nobody knows what the real current is, electron or positive "holes" running in the opposite direction)
    So, I am sharing the question about if it makes a difference to put it on - side of power source.
    (It is not just theoric, because maybe I will have to reopen my difficult to close handheld device before I try it)

    Thanks.
  • kwinnkwinn Posts: 8,697
    edited 2012-12-06 09:12
    EMHmark7 wrote: »
    Another basic electronics,
    Somebody whom knows more in that field told me that about putting tu power switch and fuse, it is normally put on + side of power source.
    (Even if as I did, he knows that nobody knows what the real current is, electron or positive "holes" running in the opposite direction)
    So, I am sharing the question about if it makes a difference to put it on - side of power source.
    (It is not just theoric, because maybe I will have to reopen my difficult to close handheld device before I try it)

    Thanks.

    Most power supplies have one side (positive or negative) that is considered the ground or neutral side. The switch and fuse should always be on the other side of the supply for safety. Not critical on a low voltage supply, but essential for higher voltages. Also good practice for low voltages.

    A supply that provides a positive voltage with the negative side grounded should have the switch and fuse on the positive side.
    A supply that provides a negative voltage with the positive side grounded should have the switch and fuse on the negative side.

    As to the electrons or holes flowing, it is really both. When an electron moves from one atom to the next one it leaves a hole behind and fills a hole in the atom it moved to. If it were possible to see this it would look like the electrons were moving in one direction while the holes were simultaneously moving in the other.
  • EMHmark7EMHmark7 Posts: 93
    edited 2012-12-06 17:56
    Thanks for your reply, it will help me in my project.

    "on the other side of the supply for safety", you mean, on the other side than the ground if I catch you well.

    (an explaination about why is well come for those who can put some more light on that)

    But as I said, I already know the electron/hole dilemma. By the way a nice image of that that I know is a less than full shampoo bottle you flip upside down while you see an air bubble going upwards while the liquid goes down.

    Thanks again,
  • EMHmark7EMHmark7 Posts: 93
    edited 2013-12-23 15:38
    Using the IM21TS http://www.digikey.com/product-detail/en/IM21TS/PB1167-ND/1828439
    relay with a reverse diode.

    Anybody have an idea about how long I can keep the relay set without resetting it without damaging it?
    Let's say I want to keep it set for 10 minutes or 1 hour or more more for keeping aperture on for shooting night sky images.

    Otherwise' I would need a relay that is bi-stable. If so, what is the typical way to interface it with the propeller?

    Thanks,
    Marc
  • Duane C. JohnsonDuane C. Johnson Posts: 955
    edited 2013-12-23 16:59
    Hi Marc;
    EMHmark7 wrote: »
    Anybody have an idea about how long I can keep the relay set without resetting it without damaging it?
    It looks like you can hold it on forever.

    It has a 3V coil that dissipates only about 60mW at 3.3V. Hardly enough to do any harm.

    Duane J
  • EMHmark7EMHmark7 Posts: 93
    edited 2013-12-23 20:17
    Thanks.

    Marc
  • ercoerco Posts: 20,256
    edited 2013-12-23 21:09
    EMHmark7 wrote: »
    Otherwise I would need a relay that is bi-stable. If so, what is the typical way to interface it with the propeller?

    localroger is the go-to guy for latching relays, which make sense for long "on" times: http://forums.parallax.com/showthread.php/151333-DPDT-latching-relays-20-cents-each
Sign In or Register to comment.