Encoder, motor, actuator - too much for Arduino Uno?

Hello,

I am very new to Arduino and inherited a project with functioning automation and coding. The device has a stepper motor and linear actuator, with A4988 and LNH5019 drivers. The actuator provides feedback to the Arduino.

I wanted to add a control system to ensure the stepper motor positioning was accurate, so I did so by adding an CUI AMT222 encoder on the motor shaft.

I tested the feedback control with an Arduino and it works perfectly. But now I want to add the linear actuator and other driver into the system, and I'm starting to think it's just too much for the Arduino.

Before I added the encoder, the digital pins 3, 5, 6, 7, 8, 9, 10, 12, and 13 were already in use, as well as A0. From my very surface-level understanding, I think the PWM pins can't be used the same way as the other pins. Both the encoder and actuator provide feedback, which I think has something to do with pins 10-13. So compiling the code and hardware won't be as simple as using the "leftover" pins, I'm guessing?

Should I just get a really big breadboard? An Arduino MEGA? Or a second Arduino and figure out a way for them to interact?

Any guidance will be useful! Thank you in advance!!

kmfweldon:
I tested the feedback control with an Arduino and it works perfectly. But now I want to add the linear actuator and other driver into the system, and I'm starting to think it's just too much for the Arduino.

Hogwash. It may be too much for your ability to code the Arduino. But that is a piece of cake for the Arduino with good code.

From my very surface-level understanding, I think the PWM pins can't be used the same way as the other pins

Then you've misunderstood something. All the pins, are usable as regular digital pins. Some have extra functions like analog inputs and pwm, but they all work like normal digital pins if you want to use them that way.

Both the encoder and actuator provide feedback, which I think has something to do with pins 10-13.

You "think it has something to do with"? Then your first step needs to be to find out for sure. You can't be doing development on things that you already don't understand. Does it use SPI? That's what normally takes up 10 - 13 at once like that.

So compiling the code and hardware won't be as simple as using the "leftover" pins, I'm guessing?

Maybe, maybe not. I still don't know every much about this project.

Should I just get a really big breadboard?

Do you need more room for more components?

An Arduino MEGA? Or a second Arduino and figure out a way for them to interact?

That certainly doesn't sound necessary for what you've described.

Any guidance will be useful!

Of course the obligatory "Read the How to use this forum post" and post your code (in a code window) and a schematic and links to any components. It's on you to get us up to speed on what you've got and how you've put it together.

Delta_G - Thanks for the quick response, and sorry for the ambiguity!

The encoder uses SPI, and the actuator is currently using pins 10, 12, and 13. The original code doesn’t indicate any use of SPI.

I’m attaching both the code I made for the encoder testing, as well as the original code (which has a button that I neglected to mention). A basic overview of this device: a linear actuator packs powder into a tube (until fully packed to a certain pressure). Once packed, a button is hit and stops the process. A second button is then manually pressed to spin a motor and align the next tube for packing, then a third button is pressed to restart the process.

The “encoder_testing.txt” file is messy now, but it works. I will implement function calls later.

encoder_testing.txt (11.4 KB)

original_code.txt (4.57 KB)

The encoder uses SPI, and the actuator is currently using pins 10, 12, and 13. The original code doesn't indicate any use of SPI.

Ok, so the next obvious question is, why is the actuator using those pins and could it use different pins. It certainly can't use those pins for anything other than SPI if the encoder needs SPI.

Do you have a functional diagram?

Is your code too large to post properly (more than 9000 characters)? If not, posting the code as described in the how to use this forum-please read stickies will allow many more members to see it. See #7. And #11 has some good advice on how to get the most from the forum.

If this was my project I would be very reluctant to use an encoder to monitor a stepper motor. If the proper stepper motor is chosen it won't miss steps. All the low end 3D printers use stepper motors without any encoders and they work for hours on end without missing a step.

Connecting all your parts to an Arduino should not present a problem but reading an encoder in real time can put a heavy computational load on a 16MHz Arduino especially if there are a lot of encoder pulses per revolution and the shaft is rotating quickly. You don't want a situation where the stepper motor works perfectly but the Arduino misses an encoder pulse and thinks it is the fault of the stepper motor. Debugging that sort of problem would require a lot of coffee.

...R