4
\$\begingroup\$

I'm a controls engineer specialising in PLC programming. I have a basic understanding of electronics, but I would like to get better and start making some integrated circuit boards for projects.

This project:

Take a PWM output of a PLC and display the mark to space ratio on an LED bar graph. I have found a suitable LED bar graph and driver (LM3914), however, the LED driver IC requires a 0..5V control signal. The PWM from the PLC can be from 8..32V, although realistically it will be closer to 10..28V as the PLC in question is used on mobile machinery with 12/24V batteries. The PWM will be a maximum of 250Hz and is freely configurable, but will be set to a suitable fixed value.

To convert a PWM signal to an analog 0..5V signal, I have found the LTC2644. The problem with this IC, is that it expects 5.5V maximum at the PWM inputs.

The problem:

I need a way of stepping down the 8..32V PWM signal to 5V, without degrading the signal integrity. I have seen a few different solutions, however, they are mostly voltage dividers which rely on a steady supply voltage for a consistent output.

My thoughts were perhaps I could design a voltage divider circuit based on the worst case (8V) and incorporate a Zener diode to clip higher voltages, but I don't know if this will affect the PWM square wave. I'm also concerned that a diode may not be able to 'keep up' with the PWM frequency.

I'm open to any ideas, including different ICs, if anyone knows of a better solution!

\$\endgroup\$
6
  • 2
    \$\begingroup\$ Resistor + Zener diode. This is a control signal, presumably, so you don't care about power delivery, or efficiency. I'm not sure what the capacitance of a Zener diode is. \$\endgroup\$ Commented May 3, 2022 at 16:02
  • 2
    \$\begingroup\$ Keeping up with 250 Hz is not difficult at all. \$\endgroup\$
    – Reinderien
    Commented May 3, 2022 at 23:56
  • \$\begingroup\$ See if you can borrow an oscilloscope from someone. That will allow you to try some of these circuits and see how they work. That's the real key to understanding this stuff. A cheaper alternative is to use a simulator like falstad.com/circuit \$\endgroup\$
    – Drew
    Commented May 4, 2022 at 2:28
  • \$\begingroup\$ This can be done easily with something beginner friendly like an arduino. \$\endgroup\$
    – Drew
    Commented May 4, 2022 at 2:30
  • 1
    \$\begingroup\$ John - Hi, You posted an "answer" which was really replies to two existing answers, but did not give a new answer itself. Since that breaks the "Stack Exchange approach" I have (by jumping through various hoops) managed to move those replies into comments on those answers. For the future, FYI, if you want to make a relevant reply or request clarification of an answer, then please write a comment on that answer. Since you are the OP (original poster) who asked the question, the only time you would write an answer is if you had a new solution and the topic could now be closed. HTH. Thanks. \$\endgroup\$
    – SamGibson
    Commented May 6, 2022 at 16:19

2 Answers 2

3
\$\begingroup\$

Agree with the answer by Reinderien that usually a microcontroller would be the way to go, but if you're reeeeeally sure that this is all you'll want to do, then its actually extremely easy - if you were ok with signal inversion, you could do it with a single transistor, but otherwise:

schematic

simulate this circuit – Schematic created using CircuitLab

