Please enable JavaScript to view this site.

How this block appears in a Simulink model?

adc_block_1

What can be configured?

adc_block_2

Configuration Parameter

Selectable Option/Value

Description

ADC Module

1--2

The ADC driver API supports ADC1 (8 channels, attached to GPIOs 32 - 39), and ADC2 (10 channels, attached to GPIOs 0, 2, 4, 12 - 15 and 25 - 27).

ADC Resolution

9Bit--10Bit--11Bit--12Bit

Specify the resolution. This value is: 4095 for 12-bits, 2047 for 11-bits, 1023 for 10-bits, 511 for 9 bits.

ADC attenuation

0DB--2.5DB--6DB--11DB

Select attenuation

(0db:100 mV ~ 950 mV, 2.5db:100 mV ~ 1250 mV, 6db:150 mV ~ 1750 mV, 11db:150 mV ~ 2450 mV)

Select ADC channels

 

Select channel pins

Sample time (sec)

-1 (inherited) or specify

Specify the sample time

INPUT/ OUTPUT Port

Port Name

Port Type

Date Type

Description

All output ports

Scalar

int16

These ports will be output ADC value corresponding to the pin.

When to use this block?

Use this block for the application which need to process analog signal by software. Example, reading level of analog sensor (Temperature, Pressure, etc.), measure voltage and current from sensing circuit.

How does this block work?

This block will setup ADC reading function and return the reading value in every time step.

Limitations

ADC module 2 cannot be used while the Wi-Fi setup block & Aimagin Connect block is using.

Demo

Demo file : esp32_adc_demo.slx

adc_block_3

Description

This demo shows how to read ADC value and control a digital output pin according to the ADC value using ADC block and Digital output block. String_processing_block block and Print_block block is to monitor the ADC value from the serial port.

Hardware Setup

Connect the variable resistance output to the ADC pin(GPIO33) and connect the digital output pin (GPIO22) to a LED.

adc_block_4

What should be happening?

When the input voltage to the ADC pin is below 1.65V the LED will OFF and if it is above 1.65V the LED will turn ON. From the Serial port user can also monitor the ADC value.

Serial monitor output: (Baud rate : 115200)

adc_block_5

Copyright 2022 Aimagin Co.,Ltd. Rev.339