Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

...

...

...

...

...

...

...

...

...

...

...

...

...

...

...

...

...

...

...

...

...

...

...

...

...

...

...

...

...

...

...

...

...

...

...

...

...

...

...

...

...

...

...

Purpose:

The pedal board reads the ADCs for the throttle and brake pedals and broadcasts the data to the MCI.

Implementation:

The pedal project will consist of 1 task, the master_task. It will also use CAN. The master task will run in the main.c file, and this file will also have init_pedal_controls to initialize the MAX11600 IC and the necessary GPIOs. The main.c file will include the header for the IC, which should be written under the [library name] library, and will also include pedal_data.h, written under the pedal project, which uses the IC to read the pedal angle of both throttle and brake.

The pedal’s calibration will be taken care of in a test file called test_pedal_calibrate, which will be structured as a test but act as the pedal’s calibration functionality. This test will have it’s own dependencies, pedal_calib.h/.c.

main.c

The main file should initialize CAN, all the tasks, and any other modules that will be used. The file should look like the standard main.c for every project. Use scons new --project=pedal to make a new project.

...

pedal_calibrate needs to read the ADC when the throttle and brake are pressed down, and when they are let go, and use that reading to set the upper and lower bounds of the pedal (subject to change, based off of MSXIV).

pedal_data.c

The pedal data file should have two functions, read_throttle_data, and read_brake_data, each of which reads the respective channel from the IC over I2C. These functions should update the values using the pointer passed into it and should return a StatusCode. The data read from these functions should be adjusted based on calibration.

test_pedal_calib.c

This should mostly be copied from MSXIV but will depend on a lot of files that need to be ported over.

max11600.c

MAX11600 datasheet.

General idea - The MAX11600 has four analog IN channels, AIN0 is throttle, AIN1 is steering angle, AIN2 is brake, and AIN3 is unused. We’ll send a configuration byte to select a channel and then simply read in the data from that channel. Taken from Figure 11 on the datasheet:

...

The driver should send the slave address with a read byte (11001001), after which the MAX will begin sending the data from the selected channel until the master transmits a STOP condition (for us this will be done will just two function calls).

...

Send a setup and configuration byte to the IC (address 11001000) and set up any necessary storage/struct pointers needed for the driver.

Byte

Bits

Setup

101x100x

Configuration

011xx001

These are channel select bits which need to be changed depending on the data we’re reading - they can be anything on initialization

View Tables 1 and 2 on the datasheet for more information on Setup and Configuration bytes.

max11600_read_raw:

Slave address 11001000 - write a config byte to select channel.

Slave address 11001001 - read in the data

This function should be passed a pointer to a storage variable/struct which will hold the three values read from the MAX.

...

Calls max11600_read_raw, then converts the values to the value in mV. Look at Figure 12 on the datasheet to understand how to convert from binary to mV.

CAN Messages:

See pedal.yaml

Message

Id

Target

Data

Types

pedal_output

18

motor_interface

throttle_output, brake_output

uint32_t, uint32_t

TODO:

Steering angle sensor

...