Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unable to get 3 and 4 controllers working #25

Closed
frdfsnlght opened this issue Sep 15, 2018 · 5 comments
Closed

Unable to get 3 and 4 controllers working #25

frdfsnlght opened this issue Sep 15, 2018 · 5 comments

Comments

@frdfsnlght
Copy link

I'm trying to get multiple controllers moving motors at the same time. I have no problems until I get to the 3rd controller, then the Teensy hangs. In fact, any time I try to use the 3rd controller, even synchronously, it hangs. I've attached a sample project that illustrates what I'm trying to do (had to use a txt extension for upload).

I'm using a Teensy 3.2.

Teensy-Stepper.txt

@luni64
Copy link
Owner

luni64 commented Sep 16, 2018

I did a quick test with a T3.2 (not connecting motors, just looking at the output) and it works nicely. Nothing hangs, Motors stop as expected some 10s after the start.

Please note: I fixed a bug a couple of weeks ago related to problems with more than 2 controllers (issue 22). Are you sure that you are using the current version?

If you are already using the current version, can you please describe the problem in more detail?


Few comments on your code (not related to the issue)

image

  • Not necessary to set the pin mode of the step and DIR pins, this is handled by the library.

  • You only use one DIR output for all motors. This will usually not work! In your example all motors move in the same direction so it doesn't harm. As soon as one motor needs to move in the opposite direction you'll get a mess.

  • There seems to be a bug in your setup():
    image
    You probably meant to set the maxSpeed for all motors but you only set it for mot0. The others stay at their default value.

I like your clear and nicely writen code very much! Just one thing which somehow "hurts my heart": I never understood why people stick with those unnecessary and ugly #defines. c++ has "constexpr" which is a much better, typesafe replacement for defines.

image

@frdfsnlght
Copy link
Author

Library version was the problem. I was using 0.97 and you had changed some things in 0.98. I didn't realize you had updated. It works as expected now. Thank you very much!

And thanks for the code review!

  • I took out the lines for setting pin directions for the motor as you noted.
  • I'm intentionally using the same pin for direction for all the steppers. My project will only ever drive all the motors in the same direction at the same time, so no problem.
  • I fixed the bug you found. Thanks.
  • I'll start using "constexpr" in my projects. I wasn't aware of it. I don't write much C++ these days.

I've attached the latest code for posterity.

And a little background: I'm using your library to drive 16 steppers from a single Teensy 3.2. I only need to drive 4 independently and simultaneously except when I need to drive all 16 synchronously. Your library is perfect for this. This is part of a Barbot I'm building. Each motor drives a 3D printed pump for a single ingredient. The Teensy is but a small, but very important part of this project. There's also an Arduino Pro Mini and a Raspberry Pi with 7" touchscreen. I hope to have it finished by Christmas when I'll need it to survive all the holiday "cheer" and family functions.

Teensy-Stepper.txt

@luni64
Copy link
Owner

luni64 commented Sep 16, 2018

Sounds like a great project, I'd love to put a video of that barbot in the TeensyStep readme. Just drop me a note if you have something and want me to put it in an "examples section"

@conkerts
Copy link

conkerts commented Sep 16, 2018

Hi, I seem to have weird behavior with 3 and 4 controller objects as well.
I just recently cloned the repo (when I wrote my first question here), and I checked I have the version=0.98 .

Basically I've got 4 Motor objects and 4 controllers (and each controller moveAsync a motor, so pretty straight forward). It first works for some commands, then I get weird motor movements, even I send commands to a completely different controller & motor. After reset of the Teensy it works again for some commands ...
(Teensy 3.5 btw , with all current Arduino versions)

Should I post my details here, or create a new, separate issue ?
And how can I debug this issue most effectively ? .

@luni64
Copy link
Owner

luni64 commented Sep 17, 2018

@conkerts: please open a new issue. Would be good to copy a minimal sketch into the issue showing the problem.

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

No branches or pull requests

3 participants