User Tools

Site Tools


the_quimdc_command_line_interface

The QuimDC Command Line Interface

The QuimDC Command Line Interface (C.L.I.) aims to behave like the linux bash.

Features

  • You can type “help” to display all the available commands
  • You can use “tab” to auto complete a command
  • You can use “tab” twice to display all the possible commands for the auto complete
  • You can move to the right and to the left using the Right and Left arrow keys
  • You can retrieve the last past commands using the Up and Down arrow keys even after a reboot or a flash of the card
  • All debug commands begin by “dbg_”, to print a list of debug commands type “dbg_” and use “tab”

Official API

This section describes all the command type available through CLI.

Help Command

Display the list of all available commands except debug commands with their syntax.

> help
    - motor_reset_position <int>
    - help
    - srst
    - rword <int>
    - set_echo <int>
    - loop_mesurement [<motor>] [<int>]
    - ref_pwm [<motor>] [<int>] [<int>]
    - ref_speed [<motor>] [<int>] [<int>]
    - ref_position [<motor>] [<int>] [<int>]                                                       
    - ref_current [<motor>] [<int>] [<int>]                                                        
    - encoder_motor [<motor>]                                                                      
    - current_motor [<motor>]                                                                      
    - speed_motor [<motor>]                                                                        
    - pwm_motor [<motor>]                                                                          
    - motor_watchdog_value [<int>]                                                                 
    - speed_pid_p [<motor>] [<int>]                                                                
    - speed_pid_i [<motor>] [<int>]                                                                
    - speed_pid_d [<motor>] [<int>]                                                                
    - speed_pid_do [<motor>] [<int>]                                                               
    - speed_pid_fixed_point_divider [<motor>] [<uint>]                                             
    - speed_pid_uIAntiWU_Limit [<motor>] [<uint>]                                                  
    - current_pid_p [<motor>] [<int>]                                                              
    - current_pid_i [<motor>] [<int>]                                                              
    - current_pid_d [<motor>] [<int>]                                                              
    - current_pid_do [<motor>] [<int>]                                                             
    - current_pid_fixed_point_divider [<motor>] [<uint>]                                           
    - current_pid_uIAntiWU_Limit [<motor>] [<uint>]                                                
    - position_pid_p [<motor>] [<int>]                                                             
    - position_pid_i [<motor>] [<int>]                                                             
    - position_pid_d [<motor>] [<int>]                                                             
    - position_pid_do [<motor>] [<int>]                                                            
    - position_pid_fixed_point_divider [<motor>] [<uint>]                                          
    - position_pid_uIAntiWU_Limit [<motor>] [<uint>]                                               
    - pwm_duty_max [<motor>] [<uint>]                                                              
    - bemf_compensation [<motor>] [<uint>]                                                         
    - minimal_speed [<motor>] [<uint>]                                                             
    - offset_current_start [<motor>] [<uint>]                                                      
    - loop_function [<motor>] [<int>]                                                              
    - ticks_per_turn_motor [<motor>] [<int>]                                                       
    - resistance_motor [<motor>] [<float>]                                                         
    - kv_motor [<motor>] [<float>]                                                                 
    - nominal_power_voltage [<motor>] [<float>]                                                    
    - polarity [<motor>] [<int>]                                                                   
    - position_speed_period [<motor>] [<int>]                                                      
    - print_board_states                                                                           
    - enter_operational_mode                                                                       
    - leave_operational_mode                                                                       
    - publish_freq [<motor>] [<int>]                                                               
    - emergency_stop [<motor>] [<int>]                                                             
    - homing [<motor>] [<int>]                                                                     
    - print_gpio_list                                                                              
    - print_gpio [<motor>] [<str>]                                                                 
    - freeWheelGpio [<motor>] [<str>]                                                              
    - homingGpio [<motor>] [<str>]                                                                 
    - negLimitSwitchGpio [<motor>] [<str>]                                                         
    - posLimitSwitchGpio [<motor>] [<str>]                                                         
    - is_homing_done [<motor>]                                                                     
    - invertNegLimitSwitchGpio [<motor>] [<uint>]                                                  
    - invertPosLimitSwitchGpio [<motor>] [<uint>]                                                  
    - invertHomingGpio [<motor>] [<uint>]                                                          
    - max_position_error [<motor>] [<uint>]                                                        
    - pwm_offset [<motor>] [<uint>]                                                                
    - acceleration_period [<motor>] [<uint>]                                                       
    - deceleration_limit [<motor>] [<uint>]                                                        
    - acceleration_limit [<motor>] [<uint>]                                                        
    - max_current [<motor>] [<uint>]                                                               
    - max_speed [<motor>] [<uint>]                                                                 
    - save_parameters_to_flash                                                                     
    - load_parameters_from_flash                                                                   
    - erase_flash                                                                                  
    - spi_xfer_dbg <int> <int> <int>                                                               
    - spi_xfer8_dbg <int> <int>                                                                    
    - spi_xfer16_dbg <int> <int>                                                                   
    - board_brake [<motor>] [<int>]                                                                
    - board_getAllExtEncPin <int>                                                                  
    - board_printSupplyVoltage                                                                     
    - board_sleep <int>                                                                            
    - board_reset <int>                                                                            
    - board_printDriverFault                                                                       
    - board_resetDriver                                                                            
    - board_setRightMotorPwm <int>                                                                 
    - board_motorControl <int>                                                                     
    - board_activateDrivers <int>                                                                  
    - board_getCurrent <int>                                                                       
    - board_seeCurrent                                                                             
    - board_getMotorEnc <int>                                                                      
    - config_DriverParam                                                                           
    - com_spi <int> <int> <int>

