Developing a spectrophotometer with integrated analog peripherals
One of the biggest selling points of a microcontroller (MCU) is the peripherals—integrated blocks of specialized hardware that offload a task from the central processing unit (CPU) or integrate new functionality into the device. One of the most common examples of this is integrated analog-to-digital Converters (ADC). But more sophisticated MCUs can have other analog peripherals on-board, such as digital-to-analog converter(s) (DAC), analog comparator(s) (CMP), fixed voltage reference (FVR), and operational amplifier(s) (op-amp). These analog peripherals can be used in conjunction with the digital logic of the MCU to create intelligent analog solutions.
As an example of an intelligent analog design, this article will discuss the author’s current (work in progress) home project, and how intelligent analog can help to increase functionality and minimize the bill of materials (BOM).
Background of the project
In August of 2020, I started to work on building a spectrophotometer for fun. A spectrophotometer is an instrument that measures the intensity of light at specific wavelength(s). There are multiple ways to design this type of instrument; my implementation uses a monochromator to select a single wavelength from a white light source, then passes this wavelength through a sample and into a detector. The detector measures the intensity of the light at that specific wavelength, which can be used to measure transmittance of the unknown material. A simplified diagram of this is shown in Figure 1, and the current (but incomplete) prototype in Figure 2.
Figure 1 A simplified diagram of the spectrophotometer where the detector measures the intensity of the light at that specific wavelength, which can be used to measure transmittance of the unknown material. Source: Robert Perkel
Figure 2 The current prototype of the monochromator with a light source, spherical mirrors, diffraction grating, and optical slit. Source: Robert Perkel
Design Considerations
Since this is a one-off build, the primary concern is performance and assemblability. Performance in this context refers to the sensitivity of the detector, the purity of the monochromator output and the implemented feature set. Assemblability refers to my ability to construct and implement this device. Physical assemblability is a big issue, but most of the physical parts can be purchased, machined, or 3D printed at a reasonable cost or effort. Electronic assemblability is mostly about reducing the number of parts, when possible, and avoiding packages that are difficult to solder by hand, like QFN and BGA. Additionally, the parts used in the design must be in stock and obtainable.
Project Modules
There are three planned modules for this system (as of the time of writing):
Analog front end (AFE)
Smart LED power supply
Data acquisition and control (DAC)
The AFE, the main subject of this article, contains the photodiode and converts the photocurrent to a voltage for acquisition on external boards or hardware. Beyond that, there are a couple of secondary outputs and other I/O signals that are used in this module. Adding an MCU simplifies implementing these secondary outputs and other side-band signals.
The smart LED power supply is a specially designed linear power supply for the main light source. The current is regulated by a custom analog-feedback loop, with support for blanking (off time) and linear intensity control. This solution was developed because the standard variable intensity regulators for LEDs work on pulse width modulation (PWM), but the ripple from the PWM dimming may become visible to the sensitive detector downstream. While this board will likely contain MCUs, it must be connected to the supervising MCU for power-up and monitoring of the main light source, which is hazardous to directly view. (Author’s note: There are multiple other integral safety circuits located on this board to prevent power-up of the high-current stage).
Finally, there is the DAC board. The primary objective of this board is to measure the output of the AFE and report it back to the user. It connects to the smart LED power supply to power-up and monitor the main light source. This board will also contain a high-resolution ADC along with an MCU that oversees the entire system.
Mixing MCUs and analog
In the AFE, there are three features that the MCU helps to integrate:
Clipping detection
Self-zeroing
Relative output control
The MCU was selected by looking at new device families with analog peripherals. However, the analog peripherals are not used directly as part of the signal chain—they are used for auxiliary signals that aren’t as noise sensitive as the main signal chain. For the main signal chain, high-end (precision, low noise, etc.) parts are used to minimize noise and increase the likelihood of success. The simplified diagram in Figure 3 shows how the MCU fits into the design.
Figure 3 Simplified block diagram of the AFE where high-end parts are used in the main signal chain to minimize noise. Source: Robert Perkel
Clipping detection
During normal operation, light from the monochromator passes through a sample and into the photodiode detector, generating a photocurrent. However, if the photocurrent exceeds the allowable output range, it will be clamped to the maximum output value. When this occurs, an error indicator should be illuminated on the exterior and a signal should be sent to the main controller, in the event automatic current control was enabled by the user.
As shown in Figure 4, this is implemented on the MCU using the comparator and a set point signal from either an:
Internal DAC
Internal FVR
External source
Using the DAC is the most flexible approach but requires the dedicated use of one of the DAC peripherals. In some situations, this is acceptable, but in others the DAC is needed elsewhere. The internal FVR (voltage reference) is another option on some devices. The same reference as the DAC can be used with the comparator, but this requires the resistor divider to be setup to match this reference, and the setpoint cannot be modified at runtime. Finally, there is the external source option. External sources can take many forms—external DAC outputs, resistor ladders, voltage references, etc. The disadvantage is the use of extra components and I/O pins.
Figure 4 Implementation of a clipping detector on an MCU with a set point signal from either an internal DAC, internal FVR, or an external source. Source: Robert Perkel
Self-zeroing
Due to dark current from the photodiodes and small offsets from the op-amps, the system will have an output above zero, even when dark. To null this error out, an external buffered DAC is connected to the error correction stage and controlled by the MCU.
To trigger the self-zeroing operation, the user can either press a physical button or connect a blanking signal from the power supply. The blanking signal is an off time when the light source is not powered. While in the middle of a blanking interval, the system can recalibrate itself, like a chopper-stabilized amplifier, although care must be taken to ensure the emitters and samples have stopped fluorescing when performing this operation. This can be achieved by adding a small-time delay after the rising edge. Figure 5 shows a simplified timing diagram.
Figure 5 A timing diagram showing the zeroing points where the blanking signal in an off time when the light source is not powered, in the middle of the blanking interval, the system can recalibrate itself. Source: Robert Perkel
In the case of the user-accessible button, debouncing can be performed by the configurable logic cells (CLC) and a timer on the MCU. This combination operates independently of the CPU, allowing it to focus on other tasks, as shown in Figure 6.
Figure 6 A logic diagram showing how to implement a debouncer using hardware peripherals. Source: Robert Perkel
Relative Output Control
The relative output mode is a secondary output that indicates the % transmission of light through a sample when compared to a reference. In other words, if the instrument was run without a filled sample vial and recorded an output of 500mV, and, with a loaded sample vial it recorded 250mV, then only 50% of the light was transmitted at the wavelength of interest.
For the highest resolution in this mode, the dedicated measurement board produces the best results, due to the high-resolution ADC. But, if the output is above the clipping threshold, the MCU will have a higher measurement range, as its input is divided, not clipped.
To improve sample acquisition time with the resistor network, an internal op-amp can be used to buffer the input signal and to increase the gain of the signal into the ADC, as shown in Figure 7. This improves the performance of the system at lower signal levels.
Figure 7 Block diagram of the relative output mode where an internal op-amp is used to buffer the input signal and increase the gain of the signal into the ADC. Source: Robert Perkel
Challenges of Integrating
There are a couple things to keep in mind when mixing an MCU with analog circuits. Firstly, the signal range of the analog section can go much higher/lower than the absolute maximum ratings of the MCU. So, appropriate limiting of the signal range is a must. Often, this increases the impedance of the signal, but this can be easily solved by buffering the network with one of the internal op-amps, as shown below in Figure 8. The output impedance of the resistor network is equal to R1 in parallel with R2.
Figure 8 Buffering a signal with an integrated op-amp the output impedance of the resistor network is equal to R1 // R2. Source: Robert Perkel
Another challenge is to prevent electromagnetic interference (EMI) from the MCU from influencing the analog circuits. This is a complex challenge that is application specific. But there are a few common methods:
Physically separate the analog and digital circuits
Do not interrupt ground planes
Limit the slew rate of the digital signals
Use separate power supplies for analog and digital electronics
Decouple digital circuits appropriately
Other methods are more application specific. For instance, in this design, the photodiode and transimpedance amplifier (TIA) will be shielded to reduce the influence of other signals and environmental conditions on this stage.
Concluding thoughts
Returning to the original topic of this article, what do integrated analog peripherals help with? The answer is that they are an invaluable tool for creating smarter analog systems. Integrated analog peripherals can be used to improve measurement resolution or to alert the system when certain events occur. This reduces the part count and the PCB layout complexity in the application.
Additional photos of the project are also available on my LinkedIn profile.
Robert Perkel is an applications engineer focusing on embedded and mixed-signal systems at Microchip. He graduated in 2019 with a B.S. in Computer Engineering from Virginia Tech.
Related Content
Mars Curiosity Rover: ChemCam laser-induced breakdown spectroscopy unveiled
The basics of digital signal spectra
How is a light source’s spectrum measured?
Proper IC interconnects for high-speed signaling
googletag.cmd.push(function() { googletag.display(‘div-gpt-ad-native’); });
–>
The post Developing a spectrophotometer with integrated analog peripherals appeared first on EDN.


