Skip to content

Conversation

zjor
Copy link
Contributor

@zjor zjor commented Feb 10, 2021

Hi,
I managed to make this stepper driver (https://wiki.dfrobot.com/MD1.3_2A_Dual_Motor_Controller_SKU_DRI0002) work with the following snippet
https://gist.github.com/zjor/a49b417d9904ab6dff6d3a2262b3fcff

See the demo on the video: https://www.youtube.com/watch?v=em70gQPN5b0

But when I tried motor.move(3) with velocity open loop, the movement was jerky, it didn't rotate properly.
Also I had to add _delay(1); to setPwm(..) which is also wrong.

digitalWrite(dir2, Ualpha > 0 ? HIGH : LOW);
digitalWrite(dir1, Ubeta > 0 ? HIGH : LOW);

_delay(1);
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this is bad, I know, but otherwise, the movement was not smooth

@askuric askuric merged commit b501d6d into simplefoc:dev Feb 11, 2021
@askuric
Copy link
Member

askuric commented Feb 11, 2021

Hey @zjor ,
I could not commit to your branch so I just merged your code directly to the dev branch.
At the end I deleted the new class that you created, just because it is basically the same as the one we already have StepperDriver2PWM so I just created a new constructor which takes the same arguments that you described in your code.
StepperDriver2PWM(int pwm1, int dir1, int pwm2, int dir2, int en1, int en2)

Now regarding _delay(1) :D
I have removed it because even if it is needed this is not the place to do it. You should probably do it in the Arduino loop function.

Could you please check if the new code works for you?

And I'd like to discuss the reasons why you need this _delay(1) in your code in the community thread:
https://community.simplefoc.com/t/stepper-motor-setup/519/3

I have some ideas why and maybe we can avoid it :D

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants