BLDC controllers are quite interesting pieces of hardware and quite obviously the future is electric. Now not every hacker can afford a Tesla but a bicycle is very affordable and electric bicycles are a lot of fun.BLDC controllers for bicycles are pretty cheap and the low cost versions start at roughly 35€. However, the second time when a controller ceased operation while I was in the middle of nowhere, I decided it was time to dig into the inner workings of these little gadgets and create my own.The project consists of:. an open hardware BLDC controller based on an Atmega 328. which can power up to 1000W. has bluetooth. and connectors for hall sensors, brakes, pedal assist and throttlePlus.
an Android app with hacker diagnostics. a cloud service to share the dataLast not least ebikes are environment friendly and good for your health. Making prototypesSo far I have made a handful of prototypes for friends & family:Doing them by hand is quite a lengthy process. The questionThe most asked question is always: 'How far can you go with the battery?' .And the answer is: 'It depends!' .The challengeThe highest point that the Tour de France has ever passed is the Col de la Bonette at 2802 m (9192 ft).The distance from Nice/France is 120 km thus back and forth is 240 km (150 miles).
Hi folks, If I want to wire my 4-pin Coolink SWiF2-120P PWM fan (yellow, black, green & blue wires) direct to a 12v DC source, do I connect the yellow lead to the 12v positive, the black to ground and ignore the blue and green signal leads? Anatomy of a BLDC Figure 1 is a simplified illustration of BLDC motor con. Slow speed commutation drive signals without any external test equipment. Each driver requires two pins, one for high drive. The code segment for determining the appropriate drive word from the sensor inputs is shown in Figure 4. Pin RE2 RE1 RE0 RC5 RC4 RC3.
The challenge is to go up and back in one day with only one battery pack.The tourThe start is in the early morning hours at the famous Promenade des Anglais in Nice.Under clear blue skies it goes along the Var river towards the mountains. In the morning there is always a bit of head wind due to typical offshore winds close to the sea.It is a very interesting landscape along the route which changes multiple times. A section in the middle is covered with red limestone.89 km after the start the real ascent begins.The peak in the background is the Col de la Bonette. Still 14km to go and 1000m of altitude to gain. It looked damn far away - and it was!Last stop to refill the water supplyThe difficult part starts roughly at 2500m - the thin air begins to effect the legs, every meter forward becomes a major effort.
There is 40% less oxygen available than on sea level taking away your forces.In the picture below is the 'Camps des fourches', an old military village - and a veeery welcome stop to take some pictures.And finally the summit - mission accomplished!Well almost, but the way back is all downhill;)Let's do some calculationsThe battery on my bike is a medium sized battery with 48V and 11.6Ah giving roughly 550Wh of energy. Let's assume an average efficiency of the motor of 70% that gives us 385Wh of mechanical energy.Let's assume the average speed is 24km/h (15mph) then we would need 10 hours for the trip.The calculator on says we need 112W for 24km/h in the flat, thus in 10 hours we need 1.12 KWh for covering the distance.For getting up to the top we need E = mgh - 100kg. 9.81.
2800m = 2746800Ws = 763Wh. Together this is a need of 1.9KWh of energy, therefore the battery has supplied about 20% of the energy.Conclusion: obviously eBikes keep you fit!The mapsAscentRetourFood5 bananas2 baguettes with mountain cheese, ham, tomatoes and olive oilplenty of waterFunPriceless!.
at 13:59. I have been a bit slow on updating the logs. Unfortunately there is a reason out of my control: the ATMEGA328PB has become unobtainium und thus making another prototype has become impossible.All this despite the fantastic.
Findchips is agreat service for managing your BOMs and finding the right places to source them.Nevertheless, they are nowhere to find anymore, not even on obscure websites and much less so official distributors.If anybody has a good channel to Microchips - who are also sponsors of the hackaday prize - maybe you can ask them to look in some drawer for some left over ICs. I'd be more than grateful to get a handful of them!Meanwhile I have been polishing the enclosure with some laser cut panels. Below is a picture of the local fab lab SOFAB:And this is what the result looks like:.
at 13:52. Doping TestGiven enough Watts, all mountains become shallow. As I live on the french riviera, the obvious place to test an ebike ist the Col de la Madonne. It is pretty famous among road cyclists because it was the favourite test drive for Lance Armstrong.And guys, it is beautiful. Say about Lance what you want, be he knew the good places.This is what it looks like:All the way up you have a stunning view over the mediterranean and very little road traffic.
The glamour of Monaco is at your feet, the blue of the sky melts into the blue of the sea.The picture below is taken at the top of the pass, a selfie taken the old fashioned way with a timer. I think I need to train this a bit more.KERS - Kinetic Energy Recovery SystemBelow is the log of the trip from Nice to Italy via the Col de la Madonne. In true geek fashion the controller is logging all the data.
Display in the chart is:. blue: speed in km/h. gray: altitude profile in m. red: ampere of the motor @ 48V. green: Kinetic Energy Recovery System = recharge the batteryThe green part is actually the cool part, the controller can does regenerative braking, in Formula 1 better known as KERS.Thus doing the long descent is the ultimate stress test for the controller.
PASS!. at 09:18. There are plenty of instructables on youtube videos out there about how to convert a bicycle into an eBike. I wont repeat this here but just cover the basics.What you need. motor (($50-$500). battery (($100-$1000).
controller ($40-$200). throttle, pedal sensor, speed sensor, brake lever with sensorMotorThe easiest conversion is done with a hub motor.
They come in two varieties: as direct drive motor which is gearless and as geared motors. Here is a picture of a geared hub motor:You can use a 36V motor also on 48V and even higher. It is not the volts that destroy a motor but the amps. Technically a motor is nothing but a copper wire.
When too many amps are pushed through for too long then the insulation of the wires will melt causing short circuits and subsequently havoc. Also the magnets will loose their force once being heated over the curie temperature.BatteryThere are plenty out there and the more capacity you want the more expensive it will be. To calculate how much battery you need there is a calculator.
As a rule of thumb 100W of assistance will give you already a nice boost. Thus with a battery of 500Wh you can have five hours of 100W of assist. That's good for cruising on the flat at 25km/h or 16mph. However when going uphill fast you may need 1000W and your battery will last only 30 minutes.In general if you continue to use the bicycle as such and use the motor only as assist then a small battery can bring you pretty far. If you want to use the bicycle as an electric motorcycle then you will need many more times of battery.ControllerThe controller must fit the battery voltage. A battery voltage too high will destroy it. A battery voltage too low and the controller will cut off believing the battery is empty.
at 08:39. Controller hardwareAfter several revision the hardware is working really well and has been tested for several thousand kilometers now. A mini series of five pieces has been produced to check the DFM.Controller firmwareThe controller firmware is mostly finished but still has some hardwired lines in it. A few minor things are still on the list for example soft fade out of assist when reaching the speed limit. Time needed: a few dozen hours.Android appNot yet on the market. Needs to be published.
However there is a sister app for offline map usage with openstreetmap which has its first beta on the market. If you want to give it already a test run, you can find it.A screenshot of the app:WebsiteOnly the very basics but upload and display of tracks from the app are working. See an.
at 22:31. Here are some pictures of the various steps of the PCB production. My -not exactly cheap- european fab house sends them per email which shortens nicely the waiting time until the PCBs finally arrive.The first step is drilling the holes for THT components and for the vias. It's more than 150 of them!The next step is applying the photo mask and etching.
You can already see very well the structure of all the traces.And this is what the board looks like right after the etching:The final steps are then to apply the solder mask and the silk screen and to finish the pads with ENIG gold plating:That's it, almost ready. The final steps are cutting and shipping. Pictures of the assembly will follow. at 11:01.
Assigning the pins is quite a puzzle. We have digital pins and analog pins, pins that need to do PWM and pins that need to do serial output.
Other pins need to be connected to interrupts. Thus we need to juggle assignments until everything fits.The pin assignment on the controller looks like this:First consideration are the PWM pins for driving the half bridges.
This could either be the OCxA or the OCxB pins. The OCxB pins allow for a more flexible configuration thus we'll use PD2, PD3 and PD5.
Next we assign the hall sensor pins. These are digital and should be next to each other and more importantly they need to be on the same port to generate the same interrupt.
PB0 to PB2 is the good choice. Next we assign the 3 shut down pins for the half bridges. For ease of programming they should be next to each other and on the same port. PB3 to PB5 are free and fit these conditions.
Also fixed are the serial pins for the communication with the bluetooth chip. Thus PD0 and PD1 are used as RX and TX lines.Pins needing analog input are the BEMF pins. These are for voltage sensing on the phases and can be used for sensorless operation. Then obviously the throttle, the voltage and current sensing and motor temperature. Last not least we use an analog pin for a three button switch together with a resistor network.Further inputs are brake, speed and pedal sensors. They are all digital inputs with no specific requirements.This leaves us with two pins of which we'll use one for a blinkenlight LED and the other to switch a small MOSFET for the bike light or for a brake light.
at 09:35. After the decision for the microcontroller is done we need to make decisions for the basic board layout.
This also includes the choice of housing for the MOSFETs. The basic choice here is whether to use SMD fets or THT fets. As we want to run up to 1000W through the board the choice of THT is more sensible and TO-220 is a good form factor with a large choice of products.Let's do a quick back-of-the-envelope calculation. We have 50Volt from the battery and we want 1000W output.
Thus we have at least 20A going through the fets. However, the controller acts together with the inductance of the motor as a DC/DC converter and the amperage can thus be even higher unless being limited by the firmware.So we'll assume 50% margin which results in 30A. The on-resistance of a reasonable MOSFET is around 5mOhm. Thus we have 30A.30A.0.005Ohm = 4.5W. As a rule of thumb a TO-220 can dissipate roughly 1 Watt when not mounted on a heat sink. Thus at 1000W we need to properly mount them on the enclosure.Here is a picture of the general layout in a 3D rendering from KiCAD:The board measures 100x60mm.
The board is properly designed into sections. The dark blue part is the power stage. The power stage contains the 6 MOSFETs, the 3 half bridge drivers with boot strap circuitry and the caps.The green part is the brain with the uC and various I/O connectors for throttle, hall sensors, brake, speed sensor, pedal sensor and ICSP.On the right side in red there are the power regulators. The top one converts the 50V from the battery to 12V for driving the fets.
It has 0.6A output thus can produce up to 7.2W. The board itself needs about 1W so we have 5W left for LED lights on the bicycle. Below is the old classic 7805 linear regulator for powering the brain.Finally we have on the lower left the bluetooth section. This contains another voltage regulator for 3.3V and a logic level converter for the 5V TTL to 3.3V TTL.That's it, stay tuned for the next diary entry!. at 19:31. Choice of microcontrollerFirst and foremost the decision of the microcontroller had to be made. While there are dedicated chips available, I like to code embedded systems and thus the whole control should be done in firmware.
The following GPIOs are needed:. 6 digital ports with hardware PWM for the 6 MOSFETs. 3 digital ports for hall sensors in the motor for position sensing. 3 analog ports for phase sensing for sensorless operation. 3 digital port for brake switch, pedal sensor and speed sensor. 3 analog ports for throttle, assist mode and thermal motor sensor. 2 digital ports for light switching.
2 analog ports for sensing battery voltage and currentIt so happens that this fits onto an Atmega328PB. The 328PB has the advantage of having 5 timers versus 3 timers on the 328P on the Arduino boards. This is a nice convenience as 3 timers can be used for the PWM generation, while still having two more timers left for general timing purposes.Why 8-bit and not 32-bit ARM core?
The idea behind this choice is a bit hacker ethics - you can still fully understand what is happening under the hood of an 8-bit chip and the datasheet is only 400 pages. In order to program the 32 bit chips you wont easily do it without using boiler plate code produced automatically by Atmel Studio. So it is a minimalist approach.
Or as Antoine de Saint-Exupery put it: “Perfection is achieved, not when there is nothing more to add, but when there is nothing left to take away.” What else is needed?The input voltage needs to cover up to 13s lipo batteries. 13s means 13 cells in series which adds up to 54.6 Volt when fully charged. These battery packs are usually sold as 48V packs and are a common standard. The controller itself needs 10-12V for driving the MOSFETs and 5V for the microcontroller.Coming down from 55V to 12V is best done with a switching regulator. This gives also enough output power to connect a normal bicycle light. The second stage 12V to 5V is done with a linear regulator as the microcontroller and the bluetooth only need a few dozen mW of power.
Power stageThe MOSFETs gates cannot be powered directly from the uC ports for two reasons: the gates need at least 10V to fully switch on and you need to switch them on and off very fast to minimize switching losses. Very fast means in the order of 100ns. There are plenty of dedicated chips out there and I choose the International Rectifier IR2104 half bridge driver for this purpose.
The chip offers shoot-through protection, i.e. High and low side MOSFET will never both be switched on at the same time.
This is nice to have because 'shoot through' means a battery short circuit and therefore the release of magic smoke with a loud bang.The chip also has a bootstrap circuitry thus N-channel MOSFETs can also be used for the high side.That's it, those are the main components of the BLDC controller.Next up: board layout overview, coming tomorrow.Enjoy this project?Share. For the 1000W version I use various 60V 3-4mOhm Fets, for the 2000W version I use 1.3mOhm Fets. The need to be rugged and have a low gate charge in the area of 100nC.Compared to the VESC mine is optimised for eBike use:- lower cost- smaller firmware, more educational- easier to fix/repair- plugs for throttle, halls, pedal sensor, brake- regenerative braking- Bluetooth- android app for setting max speed, wheel diameter etc- website to upload your trips- power output for normal bike light- TO 220 MOSFETs - better to cool and easier to replace - more continuous power- atmega 328 easy to programAre you sure?. I am quite interested in buying a ready made one. If i am to turn my bike into a ebike i would really prefer to use a libre hardware, libre software product.Hmm. I see your buying parts from digkey and the alike.
Ive been following a project that has been quite educational for me. Apparently i believe i remember these shops buy up old components and when you go to china you can’t necessary buy the same components. Wheres by using common china components, products can be made a lot cheaper and the maker has a much easier time sourcing the components.if of interest, that project was the posts on the mailing list: and the updates from the crowdfunding, had some nice written up experiences i think:Are you sure?. You just got it reversed. In China you get old components and what worked last month doesn't work next month any more.
Components are often a lot cheaper but also often counterfeited. I had a batch made last year by a company that does smart prototyping and I got fake LM2576HV.
Instead of being capable to do 60V, they blew at 40V taking all other components on the board down with them. A waste of time to figure out what was going on and almost $1000 for the boards.If you buy from digikey you get reliably top quality directly from the manufacturers - no grey market stuff.Are you sure?.
Now that's a good point, although I don't think it's necessary. I'm not sure what 'sense' means in the 4-pin layouts, usually with 3 pin, the 'control' is the fan speed. The motherboard reads out the temp and tells the pin to go up in RPM or down in RPM depending on the need for heat dispersion.I wired up some regular 3-pins in a cabinet one time for an HTPC and they had the molex connector adapter. I liked going through the molex adapter because I could change out the fans if they died/quit working without having to desolder anything or clip and resolder. Now that's a good point, although I don't think it's necessary. I'm not sure what 'sense' means in the 4-pin layouts, usually with 3 pin, the 'control' is the fan speed.
The motherboard reads out the temp and tells the pin to go up in RPM or down in RPM depending on the need for heat dispersion.I wired up some regular 3-pins in a cabinet one time for an HTPC and they had the molex connector adapter. I liked going through the molex adapter because I could change out the fans if they died/quit working without having to desolder anything or clip and resolder.Thanks again. It's funny that I'm having such a hard time finding the answer to this question.
Answers given on other internet sites to similar questions by other posters were conflicted.I would use the molex connector, but these fans are going into a telescope that doesn't use those connectors. Soldering is just part of the deal.While trying to figure this out for myself, I touched the yellow wire to the red terminal on my 12v battery and the black wire to the black.
What I got was a momentary spin-up of the fan that then stopped. I don't know if the weak connection formed by just touching the wires lightly to the terminals causes the temporary spin of the fan, or whether the green or blue wires need some kind of DC voltage for the fan to work.While I was experimenting with touching different wires to the red terminal on the battery I fried a $15 fan. I ordered another, but I would like to avoid more costly experimentation. Now that's a good point, although I don't think it's necessary. I'm not sure what 'sense' means in the 4-pin layouts, usually with 3 pin, the 'control' is the fan speed. The motherboard reads out the temp and tells the pin to go up in RPM or down in RPM depending on the need for heat dispersion.I wired up some regular 3-pins in a cabinet one time for an HTPC and they had the molex connector adapter. I liked going through the molex adapter because I could change out the fans if they died/quit working without having to desolder anything or clip and resolder.Thanks again.
It's funny that I'm having such a hard time finding the answer to this question. Answers given on other internet sites to similar questions by other posters were conflicted.I would use the molex connector, but these fans are going into a telescope that doesn't use those connectors. Soldering is just part of the deal.While trying to figure this out for myself, I touched the yellow wire to the red terminal on my 12v battery and the black wire to the black. What I got was a momentary spin-up of the fan that then stopped. I don't know if the weak connection formed by just touching the wires lightly to the terminals causes the temporary spin of the fan, or whether the green or blue wires need some kind of DC voltage for the fan to work.While I was experimenting with touching different wires to the red terminal on the battery I fried a $15 fan. I ordered another, but I would like to avoid more costly experimentation.
The reason that is, is because you're sending 12v to some controllers on the fan that weren't intended to handle 12v.This is kind of something I was referring to when I said 'adapter'That way you could simply unplug and swap the fan for another one if it ever had a ballbearing develop a flat spot and start squealing or clicking or if it ever went out completely.edit: you'd simply clip the smaller black/red wires a ways back from the plug and solder/join those to the 12v lead making it easy to change out the fan if necessaryAh, thanks for the picture of the adaptor. That, indeed, would make future changeouts easier. Definitely a consideration assuming my fans will work as we expect them to with just the two leads connected.Thanks again for all your help! Hi all, I found this post that has been useful to me!
Hi I just wired a 4 pin fan, the yellow is possitive and the black is neggative so ignore blue and greenI would use the molex connector, but these fans are going into a telescope that doesn't use those connectors. Soldering is just part of the deal.While trying to figure this out for myself, I touched the yellow wire to the red terminal on my 12v battery and the black wire to the black. What I got was a momentary spin-up of the fan that then stopped. I don't know if the weak connection formed by just touching the wires lightly to the terminals causes the temporary spin of the fan, or whether the green or blue wires need some kind of DC voltage for the fan to work.While I was experimenting with touching different wires to the red terminal on the battery I fried a $15 fan. I ordered another, but I would like to avoid more costly experimentation./quotemsg. Hi I just wired a 4 pin fan, the yellow is possitive and the black is neggative so ignore blue and greenWhat power source did you use in your setup? I am attempting to power the standard Intel heat sink 4 pin fan with an external power supply I picked up at micro center, but am not having any luck.
I connected the yellow (positive) and black (ground) wires to my power supply, plugged it in, and the fan attempts to start or 'stutters' forward, but then stops. If you wait a second, it will stutter forward again, and then stop.My power supply Output is 12V DC 1A, and the fan requirements on the label read DC 12V 0.28A.Everything I've read on the internet says to just 'ignore the green and blue wires' so I think either my power supply is insufficient or somehow I need to feed a signal to the PWM (blue) wire.
Hello, rockethead26. 4 pin fans use Pulse Width Modulation to regulate speed - the PWM pin. Accepted voltages are TTL standarts - so, max voltage is a bit above 5V - hence your busted $15 fan.
If you wanna make your fan work you'll need a 5V source and connect it to the PWM pin (100% speed). Usually you can get it from the 4 pin molex connector (don't know which color - search it.I must say I have not tested it yet but I found your question researching on the subject for installing a 4 pin fan on my RAID server. Here's a good documentation:Check page 10. Also, if you want, search for Pulse Width Modulation on the web - it's the same method used in Digital Amplifiers for audio.Hope I could help!
Sammycoup, that color system is NOT common, so the colors alone may not help. But IF it has a standard 4-pin female fan connector on the end of those wires, we can figure it out.
A 'standard' connector has on one side of it two ridges just outside the first and third pins, with the fourth pin beyond the one ridge. When this is plugged into a male mobo fan header, that header has a plastic 'tongue' sticking up beside Pins 1-3, and those ridges must fit outside the tongue. That way you can only plug the fan in one way.Now, look again at the connector. The hole on the fan connector at one end that is OUTSIDE the ridges is Pin #4. Pin #1 starts at the other end, just inside one of the ridges.
Ignoring the colors for a moment, the pins (hole) have these functions:Pin # 1 Ground (normally Black)Pin # 2 +12 VDC fixed voltage on a 4-pin fan system (normally Yellow, sometimes Red)Pin # 3 Speed pulse signals from motor to mobo (normally Green, sometimes Yellow)Pin # 4 (outside the ridges) PWM signal (normally Blue).