0

motor shield v2.3: wrong RPM, irregular motion
Moderators: adafruit_support_bill, adafruit

Please be positive and constructive with your questions and comments.

Re: motor shield v2.3: wrong RPM, irregular motion

by curtwelch on Wed Jul 04, 2018 9:36 am

I don't know what Adafruit intends to do, but there is a problem with "fixing" the code using my changes. It breaks backward compatibility with people that used the "broken" version but made their project work anyway by picking whatever value worked to make the stepper move at the speed they wanted. After making their project work with the broken driver, if they ever tried to update to the new driver, their code would no longer spin their stepper at the same rate. So Adafruit would need to decide if they want to break backward compatibility by fixing the code or just leaving it "broken" and keeping backward compatibility. Or something more complex such as supporting a new version that maintains the old code for backward compatibility and adds new code that works correctly.

I doubt this bug is a big issue for them. There probably just aren't that many people using this function of the library or if they do use it, the actual speed of the stepper is not critical so people don't notice the problem. But if you need it to work for your project, there's my code you use to make it work -- or just copy what I did into your own version of the code, etc.

I don't know if Adafruit fully understands how broken their code actually is. They may just think it's a slight timing error instead of the massive random number generator for RPM values their code actually is because of this obscure little bug.

curtwelch
 
Posts: 7
Joined: Wed Apr 12, 2017 11:01 pm

Re: motor shield v2.3: wrong RPM, irregular motion

by naginar on Tue Jul 10, 2018 4:59 pm

Thanks for your help Curt!

I had used this code for the small stepper that came with Adafruit's Motor Party add on pack for Arduino and it gave 5rpm as expected. I was wondering if that had something to do with unipolar vs bipolar steppers when I saw NEMA 17 giving 20rpm instead of 5rpm.

However, before making any changes to the motor shield library I tried using AccelStepper-master library's constant speed example and I am getting better results.

Any inputs about using the update that Curt is suggesting vs using AccelStepper-master library instead?

naginar
 
Posts: 10
Joined: Tue Apr 03, 2018 6:54 pm

Re: motor shield v2.3: wrong RPM, irregular motion

by adafruit_support_bill on Wed Jul 11, 2018 6:18 pm

Backwards compatibility is a concern here, since there are multiple published projects based on the library in its current state. I will review the proposed changes and discuss it with the team.

adafruit_support_bill
 
Posts: 69997
Joined: Sat Feb 07, 2009 10:11 am

Re: motor shield v2.3: wrong RPM, irregular motion

by curtwelch on Thu Jul 12, 2018 9:38 am

adafruit_support_bill wrote:Backwards compatibility is a concern here, since there are multiple published projects based on the library in its current state. I will review the proposed changes and discuss it with the team.


Keep in mind that your published version of the code doesn't just have a small bug that you're run into under odd. conditions. It's TOTALLY broken.

See the first post in this thread for what your code does:

RPM set | RPM measured
1 | 33.2
2 | 46.5
5 | 20.3
10 | 17.1
20 | 15.6
50 | 30.6
100 | 44.3

The speed your code runs the stepper has nothing to to do with the RPM set. If you change the RPM setting, the speed changes, but lowering the rpm is just as likely to raise the speed as to lower it, etc. Your code . does make the stepper spin, but has no ability to control the RPM.

I personally know of two makers, that tested your card for a project they wanted to build with steppers, couldn't make it work (probably because of this bug), and changed their projects to use Pololu stepper driver cards instead. I can imagine your card has gotten a bad rep as a stepper driver because of this bug and you have lost a lot of potential sales because of it. Code like this that you are well known for providing is a huge positive sales feature of your products. But when you positive sales feature has a bug so serious it doesn't work at all, I think it stops being a sales feature and turns into a sales destroyer.

This bug only exists in the part of your code that is used to drive a single stepper. If any project needs more than one stepper at the same time, they need to use the asynchronous interface, and that does NOT have the bug. But I would suspect that that anyone that tests your card for use in their project, they are very likely going to try the simple synchronous code first, run into this serious bug, assume it's a hardware compatibility problem instead of a software bug in your old and assumed "tested" code, give up trying to figure out what they were doing "wrong", and throw the card away and try a different vendor.

If I were running your business, I'd fix (and document) the serious bug and not worry about backward compatibility in this case.

Just my 2 cents.

curtwelch
 
Posts: 7
Joined: Wed Apr 12, 2017 11:01 pm

Please be positive and constructive with your questions and comments.