p.6: Building the COSMAC ELF Microcomputer: Retro Design Reloaded, By Scott Weber
 “Retro-Computing Takes to the Cloud,” by Todd Wade — Circuit Cellar 359, June 2020
 “Understanding Proper PCB Design (Part 1): 4-Layer Board Design,” By Robert Lacoste — Circuit Cellar 367, February 2021
Be sure the check on the code for this article on Circuit Cellar’s article code & files webpage
p.14: Ultraviolet: The Next LED Frontier: Hurdles and Hopes Examined, By Faiz Rahman
 Zinc oxide light-emitting diodes: a review
Optical Engineering (OE) published peer-reviewed papers reporting on research, development, and applications of optics, photonics, and imaging science and engineering.
 Effect of DUV on pathogens and human cells.
GMS Hygiene and Infection Control. 2021; 16: Doc07.
p.18: Build a Power Supply Monitoring and Control System: Using the ESP32 MCU, By Anuj Justus Rajappa and Vairamani Kanagavel
 ESP32 development board description, Link
ESP32 development board schematic diagram, Link
 ESP32 Series datasheet, Link
 ESP-IDF Programming guide, Link
 LM338T datasheet, Link
 INA219B power monitor sensor datasheet, Link
INA219 DC Current Sensor Breakout board schematics, Link
 Sitronix ST7789V driver https://www.sitronix.com.tw/en/products/display-driver-ic
 L7805CV datasheet, Link
p.26: Voltage-Level Translation in MCU Projects: Solutions for Digital Controllers, By Wolfgang Matthes
Editor’s Note: Because this article has so many References and other resources, we’ve placed them all at the end of this webpage. This article also includes an extensive ADDENDUM, which is also provided at the end of this webpage.
p.36: Cache Coherence and the ACE Protocol: Snooping and Synching, By Nishant Mittal
 “Understanding the AMBA AXI4 Spec” (Circuit Cellar 370, May 2021),
Arm Developer | https://developer.arm.com
p.41: Intelligent Vision Systems Leverage Embedded Tech: Smart Cameras, Software and Box-Level Systems, By Jeff Child
ADLINK Technology | www.adlinktech.com
Allied Vision Technologies | www.alliedvision.com
Axiomtek | www.axiomtek.com
eCapture | www.ecapturecamera.com
Imago Technologies | www.imago-technologies.com
IOTech | www.iotechsys.com
Maxim Integrated | www.maximintegrated.com
OnLogic | www.onlogic.com
Teledyne DALSA | www.teledynedalsa.com/mv
Vecow | www.vecow.com
p.48: RISC-V Shakes Up the Embedded Processor Space: Open ISA Era Is Here, By Jeff Child
Aldec | www.aldec.com
Espressif Systems | www.espressif.com
Green Hills Software | www.ghs.com
IAR Systems | www.iar.com
Microchip Technology | www.microchip.com
Renesas Electronics | www.renesas.com
SEGGER Microcontroller | www.segger.com
SiFive | www.sifive.com
p.54: DATASHEET: Sensor ICs: Integration and Performance, By Jeff Child
Bourns | www.bourns.com
Infineon Technologies | www.infineon.com
Maxim Integrated | www.maximintegrated.com
NevadaNano | www.nevadanano.com
ON Semiconductor | www.onsemi.com
Renesas Electronics | www.renesas.com
STMicroelectronics | www.st.com
TDK-Micronas | www.micronas.tdk.com
Texas Instruments | www.ti.com
Infineon Technologies https://edit.infineon.com/cms/en/product/sensor/current-sensors/tli4971-a120t5-e0001
Maxim Integrated www.maximintegrated.com/en/products/sensors/MAX25405.html#online-ds
ON Semiconductor www.onsemi.com/products/sensors/image-sensors/xgs-16000
Renesas Electronics www.renesas.com/us/en/document/dst/zmod4510-datasheet
Texas Instruments www.ti.com/lit/ds/symlink/hdc3020.pdf
p.58: EMBEDDED IN THIN SLICES: FreeRTOS (Part 6): FreeRTOS Security, By Bob Japenga
 For more about phone phreaking see: https://www.theatlantic.com/technology/archive/2013/02/whatever-happened-to-the-phone-phreaks/273332
 For more on this see: https://www.atlasobscura.com/articles/capn-crunch-whistle
Also find out how Captain Crunch was instrumental in launching Apple.
 For a high-level review of the Stuxnet worm hack, see:
 This is the website of the company that uncovered the 11 vulnerabilities in VxWorks. https://www.armis.com/research/urgent11
 See Bob’s article from Circuit Cellar Issue 315 from October 2016 Internet of Things series: “Security Vulnerabilities from OWASP”. The OWASP Foundation maintains a list of the top ten vulnerabilities for Web based devices. https://owasp.org/www-project-top-ten
NIST maintains one list of existing vulnerabilities in real systems at https://nvd.nist.gov/vuln/full-listing
 MITRE maintains a Common Weakness Enumeration list to identify common software security weaknesses. https://cwe.mitre.org
 “An Analysis of Embedded Software Vulnerabilities and Related Security Solutions” https://kth.diva-portal.org/smash/get/diva2:1149047/FULLTEXT01.pdf
“Depending on the scheduling policies used by the OS, an attacker could lead low-priority tasks to steal execution time of higher priority tasks.”
 See Bob’s article “The Internet of Things (Part 5): IoT Security,” (Circuit Cellar 307, February 2016)
 Based on the Common Criteria, the Security Evaluation Standard for IoT Platforms provides a set of tests for evaluating how secure a software system is. See https://www.freertos.org/2021/03/why-sesip-certification-for-freertos-matters.html
 See Bob’s Circuit Cellar article from August 2018 (Issue 337) “Internet of Things Security Part 4” where he introduces Common Criteria
p.62: THE DARKER SIDE: Blocking and Interference Rejection: Signals and Sensitivity, By Robert Lacoste
 ADF7030-1 integrated transceiver (Analog Devices)
 CEPT ECC report 207
Adjacent band co-existence of SRDs in the band 863-870 MHz in light of the LTE usage below 862MHz
Analog Devices | www.analog.com
p.68: FROM THE BENCH: How Gun-Style IR Thermometers Work (Part 2): Time for Temperature Tests, By Jeff Bachiochi
 “How Gun-Style IR Thermometers Work (Part 1)” Circuit Cellar 374, September 2021
 MLX90614 Data Sheet
 Human Body Temperature (Table of normal temperatures for men and women, measured by different techniques)
 Chen, H.-Y.; Chen, A.; Chen, C. “Investigation of the Impact of Infrared Sensors on Core Body Temperature Monitoring by Comparing Measurement Sites.” Sensors 2020, 20, 2885.
Melexis | www.melexis.com
p.79: The Future of Massive IoT: Massive IoT and the Internet of Transformation, By Tom Nelson
Everynet | www.everynet.com
References and other resources for (p.6:) Voltage-Level Translation in MCU Projects: Solutions for Digital Controllers, By Wolfgang Matthes “Voltage-Level Translation Techniques: Managing Mixed-Voltages,” By Robert Lacoste— Circuit Cellar 365, December 2020
Industrial PCs and I/O modules: Generation 4 Digital I/O Family Data Book. Form 727-190521. Opto 22, 2019.
 Titus, Jon; O’Hanlan, Tom: The Digital I/O Handbook. A Practical Guide to Industrial Input & Output Applications. Sealevel Systems, Inc., 2004.
 Pamux User’s Guide. Form 726-080118. Opto 22, 2008.
