Main Content

Analog Output

Generate voltage on the specified DAC pin

Add-On Required: This feature requires the Simulink Support Package for Arduino Hardware add-on.

  • Analog Output block

Libraries:
Simulink Support Package for Arduino Hardware / Common

Description

The Analog Output block generates voltage on the specified DAC pin of the board.

You can run a Simulink® model containing Analog Output block in Connected IO mode on Arduino® boards.

Supported Arduino Boards

  • Arduino Due

  • Arduino MKR 1000

  • Arduino MKR Zero

  • Arduino MKR Wi-Fi® 1010

  • Arduino compatible ESP32 – WROOM

  • Arduino compatible ESP32 – WROVER

  • The Arduino Due board has two12-bit DAC pins, DAC0 and DAC1, available for conversion. When using this board, the block accepts a uint16 value but considers only the least significant 12 bits for conversion.

  • The Arduino MKR1000, Arduino MKR WIFI 1010, Arduino MKR ZERO, and Arduino Nano 33 IoT boards have one 10-bit DAC pin, DAC0, available for conversion. When using these boards, the block accepts a uint16 value but considers only the least significant 10 bits for conversion.

The block outputs voltage (Vout) on the DAC pin, such that:

Vout = VrefX(input/2N-1)+ Voffset

This table explains the variables in the formula.

VariableArduino BoardDescription
Arduino Due, Arduino 33 BLE SenseArduino MKR1000, Arduino MKR WIFI 1010, Arduino ZERO, Arduino Nano 33 IoT
Vref2.23.27Reference voltage for the DAC pin.
input0 < input < 40950 < input < 1023When using Arduino Due, input provided to the block must be between 0 and 4095. Any value higher than 4095 saturates the voltage output at the DAC pin. When using Arduino MKR1000, input provided to the block must be between 0 and 1023. Any value higher than 1023 saturates the voltage output at the DAC pin.
N1210Number of bits on DAC channel.
Voffset0.560.007Offset voltage on Arduino board.

Ports

Input

expand all

When using Arduino Due, input provided to the block must be between 0 and 4095. Any value higher than 4095 saturates the voltage output at the DAC pin. When using Arduino MKR1000, Arduino MKR WIFI 1010, or Arduino MKR ZERO, input provided to the block must be between 0 and 1023. Any value higher than 1023 saturates the voltage output at the DAC pin.

Data Types: uint16

Parameters

expand all

Select a DAC pin on which to generate analog voltage. When using Arduino MKR1000, Arduino MKR WIFI 1010, or Arduino MKR ZERO board, select DAC0. The DAC pin, DAC1, is not supported on these boards.

Click View pin map to open the Arduino Pin Mapping table.

To know how to assign pins for the block, see Pin Mapping for Arduino Timer Independent Blocks.

Version History

Introduced in R2014a