Files

README.md

Svetozar: an open-source e-vehicles peripherals controller

View this project on CADLAB.io.

Current project status: in active development. Some features work, some don't.

In a nutshell:

device board

This ~30$ device allows you to control headlights/turn signals/horn/fan/etc on a typical e-bike/e-scooter.

It consists of a <![CDATA[]]>‘Blue pill’<![CDATA[]]> board with STM32F103 microcontroller which is widely available on eBay or <![CDATA[]]>Aliexpress<![CDATA[]]> and a custom board with high-voltage circuitry. (You can order this board at <![CDATA[]]>jlcpcb.com<![CDATA[]]> 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).

Current functions:

  • 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

Hardware requirements

  • 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)

Firmware requirements

  • <![CDATA[]]>Arduino IDE<![CDATA[]]>
  • Arduino SAM boards (Cortex-M3) support installed from Ardiuno IDE's boards manager
  • <![CDATA[]]>coddingtonbear's fork<![CDATA[]]> of Arduino STM32 ‘hardware’ files with hardware CAN support (HardwareCAN git branch)
  • <![CDATA[]]>STM32duino bootloader<![CDATA[]]> for Blue pill boards
  • Some STM32 <![CDATA[]]>ST-Link/V2<![CDATA[]]> or <![CDATA[]]>USB-TTL<![CDATA[]]> flashing software

Flashing a Blue Pill board with the bootloader

Mac OS X

Requirements

Software
  • python 3.x (brew install python)
  • libusb (brew reinstall libusb)
  • pyusb (pip3 install pyusb)
  • <![CDATA[]]>pystlink<![CDATA[]]>

Process

  1. Download <![CDATA[]]>STM32duino bootloader<![CDATA[]]>
  2. Connect ST-Link programmer to the board
  3. Flash it with

pystlink --cpu STM32F103xB flash:erase:verify:genericboot20pc13.bin

  1. Reset or re-connect the board

Windows

To Do

Flashing via USB-TTL adapter under Windows

<![CDATA[]]>Please read this russian article<![CDATA[]]>

Installing Arduino with STM32duino support

<![CDATA[]]>STM32duino installation instructions<![CDATA[]]>

Mac OS X

  1. Install Arduino
  2. Install libusb (brew install libusb)
  3. Launch Arduino IDE, go to Tools -> Board: ... -> Boards Manager and install the Arduino SAM boards (Cortex-M3) support.
  4. Download <![CDATA[]]>coddingtonbear's fork<![CDATA[]]> of Arduino STM32 ‘hardware’ files with hardware CAN support, checkout HardwareCAN branch and move and rename it to ~/Documents/Arduino/hardware/Arduino_STM32.
  5. In Arduino IDE select Tools -> Board: ... -> Generic STM32F103C series.
  6. In Arduino IDE select Tools -> CPU speed(MHz): -> 48MHz.

Credits

Blue pill board library is from <![CDATA[]]>github/sagarHackeD<![CDATA[]]> VOM1271T.lbr, MAX3051ESA.lbr & MC14504BDR2G.lbr are from <![CDATA[]]>SnapEDA<![CDATA[]]>

Report a bug