Open-source e-bike lights/fan/horn controller

Get all your technical information about electric bikes here.
Post Reply
User avatar
xek   100 µW

100 µW
Posts: 9
Joined: Sep 12 2014 3:29am
Location: Moscow, Russia
Contact:

Open-source e-bike lights/fan/horn controller

Post by xek » Oct 04 2018 7:45am

Please correct me if I had chosen wrong forum thread.

I really want to develop e-biking into something with a shared community knowledge, like 3d-printing or quadcopters.
What a pity the whole world has no more than two open-source motor controllers, both are too feeble for e-bikes.

I'm making my own e-bike on a custom built frame, middrive 8Kw motor and pulley-belt transmission and I need a horn/lights controller — why not make one =)

This is a work-in-process right now.

Features:
  • 9x digital inputs
  • an analog input for KTY83/84 temp sensor, other sensors would probably work too
  • an analog input for brake hall sensor
  • CAN-bus
  • 3x optoisolated outputs which commutate 12-130V, all three have 1.6A fuses
  • 3x 12V 1.6А outputs with 1.6A PTC fuses
  • 1x 12V 4А output with stabilized current, this can drive a fan up to 12V 4A (4А PTC fuse)
  • 2x 12V 4А outputs (4А PTC fuses)
  • All outputs can be hardware-PWM-contolled
  • Based on a Blue Pill stm32 board which should be bought separately from Aliexpress or eBay for ~2$
  • Open firmware which can be updated via USB.
PCB copper limits total 12V bus current to 8 Amperes.
And, this thing requires an external 12V power source.

https://github.com/ryba-xek/Svetozar

Uploaded first PCB version.
Screen Shot 2018-10-06 at 00.24.19.png
Fits Gainta G0471 or Gainta G0471F aluminum enclosures.

I'll post updates with the build process. And pardon my English.
Attachments
scheme.pdf
(34.88 KiB) Downloaded 35 times
Last edited by xek on Oct 05 2018 4:29pm, edited 1 time in total.
skype: ryba_xek

User avatar
amberwolf   100 GW

100 GW
Posts: 25457
Joined: Aug 17 2009 6:43am
Location: Phoenix, AZ, USA, Earth, Sol, Local Bubble, Orion Arm, Milky Way, Local Group
Contact:

Re: Open-source e-bike lights/fan/horn controller

Post by amberwolf » Oct 05 2018 11:26am

xek wrote:
Oct 04 2018 7:45am
What a pity the whole world has no more than two open-source motor controllers, both are too feeble for e-bikes.
You might read around the forum here; you'll find more than that.

A "partly open" controller is Lebowski's: It's open except for the code itself; you order the MCU preprogrammed from him, then set it up however you need it to run your system.


Regarding controlling the lights and horn, what specifically do you need to control about them that isn't done by switches on the hand/etc controls?

Fans I can see a potential need for a controller, though there are simpler existing methods one can use for that, too.


At one time, a decade ago, I tried to start an open-source development of a complete ebike system, including lights and safety cutoffs, etc., but it didn't go anywhere past REQ stage, since I'm not a programmer and couldn't get anyone else interested. There's a thread about it around here somewhere, and over on the Adafruit forums. If any of it is useful, you can look over there under the same username I have here.

User avatar
xek   100 µW

100 µW
Posts: 9
Joined: Sep 12 2014 3:29am
Location: Moscow, Russia
Contact:

Re: Open-source e-bike lights/fan/horn controller

Post by xek » Oct 05 2018 4:35pm

amberwolf wrote:
Oct 05 2018 11:26am
You might read around the forum here; you'll find more than that.

A "partly open" controller is Lebowski's: It's open except for the code itself; you order the MCU preprogrammed from him, then set it up however you need it to run your system.
Please show me some more controllers. Lebowski is not an open controller. There are many things that matter which are controlled by firmware.
amberwolf wrote:
Oct 05 2018 11:26am
Regarding controlling the lights and horn, what specifically do you need to control about them that isn't done by switches on the hand/etc controls?
Fans I can see a potential need for a controller, though there are simpler existing methods one can use for that, too.
I find it hard to use powerful 12V headlights, as you'll have to buy rare and expensive DC-DC. So I have 24s lithum battery and 8-100V headlights and 48-100V horn. There are three control channels onboard which can commutate 12 to nearly-150 Volts exactly for this puprose.

amberwolf wrote:
Oct 05 2018 11:26am
xek wrote:
Oct 04 2018 7:45am
At one time, a decade ago, I tried to start an open-source development of a complete ebike system, including lights and safety cutoffs, etc., but it didn't go anywhere past REQ stage, since I'm not a programmer and couldn't get anyone else interested. There's a thread about it around here somewhere, and over on the Adafruit forums. If any of it is useful, you can look over there under the same username I have here.
https://forums.adafruit.com/viewtopic.p ... 6&start=15
This one?
skype: ryba_xek

User avatar
wturber   100 kW

100 kW
Posts: 1440
Joined: Aug 23 2017 8:52pm
Location: Fountain Hills,AZ
Contact:

Re: Open-source e-bike lights/fan/horn controller

Post by wturber » Oct 05 2018 7:19pm

xek wrote:
Oct 05 2018 4:35pm

I find it hard to use powerful 12V headlights, as you'll have to buy rare and expensive DC-DC. So I have 24s lithum battery and 8-100V headlights and 48-100V horn. There are three control channels onboard which can commutate 12 to nearly-150 Volts exactly for this puprose.
Rare and expensive? Really? I think I paid around $20 for mine. 12 volt switches are pretty common given that they are the standard for automobiles. You can even buy multi-function switches that mount to handlbars. They are usually made for motorcycles.

I'd guess the lack of open source in this area is that the need isn't particularly large.
"Commuter - DC Booster"
Iron Horse 3.0 hardtail - 48V / 1000W / 470rpm generic Chinese DD Hub motor (ebay)
8 x 36v 4.3ah 10s 2P battery packs - 1500W 30A DC Boost Converter delivers 54v and about 1000 watts peak
53T/42T Sakae Road cranks - 30mph+ on flats
viewtopic.php?f=2&t=90369

User avatar
amberwolf   100 GW

100 GW
Posts: 25457
Joined: Aug 17 2009 6:43am
Location: Phoenix, AZ, USA, Earth, Sol, Local Bubble, Orion Arm, Milky Way, Local Group
Contact:

Re: Open-source e-bike lights/fan/horn controller

Post by amberwolf » Oct 06 2018 12:11am

Regarding other OS controllers, there's a few here on ES. I don't know their status, so you'd have to look at the threads. This search finds some of them (along with a lot of irrelevant stuff):
search.php?keywords=open+source+control ... mit=Search
There are others not found in that search; not sure what terms might find all of them at once.


and these are some of the specific threads; I didn't list the VESC ones because there's a lot of variations, and you'd probably have to look at them all to find which one suits your needs or could be adapted to them.
viewtopic.php?f=2&t=22630
viewtopic.php?f=30&t=36479
viewtopic.php?f=7&t=62995
viewtopic.php?f=30&t=58382
viewtopic.php?f=7&t=34483
viewtopic.php?f=2&t=34422
viewtopic.php?f=34&t=24602
viewtopic.php?f=2&t=11246
viewtopic.php?f=2&t=6688
viewtopic.php?f=2&t=73053
viewtopic.php?f=2&t=20731



There are also several threads that Casainho and Stancecoke are developing OS firmware for existing controller and display hardware; you can search their posts to find those threads.


xek wrote:
Oct 05 2018 4:35pm

I find it hard to use powerful 12V headlights, as you'll have to buy rare and expensive DC-DC.
Rare? Maybe commonality depends on location. I suppose some of them are expensive (like the Sevcon ones), but they aren't all.

I know it's not what you're looking for or asking about, but in case you didn't know this: For currents up to a few amps, you can often use switching power supplies that were originally intended to plug into the wall for AC, because at 24s it's high enough voltage to run those from directly even though it's DC (as long as they are switching types, and not the old transformer/rectifier type). Many of them will run on half that voltage. Thrift stores here in the USA often have them, and they can be found on ebay fairly cheap if you already know which one you're after.




So I have 24s lithum battery and 8-100V headlights and 48-100V horn. There are three control channels onboard which can commutate 12 to nearly-150 Volts exactly for this puprose.
It sounds useful, but it might end up more expensive than some of the mass-produced DC-DC units (though they probably wont' have the features or controllability yours would).



Yes, that's the one. Unfortunatley I lost all the sketches, notes, diagrams, etc., that I had offline in a housefire several years ago, so anything that isn't in that thread or here on ES is probably gone. :(

User avatar
xek   100 µW

100 µW
Posts: 9
Joined: Sep 12 2014 3:29am
Location: Moscow, Russia
Contact:

Re: Open-source e-bike lights/fan/horn controller

Post by xek » Oct 06 2018 4:46am

wturber wrote:
Oct 05 2018 7:19pm
Rare and expensive? Really? I think I paid around $20 for mine. 12 volt switches are pretty common given that they are the standard for automobiles. You can even buy multi-function switches that mount to handlbars. They are usually made for motorcycles.
I'd guess the lack of open source in this area is that the need isn't particularly large.
12 V handlebar switches can't stand 4 A of load. Plus I personally need to control a fan based on motor temperature.
skype: ryba_xek

User avatar
xek   100 µW

100 µW
Posts: 9
Joined: Sep 12 2014 3:29am
Location: Moscow, Russia
Contact:

Re: Open-source e-bike lights/fan/horn controller

Post by xek » Oct 06 2018 4:52am

amberwolf wrote:
Oct 06 2018 12:11am
I know it's not what you're looking for or asking about, but in case you didn't know this: For currents up to a few amps, you can often use switching power supplies that were originally intended to plug into the wall for AC, because at 24s it's high enough voltage to run those from directly even though it's DC (as long as they are switching types, and not the old transformer/rectifier type). Many of them will run on half that voltage.
It sounds useful, but it might end up more expensive than some of the mass-produced DC-DC units (though they probably wont' have the features or controllability yours would).
I know about this solution, thanks. I bought some good motorcycle headlights and it supports 8-100V, that's the reason I need to switch 100V. Someone may consider this potentially dangerous.
In my case I can PWM any channel, and one 12V channel outputs controlled stabilized current for a fan.
The cost of the device is around 35$ + 2$ for a blue pill board + you have to order a PCB
Last edited by xek on Oct 06 2018 2:10pm, edited 1 time in total.
skype: ryba_xek

User avatar
amberwolf   100 GW

100 GW
Posts: 25457
Joined: Aug 17 2009 6:43am
Location: Phoenix, AZ, USA, Earth, Sol, Local Bubble, Orion Arm, Milky Way, Local Group
Contact:

Re: Open-source e-bike lights/fan/horn controller

Post by amberwolf » Oct 06 2018 11:30am

xek wrote:
Oct 06 2018 4:46am
12 V handlebar switches can't stand 4 A of load.
Just to correct this for others reading or searching:

Many, probably most or even all, of the ones for motorcycle headlights and turn signals and such can, as the incandescent versions of those often take that much current, or more.

The old 1980s Honda scooter headlight I used at one time was 5-6A for low beam, and something like 8-10A for high beam, IIRC. The headlight switch on the handlebar unit from that still works after decades of use (it's on my brother's trike now). I think my present incandescent turn signals (from another Honda) on SB Cruiser take around 3A while on (more during light-up), and even the cheap plastic ebike control unit on the handlebars works ok with that load; one built for motorcycle incandescent stuff would certainly work.


Most of the cheap plastic ebike type handlebar controls have very thin wires that aren't intended for such currents, and may have switches that aren't either, so those you'd have to open up and check (since they generally don't have specifications available, or the ones they do have are made up on the spot, or outright lies). (A solution to use those low-current controls is to have them either switch only the enable/disable line of a DC-DC, or use them to switch a relay that actually handles the higher currents. )

User avatar
wturber   100 kW

100 kW
Posts: 1440
Joined: Aug 23 2017 8:52pm
Location: Fountain Hills,AZ
Contact:

Re: Open-source e-bike lights/fan/horn controller

Post by wturber » Oct 06 2018 11:47am

xek wrote:
Oct 06 2018 4:46am
wturber wrote:
Oct 05 2018 7:19pm
Rare and expensive? Really? I think I paid around $20 for mine. 12 volt switches are pretty common given that they are the standard for automobiles. You can even buy multi-function switches that mount to handlbars. They are usually made for motorcycles.
I'd guess the lack of open source in this area is that the need isn't particularly large.
12 V handlebar switches can't stand 4 A of load. Plus I personally need to control a fan based on motor temperature.
The one I just bought is rated for 16 A. I can see how a temperature controlled fan circuit could be useful.
"Commuter - DC Booster"
Iron Horse 3.0 hardtail - 48V / 1000W / 470rpm generic Chinese DD Hub motor (ebay)
8 x 36v 4.3ah 10s 2P battery packs - 1500W 30A DC Boost Converter delivers 54v and about 1000 watts peak
53T/42T Sakae Road cranks - 30mph+ on flats
viewtopic.php?f=2&t=90369

User avatar
xek   100 µW

100 µW
Posts: 9
Joined: Sep 12 2014 3:29am
Location: Moscow, Russia
Contact:

Re: Open-source e-bike lights/fan/horn controller

Post by xek » Oct 06 2018 2:16pm

Okay, you are right, good handlebar switches are capable of high currents.
I'm using cheap chinese switches which are not so good.

Today I've improved the PCB a little and ordered my first batch at JLCPCB, hooray!

Firmware is not ready yet.
Attachments
Screen Shot 2018-10-06 at 18.51.56.jpg
skype: ryba_xek

flat tire   10 kW

10 kW
Posts: 991
Joined: Feb 26 2014 12:20am

Re: Open-source e-bike lights/fan/horn controller

Post by flat tire » Oct 06 2018 3:55pm

A strong open source controller is a great idea.

You might think there is little need, with all the readily available controllers most users accept as good enough. But, most are not that configurable and the ones that are tend to be very expensive and poorly documented since support is part of the business model.

So a controller with the configurability and quality of the ASI BAC series but fully documented and hackable would be ideal.

As for the light, your "100V" headlight probably does some kind of regulation anyway and DC-DC converters are ubiquitous and inexpensive so I'm not sure there is a need in this case to rebuild content published literally thousands of times on "high end flashlight" type forums.

The horn is an area that's underdeveloped. Especially in the case of configurability for exotic noises and integrated as part of a complete audio system, with subwoofer.

No comment on the fan.

User avatar
xek   100 µW

100 µW
Posts: 9
Joined: Sep 12 2014 3:29am
Location: Moscow, Russia
Contact:

Re: Open-source e-bike lights/fan/horn controller

Post by xek » Oct 07 2018 5:38pm

flat tire wrote:
Oct 06 2018 3:55pm
So a controller with the configurability and quality of the ASI BAC series but fully documented and hackable would be ideal.
+1.
I'm studying motor control literature right now. Motor controllers are much more complex than any stuff I made.
flat tire wrote:
Oct 06 2018 3:55pm
The horn is an area that's underdeveloped. Especially in the case of configurability for exotic noises and integrated as part of a complete audio system, with subwoofer.

No comment on the fan.
100V headlight it's sealed and I don't want to disassemble it, but I've seen photos of it disassembled — it has a step-down converter.

There is no problem with 12V headlights, first three output channels on the board have separate “battery power connector”, if you connect BATT+ to 12V and BATT- to GND to it you'll get all three outputs working the same way as other 12V ones.

For the horn... I am theoretically able to PWM it, this can make strange noises. But anyway nothing stops you from modifying the design and making-your-own-with-lights-and-whistles. I have a simple horn which produces strong sound when connected to 48-100V that's enough for me.

Fan is a good thing, it allows me to feed the motor with much more amperes without overheating it's windings.
skype: ryba_xek

User avatar
xek   100 µW

100 µW
Posts: 9
Joined: Sep 12 2014 3:29am
Location: Moscow, Russia
Contact:

Re: Open-source e-bike lights/fan/horn controller

Post by xek » Oct 15 2018 8:15am

Added bom.pdf to the repo.
Total cost is around 23$ for the parts and ~3,2$ for the pcb.
skype: ryba_xek

User avatar
xek   100 µW

100 µW
Posts: 9
Joined: Sep 12 2014 3:29am
Location: Moscow, Russia
Contact:

Re: Open-source e-bike lights/fan/horn controller

Post by xek » Oct 24 2018 10:06am

Ok, I have my board now, will solder it in a day or two.
2018-10-24 18.02.08.jpg
skype: ryba_xek

Tommm   100 W

100 W
Posts: 227
Joined: Apr 03 2018 2:32am

Re: Open-source e-bike lights/fan/horn controller

Post by Tommm » Oct 24 2018 1:44pm

xek wrote:
Oct 24 2018 10:06am
Ok, I have my board now, will solder it in a day or two.
2018-10-24 18.02.08.jpg
Can I ask if you have blinking turn signal feature? I tried to look for blinking signals, they are not integrated, lights and big relays are sold separately. It should be able to be controlled with a micro controller.

User avatar
xek   100 µW

100 µW
Posts: 9
Joined: Sep 12 2014 3:29am
Location: Moscow, Russia
Contact:

Re: Open-source e-bike lights/fan/horn controller

Post by xek » Oct 25 2018 3:55am

Tommm wrote:
Oct 24 2018 1:44pm
Can I ask if you have blinking turn signal feature? I tried to look for blinking signals, they are not integrated, lights and big relays are sold separately. It should be able to be controlled with a micro controller.
This thing has microcontroller, you can program any complex blinking algorithm you want. Every output has PWM, so you can even make fade-in & fade-out. I also use just ordinary LED turn signals without any logic in them. They would work okay.


NOTE: boards v 1.1 have an error in IRLML9301TRPBF footprint, so I need to order new PCBs. And I have just started writing firmware. Stay tuned.
skype: ryba_xek

litespeed   100 kW

100 kW
Posts: 1282
Joined: Aug 11 2010 4:42pm
Location: St. Peters, Missouri

Re: Open-source e-bike lights/fan/horn controller

Post by litespeed » Oct 25 2018 9:55pm

I’m interested in this project.

Tom
I'm married so you know I'm no stranger to pain!

Post Reply