VNH2SP30 - How to generally use it?


I bought a VNH2SP30 Stepper motor driver and I am struggling to run my stepper motor with this driver. Which are the pins for my stepper?

Thank you in advance

Have you bought this:

Are you here because you want to unlock the power of FOC or do you want the easier/openloop solution :wink:

Hey @Marco,

Have you been able to use 2xVNH2SP30 to run a stepper mtoor?

I am not sure it the class StepperDriver4PWM will be able to control this board.
What you can try is connect the INA and INB of each phase as PWMxA and PWMxB and then adding the PMW pin as enable pin. For example:

StepperDriver4PWM driver = StepperDriver4PWM(IN1A,IN1B, IN2A, IN2B, PWM1, PWM2).

And then in code you can just set pins EN1 and EN2 in HIGH.

But this might not work, if it doesn’t please let me know and I will make a new class implementation (I’ll try to do it anyway) with 2PWM pins and 4 direction pins.
Something like:

StepperDriver2PWM driver = StepperDriver2PWM(PWM1, IN1A,IN1B, PWM2, IN2A, IN2B, EN1, EN2).

I see now that it has a pwm frequency limit at 20 kHz, also a thing to think about.
Which MCU are you using?

Hey @Marco,

I’ve implemented the 2PWM version of the stepper driver it is currently in the dev branch:

Basically the code is:

StepperDriver2PWM driver = StepperDriver2PWM(PWM1, IN1A,IN1B, PWM2, IN2A, IN2B, EN1, EN2).

All the rest of the code will be the same as for the other stepper driver.

You have a standalone example in the utils folder for quick testing.
Let me know how it goes!

@Owen_Williams I want to unleash the power of FOC :smiley: But I am kind of struggling with some basics so I am focussing on really understanding everything.

@Antun_Skuric I didn’t figure out how yet, because my new driver DM860 arrived for the big stepper. I also didn’t really had time to keep going with my project. Tomorrow I’ll try your example.
Thank you very much in advance for your help and the example! :slight_smile:

@Antun_Skuric @Owen_Williams
Hello, I do have some further questions and I don’t want to spam your forum with new topics so I am posting it here - I hope that is okay.

There are some general questions which I have:

  1. For a long time I thought, that I can control the speed of a stepper with the frequency of the pwm signal. But I think now I understood, that the rpm of the stepper doesn’t vary with the pwm frequency. I can control the speed with the duty cycles. Is that right?

  2. In general I almost control everything just with the duty cycles. Referring to your code you only have to calculate Ualpha and Ubeta (the two voltages for the coils) and then you have to calculate the duty cycles to apply these voltages in RMS. By doing so you also set the current RMS because: current RMS = voltage RMS / coil resistance. And this is also the way you control the torque - because the current in the coils produces the magnetic field from the stator. Did I miss something? Have I understood something wrong?

@Antun_Skuric @Owen_Williams Hello?

The frequency of PWM has no bearing on speed. The library tends to set it quite high so that is above the audible range.

Do you have a sensor attached to your motor?

Are you interested in angle control or velocity control?

@Owen_Williams Thank you for your reply and sorry for my late answer. It was a long time ago I visited the forum.

I have a potentiometer connected to the motorshaft as seen in the picture

I am interested interested in torque control. The nema 34 is currently to strong, even if I set the lowest current with my driver (DM860).

Your current solution doesn’t use SimpleFOC, right?

I get the impression you are not sure where to start. Perhaps you should experiment with the L298N to begin with. It should be able to drive this nema but isn’t that powerful / can get hot. Antun has done a fair bit on describing how this $3 board can control a stepper so it might provide a learning path to using your motor with your VNH2SP30 driver.

@Owen_Williams No I am currently not using SimpleFOC. Like I already said I am still struggling with some basics. I’ll get to it but it takes some time to really understand everything.

I think the idea beginning with a L298N is great… Maybe I wanted too much too fast.

Thank you, that you are always replying and helping me! :slight_smile: