Main Content

M1 M2 DC Motors

Control speed and direction of DC motor on port M1 or M2

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

  • M1 M2 DC Motors block

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

Description

The M1 M2 DC Motors block controls the speed and direction of a DC motor connected to an MKR Motor Carrier. The input signal determines the power supplied to the motor and the direction of rotation of the motor.

If you simulate a model that contains the M1 M2 DC Motors block without connecting the hardware, the block outputs zeroes. See Block Produces Zeros or Does Nothing in Simulation.

Supported Hardware

You can use the M1 M2 DC Motors block only with MKR and Nano 33 IoT boards.

Ports

Input

expand all

The sign of the input signal determines the direction of rotation of the DC motor. A positive sign indicates a forward rotation, whereas a negative sign indicates a reverse rotation. The amplitude determines the power supplied to the motor.

  • 1 to 100: Forward rotation, minimum to maximum power.

  • –1 to –100: Reverse rotation, minimum to maximum power.

  • 0: No power is supplied.

Any out-of-range values, at the block input port has the same effect as the maximum or minimum input values. For example, a value of 500 is interpreted as the maximum value, 100.The block input inherits the data type of the upstream block and internally converts the input to uint8.

Data Types: single | double | int8 | int16 | int32 | uint8 | uint16 | uint32

Parameters

expand all

Select the port number on the MKR Motor Carrier to which the DC motor is connected.

Version History

Introduced in R2019a

See Also