Main Content

Simulate Analog to Digital Conversion for MCU

This example shows a minimal ADC simulation for an MCU using SoC blocks.

Model

The following model simulates an analog-to-digital converter (ADC) in an MCU. The original voltage signal is a sine wave with an amplitude of 1.5V with an average offset of 1.5V. An initial signal at 1 us starts the ADC sampling. The ADC Interface block samples the signal at the rate of the combined Acquisition time and Conversion time of the simulated ADC hardware, approximately 0.1 us. At each sample an asynchronous task executes to process the data sample and give the normalized ADC mesurement.

Results

In the Simulation tab, click Run. When the simulation completes, open the Simulation Data Inspector to view the resulting signals and tasks. From the graphs, the original signal is sampled and normalized inside the process running on the MCU. The entire process run asynchrously, with Task1 executing only upon receiving a new value.