1. Configuring the VESC

Danger

Important Safety Tips

  • Put your car on an elevated stand so that its wheels can turn without it going anywhere. If you don’t have an RC car stand, you can use the box that came with your Jetson.

  • Make sure you hold on to the car while testing the motor to prevent it from flying off the stand.

  • Make sure there are no objects (or people) in the vicinity of the wheels while testing.

  • Use a fully-charged LiPO battery instead of a power supply to ensure the motor has enough current to spin up.

Equipment Required:
  • Fully built F1TENTH vehicle

  • Box or Car stand to put vehicle on

  • Laptop/computer (does not need to running Linux)

Approximate Time Investment: 1 hour

Note

If using the VESC mkIV, see here.

1. Installing the VESC Tool

We need to configure the VESC so that it works with the ROS driver package. Before you start, you’ll need to install the VESC Tool v2.03. The latest version, v2.05 does not contain the firmware that we use. The Linux VESC tool v2.03 can be found here.

2. Powering the VESC

First we need to power the VESC. Plug the battery in.

../../_images/vesc01.JPG

Plug the battery in. Make sure the polarity is correct.

Note that you don’t need to turn on the Powerboard for configuring the VESC.

Next, unplug the USB cable of the VESC from the Jetson NX and plug the USB into your laptop. You may want to use a longer cable.

../../_images/vesc02.JPG

Plug a longer micro USB cable from the VESC to your computer.

3. Connecting the VESC to Your Laptop

Launch the VESC Tool. On the Welcome page, press the AutoConnect button on bottom left of the page. After the VESC is connected, you should see an updated status on the bottom right of the screen.

../../_images/connect.png

Click Autoconnect in the VESC Tool.

4. Updating the Firmware on the VESC

The first thing you’ll need to do is to update the firmware onboard the VESC. On the left side of the screen, click on the Firmware tab. On bottom left of the page, check the Show non-default firmwares check box. On the right, you should see extra firmware options show up. Select the VESC_servoout.bin option. Afterwards, on the bottom right of the page, press the button with the down arrow to update the firmware on the connected VESC. A status bar at the bottom of the page will show firmware update status. After it’s finished, follow the prompt on screen.

../../_images/firmware.png

Update the firmware.

5. Uploading the Motor Configuration XML

After firmware update, Select Load Motor Configuration XML from the drop down menu and select the provided XML file from here . After the XML is uploaded, click on the Write Motor Configuration button (the button with a down arrow and the letter M) on the right side of the screen to apply the motor configuration. Note that in the future, you’ll have to press this button whenever you make a change in motor configuration.

../../_images/xml.png

Upload the XML file.

6. Detecting and Calculating Motor Parameters

To detect and calculate the FOC motor parameters, navigate to the FOC tab under Motor Settings on the left. At the bottom of the screen, follow the direction of the arrows and clck on the four buttons one by one, and follow the on screen prompt. Note that during the measuring process, the motor will make noise and spin, make sure the wheels of your vehicle are clear.

../../_images/detect_motor.png

Detect the motor.

After the motor parameters are measured, the fields at the bottom of the screen should turn green. Click on the Apply button, and click the Write Motor Configuration button.

../../_images/apply_motor.png

Apply the motor parameters.

7. Changing the Openloop Hysteresis and Openloop Time

Navigate to the Sensorless tab on top of the screen. Change the Openloop Hysteresis and Openloop Time to 0.01, and click the Write Motor Configuration button.

../../_images/open_loop.png

Change the openloop time.

8. Tuning the PID controller

Now you can start tuning the speed PID controller. To see the RPM response from the motor, navigate to the Realtime Data tab under Data Analysis on the left. Click Stream Realtime Data button on the right (the button with letters RT), and navigate to the RPM tab on the top of the screen. You should see RPM data streaming now.

../../_images/realtime.png

RPM data streaming.

To create a step response for the motor, you can set a target RPM at the bottom of the screen (values between 2000 - 10000 RPM). Click the play button next to the text box to start the motor. Note that the motor will spin, so make sure the wheels of your vehicle are clear from objects. Click the Anchor or STOP button to stop the motor.

../../_images/response.png

Step response from the motor.

You want to look for a clean step response that has a quick rise time and zero to very little steady state error. Adjust the gains accordingly by navigating to the PID Controllers tab under Motor Settings on the left, and change the Speed Controller gains. General rules of tuning PID gains apply. If you’re seeing a lot of oscillations, try changing the Speed PID Kd Filter.

../../_images/pid_gains.png

Adjusting PID gains.

Danger

REMEMBER TO UNPLUG THE BATTERY WHEN YOU ARE FINISHED OTHERWISE YOU WILL OVERDRAIN THE LIPO BATTERY AND WILL HAVE TO BUY A NEW ONE ON TOP OF CAUSING A FIRE.

Hopefully you’ve tuned it well enough that your car will run better than this:

../../_images/vesc03.gif