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 and the master_task. It will also use CAN. The project should divided into 3 .c
files; main.c
, pedal_controls.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.
The master task should also read whether the brake is pressed and if so, disable throttle. This means that there are three cases where we transmit different data:
Throttle pressed (equivalent to brake NOT pressed, no pedals pressed) → Send throttle data as normal
Throttle & Brake pressed → Send throttle as 0
Brake pressed → Send throttle as 0
Medium Cycle:
Runs
pedal_controls
Runs
can_tx_task
pedal_controls.c
This file should provide an init
function to be used by main. All other functions and variables should be private to the task unless necessary.
The init_pedal_controls
function should initialize the GPIOs needed for the throttle, and initialize ADC for ADC readings. It should also calibrate the pedal upon initialization (set what we consider max value and min value for each pedal).
The read_pedal_throttle
function should read any GPIOs and the ADC for throttle.
The read_pedal_brake
function should read any GPIOs and the ADC for throttle.
CAN Messages:
See pedal.yaml
Message | Id | Target | Data | Types |
---|---|---|---|---|
| 18 |
|
|
|
TODO:
Steering angle sensor
Parking brake limit switch