View this project on CADLAB.io.
Current project status: in active development. Some features work, some don't.
This ~30$ device allows you to control headlights/turn signals/horn/fan/etc on a typical e-bike/e-scooter.
It consists of a ‘Blue pill’ board with STM32F103 microcontroller which is widely available on eBay or Aliexpress and a custom board with high-voltage circuitry. (You can order this board at jlcpcb.com for around 11$/10 pcs delivered.)
An external 12V power source is required. The device is able to switch 6x 12V outputs plus 3x 12..100V outputs (12..100V nets are optically isolated). One of the 12V outputs is intended to drive a high-current fan and generates a stabilized 0..12V current for a smooth fan speed control. CAN bus is also supported, so you can write some code to interact with other CAN devices. There are 11 inputs on the left side, most of them are digital and trigger when connected to ground. ABRK input is analog and accepts voltages up to 5V, ATEMP input should be used with KTY84/130 temperature sensor (or NTC10k, but you'll have to change input resistors to match the sensor).
- Stoplight has medium brightness when not triggered
- ABRK & DBRK trigger stoplight to full brightness with a starting blink
- LTURN, RTURN, WARN trigger (left/right/both) turn signals flash with ~1 Hz frequency
- LBEAM triggers LBEAM output
- HBEAM triggers both LBEAM & HBEAM outputs
- HORN triggers HORN output
- AUX triggers AUX output
- BLGHT triggers BLGHT output
- ATEMP can be programmed to smoothly control FAN output
- 12V net triggers current protection at ~25A peak, this disables all 12V outputs
- BATT+ net triggers current protection at ~12A peak, this disables all 12..100V outputs
- Blue pill board
- Main board with all the components soldered (BOM)
- ST-Link/V2 or V2-1 programmer (V1 is supported via native ST software under Windows)
- Arduino IDE
- Arduino SAM boards (Cortex-M3) support installed from Ardiuno IDE's boards manager
- coddingtonbear's fork of Arduino STM32 ‘hardware’ files with hardware CAN support (
HardwareCAN
git branch) - STM32duino bootloader for Blue pill boards
- Some STM32 ST-Link/V2 or USB-TTL flashing software
- python 3.x (brew install python)
- libusb (brew reinstall libusb)
- pyusb (pip3 install pyusb)
- pystlink
- Download STM32duino bootloader
- Connect ST-Link programmer to the board
- Flash it with
pystlink --cpu STM32F103xB flash:erase:verify:generic_boot20_pc13.bin
- Reset or re-connect the board
Please read this russian article
STM32duino installation instructions
- Install Arduino
- Install libusb (brew install libusb)
- Launch Arduino IDE, go to Tools -> Board: ... -> Boards Manager and install the Arduino SAM boards (Cortex-M3) support.
- Download coddingtonbear's fork of Arduino STM32 ‘hardware’ files
with hardware CAN support, checkout
HardwareCAN
branch and move and rename it to~/Documents/Arduino/hardware/Arduino_STM32
. - In Arduino IDE select Tools -> Board: ... -> Generic STM32F103C series.
- In Arduino IDE select Tools -> CPU speed(MHz): -> 48MHz.
Blue pill board library is from github/sagarHackeD VOM1271T.lbr, MAX3051ESA.lbr & MC14504BDR2G.lbr are from SnapEDA