⬆️ ⬇️

We drive beskollektorny engines, gentlemen

Hello Habrovchane!

I decided to tell "the whole world" about the problem I encountered when building my project, and how I managed to solve it.



And today we will talk about brushless motors, stroke controllers and how to control them.

What is a brushless motor, I will not paint for a long time (you can see the Wiki yourself), but in 2 words, this is a 3-phase DC motor.



And this miracle is set in motion thanks to a special regulator, which sequentially switches the windings with a certain frequency.

By controlling the switching frequency of the windings we control the speed of rotation of the rotor.

Well, I hope everything is understood here, we go further.



First problems

Were purchased 2 sets of engine + regulator, waited about a month, came.

image

')

I was seized by an attack of unbridled fun about this, but, unfortunately, it was not for long ...

Having considered these wonders of technology, I decided to connect them to a power source, and then the first disappointment, quiet clap (as from short-circuits) and silence, the LEDs are off, there is no squeak (and it should be), only the cooler on the regulator turns, the trouble is ...

He ran to the nearest Hobby store, and the kind consultant delivered a verdict: burned out!



With the second the same story, in general, guys, no luck, both defective ...

Well, at least the cat was glad:



image



I had to fork out and buy a regulator from them for the price of both sets (deadlines were pressed).

I bought it, hooked it up, everything squeaks, it burns, it works, it’s right that the soul is happy! (it is highlighted in the photo):



image



Problem number two

Now it's time to turn the engine.

And you need to twist not with a servo tester or a radio control unit, but with a microcontroller, or rather with such a handkerchief:

image



Shoveling tons of sites, rereading hundreds of forums and answers to my question, so how do I manage to manage this regulator only one thing: "... man and there is a simple PWM ...", "... PWM to help you ...".

Well PWM, so PWM.

I wrote a simple program:

#include <Servo.h> Servo motor; int mot_pin = 7; //     7 int js_position = 800; int max_position = 3000; void setup() { motor_teft.attach(mot_pin, js_position, max_position); //  } void loop() { motor.write(1800); //      } 




Filled, zero emotion ...



He fought for 2 days, until he came across a random post, that the controller has protection, and it starts functioning only when a 1.5 ms signal is applied to its PWM input.

Okay, that will be done.



Then I picked up an ordinary resistor through the ADC, and empirically picked up the extreme values ​​of the PWM controller.

The resulting code is:



 #include <Servo.h> Servo motor_teft; Servo motor_right; int mot_pin_left = 7; //     7 int mot_pin_right = 8; //     8 int js_position = 1500; // ,  1.5      int max_position = 2300; //   2.3  int min_position = 800; //   0.8  int start = 1; //   void setup() { motor_teft.attach(mot_pin_left, js_position, max_position); //   (,  ,  ) !!! motor_right.attach(mot_pin_right, js_position, max_position); //   (,  ,  ) !!! } void loop() { //      if(start == 1) { motor_teft.write(js_position); motor_right.write(js_position); delay(700); start = 0; } js_position = analogRead(A0); //   js_position = map(js_position, 0, 1023, 75, 140); //      motor_left.write(js_position); //        motor_right.write(js_position); //        delay(20); //  20  } 




And it all worked.

Now everything is spinning, noise, beeps and just happy.

PS This is the code to control 2 engines at once.



And the last problem, food ...

Here I will tell you a little, namely, 3 wires go from the regulator:

image



The central block, in order Black - minus, Red - plus and White - control wire .



And the snag is that, unlike servos, these are not power inputs, but outputs, i.e. eat from them.

Why am I doing this, besides the fact that having connected the controller as a servo, I almost burned the ports on the laptop, because at that time the board was powered by USB.

But fortunately, my old man's protection worked and everything worked for a restart ...



Video of work:





Thank you very much for your attention.

I hope my experience will be useful for you.

See you soon.

Source: https://habr.com/ru/post/219723/



All Articles