Since warm seasons are slowly approaching, it was time for me to free my bicycle from dust and oil it's chain And, as you can see its mechanical drive system still works without a problem. But for an electronics enthusiast like me, it is kind of boring… That is why I ordered an E – bike conversion kit for around 200 euros ($246.95 US), which is not a bad deal if you compare the price to commercial E – Bikes.
But anyway, once I received the kit, I unpacked all the delivered goods and found the front wheel with integrated hub motor, a throttle, brakes, and electric speed controller, and a couple of complementary components So, I simply removed my old front wheel, as well as my front disc brake, and secured the new electric front wheel in place. The whole process barely took around 10 minutes. Next, I wanted to test the new wheel at home, and thus connected the three motor wires… Along with the motor sensor connector, and the throttle connector to the electric speed controller, according to how the manual describes it. Then, I connected the battery connector to my lab bench power supply, which was set to its maximum voltage of 30 volts and… By powering up the system, and turning the throttle control, the motor tried to start spinning, but never succeeded.
The problem is that the 30 volts are, apparently, not high enough voltage for the electric speed controller. …which is something that bothered me quite a lot. So in this video we will create our own sensored electric speed controller, …which does work with low voltages and, thus allows me to test my new electric front wheel extensively. Let's get started! [Intro + Music] This video is sponsored by JLCPCB. One fact about them: JLCPCB produces 200,000 square meters (656,000 feet) of single, double, or multiple layer PCBs monthly.
Upload your Gerber files to order ten professional PCBs for only $2.00! To create a suitable sensored ESC, let's firstly have a closer look at the hub motor. After removing its metal cover, we can see that it consists of a dozen of coils on the inside, that do not move when the wheel is rotating Simplified, the coil arrangement would look something like this: with the wires A, B, and C being leads through the outside.
The rotating parts of the hub motor on the other hands, consist of neodymium magnets with alternating polarity… …which according to how current flows through the coil arrangement aligned in a certain way due to the magnetic forces. that means what we're dealing here with is a so-called BLDC motor, aka a brushless direct current motor. I already talked about how you can make them rotate by creating your own ECE in a previous project so definitely have a look at that if you want to know more about the theory of those motors as as a reminder though We simply must connect each phase of the motor to either the supply voltage or ground in a very specific order Which repeats continuously it too creates the rotational movements But does that mean we could simply hook up an ordinary ESC to the bike wheel and powered like that? Well as you can see it does kind of work But definitely not optimal since such bike wheels are supposed to rotate much slower than traditional BLDC motors That is why it got those three Hall effect sensors attached to the motor By connecting their red wire to five volts and that black wire to ground We can hook the output of each of them up to the oscilloscope and see that whenever a magnet comes close to them They pull their outputs up to 5 volts This way we got 3-year phase shift to square waves that tell us where the rotor is located now we can use this information to determine when the next step should be initialized and Just like that we no longer need to back electromotive force of the floating face which was proportional to the rotation speeds and thus only possible at high speeds and with the motor control theory out of the way, let's start creating our own censored ESC as As you can see I use P channel and N channel MOSFETs with an appropriate driver for each To connect the three motor phases either to the supply voltage or ground But since the p-channel MOSFETs turn on at zero volts and turn off at 5 volts Which is the exact opposite of the N-Channel MOSFET behavior I simply added a hex may trigger inverter to the control lines of the p-channel MOSFETs So that the programming for the Arduino will be easier later on The last mandatory component was a potentiometer to set the rotation speeds and three inputs for the Hall effect sensors and With those guidelines in mind I started creating a schematic for the project which in the end turned out to look something like this so I gathered all the required components and started soldering them to a piece of perfboard and afterwards to one another according to the schematic and if you're interested in experimenting with your own sensor BLDC motor Then you can of course find the schematic, code, pictures and more information about this project as always in the video description after four hours of soldering the circuit was finally complete and after inserting the ICs all that was left to do was the programming Now while the codes which, I created looks pretty intimidating it is quite easy to understand if you are familiar with external interrupts pin change interrupts the free run mode of the ADC Timers and port manipulation, so have a closer look at my other videos and learn all about it if you're interested Anyway, what the codes basically does is firstly waiting for state change of one of the Hall effect sensors? If one happens the Arduino determines, which step needs to be activated Then timer one says okay, let's activate the corresponding MOSFETs of the step But after a certain amount of time which is determined by the potentiometer Timer one then says let's connect all phases to one another and take a quick break before we power the phases once again This creates a PWM signal which basically lowers the average voltage and thus lowers the current Which lowers the magnetic forces and thus the rotation speed This process continues until there's an another Hall effect sensor state change, which then activates the next step So in theory the code should work fine which means it was time to upload it connect the motor wires as well as the Hall effect sensor wires to the boards and Power it all up and as you can see the wheel starts rotating and the speeds can be adjusted by the potentiometer But as expected the wheel rotates rather slowly with a 15 volt supply voltage but it is still a lot of fun to play around with I hope you enjoyed watching this video and are looking forward to the next episode of the electric bike conversion project As always don't forget to Like share and subscribe Stay creative, and I will see you next time