Main Content

Battery

Measure voltage level of battery in EV3 brick

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

  • Lego EV3 Battery block

Libraries:
Simulink Support Package for LEGO MINDSTORMS EV3 Hardware

Description

Use the Battery block to measure voltage of the battery in the LEGO® MINDSTORMS® EV3 brick, in millivolts. For example, when the six 1.5-volt batteries are fully charged, the output value is approximately 9000 millivolts.

During simulations without hardware, this block emits zeros. See Block Produces Zeros or Does Nothing in Simulation.

Examples

expand all

This example shows how to measure and display battery voltage of an EV3 brick.

Open the legoev3lib block library as described in Open Block Library for LEGO MINDSTORMS EV3 Hardware.

Copy the Battery and Display blocks to a new model and connect these blocks.

Battery model

Prepare and run the model on the EV3 brick as described in Run Model on EV3 Hardware. Observe the battery voltage, in millivolts, on the LCD display of the EV3 brick.

Ports

Output

expand all

The block outputs the battery voltage from the LEGO MINDSTORMS EV3 brick in millivolts.

Data Types: uint16

Parameters

expand all

Specify the frequency of how often the block reads battery values of EV3 brick. Shorter sample times, such as 0.01, may produce unreliable measurements.

Smaller sample times require the processor to complete the same number of instructions in less time, which can cause task overruns.

Version History

Introduced in R2012a