This is just an ultra-quick blog post about an interesting circuit.
I wanted to be able to measure an output up to about 1kV, and so I really desired the measurement to be isolated! I also wanted it to be cheap. This blog post shows the method I won’t use in the end for my specific use case, but is still worth documenting because it could be useful for other projects that either require cheap PWM or require very low-cost isolated measurements. This method costs under £1/$1. The result is not very instrumentation-grade at this price!
The method involves converting the analog signal of interest into PWM and then using an opto-coupler to send it to the other side (where low-pass filtering can be used to get back the analog signal). PWM can be created with a ramp (sawtooth) signal connected to a comparator chip. The diagram here shows the general idea.
A 555 plus a transistor could be used to generate a sawtooth output. However, despite being low-cost, the 555 was missing a comparator function. Op-amps could be used, but I was curious if there was something out there already designed for PWM type of purposes.
Looking around, I realized that a super-low-cost chip already contains the oscillator and comparator! It’s the TL494 , which is an ancient chip but still used in a lot of switching power supplies. Ordinarily, the TL494 generates PWM for driving transformer windings, and the control signals arrive at op-amp inputs on the chip. However, since we are only interested in simple PWM generation, it is possible to force the op-amp outputs low, putting them out of the equation, and instead feed an analog control voltage into a pin called Feedback, as can be seen in the block diagram.
(image source: Texas Instruments website)
In the circuit below (which is pretty much just the test circuit from the datasheet), resistor R2 and the connections to pins 1,2,16, and 15 are used to permanently set the op amp outputs to low.
Components R1 and C1 are used to set the sawtooth oscillator frequency; it is about 12.5 kHz with the values shown. The TL494 requires at least 7V to operate, and there is an internal 5V regulator with an output on pin 14. It is used to provide the pull-up voltage using resistor R3, for the 5V PWM output. There is a spare output which isn’t being used (the CTRL pin is used to select the single-output mode).
That’s it! The above circuit costs about £0.70 even in a single quantity since the TL494 is so cheap. For isolation, adding an optocoupler to the output would add another 0.20 to the cost.
About the only main drawback* to the circuit is that the PWM duty cycle cannot quite reach zero percent. That’s because the TL494 isn’t intended as a fully general-purpose PWM output. It is intended for power supply applications. The PWM is inhibited from reaching 0% because of a small positive voltage that is added to the input of a pin called DTC (pin 4). There is a trick to forcing the chip to output PWM down to zero percent, but it isn’t straightforward; it needs a small negative voltage applied to pin 4 (this isn’t a documented method, but it seems to work with the TL494 that I tried). Anyway, it’s not always necessary to require 0% PWM for many other applications (for instance, hobby servo control doesn’t require zero percent; by replacing R1 with 47k and C1 with 100nF, the circuit above can be used as a servo tester), so I left the circuit as it is, with just the single supply.
*Actually, another drawback is that the chip requires at least 7V. It would be nice if it operated from 5V.
Testing It
I applied known voltages at the input and measured the output duty cycle using a ‘scope. The results are in the chart below. It was fairly linear between 1V and 3.4V. From the chart, it is clear this is not an instrumentation-grade solution. Nevertheless, it could be suitable for far less demanding use cases, and as mentioned, it’s super-cheap and will provide isolation with a low-cost opto-isolator. I didn't use it in the end because the low-pass filtering has a slow response, at least tens of milliseconds for the PWM rate being used (although there are ways to reduce this). However, that would be perfectly suitable for many applications.
Thanks for reading!