You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The switch table is the "brain" of the car, used for controlling most functions like lights, wiper, and brake. It processes the inputs from the switches, steering wheel and pedal then compiles them into it's state and sends that out over the CAN bus. It can also send motor control commands when the override switch is turned off.
Features
State Broadcasting: Sends a CAN message every 50ms about its own state (switch positions, throttle position)
Wiper Control: Controls the wiper converter and servo with PWM
Throttle Input: Reads and filters the analog potentiometer on the throttle pedal
Motor Control: Optionally sends motor control CAN messages
Test hardware
Nucleo C092RC Development Board
Microcontroller: STM32C092RCTx (LQFP64)
Clock: Internal HSI oscillator running at 48MHz
CAN Interface: FDCAN1 using the on-board CAN transceiver
Programmer/Debugger: Nucleo built-in ST-Link
Communication Protocols
This controller uses 4 types of IO to achieve its functionality:
CAN bus for communicating with the various components of the car
GPIO to read switch positions and control some outputs
ADC (Analog to Digital conversion) to read the throttle pedal potentiometer
PWM for controlling the wiper servo motor
Pin Configuration
CAN Bus
Signal
Pin
Direction
FDCAN1_RX
PC2
Input
FDCAN1_TX
PC3
Output
GPIO Inputs (Switches)
Function
Name
Pin
Type
Switch used to enable lights
SW_LIGHTS
PC8
Digital Input
Wiper on/off
SW_WIPER
PC6
Digital Input
Hazard signal
SW_HAZARD
PC13
Digital Input
Autonomous mode switch
SW_AUTO
PC11
Digital Input
Motor control override
SW_MC_OW
PC7
Digital Input
Headlight switch
SW_HEADLIGHT
PC0
Digital Input
Shell relay input
IN_SHELL_RELAY
PC1
Digital Input
Brake pedal input
IN_BRAKE
PC12
Digital Input
GPIO Outputs
Function
Name
Pin
Type
Wiper converter enable
OUT_WIPER_CONVERTER
PD3
Digital Output
ADC Input
Function
Name
Pin
Throttle Potentiometer
ADC1_IN0
PA0
PWM Output
Function
Timer
Channel
Pin
Wiper Servo Control
TIM2
CH1
PA5
CAN Bus Messages
Received Messages
ID
ID Type
Name
Purpose
0x185
Standard
Sync State
No idea
0x190
Standard
Steering Wheel
State of buttons and position of switches on the steering wheel
0x123
Standard
RPM Measurement
RPM data from the posigion sensor
Steering Wheel State (0x190) Bit Fields
Byte 0 (STW_STATE_A):
Bit 0: ACC (Cruise Control Activate)
Bit 1: DRIVE (Drive Mode)
Bit 2: REVERSE (Reverse Mode)
Bit 3: LAP (Lap timing signal)
Bit 4: TS_L (Traction Control Left)
Bit 5: TS_R (Traction Control Right)
Bit 6: FUNCTION1 (Reserved)
Bit 7: FUNCTION2 (Reserved)
Bytes 1-3: Position of the 3 switches on the steering wheel (STW_STATE_B/C/D)
Byte 0 (VCU_STATE_A):
Bit 0: HEADLIGHT
Bit 1: HAZARD
Bit 2: AUTO
Bit 3: BRAKE
Bit 4: LIGHTS_ENABLE
Bit 5: MC_OW (Motor Control Override)
Bit 6: WIPER
Bit 7: Reserved
Byte 1 (VCU_STATE_B):
Bit 0: RELAY_NO
Bit 1: RELAY_NC
Bits 2-7: Reserved
Code Structure
This code is designed to minimize the amount of user code in generated files. The main working logic is in user.c and user.h.