Home Forums Chat Forum Of Arduinos, logic levels and input resistances

Viewing 16 posts - 1 through 16 (of 16 total)
  • Of Arduinos, logic levels and input resistances
  • gofasterstripes
    Free Member

    Hello all,

    I’m stuck on something, on a little project.

    I need to be able to detect logic pulses at 3.3, 5 or 24v logic levels, and pass them to an Arduino. The Arduino can only handle 5v logic and so I need to boost or shed input voltage to allow autoranging*

    So far I’ve got as far as using
    https://www.sparkfun.com/products/12009
    this, but it won’t handle >12v

    So I have been looking into using a zener diode

    or a diode chain to generate a fixed voltage to monitor….

    But this is really pushing the boundaries of my knowledge on electronics.

    The zener diode circuit may have issues with the input resistance falling on conduction? We want to keep out input resistance high.

    Yes it would be possible to add a range switch, but the problem is that the user may forget to switch it and send 24v into the 3.3v setting.

    Maybe there’s just an easier way? My google-fu is failing me and, again, I’m basically on my own here with this one.

    Anyone care to help?

    Cheers!

    Flaperon
    Full Member

    Why not just use voltage dividers and multiple inputs on the Arduino? Alternatively, one VD on an analog input and check for 1, 2, or 3 at once. With the six combinations there are 6 (7, technically) discrete measurements.

    Small SMD potentiometers ideal for this task (that’s how I’ve done it in the past).

    http://www.maplin.co.uk/p/25k-andohm-carbon-vertical-sub-miniature-fully-enclosed-preset-potentiometer-n53br

    gofasterstripes
    Free Member

    Yo.

    Sadly we’re a bit short of inputs as they’ll be used for other things.

    Optoisolators any good?

    Flaperon
    Full Member

    With potentiometers you can still measure your three inputs discretely on a single analog input.

    http://arduino.cc/en/Tutorial/ReadAnalogVoltage

    Or buy an Arduino Mega?

    gofasterstripes
    Free Member

    Aaah, sorry I get it now.

    Any other ideas anyone, in case I can’t get it working like that?

    leffeboy
    Full Member

    Zener is perfect for this. What is your problem with it?
    edit: your 3 regular diodes would also work but you want the resistor on the input side rather than the ground side imho

    gofasterstripes
    Free Member

    Zener is perfect for this. What is your problem with it?

    Ha! Great way to put it.

    My only worry with that is I need 3.9K as the resistor so I thought 3.9K was going to be the input resistance when the diode starts to conduct, which I thought was a little low.

    It’s going to be responding to a signal from an injection moulding machine starting to input the polymer, TTL going high, and I worried that perhaps the input resistance was too low then.

    As I said, I thought it might work, but I’d like to check as I’d rather put time in to getting it right first time 🙂

    Thanks.

    *No workings shown, I know, I know…..

    maxtorque
    Full Member

    The “trick” is to make your zener and input protection resistance WORK for their living.

    So, at up to 5v, the only current flowing into the pin is that required by the ADC, which is tiny.

    But at 24v, to keep the max min voltage below the critical 5v, you need to shunt 19v off to ground. Now 19v is a lot, so at any significant current whatsoever, you will be putting a lot of heat into your series resistor and the zener.

    So, calculate the max power dissipation in the system as follows:

    Vin = 24v
    VmaxIO = 5v (assuming a 5v zener, see note at end!!)
    Vground = 0v

    So assume we have a 10k input resistor in series with the input(which is about the max impedance for an ADC input at DC), this resistor sees (at 24v input) 24 minus 5 volts = 19v using V=IR over that resistor we can calculate the current to be 19/10,000 = 1.9mA and the power disipated in that resistor is (P=VI) 36mW. Not too bad for a typical resistor, (normally 1/4watt or 250mW), which suggests you could lower the input resistance a bit.

    Of course, this is a trade off, and your zener needs to be able to dissipate the power too (it’s power is the voltage drop across it and the current through it (5V x 19mA = 9.5mW)

    Now, in reality,no diode is ideal, and the voltage vs current characteristic is NOT a linear or ideal. So you need to check the data sheet for your diode of choice and work out what the voltage will be across it at say 19mA. What you will find is that this will raise the voltage at the IO pin ABOVE 5v!

    Several options exist:

    1) more series input resistance (less A is less V across zener for given value of zener)

    2) Use an opamp with the zener as a voltage refference to generate a suitable “sink” for excess voltage, but with low impedance

    3) accept you are going to over volt your IO ! (generally, most GPIO is diode clamped to the Vcc rail, so typically isn’t damaged by Vcc + ~0.7v (the V of diode drop). In this case though, you might be shunting current to Vcc and not Ground, so this can have implications on your design!

    And finally, you will have to estimate what a sensible case is for this. ie can you guarantee that Vin will never exceed 24V??

    Once you have your GPIO pin protected against over voltage, using a selectable (manually or via your code on a “max ADC” result etc) is easy!

    😉

    gofasterstripes
    Free Member

    Shoot, original post should have read

    We want to keep OUR input resistance high.

    EDIT:

    Cheers maxtorque[/url] 🙂

    maxtorque
    Full Member

    BTW, depending on circumstance, i like to protect for typically around a continuous 20% overrange voltage, and around a 50% transient (<10sec) overvoltage in my designs. The exception is where the end user can easily apply a higher voltage accidentally. For example, if you have a device that is in a mixed supply voltage system, say 12 & 24v, it’s wise to protect against a continuous application of the higher system voltage, because that is a very obvious and regular end user error!!

    maxtorque
    Full Member

    oh, btw, the another option is to use a transitor set up as a constant current sink, with a downstream resistor to generate the “sensing” voltage. That way, the max voltage capability is set by the transistors Collector -> Emitter breakdown voltage, and you get a good “signal” level even at low voltage inputs (whereas, with a static resistive divider, your signal is proportional to the applied voltage)

    leffeboy
    Full Member

    maxtorque ftw – nicely done

    In addition since this looks like an industrial process rather than just keeping your beer warm in your garage I would be debouncing the input signal in software. maxtorque’s comments on overrange apply as well of course!

    Cougar
    Full Member

    <THREAD HIJACK!!>

    Can anyone recommend a good website to learn more about this stuff?

    I’ve got a mostly-forgotten handle on electronics – I got an ‘A’ in it at GCSE level and haven’t really touched it since – and whilst I can follow some of the discussion here I don’t really understand it to any sort of practical level any more.

    </THREAD HIJACK!!>

    gofasterstripes
    Free Member

    Yo – I’ll update this when we’re finished – but it’s all on its way.

    Cougar – youtube, the Arduino forum, Sparkfun etc etc – it’s all out there for free. Good luck!

    gofasterstripes
    Free Member

    Meanwhile – here’s a little bit of testing for the case:

    The ports will be at the back and I want to label them on the back edge of the top of the case to aid connection. I’m looking to 3d Print the case, and here’s a test run with 2-colours of ABS material to in-mould the text!

    Neat, huh?

    oliverd1981
    Free Member

    I’d say opto-isolators – everything I’ve worked on that’s been robust has had opto isolatos on all of the inputs..

Viewing 16 posts - 1 through 16 (of 16 total)

The topic ‘Of Arduinos, logic levels and input resistances’ is closed to new replies.