Skip to content

CAN bus controlled power distribution module for vehicle electrical circuits

License

Notifications You must be signed in to change notification settings

trailcurrentoss/TrailCurrentPowerDistributionModule

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

TrailCurrent Power Distribution Module

CAN-controlled 8-channel PWM power distribution module for vehicle lighting and accessory control with OTA firmware update capability.

Hardware Overview

  • Microcontroller: ESP32 (WROOM32)
  • Function: 8-channel PWM lighting/accessory controller with CAN bus interface
  • Key Features:
    • 8 independent MOSFET-driven PWM outputs (0-255 brightness)
    • CAN bus communication at 500 kbps
    • Individual and master on/off/brightness control
    • Animated light sequences (startup, interior, exterior)
    • Over-the-air (OTA) firmware updates via WiFi
    • WiFi credentials provisioned dynamically over CAN bus
    • Hierarchical PCB schematic design (5 sheets)

Hardware Requirements

Components

  • Microcontroller: ESP32 development board
  • CAN Transceiver: Vehicle CAN bus interface (TX: GPIO 15, RX: GPIO 13)
  • MOSFET Drivers: 8 channels for PWM output switching
  • DIP Switches: Configuration switches

Pin Connections

PWM Outputs:

GPIO Function
32 Output 1
33 Output 2
26 Output 3
14 Output 4
4 Output 5
17 Output 6
19 Output 7
23 Output 8

KiCAD Library Dependencies

This project uses the consolidated TrailCurrentKiCADLibraries.

Setup:

# Clone the library
git clone git@github.com:trailcurrentoss/TrailCurrentKiCADLibraries.git

# Set environment variables (add to ~/.bashrc or ~/.zshrc)
export TRAILCURRENT_SYMBOL_DIR="/path/to/TrailCurrentKiCADLibraries/symbols"
export TRAILCURRENT_FOOTPRINT_DIR="/path/to/TrailCurrentKiCADLibraries/footprints"
export TRAILCURRENT_3DMODEL_DIR="/path/to/TrailCurrentKiCADLibraries/3d_models"

See KICAD_ENVIRONMENT_SETUP.md in the library repository for detailed setup instructions.

Opening the Project

  1. Set up environment variables (see Library Dependencies above)
  2. Open KiCAD:
    kicad EDA/trailer-power-control-system.kicad_pro
  3. Verify libraries load - All symbol and footprint libraries should resolve without errors
  4. View 3D models - Open PCB and press Alt+3 to view the 3D visualization

Schematic Sheets

The design uses a hierarchical schematic with dedicated sheets:

  • Root - Top-level connections
  • Power - Power distribution and regulation
  • CAN - CAN bus transceiver interface
  • MCU - ESP32 microcontroller and support circuits
  • MOSFETs - 8-channel MOSFET driver outputs
  • DIP Switch - Configuration switches

Firmware

See src/ directory for PlatformIO-based firmware.

Setup:

# Install PlatformIO (if not already installed)
pip install platformio

# Build firmware
pio run

# Upload to board (serial)
pio run -t upload

# Upload via OTA (after initial flash)
pio run -t upload --upload-port esp32-DEVICE_ID

Firmware Dependencies

This firmware depends on the following public libraries:

All dependencies are automatically resolved by PlatformIO during the build process.

WiFi Credentials:

  • WiFi credentials are provisioned dynamically via CAN bus (Message ID 0x01)
  • Credentials are stored in NVS (non-volatile storage) and persist across reboots
  • For standalone testing, credentials can be set manually in firmware

CAN Bus Protocol

Receive (Bus to Module):

CAN ID Description
0x00 OTA update trigger (MAC-based device targeting)
0x01 WiFi credential provisioning (SSID/password via CAN)
0x18 Toggle channel on/off (byte 0 = channel 0-7, 8=all on, 9=all off)
0x21 Set brightness (byte 0 = channel, byte 1 = PWM value 0-255)
0x1E Trigger light sequence (interior/exterior animations)

Transmit (Module to Bus):

CAN ID Description
0x1B Status report - current PWM values for all 8 channels (8 bytes)

Manufacturing

  • PCB Files: Ready for fabrication via standard PCB services (JLCPCB, OSH Park, etc.)
  • BOM Generation: Export BOM from KiCAD schematic (Tools > Generate BOM)
  • JLCPCB Assembly: See BOM_ASSEMBLY_WORKFLOW.md for detailed assembly workflow

Project Structure

├── EDA/                          # KiCAD hardware design files
│   ├── trailer-power-control-system.kicad_pro
│   ├── trailer-power-control-system.kicad_sch  # Root schematic
│   ├── can.kicad_sch             # CAN subsystem
│   ├── mcu.kicad_sch             # MCU subsystem
│   ├── power.kicad_sch           # Power subsystem
│   ├── mosfets.kicad_sch         # 8-channel MOSFET drivers
│   ├── dip_switch.kicad_sch      # Configuration switches
│   └── trailer-power-control-system.kicad_pcb  # PCB layout
├── src/                          # Firmware source
│   ├── main.cpp                  # Main application
│   ├── globals.h                 # Pin definitions and debug macros
│   ├── canHelper.h               # CAN message handling (408 lines)
│   ├── lightSequences.h          # Startup and animated light sequences
│   ├── wifiConfig.h              # NVS WiFi credential storage
│   └── debug.h                   # Debug macros
├── data/
│   └── partitions.csv            # ESP32 flash partition layout
└── platformio.ini                # Build configuration

License

MIT License - See LICENSE file for details.

This is open source hardware. You are free to use, modify, and distribute these designs under the terms of the MIT license.

Contributing

Improvements and contributions are welcome! Please submit issues or pull requests.

Support

For questions about:

About

CAN bus controlled power distribution module for vehicle electrical circuits

Topics

Resources

License

Contributing

Stars

Watchers

Forks

Packages

No packages published