Start of trail End of trail navigation bar

Table of Contents

ESC Output

Computes the PWM output value to use to achieve a particular ESC output.

Library

QUARC Targets/Data Acquisition/Generic/Transformations

MATLAB Command Line

Click to copy the following command line to the clipboard. Then paste it in the MATLAB Command Window:

qc_open_library('quarc_library/Data Acquisition/Generic/Transformations')

Description

ESC Output

The ESC Output block computes the PWM output value to use to achieve a particular ESC output. The output of this block is fed to the PWM input of one of the HIL blocks supporting PWM, such as the HIL Write PWM block.

For ESC protocols like standard PWM, OneShot and Multishot, the throttle value as a percentage (0% to 100%) is mapped to a pulse width in seconds. The PWM output mode should be configured as PWM_TIME_MODE (4) in the HIL Initialize block when using these protocols. The desired PWM period must also be configured in the HIL Initialize block.

For the DSHOT protocol, there are three inputs: throttle, telemetry and command. The throttle value is a percentage (0% to 100%) and the telemetry is a logical input indicating whether to include a telemetry request in the DSHOT output. The command input is used for special commands. A command value of 0 means "disarm", for instance. Command values from 0-47 are for special commands and the throttle value will be ignored in the output. A command value of 48 means "armed". In this case, the throttle value is included in the output value.

For DSHOT, the PWM output should be configured in PWM_RAW_MODE (6) in the HIL Initialize block and DSHOT should be enabled in the board-specific options e.g. pwm0_dshot=1. The PWM frequency will determine the bit rate for the DSHOT. For example, a PWM frequency of 600e3 will result in DSHOT600 being output from the PWM output.

The table below enumerates the typical settings employed for various ESC protocols.

Protocol

Description

PWM Mode

PWM Frequency

Standard PWM

1 to 2 ms pulse every 20 ms.

PWM_TIME_MODE (4)

50

OneShot125

125 to 250 us pulse every 500us.

PWM_TIME_MODE (4)

2000

OneShot42

42 to 84 us pulse every 168us.

PWM_TIME_MODE (4)

1/168e-6

Multishot

5 to 25 us pulse every 50us.

PWM_TIME_MODE (4)

20000

DShot150

16-bit packet at 150 kbaud.

PWM_RAW_MODE (6)

150e3

DShot300

16-bit packet at 300 kbaud.

PWM_RAW_MODE (6)

300e3

DShot600

16-bit packet at 600 kbaud.

PWM_RAW_MODE (6)

600e3

DShot1200

16-bit packet at 1200 kbaud.

PWM_RAW_MODE (6)

1200e3

DShot2400

16-bit packet at 2400 kbaud.

PWM_RAW_MODE (6)

2400e3

The DSHOT commands are unique to the ESC, other than disarm (0) and armed (48). The table below shows the commands implemented by KISS. Not every ESC is guaranteed to implement all of these commands, and other manufacturers may implement a different set of commands.

Command

Description

0

Disarm. The motor will stop.

1-5

Beep (1 = low frequency, 5 = high frequency).

6

ESC information request (firmware version, serial number and settings sent over telemetry wire).

7

Rotate in one direction.

8

Rotate in the other direction.

9

3D mode off.

10

3D mode on.

11

ESC settings request (settings will be saved over the telemetry wire). Not currently implemented.

12

Save settings.

13-19

Reserved.

20

Rotate in the normal direction.

21

Rotate in the reverse direction.

22-25

LED 0-3 on (BLHeli32 only).

26-29

LED 0-3 off (BLHeli32 only).

30

Audio stream mode on/off.

31

Silent mode on/off.

32-47

Reserved.

48

Armed (normal operation).

Limitations

DSHOT Protocol

Warning The DSHOT protocol is currently only supported by the Quanser QDrone and QCar via board-specific options such as pwm0_dshot. The other ESC protocols can be produced by most data acquisition cards with PWM support.

Input Ports

%

The throttle value as a percentage. A value of 0 means 0% throttle and a value of 1 is 100% throttle. Any fraction in between indicates an intermediate throttle value.

tele

Whether to request telemetry data from the ESC. This input is treated as a boolean value. Any non-zero value means true and a value of zero means false. This input is only available when the DSHOT protocol is selected.

cmd

The command to use when the DSHOT protocol is selected. Values from 0 to 47 are special commands. Special commands ignore the throttle value. A value of 48 indicates "armed" and will use the throttle value to set the ESC throttle.

Output Ports

v

A double output to be used as the PWM input value for one of the HIL blocks supporting PWM.

Data Type Support

The ESC Output block supports any of the standard Simulink data types at its telemetry or command inputs. Fixed-point data types are not supported. The throttle input is always a double.

Parameters and Dialog Box

ESC Output

Protocol

The ESC protocol for which to produce a PWM output value.

Targets

Target Name

Compatible*

Model Referencing

Comments

QUARC Win32 Target

Yes

Yes

QUARC Win64 Target

Yes

Yes

QUARC Linux Nvidia Target

Yes

Yes

QUARC Linux QBot Platform Target

Yes

Yes

QUARC Linux QCar 2 Target

Yes

Yes

QUARC Linux QDrone 2 Target

Yes

Yes

QUARC Linux Raspberry Pi 3 Target

Yes

Yes

QUARC Linux Raspberry Pi 4 Target

Yes

Yes

QUARC Linux RT ARMv7 Target

Yes

Yes

QUARC Linux x64 Target

Yes

Yes

QUARC Linux DuoVero Target

Yes

Yes

QUARC Linux DuoVero 2016 Target

Yes

Yes

QUARC Linux Verdex Target

Yes

Yes

QUARC QNX x86 Target

Yes

Yes

Last fully supported in QUARC 2018.

Rapid Simulation (RSIM) Target

Yes

Yes

S-Function Target

No

N/A

Old technology. Use model referencing instead.

Normal simulation

Yes

Yes

* Compatible means that the block can be compiled for the target.

See Also

 

navigation bar