I’m currently developing a PCB to drive NEMA23 steppers with integrated encoders. Looking to make something that’s affordable but can drive fairly big motors. I’ve been looking at a lot of different drivers and microcontrollers and think I have settled on DRV8873 drivers with an RP2040.
For the motors, I was thinking about the 2 x VNH7070AS but they can only handle PWM up to 20KHz so now leaning towards the 2 x DRV8873 as don’t what audible noise. It has a lower current output but still enough for what I need and up to 100KHz PWM.
On the microcontroller side, thinking about an RP2040 as they’re super cheap, rock solid and I should be able to do 30KHz PWM with 12 bit resolution.
Anyone have any opinions about this setup, especially the VNH7070AS vs DRV8873? Thanks!
@runger Ah, interesting. Back to the drawing board. Guess I could use an ESP32 or maybe an external ADC chip.
Is current sensing used at all in angle control mode?
Also, the datasheet for the DRV8873 says…
A current mirror allows the controller to monitor the load current. This mirror approximates the current through the high-side FETs, and does not require a high-power resistor for sensing the current.
…so assuming it wouldn’t work with SimpleFOC anyway as it’s high side current sensing? Maybe the VNH7070AS is the way to go after all as looks like it’s inline
It can be - the current sensing is used at the lowest level, to control the FOC loop, and works in combination with the higher level control for velocity or angle in the move loop…
I think maybe the benefits of the DRV chip outweigh the current sensing thing. You can always add external inline sensing if you want it.
Or you can add the high side sensing to SimpleFOC, that’s a matter of software. I didn’t check the details of the current sensing implementation in the DRV8873, I should take a look.
Thanks for the feedback @runger! I went with the DRV8873 in the end. Just got the PCB back and running the example code below which sets the PWM frequency to 20KHz. When I attach a scope though (yellow is RP2040, blue is DRV8873 output), it looks like the frequency is 1KHz, is that correct?
There are also some little glitches on the input and output so guessing need to add more decoupling caps.
Thanks! Not quite working yet, still need to revise it to remove electrical noise. I’m using PlatformIO, sketch in previous post and the below plaformio.ini
Seems like it might be using generic_mcu.cpp. Will have a dig around later and see if there is a define wrong somewhere.
; PlatformIO Project Configuration File
;
; Build options: build flags, source filter
; Upload options: custom upload port, speed and extra flags
; Library options: dependencies, extra library storages
; Advanced options: extra scripting
;
; Please visit documentation for the other options and examples
; https://docs.platformio.org/page/projectconf.html
[env:waveshare_rp2040_zero]
platform = https://github.com/maxgerhardt/platform-raspberrypi.git
board = waveshare_rp2040_zero
framework = arduino
monitor_speed = 115200
board_build.core = earlephilhower
lib_deps =
askuric/Simple FOC@^2.3.4
Thanks, that works! Guess “weak” was getting hidden.
The driver output has a back EMF spike which makes sense. Will this be OK for SimpleFOC? I’m not sure as a motor control newb. I have the slew rate set to the max for the DRV8873, 53.2V/μs. I could slow the it down but thought having the most responsive made sense based on some other posts here.
At the moment the motor is not moving and wondering if could be related to this
MOT: Failed to notice movement
MOT: Init FOC failed.
Yes, in this state the motor is disabled. What kind of sensor are you using? This message means either the sensor is not working or the motor driver isn’t working… does the motor move a bit during initialization?
I’m using an optical encoder. The encoder and open loop code worked OK (although open loop was louder than I’m used to with SimpleFOC). The motor I’m using is 5A and 0.42R per phase stepper so calculated the max voltage should be 2.1V. If I set that in any of the closed loop examples though, it didn’t work. However, the torque_control example does work if I set…
motor.voltage_sensor_align = 3;
If I set the supply voltage to 8 and run the torque example, it doesn’t start moving until the target is 6V and at 6V, it’s a lot quieter with bench supply showing less than 0.2A. Looking through the motor data sheet, the “time mean between failures" is measured at 24V and the torque curve is measured at 48V so a lot higher than the max voltage I calculated. Should this size stepper work OK with SimpleFOC? Is there a better way than trial and error to choose voltage variables?
There’s nothing on my PCB for current sensing at the moment but I could add that if it might make this type of motor work better.