TL/DR — Code and wiring diagram to output a simulated spectrum WITH noise on a specified microcontroller output pin. Requires hardware interrupts which simulate a gating pulse.
When developing new approaches to signal processing or simply designing a new data acquisition system, having a reasonable reflection of the target signal is helpful during the development/testing stage. In an effort to supply the community with such a resource, below is a set of arduino code that is designed to output a simulated spectrum from a microcontroller following a hardware interrupt (i.e. a gate opening event). Using the variables in the code it is possible to space the output of the sequence. Though a standard arduino (e.g. 16 MHz clock) may be able to simply output the spectrum, if we want to add a level of random noise a call to generate a random integer is required. In that case a few extra clock cycles are necessary to generate such a number. For such a situation, a slightly faster clock speed is warranted.
The Adafruit WICED is an entirely capable little beast that fits the bill. In addition to sporting a WIFI chip and an additional flash module, this unit boast a 120 MHz ARM Core 3 processor. When considering the target goal (i.e. hardware simulation of an IMS spectrum), that speed comes in handy. More specifically, the code below illustrates that after each interrupt the next element in the simulated spectrum is output BUT it includes and extra call that generates a random integer that is added to the spectral element. The net effect is that a spectrum with a user-defined level of noise is output. When combined with a scope or data acquisition system, the impact of signal averaging can be explored.
To aid anyone interested in adapting the arduino code a sample spectrum from raw spectrum is provided along with output from the WICED platform with added noise. Additionally, a wiring diagram is provided though be sure that the input trigger is not too large as to overload the WICED input levels. For reference, we are a big fan of the Digilent Analog Discovery units as they provide a wide degree of functionality (i.e. two 100 MS/s ADC inputs and two 100 MS/s DAC outputs), an intuitive graphical interface, and the capacity to script the data acquisition.
Updated 2/27/2019: Here’s a video used to demonstrate SNR scaling for WSU’s Instrumental Analysis class using the output from the posted code.
Raw Simulated Spectrum:
PA5 is the interrupt pin (Trigger In)
A4 is the simulated spectrum out (Spectral Output)
Arduino Code for WICED Feather Platform