User Tools

Site Tools


USB2LDS: Setting parameters

The USB2LDS has a set of parameters that can be changed to adapt the behaviour of the LIDAR control. This page only relates to the parameters of the USB2LDS, see Talking directly to the LDS if you want to get send commands to the LDS itself.

Putting the USB2LDS in setup mode

To set the parameters, the USB2LDS has to be in setup mode.

  • Start a serial terminal application (like PuTTY or Arduino Serial Monitor)
  • Open the Virtual serial port with a baud rate of 9600 (or 1337 in the first prototypes).
  • Send 'a' to get back an overview of the current setup.


All the setup can be managed with single-character commands.

All parameters are applied immediately, so it is possible to tune them live while the LDS is turning.

Command Description
a Display complete setup
L Load default values
p Decrease PID coefficient P - delta (P-=delta)
P Increase PID coefficient P + delta (P+=delta)
i Decrease PID coefficient I - delta (I-=delta)
I Increase PID coefficient I + delta (I+=delta)
d Decrease PID coefficient D - delta (D-=delta)
D Increase PID coefficient D + delta (D+=delta)
+ Set delta to the upper decade (delta*=10)
- Set delta to the lower decade (delta/=10)
r Decrease turn rate setpoint by 64 (RPM-=64)
R Increase turn rate setpoint by 64 (RPM+=64)
0 Set Feedforward mode to NONE
1 Set Feedforward mode to FIXED
2 Set Feedforward mode to PROPORTIONAL
f Decrease Feedforward by 1 (feedforward-=1)
F Increase Feedforward by 1 (feedforward+=1)
c Decrease Feedforward coefficient by delta (feedforward_coeff-=delta)
C Increase Feedforward coefficient by delta (feedforward_coeff+=delta)
s Save parameters to EEPROM (careful, there is no confirmation!)
m Stop the motor
M Start the motor
g Set Display mode to NONE
G Set Display mode to GRAPH (Not Implemented Yet)
v Set Display mode to VALUES
' ' (space) Set PWM to 200 to make the motor spin whatever the PID controller output


There are 3 types of memory on the USB2LDS, and settings can be managed

RAM : short term stoarge that is used for current operations.
EEPROM : long term storage that is not wiped out when power is removed. It can be modified by user actions.
FLASH : Long term storage that is not wiped out when power is removed. It can be changed only by re-programming the board, so there is no risk of losing it.

  • At startup ⇒ EEPROM to RAM
  • all the modifications done with commands happen in RAM
  • Save ⇒ RAM to EEPROM
  • Load default ⇒ FLASH to RAM


For most numerical values, there is a common “delta” parameter that is used to make it easy to adjust very different ranges. It's like selecting the digit you want to go up or down in the number (in decimal) you are adjusting, and it can go all the way up (>10000) or down(<0.0001).

PID coefficients

  • P, I and D cannot be negative and are limited to 0.

Default are Kp=0.05000, Ki=0.00010, Kd=0.00010

Turn rate setpoint

The desired turn rate of the LDS can be selected by adjusting the turn rate setpoint. Its unit is in RPM *64, meaning that a setpoint value of 19200 will be interpreted as 300 RPM (300*64 = 19200) or 5 rotation per second (5*60*64=19200).

Refer to LDS documentation, section "Gotchas" for info on what values are best.

Default is 19200 (=300 rpm, =5 rps, = 5Hz)


The system accepts a feedforward value, that is to say a value that will be added automatically to the output in an effort to lighten the load of the PID. Its presence is there to counteract known and constant disturbance like the friction of the rotating assembly.

  • NONE: no feedforward
  • FIXED : feedforward is a fixed value (adjused with 'f' and 'F')
  • PROPORTIONAL : feedforward is a percentage of the RPM setpoint (adjusted with 'c'and 'C')

Default is PROPORTIONAL with a coef of 100.0.
Fixed feedforward default is 190.


The motor can be turned ON or OFF with 'M' or 'm'. The command of the motor is then computed using the PID algorithm and the current parameters.

In some cases, badly tuned PID parameters can lead to instability. Given that the PID algorithm needs information on the actual turn rate of the sensor, and that the sensor only gives this information if it's turning, it is sometimes necessary to help the system to bet back to normal operation by giving the motor a little push. While this can be done physically by turning the sensor by hand, there is a command that briefly forces the motor to run (space). It might be necessary to send a lot of these commands at once (keep the key pressed) for the system to actually get back up.

By default, the motor starts to turn whenever the serial port is open.


To make it easier to tune the parameters live, data from the PID can be displayed.

  • NONE: no output.
  • GRAPH: not yet implemented.
  • VALUES: prints the following values: Current RPM*64 value; error (setpoint - current RPM*64 value); output (PWM output sent to the motor, before clamping between 0 and 255).
product/usb2lds/parameters.txt · Last modified: 2016/09/29 13:12 by xevel