Control more BLDC

Has anyone ever encountered this error when driving a motor? When I control 2 BLDC motors using the simpleFOC library and use vs code to load, the motors emit a sound like pipiiippp,…(2 gears rotate) but when I switch to the Arduino IDE to load, the controller of one gear recognizes it. No noise, the wheel rotates (while controlling 2 wheels, the alight sensor step 1 wheel is clogged). The code I loaded is identical. I use stm32f103c8.

Do you have the option lib_archive=false in your platformio.ini file?

I don’t have it yet, what does it do?

It’s required on platformio, otherwise it won’t find the right hardware drivers. Setting it will fix the noise problem.

Thank you, I will try tomorrow, but the problem is that when I use Arduino IDE, I can only light 1 motor. Is it because the IDE compiled it? On vs code, I can light 2 motors.

Please try with the correct option.

It might be that then in platformio you will have the same problems.

While you are at it, please add the following option:

build_flags = -DSIMPLEFOC_STM32_DEBUG

and then please add to the start of your setup:

void setup(){
  Serial.begin(115200); // start serial
  SimpleFOCDebug::enable();
  delay(5000); // wait 5s for serial monitor to connect

And then please let us know the output…

Thank you, I will try it tomorrow

Today I added it to platformio and the motor didn’t make sound but it was stuck at the alight sensor part of the 2nd motor. This is the same as when I compiled on arduinoIDE it was also stuck there.

Now they are the same :slight_smile: Sorry about that, but this is now actually the correct hardware driver being used in platformio, so if there is a problem now with both setups then it is a “real” problem.

Please let us know the debug output, it should give information about the initialisation process and the pins being used.

1 Like

Thank you, I have fixed the error

1 Like

Can I use the command.scalar() function to get 2 target values ​​assigned to 2 motors because I am controlling 2 motors?

Only if you always want to set the same value to both motors :slight_smile:

If you want to be able to set different values (which I assume is the case) then you need two command.scalar() functions, with different command-letters. So instead of using ‘T’ you could use ‘L’ and ‘R’ for left and right or something similar.

1 Like

Thank you, but I want to send 2 different speed commands at the same time when pressing enter, what should I do?

I want to send two commands at the same time for example “R2, L2” and then press Enter

I have one of those 8302 controllers also. And Im usig an ESP32. I think I can connect two 8302 drivers and then I’m out of pins.

My plan is to try an RP2040 next. The advantage of the RP2040 (raspberry pi Pico) is that (1) they only cost $1 each if you buy the bare chip and (2) they are very small so I don’t care if I need on RP2040 per motor.

Also, both the ESP32 and the RP2040 are dual core chips. There are two CPUs. My plan is to run the motor with one core and run CAN Bus and maybe some utility funtions with the other core.

1 Like

Thank you I will look into them

The commander can’t do this out of the box, you’ll have to extend its functionality or write your own command parser code…

1 Like

Thank you I will try