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

xek

1 mW
Joined
Sep 12, 2014
Messages
11
Location
Moscow, Russia
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:
[list type=]
[*]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.
[/list]
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.

Fits Gainta G0471 or Gainta G0471F aluminum enclosures.

I'll post updates with the build process. And pardon my English.
 

Attachments

  • scheme.pdf
    34.9 KB · Views: 74
xek said:
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.
 
amberwolf said:
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 said:
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 said:
xek said:
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.php?f=26&t=7346&start=15
This one?
 
xek said:
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.
 
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):
https://endless-sphere.com/forums/search.php?keywords=open+source+controller*&terms=all&author=&sc=1&sf=firstpost&sr=topics&sk=t&sd=d&st=0&ch=300&t=0&submit=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.
https://endless-sphere.com/forums/viewtopic.php?f=2&t=22630
https://endless-sphere.com/forums/viewtopic.php?f=30&t=36479
https://endless-sphere.com/forums/viewtopic.php?f=7&t=62995
https://endless-sphere.com/forums/viewtopic.php?f=30&t=58382
https://endless-sphere.com/forums/viewtopic.php?f=7&t=34483
https://endless-sphere.com/forums/viewtopic.php?f=2&t=34422
https://endless-sphere.com/forums/viewtopic.php?f=34&t=24602
https://endless-sphere.com/forums/viewtopic.php?f=2&t=11246
https://endless-sphere.com/forums/viewtopic.php?f=2&t=6688
https://endless-sphere.com/forums/viewtopic.php?f=2&t=73053
https://endless-sphere.com/forums/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 said:
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).



https://forums.adafruit.com/viewtopic.php?f=26&t=7346&start=15
This one?
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. :(
 
wturber said:
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.
 
amberwolf said:
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
 
xek said:
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. )
 
xek said:
wturber said:
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.
 
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
    Screen Shot 2018-10-06 at 18.51.56.jpg
    222.3 KB · Views: 1,840
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.
 
flat tire said:
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 said:
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.
 
Added bom.pdf to the repo.
Total cost is around 23$ for the parts and ~3,2$ for the pcb.
 
xek said:
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.
 
Tommm said:
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.
 
Okay, I've redesigned the board, it now has electronic short circuit protection.
I've ordered a new batch of PCBs, they arrived yesterday. Firmware is not ready yet.

I've uploaded new board design and BOM to https://github.com/ryba-xek/Svetozar.
 
Cool. I’d like to purchase once you get the final bugs worked out. Will you have a BOM that is specifically for us in the United States? I noticed yours called out for European symbols, not sure if there is a difference? Or will you supply all parts with a board?

Tom
 
The BOM was updated recently, and is valid for any country. Maybe you will have to search for some parts on Mouser or Digikey, but nothing special.
I think you can buy all the parts from Mouser, that won't be a problem.
I'm sorry, I do not plan to sell anything (it takes a lot of time to solder all the parts). The project is completely open-source, you can order a batch of PCBs from jlcpcb.com for about 11$ shipped and D-I-Y.

I'll fix the firmware and release is as soon as I finish it.
 
Back
Top