support for simpleFOC library (brushless motors)
-
@o_lampe A little teaser and always fun to watch is the 5-bar SCARA with brushless motors using simpleFOC
If we had a 3-phase-3Amp-closed loop toolboard that speaks RRF, it would be awesome... -
@o_lampe I have been wondering if a Sammy boards firmware could be customised via the library to drive a SimpleFOC driver board. Another thing on my list that's nowhere near the top at the moment.
I was going to just create a step and direction deployment of simpleFOC and hook it up as an external driver in the short term.
Definitely something I'd like to see pulled into the duet ecosystem in the future...
All the best
Barry M -
@CNCModeller The older simpleFOC is just an arduino-shield. They could have integrated an mcu on the shield to have a standalone driver. Same goes to the bigger discrete driver version you've linked.
That's almost yelling for direct control by a RRF toolboard to skip the middleman.
Downside would be the higher pincount and required PWM registers, so we will probably not see a 3-phase mainboard with 5 or 6 drivers soon. -
@CNCModeller said in support for simpleFOC library (brushless motors):
I have been wondering if a Sammy boards firmware could be customised via the library to drive a SimpleFOC driver board.
I guess not soon, since the lib doesn't support SAM-mcu's AFAIK. (SAM D21/51 supported)
But the 1HCL toolboard might have the right mcu already? -
@o_lampe what about flipping it the other way, could the Sammy firmware be compiled to an Arduino compatible board with can FD so the SimpleFOC library could be integrated, such as a Teensy 4?
-
@CNCModeller I'm no software expert. From afar everything looks easy.
Question is: does it all fit together?
PID control loops for the encoder are probably differerent or some registers for PWM are occupied by RRF stuff.
Merging two big chunks of software is difficult.They say it works best on STM32 boards (*). They produce the fastest control loop, but SAMD21 is another good candidate.
Time to figure out what's different between the SAM-C21 and the D21...
*) maybe we can interest @gloomyandy and his team to make a Mellow-version?
-
FYI
I just searched forklipper simpleFOC
and there seems to be a lot of people interested in klipper supporting BLDC motors.
There is one klipper fork for open loop BLDC support, but it uses a different driver than simpleFOC.
But no official FW so far. -
What does Odrive use for their brushless motor control? I believe looking at the docs for them and Duet, they are going to be supporting Odrive
-
I guess, we will not see simpleFOC integrated in Duet3d, but I want to mention that we can also drive stepper motors with these drivers.
In open loop it can run with velocity control. A feature frequently asked on this board is infinite rotation which would be possible with sFOC.
It's also possible to communicate via serial interface to set the target velocity on the fly.
It would require post-processed gcode, though. -
@o_lampe we're doing something similar to FOC in RRF 3.5 on the Expansion 1HCL board. This type of motor control is computation-intensive unless the speeds are low, so it's best done using a dedicated or semi-dedicated processor, such as we have on the 1HCL board.
In the future we may make a board similar to the 1HCL but with bridge outputs and sensor inputs for 3-phase BLDC motors. It wouldn't be difficult to run SimpleFOC or something similar on a 1HCL board modified to provide the required hardware.
Using a BLDC motor to control an axis of a 3D printer or CNC machine requires a reduction gearbox, and to counteract backlash in the gearbox you need a second encoder. All of this usually makes it less attractive than using a stepper motor, unless the machine is very large; in which case an integrated AC servo such as Clearpath is probably more appropriate.
-
@dc42 I would also add current sensing, since that is the only way to have low power consumption, but still good starting torque.
I've played around with simpleFOC and small BLDC motors. Their torque can't compare to same size stepper motors, but the FOC algorhythm makes them run really smooth.
I will still build a screw-extruder with both motor types (hollow shaft is mandatory) and report in the appropriate thread. -
New proposal
Over at the simpleFOC forum, I started a discussion about using dual-core features of the Cortex M0 MCU ( and other dual core MCUs)
Since they don't use it yet, it is obvious, why they disencouraged me to implement their sFOC algorithm in a toolboard. There is just too much else going on to keep the FOC-loop running smooth.But if we could keep the FOC-stuff on the second core, there is plenty of headroom for CAN and temp-control a.s.o.
Does RRF use both cores on their M0-toolboards?
-
@o_lampe said in support for simpleFOC library (brushless motors):
I don't think any of the current Duet3D toolboards use a multi core mpu. Some of the 3rd party boards (like the ones from Mellow/Fly) use the rp2040 mcu (which is dual core), but on those boards the 2nd mcu is already used to handle the CAN-FD interface.
-
@gloomyandy The CAN-FD traffic is so high-demanding? What a pity...
The SAMMY-C21 MCU is dual core. Maybe they're using the second core for CAN-FD too, but IIRC it is HW-implemented...
-
@o_lampe said in support for simpleFOC library (brushless motors):
The SAMMY-C21 MCU is dual core.
Are you sure? I don't see anything that says it is dual core?
-
@gloomyandy Maybe I'm wrong? I was under the impression, all Cortex M0+ MCUs are dual core...