PLCs: PLC Handbook. Practical Guide to Programmable Logic Controllers. Automation Direct.
 Elavsky, Tom: A Condensed Guide to Automation Control. System Specification, Design and Installation. Whitepaper. AutomationDirect
 Kopczyk, Jonathan: Engineering Essentials: A Closer Look at the I’s and O’s of VFDs. Making use of the inputs and outputs on a VFD can prove very beneficial to an application. Machine Design, June 01, 2018.
 Purvis, Damon: The PLC Breaks Out! A new architecture takes advantage of technological advances to boost performance. Machine Design, April 30, 2021.
 Controller PFC200 Data Sheet. Wago, 2019.
SELV/PELV: Directive 2014/35/EU, Electrical safety: low-voltage electrical equipment / IEC 60950:1991-09.
Industrial control transformers: Distribution Dry-Type Transformers – Low Voltage 19.0-1. Eaton, 2016. (Contains a glossary of transformer terms.)
IEC 61131: International Standard IEC 61131-2 Preview Edition 4.0. International Electrotechnical Commission, 2017.
 Beckhoff I/O systems: Digital inputs for 2-wire and 3-wire sensors according to EN 61131-2.
Application Note DK9222-0909-0008. Beckhoff Automation GmbH, September 2009.
 Connection of Encoder Types in Compliance with IEC 61131-2 to DI Modules. Siemens AG, 2015.
 Laupheimer, Peter: CLT3-4BT6 Factory Automation Seminar 2007.
 CLT3-4 termination in industrial automation logic inputs. Application Note AN2527. ST Microelectronics, 2007.
 CLT3-4B current limited over-voltage protected quad digital termination. Data Sheet. ST Microelectronics, 2007.
 PCLT (Programmable current limited termination). Application Note AN2482. ST Microelectronics, 2007.
 Hofman, Milos: Self-Powered Digital Input with CLT03-2Q3. ST Microelectronics, 2020.
 Rossetti, Nazareno; Partow, Tony: Efficient I/O Interfaces Dramatically Reduce Heat Generation in Your PLC Digital I/O Module. Design Solutions 9. Maxim Integrated, 2016.
Bidirectional I/O: Finally – Digital IO Means Digital IO! Design Solutions 46. Maxim Integrated, 2016. https://www.mouser.com/pdfDocs/ds46-finally-digial-io-means-digial-io1.pdf
 Long, Sean; Jackson, Michael: Use Configurable Digital IO to Give Your Industrial Controller the Edge. Design Solutions 7349. Maxim Integrated, 2020.
 “Emulating Legacy Interfaces. Do it with Microcontrollers,” By Wolfgang Matthes— Circuit Cellar 327, October 2017.
Integrated level translators: Industrial Digital Inputs: They’re Not Quite as Simple as Counting from 0 to 1. Design Solutions 111. Maxim Integrated, 2018.
 Design Guide for PLC Digital Input Modules Using the Si838x. Application Note AN970. Silicon Labs, 2019.
 Programmable Logic Control (PLC) Solutions Guide SLYY041a. Texas Instruments, 2013.
 Voltage Translation Buying Guide SLYY165a. Texas Instruments, 2021.
 8-Channel Digital Input Module for Programmable Logic Controllers (PLCs). Reference Design TIDU196A. Texas Instruments, 2014.
 Kamath, Anant: How To Simplify Isolated 24-V PLC Digital Input Module Designs. TI Tech Notes SLLA370B. Texas Instruments, 2018.
IC Packages: SMT Assembly and PCB Design Guidelines for Maxim’s Standard Wire-Bonded Quad Flatpack, No Leads (QFN) Packages. Application Note 6382. Maxim Integrated, 2014.
 Thomas, Shasta; Quach, Bill: Layout Considerations for High-Power Circuits. Tutorial 5389 Maxim Integrated, 2012.
