Magicshine, bicycle front light, MJ808, MJ-808, MJ818, MJ-818, bicycle rear light, CAN bus
BRANCH ZC_debugging
front and rear lamps do work together and can be used on a bike. logic unit and auxiliary devices are still WIP.
this undertaking originated as an attempt to redesign the MJ808/MJ818 lights by:
- designing a custom PCB w. driver/controller ICs,
- writing firmware for a stm32 microcontroller,
- encapsulating the above in MJ808's/MJ818's original housing,
- combining:
- the rear light (MJ818),
- the front light (MJ808) and
- a control unit into an interconnected smart bicycle light system.
- developing further auxiliary devices which extend functionality of the lights.
== and || denote the CAN bus, power lines are omitted.
front and rear lights are interconnected via the CAN bus; the front light activates the rear light via commands transmitted over CAN.
(front light) - (rear light)
------------------------------------------------
(mj808) ====== (mj818)
front and rear lights are extended in their functionality by other auxiliary devices interconnected via the CAN bus
(front light) - (control unit) - (rear light)
------------------------------------------------
(mj808) ====== (control unit) ====== (mj818)
|| ||
|| ||
|| (future device(s))
(dynamo)
google magicshine mj-818 / magicshine mj-808 for an idea what the lights are and look like.
these are decent made-in-china bicycle lights operated off a 2S2P Li-Lion battery pack.
their functionality, apart from producing light, sucks.
light operating mode selection and high power consumption on the original lights is what i would like to have different.
the only reasonable way to achieve this is to start from scratch.
- eagle for PCB layout & schematics,
- STM32CubeIDE for the code,
- one STLink or similar,
- some cheapo arduino/stm-based CAN capable dev. board for quick and dirty CAN testing
- SMD soldering equipment and skills,
- parts.
- /datasheets/*/: contains what the name suggests,
- /dwg/: AutoCAD drawings & STLs of various sub-components,
- /eagle designs/: contains subfolders with eagle designs (.brd, .sch & BOMs) of various sub-components:
- mj808/: the front light,
- mj818/: the rear light,
- mj828/: a small handlebar mounted UI (nothing fancy), WIP,
- mj838/ (aka. Čos): a dynamo thing, WIP,
- mjfoo/: a development board based on the mj8x8 infractructure,
- branch-dependant: whatever stuff is in the particular branch.
- /mj8x8/: C source code for everything, to be used with STM32CubeIDE
- /saleae/: HLA for the logic analyzer
look in /datasheets/ for a BOM.
core components:
- 4-layer PCB manufactured via OSH Park,
- STM32F042G6U6 microcontroller,
- TCAN334 3.3V CAN transciever,
- MAX16819 & MAX16820 LED drivers,
- LDK320 5V LDO,
- 0402 passives and
- Cree XM-L and XP-E high power LEDs.
when chosing components the primary criterium was size, since everything needed to fit into existing housings. maximizing light output to the extreme was not a design factor.
the language of choice is C, written in an object-oriented fashion:
- it uses HAL. (don't like it? -> go away.),
- common core components translate into an abstract base class (implemented via C-structs),
- concrete implementations (e.g. mj808 ) translate into derived classes (again C-structs),
- methods are generally implemented via function pointers (e.g. CAN driver message operations),
- behaviour is sometimes achieved with OO interfaces,
- polymorphism is implemented manually via constructors (ctor in mj808_t) and
- information is hidden by nesting C-structs and placing them into either .c or .h files.
due to memory limitations there are only hints of SOLID and design patterns to be found.
code is commented in a somewhat reasonable manner.
TODO