Board States

The print_board_states displays useful informations according to the current loop function of each motor. Here is an example with motor 1 in position speed current closed loop and motor 2 in pwm open loop :

>D:004-000000 
D:005-000000 ####################
D:006-000000 # THE BOARD STATES #
D:007-000000 ####################
D:008-000000 Operational Mode : no
D:009-000000 Motor Watchdog value : 15
D:010-000000 Right Motor(1) : 
D:011-000000     Control : Position Speed Current double Closed Loop
D:012-000000     Polarity : 1
D:013-000000     Position and Speed Period : 1 ms
D:014-000000     Position ref : 0 tick
D:015-000000     Position PID : p=10000 i=1000 d=0 do=0 uIAntiWU=15000 FPdivider=128
D:016-000000     Speed ref : 0 tick/s
D:017-000000     Speed PID : p=5 i=1 d=0 do=0 uIAntiWU=40000 FPdivider=300
D:018-000000     Current ref : 0 mA | 0 ADC
D:019-000000     Current PID : p=0 i=5 d=0 do=0 uIAntiWU=15000 FPdivider=128
D:020-000000     Resistance : 1.000000 Ohm
D:021-000000     Kv : inf Rpm/V
D:022-000000     Ticks Per Turn : 1
D:023-000000     Nominal Power Voltage : 1.000000 V
D:024-000000 Left Motor(2) : 
D:025-000000     Control : Pwm Open Loop

Save parameters

You can save the parameters using save_parameters_to_flash.

>save_parameters_to_flash 

>D:001-000000 Parameters saved

Operational Mode

To enter operational mode use :

>enter_Operational_Mode 

To leave operational mode use :

>leave_Operational_Mode 

Data Publication

Some information like average speed, PWM duty cycle, voltage, and current can be published periodically to the serial port. To enable this auto-publishing mode for a specific motor, use :

>publish_freq [<motor>] [<int>]

To disable auto-publishing mode, use :

>publish_freq [<motor>] 0

Motor Parameters

Getter and Setter

Some functions are used to access specific parameters for each motor. They can take up to 2 parameters :

- func_name [<motor>] [<int value>]

Let's use ref_speed as an example :

  • With 0 parameter, ref_speed displays the reference/target speed for both motors separated by ':'.
>ref_speed 

>D:001-000000 ans = 30000:15000
  • With 1 parameter, ref_speed displays the reference/target speed for the selected motor. The parameter is called motor and can take the following value : '1' '2' 'r' 'l'. '1' and 'r' stand for the right motor and '2' and 'l' stand for the left one.
>ref_speed 1

>D:001-000000 ans = 30000

>ref_speed l

>D:001-000000 ans = 15000
  • With 2 parameters, ref_speed will set the reference/target speed for the selected motor. [<int value>] or [<float value>] in the help section indicate the type value.
>ref_speed r 

>D:001-000000 ans = 30000

>ref_speed r 0

>ref_speed r 

>D:003-000000 ans = 0

>ref_speed  

>D:004-000000 ans = 0:15000

List of commands :

