Control a BLDC motor, Hall sensor with SimpleFOC PowerShield v0.2


I came across this project after several unsuccessful searches. I am looking to make a small electric car for children that I can control remotely.

I have an arduino to control: an electric scooter wheel (24V) with hall sensor for the propulsion and a NEMA 23 (4 wires) for the steering.

For my prototype I used amazon drivers and I would like to make an electronic board (I have some basics) which would combine the arduino and the two drivers.

I did a lot of research and this project seems pretty good to me, especially with the Arduino SimpleFOC PowerShield v0.2. However I am not sure I fully understand the library available to control a motor with hall sensor or the one to control a stepper. In fact what I would like to do, is to control my wheel with PWM while avoiding the big acceleration at the start for the peaks of currents. And I would like to turn the stepper and know its position to have a good direction. But again, I’m not sure I fully understand the codes. I am thinking of using the Arduino SimpleFOC PowerShield v0.2 for the stepper also as there will be weight the stepper will have to force and therefore consume more and I am afraid that the simple board will burn out.

How can I be sure that the stepper is in the desired position? How can you be sure that it hasn’t been blocked? And I would also like it to retain the starting 0 at each start to return to the center alone if I let go of the joystick (nothing complicated if I understood the code: /).

And I couldn’t find if there was a way to brake the engine. I guess you have to turn it the other way around but it will heat up the transitor more than normal, right?

In addition, I noticed that the power supply for the hall sensors is 3.3V and on my board it is 5V I don’t think that’s a problem but just to be sure I ask you.

What I would like to do first is to be sure that with a card for my wheel and one for my stepper I could control the system via a joystick. The idea is that I use the diagrams to design my board by adding the arduino directly on it to make a kind of motherboard for the project. With only the connectors for the motors and the joystick.

My only problem today is that I can’t quite understand the code to be sure that I can get started and order both cards for my tests.

So I wanted to know if you could help me with this project, by helping me with the code. Thank you in advance for your help

And just in case I can speak French and English.

My advice is that you carry out a minimum project that allows you to obtain the basic knowledge of how to use the library before carrying out your “big project”

To adapt logic levels, if needed, you can use level shifters

Regards :slight_smile:

Hi ! Thank you for your answer !

This is not my first big project, I already have several projects under my belt. It’s just the librairie that I don’t quite understand. Actually I already realize a V1 of the idea. My problem is that it is with Amazon boards and I would have liked to have done it with something more secure.

In fact my real problem is just understanding how the code works with the Hall sensor. According to my research it is with interrupts.

For 3.3V or 5V it’s a general question it’s only the power supply I can connect to the arduino since my mass is common. And as I plan to redo a card for the whole thing, it’s not very serious.

Regarding the stepper it is also just understanding the code. Because I can already run mine with a TB6600 but I would like to do more like knowing its position ect … And I wanted to know if there were people who had already done that.

I know that I cannot have the stepper and the BLDC connected to 1 single driver but the arduino will be able to handle both drivers.

My real question around SimpleFOC PowerShield v0.2 is simply to know if there are libraries already made to achieve this or if someone has done a similar project that could help me.

Regards :slight_smile:

1 Like

If the Hall’s want 3.3V, you can’t just power them with 5V. Adapting the voltage is not difficult, there are regulators for the supply voltage, and level shifters for the logic signals.

It should be possible, but Arduino is not a very fast MCU, so your performance might be limited… A faster MCU (like a Raspberry Pico) would be able to do it quite easily.

Yes, with interrupts. There are examples in the “examples” directory of the library.

To sense the position of the stepper, you could use an encoder or a magnetic sensor. Or, if you don’t expect any skipping of steps, you can just count the steps.

Hi ! Thank you for response ! I have not received notification of your message. Sorry to respond so late.

Ok thank you but there is no project library in python it seems to me? Or can I run the code on the RPI? I’ve never touched that too much. Only small projects.

Yep I found it. I don’t understand how I can put my PWM to the motor that keeps me going.

Okay, my stepper doesn’t have a hall sensor and I don’t want to add any more so I think I’ll be counting the steps. But without a hall sensor, there is no way to know if the stepper has reached this position.

Regards and thanks for the infos :slight_smile:


Raspberry Pico (RP2040) is a MCU as many other and can be programmed using C/C++ or MicroPhython. You can use it to run Arduino applications like SimpleFOC

Hi ! Thank you for response !

I didn’t know I could flash the MCU from a raspbery pi to use arduino on it. Thanks I would try that but I think for the moment I will not worry about the speed of execution. I even prefer it to be slow. For more security.

Regards and thanks for the infos :slight_smile: