Main Content

Battery Read

Read voltage of battery

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

  • Battery Read block

Libraries:
Simulink Support Package for Arduino Hardware / Arduino Motor Carrier

Description

The Battery Read block reads the voltage of the battery connected to an MKR or Nano Motor Carrier. The block outputs the voltage as a 12-bit digital value ranging between 0 and 4095. An output of 0 corresponds to minimum volts and an output of 4095 corresponds to maximum volts on an analog pin connected to the battery.

If you simulate a model that contains the Battery Read block without connecting the hardware, the block outputs zeroes. For more information, see Block Produces Zeros or Does Nothing in Simulation.

Supported Hardware

You can use the Battery Read block only with MKR and Nano 33 IoT boards.

Ports

Output

expand all

The port outputs the voltage of the battery connected to the MKR or Nano Motor Carrier. The block outputs the voltage as a 12-bit digital value ranging between 0 and 4095. An output of 0 corresponds to the minimum volts, and an output of 4095 corresponds to the maximum volts on an analog pin connected to the battery.

Data Types: uint16

Parameters

expand all

Specify how often the block reads the voltage of the battery, in seconds. When you specify this parameter as -1, Simulink® determines the best sample time for the block based on the block context within the model.

Version History

Introduced in R2019a