Some Data Sheets:
The corresponding Internet links have been omitted here because it is easy to find the data sheets on the manufacturer’s websites. If not, searching the web may help.[D1] MAX31910 Ultra-Low Power Industrial, Octal, Digital Input Translator/Serializer. Data Sheet. Maxim Integrated, 2014.
[D2] MAX31912 Ultra-Low Power Industrial, Octal, Digital Input Translator/Serializer. Data Sheet. Maxim Integrated, 2015.
[D3] MAX31914 Ultra-Low Power Industrial, Octal, Digital Input Translator/Serializer. Data Sheet. Maxim Integrated, 2015.
[D4] MAX31911 Industrial, Octal, Digital Input Translator/Serializer. Data Sheet. Maxim Integrated, 2017.
[D5] MAX31913 Industrial, Octal, Digital Input Translator/Serializer. Data Sheet. Maxim Integrated, 2015.
[D6] MAX31915 Industrial, Octal, Digital Input Translator/Serializer. Data Sheet. Maxim Integrated, 2015.
[D7] MAX14900E Octal, High Speed, Industrial, High-side Switch. Data Sheet. Maxim Integrated, 2015.
[D8] MAX14914 High-Side Switch with Settable Current-Limiting, Push-Pull Driver Option, and Digital Input Configuration. Data Sheet. Maxim Integrated, 2020.
[D9] MAX22190 Octal Industrial Digital Input with Diagnostics. Data Sheet. Maxim Integrated, 2020.
[D10] MAX14906 Quad-Channel Industrial Digital Output, Digital Input. Data Sheet. Maxim Integrated, 2020.
[D11] MAX14483 6-Channel, Low-Power, 3.75kVRMS SPI Digital Isolator. Data Sheet. Maxim Integrated, 2020.
[D12] Si838x Data Sheet. Bipolar Digital Field Inputs for PLCs and Industrial I/O Modules. Silicon Labs, 2019.
[D13] SN65HVS880 24 V, Eight-Channel Digital-Input Serializer. Data Sheet SLAS592C. Texas Instruments, 2018.
[D14] SN65HVS881 Industrial 8-Digital-Input Serializer with Diagnostics. Data Sheet SLAS642. Texas Instruments, 2009.
[D15] SN65HVS88534 V Digital-Input Serializer for 5V Systems. Data Sheet SLAS638. Texas Instruments, 2009.
[D16] DRV8806 Quad Serial Interface Low-Side Driver IC. Data Sheet SLVSBA3B. Texas Instruments, 2014.
[D17] DRV8860 8 Channel Serial Interface Low-Side Driver. Data Sheet SLRS065B. Texas Instruments, 2014.
[D18] SN74LVC8T245 8-Bit Dual-Supply Bus Transceiver with Configurable Voltage Translation and 3-State Outputs. Data Sheet SCES584B. Texas Instruments, 2014.
The author’s project homepages:
Datasheets, application notes, reference designs, tutorials and so on:
Some manufacturers of I/O modules and industrial PCs:
Opto22: http://www.opto22.com Opto22 has pioneered what would be called nowadays the ecosystem of industrial PC applications. The adapter boards shown in Figure 1 and 2 come from Opto22.
Dataforth Corporation: https://www.dataforth.com/default.aspx
Selavel Systems, Inc. : https://www.sealevel.com
ADL Embedded Solutions, Inc.: https://www.adl-usa.com
Advanced Micro Peripherals Ltd.: https://www.ampltd.com
Advantech Co., Ltd.: https://www.advantech.com
Measurement Computing: https://www.mccdaq.com
Embedded and industrial PCs:
Steele, Denny: Cut Power 100X Using CPLD Coprocessors in Portable Applications. Altera, 2007.
Six Ways to Replace a Microcontroller with a CPLD. White Paper WP-01041. Altera, 2007.
Using Zero-Power CPLDs to Substantially Lower Power Consumption in Portable Applications. White Paper WP-01042. Altera, 2007.
– Addendum –
Voltage-Level Translation in MCU Projects: Solutions for Digital Controllers, By Wolfgang Matthes
3-wire and 2-wire sensors
The 3-wire sensor is easy to understand. It is a device powered by a 24-V supply voltage and energizing a digital output signal to be connected to an input of the level-translating circuitry. A 2-wire sensor is only connected to a 24-V wire and the signal wire. To power such a sensor, some current must always flow.
Simple and IEC-compliant 24-V inputs
A simple input senses only the voltage level. Contact sensors (e.g., limit switches) are the most straightforward examples.
An IEC-compliant sensor, however, always behaves as a current source. Current flows from the 24-V terminal through the sensor and the signal wire and the input circuitry of the translating device to ground.
How to power the circuitry in a contactless 2-wire sensor (e.g., in a proximity switch)? Power is supplied by letting a current flow from the 24-V terminal via the input wire to ground. Therefore, the translation circuitry must behave as a current sink. In the OFF state, the signal must not rise above 5 V. In the ON state, it must be at 11 V or above. According to the IEC type, a current of up to 15 or even 30 mA may flow through the sensor.
A simple worst-case analysis
It will be something like a calculation on the back of an envelope. Let us assume a 24-V supply voltage varying between 18 and 40 V and a current limit of 5 mA. To make things not too complicated, we will furthermore neglect the input series resistors RINX (that are mandatory for these ICs).
In the OFF state, the current flows only through the equivalent series resistance RES. The voltage drop must be large enough so that the voltage at the input terminal is well below the maximum VIN_OFF (VIL) voltage of 5 V (as stipulated in IEC61131-2). The worst case occurs if the sensor is fed with 40 V. Thus the voltage drop must become 35 V, yielding an RES = 35 V : 5 mA = 7 kOhm.
In the ON state, the sensor’s circuitry will activate an additional parallel resistance RP to decrease the voltage drop. It must be reduced so that the voltage at the input terminal is well above the minimum VIN_ON (VIH) voltage of 11 V (as stipulated in IEC61131-2). The worst case occurs if the sensor is fed with 18 V. To guarantee a voltage drop of not more than 7 V, the resistance of the sensor must be reduced to 7 V : 5 mA = 1.4 kOhm. To this end, the sensor must activate a parallel Resistor RP of approx. 1.75 kOhm.
The sensor’s circuitry must be content with an intensively varying power supply. In our example, the supply voltage (VDD) corresponds to the voltage drop varying between 7 and 35 V and the current may plummet down to somewhat around 2 mA.
The power requirement of the sensor and the current-sinking capability of the translation device must fit together. For example, it will not work if the current clamp within the translation IC limits the input current to 2 mA while the sensor needs 5 mA.
IEC 61131-2 sensor types and operating regions
The microcontroller-CPLD combo
The IOs of some CPLDs are grouped in banks having their own VIO supply voltage. Thus, for example, the 1.8-V or 2.4-V signals of the microcontroller can be translated to 2.5-V LVCMOS levels, 3.3-V LVTTL levels, and so on. Besides, the CPLD may swallow up most of the glue logic that otherwise would be spread over the PCB. Occasionally, the CPLD may accommodate even a coprocessor.
The principal question is which device is the master. In the first variant, it is the CPLD. The microcontroller is only used for initialization, diagnostics, communication, and the human-machine interface (for example, implemented by an LCD together with some keys and LEDs). In a second variant, the microcontroller is the master. It executes the application-specific software. The CPLD is merely an auxiliary device for level translation, marshalling, glue logic, and so on. Occasionally, it may accommodate even an accelerator or coprocessor.
The most straightforward approach is to connect all the microcontroller’s signals that are to be translated to the CPLD, regardless of whether they belong to an industry-standard or peripheral interface (think of SPI, asynchronous interfaces, or the IOs of a counter-timer unit) or are to be used as programmable IOs. Thus the CPLD will be something like a patch or marshalling panel. It is, however, just as obvious to connect interface signals directly to the translation circuits.
Concerning the programmable IOs connecting the microcontroller to the CPLD, I recommend contemplating some sort of architecture (in contrast to pure application-specific wiring, like between the components on a conventional PCB). Typical examples would be a data bus accompanied by some control and status signals or a simple shift register interface. The details may be application-specific; the basic ideas could be adopted from the typical bus systems of the early microprocessors (think, for example, of Intel’s 8051 or Motorola’s 6800), from asynchronous SRAMs, and the like. For simple shift register interfaces, see also Figure 11 in the printed article.
The rationale behind this recommendation is that you will have to work with two different development environments, and you would certainly not want to be urged to modify the microcontroller software when changing something in the CPLD and vice versa. It goes without saying that true hardware-software co-design is state of the art. To be able to switch seamlessly between hardware and software requires, however, to move to FPGAs and their development environments, which are considerably more demanding (and expensive).
The 24-V companion – an educational example
A 24-V microcontroller or CPLD would be a densely packed small PCB. When the basic architecture has been defined and the functional units developed, it is only a question of PCB design and manufacturing. Therefore, my own experiments had begun not with a tiny IOT module but with somewhat larger PCBs, one for each basic functional unit. The philosophy behind this approach and some of the modules I have described already in Circuit Cellar articles (, ).
The microcontroller module carries an operating and display panel, thus constituting an HMI device. The CPLD module contains a Xilinx CoolRunner XC2C384 CPLD and an SRAM 256k • 16. The 24-V companion supports 24 inputs and 24 outputs, grouped in six 8-bit ports. The companion has a parallel logic interface, comprising 48 signals, that can be, via the so-called multi-purpose connector, attached to the CPLD module or appropriate microcontroller modules. The multi-purpose connector has been mentioned in my article . The interface between the microcontroller and the CPLD comprises 16 signals that may be used for application-specific wiring. I prefer, however, a somewhat architected solution with an 8-bit data bus and up to 8 control and status signals. The 24-V indicator board is a purpose-built auxiliary device displaying the status of 24 output signals, grouped in three ports of eight. It consists essentially of 24-V LED signal lamps wired to headers. All components are mounted in the front panel of a sloped enclosure.
Input translation is done in two stages, from 24 V to 5 V by a MAX31915 ([D6]) and from 5 V to 3.3 V by a 74LV8T245 ([D19]). Translation ICs with parallel interfaces have been chosen because the companion should preferably be attached to a CPLD.
The output stages are straightforward ULN2803 Darlington drivers. To ensure definite signal levels even when no module or load is attached, the logic and 24-V signals are connected to pull-down and pull-up resistors, respectively.
Integrated level translators
Our block diagrams – in the printed article and here – are based on actual data sheets. They have been, however, considerably simplified and redrawn to illustrate the essential principles of operation. Who wants to know more, we refer to the data sheets, whitepapers, and application notes of the semiconductor manufacturers. The references  to  and [D1] to [D19] are thought of as introductory examples.
Simple 24-V logic
Some decades ago (we speak of the Fifties and Sixties), control equipment manufacturers offered transistorized pluggable modules performing logic functions, like gates, flip-flops, counters, and so on. The modern equivalents are essentially very small PLCs, down to programmable relays. Occasionally, however, the need arises to implement hard-wired logic functions at the 24-V level without resorting to PLC programming. The problem can be solved by developing application-specific modules or by tinkering with diodes, transistors, driver modules, and so on. Manufacturers know this need and offer appropriate building blocks. As an alternative solution, we propose the 24-V CPLD.
A sophisticated AI-based system controls the traffic lights on an intersection. What must never occur is that all the green lights on the intersection lanes switch on simultaneously. Here, all red lights will switch on if this fault occurs. Improvements are obvious. For example, a timing relay could, after an appropriate time period, disable all the lights. Thus the traffic may resume whereby the drivers have to heed the right of way as stipulated in the traffic regulations. A microcontroller-CPLD combo could do much more than a few logic gates. For example, it could take over the traffic light control and keep the traffic going by an unsophisticated and stupid but guaranteed error-free algorithm.
IC manufacturers recommend inserting the isolation between the translator circuits and the processing platform (which is typically a microcontroller or an FPGA).
Translation with discrete components
Level translation problems can be solved with discrete or SSI components, such as Zener diodes, bipolar junction transistors (BJTs), field-effect transistors (FETs), and comparators. Zener diodes and MOSFETs are well-suited to translate 24-V to logic signals (down to 3.3 V or below). BJTs and comparators may be employed in both directions.
Designing with discrete components is an art in itself. Regrettably, today it is only seldom taught. Even textbooks which are otherwise excellent, deal with those topics quite sketchily. Here, we can only touch a few of the most basic circuits. For more, we refer to appropriate sources provided by the semiconductor manufacturers and the vintage literature.
The 4.7-V Zener begins to conduct if the input voltage exceeds approx. 5 V, thus guaranteeing a LOW level as long as the input voltage is less than 5 V. The 2.7-V Zener limits the input voltage of the 7414 Schmitt trigger. The 10k/2n2 combo acts as a low-pass or de-glitching filter.
Watch out for anomalous conditions at the inputs
More intricate problems like ESD, power line interference, crosstalk, and so on we cannot discuss here. They are typical of true factory floor environments. When pursuing humble hobbyist or educational projects, the environment will not be that harsh. There are, however, two conditions you should consider even under those benign circumstances: The first is no signal at all, that is, an open input. The second is a high-impedance (tri-stated) signal. This condition may occur during initialization or as a consequence of faults. A microcontroller running self-tests, communicating via the network, and the like before initializing its output ports may cause such signals to float for a prolonged time. Under both conditions, you should guarantee your translation circuit sees a definite LOW or HIGH input level. Which of both levels to choose as the default depends on the particular application.
How to drive a BJT
The decisive data sheet value is the Base-Emitter Saturation Voltage VBE(sat). Small-signal BJTs are rated typically between 0.7 V and somewhat above 1 V. To keep the transistor safely in the OFF state, the base-to-emitter-voltage should be kept well beyond VBE(sat), say, for example, at approx. 0.3 V. To switch it on, the signal source should deliver a voltage well above 1 V. Then the current path from the base to the emitter will behave like a diode operated in forward direction. Therefore, it is necessary to limit the base current. When no anomalous conditions will occur, especially when the signal source is a CMOS logic output, then the current–limiting resistor alone may suffice. It’s value according to a proven rule of thumb:
(Signal voltage – VBE(sat)) divided by a tenth of the output current.
For 24-V inputs, however, you would be better off with the voltage divider, eventually combined with a Zener-based voltage limiter.
The BJT switched ON
The most important parameter is the Collector-Emitter Saturation Voltage VCE(sat). Small-signal BJTs have typical data sheet values around 0.2 V. However, to keep the voltage this low, the transistor must be operated in saturation, that is, overdriven by a base current sufficiently high. (Hence we divide the output current by 10 and not by the current-gain parameter h21E or Beta in the data sheet.)
How to drive a MOSFET
In contrast to the BJT, which is controlled by the base current, the MOSFET is controlled by the gate voltage. To keep the transistor safely in the OFF state, the gate-to-source voltage should be kept well below the Gate-Source Threshold Voltage VGS(th). Typical values are between somewhat under 1 V up to somewhat around 5 V. To switch the transistor on, you have to consider the minimum gate voltage that guarantees the data sheet value of the Drain-Source Resistance RDS(on). 10 V is a common value. Observe that the VGS(th) data sheet value relates not to a transistor completely switched ON but to the transitional range between OFF and ON. VGS(th) is often specified as a gate voltage permitting a mere weak drain current to flow (for example, as low as 250 µA).
The MOSFET switched ON
FETs are voltage-controlled variable resistors. The voltage drop VDS between drain and source results from the drain current flowing through the drain-to-source resistance (VDS = ID • RDS(on)). So keep the gate voltage high enough and the drain current only as high as necessary.
Level translation with comparators
The comparator is a high-gain, non-feedback differential amplifier. The output should assume only one of two levels (Low or High), depending on the voltage difference VDIFF between the inputs. Many comparator ICs have open-collector or open-drain outputs. The output voltage swing may be as large as the appropriate data sheet parameter permits; it does not depend on the comparator’s supply voltage. Thus, for example, a comparator supplied with 24 V may output 3.3-V signals.
It seems straightforward to employ a comparator. Connect one input to the signal to be translated and the other input to an appropriate reference voltage, which may be provided by a simple voltage divider. There are, however, a few caveats. Here, we will only mention the two most important: the slew rate of the input signal and the input common-mode range.
A comparator has no built-in snap-action mechanism. The threshold effect results solely from the high voltage gain, causing even a small difference in input voltages to overdrive the amplifier. If this difference is very small, however, there will be no overdriving. Parasitic feedback effects could cause the output even to oscillate. On the other hand, if this so-called linear region is traversed fast enough, the comparator will find no opportunity to switch back and forth. Hence only a single signal edge will occur. Thus you have to consider the rise and fall times of the input signal. If they may be too slow, the simple circuit will not work properly. Well-proven remedies you will find in the literature, for example, the Schmitt-trigger circuit or to introduce a particular input behavior, called hysteresis (, ).
The input common-mode range is typically somewhat smaller (at least some hundreds of millivolts) than the voltage difference between both power supply terminals. This may be a problem if the negative power terminal is connected to the ground (single-ended operation). If the LOW level of your input signal is nearly equal to 0 V (for example, if it is driven by a CMOS logic output switching rail-to-rail), you should prefer a comparator that will function properly in such a case. This property is termed ground sensing in single-ended applications (or something like that).
References (for Addendum only):
Microcontrollers and CPLDs:
 Steele, Denny: Cut Power 100X Using CPLD Coprocessors in Portable Applications. Altera, 2007.
 Six Ways to Replace a Microcontroller with a CPLD. White Paper WP-01041. Altera, 2007.
 Using Zero-Power CPLDs to Substantially Lower Power Consumption in Portable Applications. White Paper WP-01042. Altera, 2007