You can adjust the resistances as needed (for example, if you need more output current), but you won't need any clamping, since the transistors will take care of that. You can probably get rid of R2 if you want, it's there to add a bit more noise immunity. This should be fine at 250Hz. The advantage over a zener diode is that the voltage output here is a bit more stable (since you're providing the 5V), but if you wanted even simpler, you could just do what user253751 mentions in a comment:

schematic

simulate this circuit

\$\endgroup\$
3
  • \$\begingroup\$ For this application if I were to use the hardware mentioned in my inital question, signal inversion is probably no big deal as all I want to do is translate the mark to space ratio of the PWM to a 0..5V output using the LTC2644. You mentioned that this could be achieved with a single transistor - how would this circuit look? \$\endgroup\$
    – John
    Commented May 6, 2022 at 15:40
  • \$\begingroup\$ (continued) If it's not too much to ask, could you explain to me how the first of the two circuit diagrams in your previous post works? I see there are two transistors in the circuit, but from my very basic understanding of electronics I would have thought the line to the base of Q2 could infact be used as the output? Is the integration of a second transistor for better signal conditioning? The second solution with a diode is definitely appealing to me because of it's simplicity. I think what I need to do is get this onto some breadboard and see what the signal looks like! \$\endgroup\$
    – John
    Commented May 6, 2022 at 15:40
  • \$\begingroup\$ @John yes, you could just use Q1, but then the signal would be inverted - Q2 inverts the signal again, resulting in the original signal \$\endgroup\$
    – BeB00
    Commented May 7, 2022 at 5:27
2
\$\begingroup\$

Your LTC2644 seems very expensive. Economies of scale dictate that this dedicated-purpose PWM-driven DAC is more expensive than a commodity microcontroller with a built-in DAC. Consider something like the ATtiny series.

Such devices that offer an 8-bit resistive DAC (much more resolution than you need for this application), but you're better off getting rid of your DAC and analog signal section entirely.

Such devices also offer timers that support capture mode to measure your PWM input. You would still have a limiting diode on the bottom end. The result would be an analog level shifter followed by a microcontroller and nothing else. You would gain the ability to add, if you want in the future, a software correction ramp etc.

You would walk through the analysis roughly in this order:

Assume Vcc=5V.

Choose a microcontroller such as the ATtiny40 for its affordability, pin count, and compatibility with 5V. Check its input logic levels:

VIH

Choose an input voltage that strikes a balance between exceeding the minimum of 0.6Vcc = 3V while staying under the absolute maximum of Vcc+0.5V = 5.5V. You don't want to go too low because the spec makes no guarantees about hearing logic high even at 4.9V. 5.0V should be fine.

Choose a zener for its affordability and nominal voltage. Something like the NZX5V1B should be fine. Look up its working voltage (bottom row) and working current:

zener voltage

Take its zener current of 5 mA to be the minimum needed during your minimum input high of 8V. That means a resistor of (8 - 5.1)/0.005 = 580 ohm. At your maximum input high of 32 V, the current can increase to (32 - 4.9)/580 = 46.7 mA. Whereas 46.7 mA * 5 V = 233 mW < 500 mW meaning the zener will survive, 46.7 mA * 27.1 V = 1.27 W which is a lot of power for the resistor to dissipate. So it is not practical to have a passive-only level shifter based on such a zener. You should go with an active solution, possibly a comparator or an integrated shifter.

schematic

simulate this circuit – Schematic created using CircuitLab

The above is a demonstration of a Schmitt trigger with input high = 6V, input low = 2V, and a zener protection diode that should kick in somewhere above the 3.3V threshold but below the supply of 5V.

Once this is out of the way, plan how to program your controller. PWM duty is easily measured with an input capture timer. A typical input capture timer section (this one for the same ATtiny) looks like

capture

Then plan for LED driving. The ATtiny40 easily has enough parallel pins to drive one LED bar each without even needing to worry about multiplexing. If your bar LED is something like the LTA-1000HR, then it supports up to 25 mA per segment, nominal 10 mA:

LED bar

You'll find 10 mA to be more than bright enough and can get away with much less than that. You can drive each LED individually, directly from the controller's I/O. Each pin supports up to 40 mA, with 200 mA total:

pin max

200 mA / 10 = 20 mA. Even 5 mA per pin will be quite bright and well within the controller's spec. With a Vf = 2 V, (5 - 2)/0.005 = ~600 ohm. The physically convenient thing to do would be to use a resistor array in bus configuration with its common pin going to Vcc and the other pins connected to the LED pins. Something like the Bourns 4611X-101 series has the right topology:

bussed resistor network

\$\endgroup\$
5
  • 1
    \$\begingroup\$ Hi Reinderien, Thank you so much for your very detailed reply. This is a very interesting solution that I think I will explore further, \$\endgroup\$
    – John
    Commented May 6, 2022 at 15:08
  • \$\begingroup\$ @John I'm glad to hear it; but could you address the question I left as a comment regarding 8V? \$\endgroup\$
    – Reinderien
    Commented May 6, 2022 at 15:12
  • \$\begingroup\$ (continued) The cost saving is definitely a big up side of using a micro controller, however, this does add to the complexity of assembly as it necessitates programming. That being said, it adds a great deal of flexibility whilst reducing hardware cost. \$\endgroup\$
    – John
    Commented May 6, 2022 at 15:40
  • 1
    \$\begingroup\$ To answer your question, the 8..32V is in fact the possible range that the PWM output could be. The reason for this is that the PLC inquestion has a rated supply voltage range of 8..32V, making it suitable for 12V or 24V vehicles essentially. The high level of each output of the controller is therefore roughly the same as the supply voltage. As it is most likely this will be in a vehicle application, the voltage will rise as the alternator charges the battery, thus changing the Vpeak of the PWM signal. \$\endgroup\$
    – John
    Commented May 6, 2022 at 15:40
  • \$\begingroup\$ @John Right; well: the fact that your input high is so variable makes a simple passive zener limiter impractical. I have shown an alternative based on a comparator. As for the controller, it's very common to "capture complexity in software" and pay a little more in design time to reduce part cost and circuit complexity. \$\endgroup\$
    – Reinderien
    Commented May 6, 2022 at 17:29

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.