Skip to content

Control

Tim Brewis edited this page Mar 17, 2022 · 3 revisions

Control Thread

The control thread receives a 10-bit throttle input from the sensor thread and maps it to a driver profile before sending a torque requests to the CAN thread.

Driver Profiles

A driver profile defines a mapping between a throttle input and a torque request and can be created and edited using the VCU Driver Profiles app. The raw data for profiles generated by this app is stored in driver_profile_data.c. Each driver profile is assigned a unique integer ID which is used in driver_profiles.c to fetch a pointer to the start of the corresponding look-up table.

To add a new profile:

  1. Generate the C code for the look-up table using the app.
  2. Paste the look-up table into driver_profile_data.c and give the array a suitable name.
  3. extern the look-up table array in driver_profiles.c.
  4. Add a new ID number definition for the profile to driver_profiles.h and increment NUM_DRIVER_PROFILES.
  5. Create a static const driver_profile_t instance in driver_profiles.c to represent the profile and initialise it with {ID_NUMBER, "Name", look_up_table}.
  6. Add a pointer to the new driver_profile_t to the driver_profiles array in driver_profiles.c, making sure that the array index at which it is stored corresponds to the ID number of the profile.

⚠️ Note: at the moment there is no mechanism to change the driver profile at runtime.