Mechanical design and level translation with discrete components: Matthes, Wolfgang: Creative Mechanical Ideas for Embedded Systems. Professional Style Projects. Circuit Cellar, Issue 358, May 2020, p. 28-35.
 Matthes, Wolfgang: Microcontroller Modules for the Ambitious. Circuit Cellar, Issue 312, July 2016, p. 34-42.
 IEC 61131-2 compatible inputs and outputs at the SC1x3 Controller. Application Note AN_SC1X3_IO_V1.PDF. Beck IPC GmbH, n. d.
 Such transistors are dubbed Digital Transistors or BRTs = Base Resistor Transistors.
Understanding a Digital Transistor Datasheet. Application Note AND9129/D. ON Semiconductor, 2013. https://www.onsemi.com/pub/collateral/and9129-d.pdf
 Kay, Art; Claycomb, Timothy: Comparator with Hysteresis Reference Design. TIDU020A. Texas Instruments Incorporated, 2013–2014.
 Guide to Adding Extra Hysteresis to Comparators. Application Note 3616. Maxim Integrated Products, 2005.
https://www.maximintegrated.com/en/design/technical-documents/app-notes/3/3616.html Sponsor this Article
Circuit Cellar's editorial team comprises professional engineers, technical editors, and digital media specialists. You can reach the Editorial Department at firstname.lastname@example.org, @circuitcellar, and facebook.com/circuitcellar