Name Type value Range value Comment
ref_speed int [0;2147483647] reference/target speed (tick/s or pwm)
ref_position int [0;2147483647] reference/target position (tick)
ref_current int [0;2147483647] reference/target current (mA)
speed_pid_p int [0;2147483647]
speed_pid_i int [0;2147483647]
speed_pid_d int [0;2147483647]
speed_pid_do int [0;2147483647]
speed_pid_fixed_point_divider int [0;2147483647]
speed_pid_uIAntiWU_Limit int [0;2147483647] saturation limit for pid integral terme
current_pid_p int [0;2147483647]
current_pid_i int [0;2147483647]
current_pid_d int [0;2147483647]
current_pid_do int [0;2147483647]
current_pid_fixed_point_divider int [0;2147483647]
current_pid_uIAntiWU_Limit int [0;2147483647]
position_pid_p int [0;2147483647]
position_pid_i int [0;2147483647]
position_pid_d int [0;2147483647]
position_pid_do int [0;2147483647]
position_pid_fixed_point_divider int [0;2147483647]
position_pid_uIAntiWU_Limit int [0;2147483647]
loop_function int 0,1,2,3
ticks_per_turn_motor int [0;2147483647]
resistance_motor float [0.0;inf] Ohm (type inf to set the value to INFINITY)
kv_motor float [0.0;inf] Rpm/V (type inf to set the value to INFINITY)
nominal_power_voltage float [0.0;inf] V (type inf to set the value to INFINITY)
polarity int -1 or 1 only -1 and 1 are supported any other value will have unexpected results
position_speed_period int [0;2147483647]

Getter and Setter for both motor

Some functions allow you to get and set one parameter for both motors at the same time. They can take up to 1 parameter :

- func_name [<int value>]

Let's use motor_watchdog_value as an example :

  • With 0 parameter, motor_watchdog_value displays the card watchdog value.
>motor_watchdog_value

>D:001-000000 ans = -1
  • With 1 parameter, motor_watchdog_value sets the card watchdog value at the specific value.
>motor_watchdog_value 15

>motor_watchdog_value   

>D:003-000000 ans = 15

List of commands :

Name Type value Range value Comment
motor_watchdog_value int [-1;2147483647] -1 will disable the watchdog

Getter

Some functions are read only, they take up to 1 parameter :

- func_name [<motor>]

Let's use encoder_motor as an example :

  • With 0 parameter, encoder_motor display the encoder value for both motor separated by ':'.
>encoder_motor

>D:001-000000 ans = 0:45359
  • With 1 parameter, encoder_motor displays the encoder value for the selected motor. The parameter is called motor and can take the following value : '1' '2' 'r' 'l'. '1' and 'r' stand for the right motor and '2' and 'l' stand for the left one.
>encoder_motor 1

>D:001-000000 ans = 0

>encoder_motor l

>D:001-000000 ans = 45359

List of commands :

  • encoder_motor
  • current_motor
Name Type value Range value Comment
encoder_motor int [0;65535] 16 bits counter
current_motor int [0;4096] 12 bits ADC

Flash memory layout (deprecated)

See “How to write a parameter in the flash” for more information.

The maximum length of a command is 64 characters. Each flash page is composed of 2048 “32 bits” units. But because of the prefetch buffer, only 512 units are available. One unit can store 4 characters so we can save 2048 characters per page.

Therefore we can save 32 command lines per page. The first page will be reserved for some configuration. The following table describes the flash memory layout for the command history.

Group's name Name Address Description
Configurations ADDR_CHECK_HISTORY_INIT 0x0807F000 If set to 0, means that a history is stored in the flash
ADDR_NUMBER_HISTORY_SAVED 0x0807F004 The number of commands saved in this page
unused
Command 1 ADDR_FIRST_HISTORY_CMD 0x0807F040 ex : h,e,l
None 0x0807F044 ex : p,\0,0xFF
Command 2 None 0x0807F080 ex : t,r,c
None 0x0807F084 ex : _,t,o
None 0x0807F084 ex : g,g,l
None 0x0807F084 ex : e, ,4
None 0x0807F084 ex : 4,\0,0xFF
Command 3 None 0x0807F0C0

For example, here the Command 1 is “help” and the Command 2 is “trc_toggle 44”. “trc_toggle 44” was the last command typed by the user.


the_quimdc_command_line_interface.txt · Last modified: 2022/06/24 11:50 by cbernier