A comprehensive electric vehicle motor control system implemented on Tiny Tapeout, featuring dual-mode operation (PLC/HMI), motor speed control with PWM, temperature monitoring, and various vehicle subsystems control.
This EV motor control system provides a complete solution for managing electric vehicle operations through a single ASIC. The design implements:
The system operates on a state-machine based architecture with an 8-operation selector that controls different subsystems:
The system supports dual-mode operation:
All control signals use XOR logic between PLC and HMI inputs, ensuring only one source can control each function at a time, preventing conflicts.
Speed Calculation:
speed = max(0, accelerator - brake)
PWM Generation:
Temperature Monitoring:
Fault Protection:
Dedicated Inputs (ui_in[7:0]):
[2:0]
: Operation selector (8 operations)[3]
: PLC power control[4]
: HMI power control[5]
: Mode selector (PLC/HMI)[6]
: PLC headlight control[7]
: HMI headlight controlBidirectional I/O (uio_in[7:0] input, uio_out[7:0] output):
uio_in[0]
: PLC horn controluio_in[1]
: HMI horn controluio_in[2]
: PLC right indicatoruio_in[3]
: HMI right indicatoruio_in[7:4]
: 4-bit accelerator/brake data (time-multiplexed)uio_out[7:0]
: 8-bit motor speed outputDedicated Outputs (uo_out[7:0]):
[0]
: Power status LED[1]
: Headlight output[2]
: Horn output[3]
: Right indicator output[4]
: Motor PWM signal[5]
: Overheat warning LED[7:6]
: System status LEDs (enable, fault)Power-Up Sequence:
- Set ena = 1, rst_n = 0
- Wait 10 clock cycles
- Set rst_n = 1
- Set operation_select = 3'b000
- Set either power_on_plc = 1 OR power_on_hmi = 1 (not both)
- Verify uo_out[0] = 1 (power status)
Headlight Test:
- Ensure system is powered on
- Set operation_select = 3'b001
- Set headlight_plc = 1, headlight_hmi = 0
- Verify uo_out[1] = 1 (headlight on)
Motor Speed Test:
- Set operation_select = 3'b100
- Set uio_in[7:4] = 4'd12 (accelerator)
- Wait 2 clock cycles for data_select toggle
- Set uio_in[7:4] = 4'd4 (brake)
- Wait 5 clock cycles
- Verify uio_out = 8'd128 (expected: (12-4)<<4 = 128)
PWM Generation Test:
- Set operation_select = 3'b101
- Monitor uo_out[4] for multiple clock cycles
- Verify PWM signal toggles between 0 and 1
- Duty cycle should correspond to motor speed
Temperature Fault Testing:
Mode Switching:
Edge Cases:
# Complete test sequence in cocotb
await reset_sequence()
await test_power_control()
await test_headlight_control()
await test_horn_control()
await test_motor_speed_calculation()
await test_pwm_generation()
await test_temperature_monitoring()
await test_mode_selection()
await test_edge_cases()
The following external hardware components are recommended for a complete EV motor control implementation:
Motor Drive Circuit:
Power Supply:
Interface Connectors:
PMOD Connectors for Easy Integration:
PMOD Motor - PWM motor control board
PMOD LED8 - Status indicator array
PMOD Switch - Manual input controls
PMOD Thermocouple - Real temperature sensing
Lighting Systems:
Sensors and Feedback:
Safety Systems:
TinyTapeout Chip
├── ui_in[7:0] → Input switches/PLC interface
├── uo_out[7:0] → LED indicators/Relays/PWM output
├── uio_in[7:4] → Accelerator/Brake sensors
├── uio_out[7:0] → Motor speed display/CAN interface
└── Power: 5V regulated, GND
External Power: 12V/24V vehicle battery
Motor: 3-phase BLDC + driver circuit
HMI: 7" touchscreen panel
PLC: Industrial controller interface
This hardware setup provides a complete, production-ready EV motor control system suitable for small electric vehicles, e-bikes, or prototype electric car applications.
# | Input | Output | Bidirectional |
---|---|---|---|
0 | operation_select[0] | power_status | horn_plc (input) |
1 | operation_select[1] | headlight_out | horn_hmi (input) |
2 | operation_select[2] | horn_out | right_ind_plc (input) |
3 | power_on_plc | right_indicator | right_ind_hmi (input) |
4 | power_on_hmi | motor_pwm | motor_speed[0] (output) |
5 | mode_select | overheat_warning | motor_speed[1] (output) |
6 | headlight_plc | status_led[0] | motor_speed[2] (output) |
7 | headlight_hmi | status_led[1] | motor_speed[3] (output) |