5 Lines of Code to spin BLDC?!? On Youtube.

Joined
Mar 31, 2013
Messages
52
Hello All,

The link below is a Youtube video by Linas K, where he demonstrates '5 Lines of Code' to spin a BLDC motor. :shock:
All he basically needed was an STM32 and an encoder.
Would appreciate any ideas or info on a complete sample code+lookup table.
If it is really that simple, it would be a great teaching tool in schools, not just ES. Thanks! :D

https://www.youtube.com/watch?v=_GL5JGfQk8o
 
Looks like he just sets the pwm duty cycles (phase voltages) from lookup tables indexed by the position read from the encoder. It's normal that it spins the motor but it's not a fine method. There is no phase current control or current limit and the efficiency is not optimal. Some cheap and obsolete non-FOC sine wave controllers may work similarly, but with hall sensors instead of an encoder and extrapolating the position from the hall sensor signals to obtain the virtually high position resolution.
The "5 lines of code" is a "bit" of exaggeration, like the "how to make your PCB in 2 minutes" videos on youtube. Setting up everything properly is 100 times of that.
 
Yes, you might be able to use 5 lines of code to just spin a motor, but if you look at the numerous abandoned threads about designing a motor controller before they even got to spin it, much less the ones that actually got one working before they gave up, or even the few you'll see the often-huge challenges involved in creating a controller, even just in the software, but sometimes especially in the hardware.

If it's intended for high power, it is even harder.



Some of the threads that finished stuff are open-source, so you can peruse the actual code. Some started with existing hardware, which both simplifies the process (cuz you know the hardware can work), and complicates it (because you're limited to it's features), like the KT / kunteng OSFW threads, the TSDZ2, etc. Some, like the Lebowski, are primarily just the brain board and software, leaving much of the powerstage design up to the user (though there are some hefty threads about those). Etc.
 
Dude, for real? Lines of code are meaningless unless this is machine language. You could just use one line Motor.spin(forward);

See???
 
Back
Top