quanser.hardware.hil.close_all End of trail navigation bar

Table of Contents

quanser.hardware.hil.esc_output

Generates a PWM output value suitable for an ESC command.

Syntax

        [value, err] = esc_output(protocol, throttle, telemetry, command)
        [value, err] = esc_output(protocol, throttle, telemetry)
        [value, err] = esc_output(protocol, throttle)
        [value, err] = esc_output(protocol, command) % COMMAND must be a T_DSHOT_COMMAND or string in this case
    

Description

Generates an appropriate value to write to a PWM output to perform the given ESC command based on the given protocol and options. If TELEMETRY is not specified then telemetry is disabled. If COMMAND is not specified then it assumed to be 'arm'.

The return value is suitable for passing to write_pwm) as an output value.

If no err output is provided then it throws an exception if an error occurs. In generated code it prints the error message. Use hil_get_error_message to get the message associated with an error code.

Parameters

protocol

The ESC protocol as a t_esc_protocol enumeration or string. Valid strings are:

'standard'

'oneshot125'

'oneshot42'

'multishot'

'dshot'

'dshot150'

'dshot300'

'dshot600'

'dshot1200'

'dshot2400'

throttle

A throttle percentage from 0 to 1.

telemetry

Whether to enable (1) or disable (0) telemetry. May be logical (true / false) as well.

command

The ESC command (only used for ESC_PROTOCOL_DSHOT) as an integer in the range 0 to 48, a member of the t_dshot_command enumeration or one of the following strings:

'disasm'

'beep_low'

'beep_medium_low'

'beep_medium'

'beep_medium_high'

'beep_high'

'esc_information'

'rotate'

'rotate_other'

'3d_mode_off'

'3d_mode_on'

'esc_settings'

'save_settings'

'rotate_normal'

'rotate_reverse'

'led0_on'

'led1_on'

'led2_on'

'led3_on'

'led0_off'

'led1_off'

'led2_off'

'led3_off'

'audio_on_off'

'silent_mode'

'armed'

The default is 'armed' if no command is specified.

Outputs

value

The output value computed from the arguments.

err

A negative error code or zero on success.

Examples

        % Writes a DSHOT 10% throttle command to PWM #0.
        value = quanser.hardware.hil.esc_output('dshot', 0.1);
        board.write_pwm(0, value);
    

See Also

 

navigation bar