Shop OBEX P1 Docs P2 Docs Learn Events
12 Volts into the propeller — Parallax Forums

12 Volts into the propeller

DavidMDavidM Posts: 630
edited 2007-11-14 20:22 in Propeller 1
HI,

I need to get an external 12 volt signal ( a short pulse about 100ms) to "trigger" an input into the propeller.

The 12v signal can be of reverse polarity, so I chose a bridge rectifier (DI104) to handle this, I then send that to an opto isolator ( 4N25) as shown in my schematic.

Q1) Can any one advise is this circuit will work?
Q2) Have I chosen the correct devices ?
Q3) Are the resistor values correct?

Thanks

Dave M

Comments

  • darcodarco Posts: 86
    edited 2007-11-14 00:17
    I'm not sure if the shunt resistor (R3) is necessary, but the resistor values overall look good to me. The optoisolator seems correctly connected. I think it will work.

    Then again, I am kinda new at this stuff. The circuit looks so simple that it would be pretty easy to whip it together on a breadboard and find out for sure.
  • LeonLeon Posts: 7,620
    edited 2007-11-14 00:23
    You don't need R3. Apart from that it looks OK. I used a similar circuit once to detect the presence of an AC signal.

    Leon

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Amateur radio callsign: G1HSM
    Suzuki SV1000S motorcycle
  • Nick MuellerNick Mueller Posts: 815
    edited 2007-11-14 00:31
    R2 seems to be too small (R3 left out). You do have about 16V and want about 10mA through the diode. 1k6 or such.
    R1 looks too big. I'd try 3k (or have a close look at the datasheet smile.gif)


    Nick

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Never use force, just go for a bigger hammer!

    The DIY Digital-Readout for mills, lathes etc.:
    YADRO
  • deSilvadeSilva Posts: 2,967
    edited 2007-11-14 00:32
    Why do you opto-couple in the first place?
  • DavidMDavidM Posts: 630
    edited 2007-11-14 00:35
    HI Guys,

    thanks for the replies,

    I have the components so I will make up the circuit!

    But..

    Would the "SHUNT" resistor R3 , help with avoiding a SHORT CIRCUIT in the 12 volt input?

    eg , Imagine that a direct voltage is applied say straight from a 12v battery into the rectifier


    regards

    Dave M
  • DavidMDavidM Posts: 630
    edited 2007-11-14 00:39
    Hi deSilva,

    I am using an opto-coupler because the 12v input can be from "unreliable" sources and I want to protect the rest of my circuit

    regards

    Dave M
  • DavidMDavidM Posts: 630
    edited 2007-11-14 00:43
    Hi Nick Muller,

    A1) R1, is 10K because I believe its a standard PULL-UP, So when the opto senses an input , the signal should be pulled to ground? I think?

    A2) If I leave out R3, then yes, I will need to make R2 smaller to let more current in, I can play with the resistor values on my PCB, Its the "wiring" I want to get right.

    Thanks

    Dave M
  • deSilvadeSilva Posts: 2,967
    edited 2007-11-14 00:52
    (1) R3 will not help any... the current will flow through the LED anyhow. In fact you have doubled the current load from 25 to 50 mA...

    (2) I should consider Nicks concerns

    (3) Take 1/2 Watt resistors by all means!

    (4) The Propeller - as all CMOS chips - is safe for around 2kV, which is the voltage wie carry "in our little finger" smile.gif
    Opto-couplig is used when you are really unsure about the GND-situation or are a true paranoic smile.gif

    Edit: No, R1 is a collector resistor!
  • DavidMDavidM Posts: 630
    edited 2007-11-14 01:25
    HI DeSilva,

    Thanks for your reply,

    1) Ok, I will forget about R3! smile.gif

    2) I will try 3K for R1, instead of 10K

    3) I will use 1/2 watt resistors,

    4) yes I am true paranoic????? So I will keep the opto!

    thanks everyone for your help!

    I can't see in the spec sheet for the opto how to derive the current required for the input to the internal LED ? What parameter in the spec sheet do I look for?
    I am figuring that a 500R to 1K resistor ( for R2) over 12 Volts should give me about 20-10ma? is this correct?

    I took off 0.7 volts for each two of the diodes in the rectifier.

    12V - 0.7 X 2 = 10.6V

    10.6V / 10ma (0.01A) = 1060 ohms ( approx 1K )

    OR,

    if I need 20ma then..

    10.6V / 20ma ( 0.02A) = 530R

    I have attached a revised schematic.


    regards

    Dave M
  • darcodarco Posts: 86
    edited 2007-11-14 03:13
    I'm not sure why 3k would be better than 10k for a pull-up resistor. If it were me, I would go with a 10k pull-up. The test circuit in the datasheet uses a 10k resistor.

    Always better to be safe than sorry when dealing with unpredictable voltages, so I think an optoisolator is a good idea.

    R1 should be as low as you can get away with.
  • DavidMDavidM Posts: 630
    edited 2007-11-14 03:58
    HI Darco,

    I am thinking the same thing,

    But..

    I need the "CONNECTIONS" right first, as I am trying to finish some PCB designs, I can always play with the resistor values later!



    Thanks
  • Beanie2kBeanie2k Posts: 83
    edited 2007-11-14 04:45
    Circuit looks good to me. The only concern I would have is leaving the base of the optocoupler (pin 6) unconnected, as, depending on how electrically "noisy" the environment is, stray currents might cause false triggering. You might try connecting a resistor between it and ground. The value will have to be found experimentally. Too low a value and the optotransistor will not turn on, too high a value and the resistor will be ineffective. If you are using the device in an electrically "quiet" area (although it sounds like you are not) then maybe the resistor can be omitted.
  • Peter JakackiPeter Jakacki Posts: 10,193
    edited 2007-11-14 05:22
    Dave, you're doing this the hard way. Try an ac input opto like the ACPL-824 which is a dual ac input/transistor output opto in an 8-pin DIP for $1.31 from Farnell. This way you skip the bulky bridge rectifier. With a CTR (current transfer ratio) of 20 to 300% you only need 5ma max input it which means a current limit resistor of around 2K2, so 1K is fine as well.

    BTW, if a base pin is available you can ignore it completely unless you want to bias the transistor in some fashion.


    *Peter*

    au.farnell.com/jsp/Optoelectronics/Optocouplers/AVAGO+TECHNOLOGIES/ACPL-824-W00E/displayProduct.jsp?sku=1339027
  • Fred HawkinsFred Hawkins Posts: 997
    edited 2007-11-14 05:50
    Following links after Peter's there is this nice design guide for optoisolators. http://www.avagotech.com/assets/downloadDocument.do?id=405
  • deSilvadeSilva Posts: 2,967
    edited 2007-11-14 08:11
    Good link, Fred - I like this (much simpler PDF) even better:
    www.jaycar.com.au/images_uploaded/optocoup.pdf
    For people who think a collector resistor is a pull-up is a "pull-up" this will be intersting to read as well:
    www.utdallas.edu/~randall.lehmann/Experiment%205.pdf
  • Nick MuellerNick Mueller Posts: 815
    edited 2007-11-14 08:48
    Concerning optocoupler or not:

    You *need* one if you need or want to isolate grounds. With a common ground it isn't necessary.
    With a common ground, a voltage divider and a limiting resistor (just to be sure) on the Propeller's input does the job perfect.



    Nick

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Never use force, just go for a bigger hammer!

    The DIY Digital-Readout for mills, lathes etc.:
    YADRO
  • Peter JakackiPeter Jakacki Posts: 10,193
    edited 2007-11-14 09:43
    On the subject of pullups and with a view to helping some understand how to use them....

    PULLUP + SWITCH
    If the propeller input is connected to a pushbutton to ground then we would also add a "pullup" resistor to VDD so that the input will either see either +3.3V or 0V right?

    PULLUP + TRANSISTOR (or PHOTOTRANSISTOR)
    Now connect a phototransistor in place of the switch and you will get either 3.3V (no activated) or close enough to 0V when the transistor is turned on right?

    So what's the difference?

    IT'S ALL ABOUT CONVERTING CURRENT TO VOLTAGE (PULLUP or COLLECTOR RESISTOR etc)
    All the resistor does is to allow current to flow so that Mr Ohm can do his work. We know that R=V/I so zero current means some infinite resistance (no such beast really). If the resistor is 10K connected to 3.3V and the other end of it is connected to a CMOS input whose resistance is way high enough not to consider but let's pick an absolute worst case figure of 330K (10ua leakage @3.3V) although it really is 100's of megaohms.

    PULLUP CMOS INPUTS
    Ohm's law tells us that V=RI where the voltage across the 10K (to VDD) is 100mv but the voltage across the input to ground is the difference of this = 3.2V(min). Voila!, this is our pullup so far that has taken the input to a logic high.

    CLOSING THE SWITCH
    Now close the switch to ground and even through a very bad contact of 100ohms what will we get at the input? Let's see... I=V/R where R = 10K+100ohms = 10100ohms and V = 3.3V so that we get I = 327ua (we can ignore the negible effect of the CMOS input). Now the voltage at the input is the same voltage across the bad contact resistance of 100ohms so that V=100*327ua - 0.0327 volts (close enough to zero).

    So it is never ever 3.3V or 0V but very very close to it which makes not one iota of difference to a logic input.

    EFFECTS OF DIFFERENT PULLUP RESISTORS
    Now that we can see how it works we can easily calculate the effect of increasing of decreasing the pullup resistor.
    Assuming the worst case 330K CMOS loading and the worst case contact resistance of 100ohms....

    RESISTOR HIGH LOW
    100K -> 2.5V 0.003V Logic high is getting a little low but still above the 2V logic high threshold
    10K -> 3.2V 0.03V Good logic levels
    1K -> 3.29V 0.3V Logic low is getting higher but still ok
    100R -> 3.299V 1.65V Logic low is unacceptable

    Great, we can use any resistor from 1K to 100K as a pullup, the choice is up to you. But the Propeller's leakage current is spec'd at 1ua max instead of 10ua so it means we could even use a 1M pullup and it will still work.

    LET'S JUST MAKE THE PULLUP HIGH OK?
    Maybe, because there is capacitance on the CMOS input that takes a finite time to charge and 6pf + 1M = 6us. Add in trace capacitance and that climbs but the response is still ok for switches. Actually you want some current to flow through the switch for "contact wetting" reasons.

    LET'S JUST MAKE THE PULLUP 1K OK?
    Maybe, because a switch would work fine but a phototransistor is conducting current and at 20% efficiency that means you would need 16.5ma through the led plus the transistor would not actually switch to 0V as it's not actually a resistor (lookup Vce saturation).

    10K is an all round value for a PULLUP!

    We knew that.

    Tired now? Me too. smhair.gif

    *Peter*
  • Nick MuellerNick Mueller Posts: 815
    edited 2007-11-14 11:22
    > If it were me, I would go with a 10k pull-up. The test circuit in the datasheet uses a 10k resistor.

    ... and 10V supply!
    We have 3.3V.


    Nick

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Never use force, just go for a bigger hammer!

    The DIY Digital-Readout for mills, lathes etc.:
    YADRO
  • darcodarco Posts: 86
    edited 2007-11-14 18:58
    Peter: Thanks for the explanation! There should be a parallax wiki for stuff like that to go in...
  • Fred HawkinsFred Hawkins Posts: 997
    edited 2007-11-14 20:22
    @darco,

    Lately I've been trying out the 'subscribe to forum' option which sends me an email for every message here. The tedious part is sorting them into heaps of discarded and nuggets of prop wisdom, but the pruning is no more problematic than any other system.
Sign In or Register to comment.