1
\$\begingroup\$

I am debating whether it is a good idea to offload the 12 servos I plan on having in my project onto an Arduino rather than on the Raspberry Pi. I am planning on using the Adafruit 16-Channel 12-bit PWM/Servo Driver to drive the servos rather than directly, so IO pins are not an immediate limitation.

This is what I have so far as pros and cons of each:

For having an Arduino

Pros:

  • Isolated servo controller, allows Raspberry Pi to do other things while moving without needing to figure out threading
  • Utilizes USB port rather than I2C port

Cons:

  • Need to make an interface between Pi and Arduino

Against having an Arduino

Pros:

  • One system to control everything. Everything can be called in line
  • One more USB slot to do whatever

Cons:

  • May choke on data
  • Complexity of writing Python over Arduino C++

From anyone that has worked on similar issues, I would really appreciate any feedback.

\$\endgroup\$
12
  • 2
    \$\begingroup\$ If you're concerned that your data rate is problem, you might need to tell us how fast you'll need to pass data \$\endgroup\$ Commented Nov 8, 2022 at 22:46
  • \$\begingroup\$ I would put the usb connection on the “cons” side. It’s a horrid bus for real-time applications and long reliability on moving systems. My intel realsenses are the least reliable parts of my robots. \$\endgroup\$ Commented Nov 8, 2022 at 22:54
  • \$\begingroup\$ @ScottSeidman That's the thing. I am currently unsure how fast I'll need it. I plan on having a basic 4 legged walk motion, along with head neck, eyes and tail, but I don't know how much demand that is on the I2C bus. For basic walking, each servo would need to be told its position probably once a second, as the servos automatically move to where they are needed based on the adafruit board \$\endgroup\$ Commented Nov 8, 2022 at 23:31
  • \$\begingroup\$ @Bryan that is really good to know that USB is not that good of a bus for realtime. Thank you. Would you recommend trying to keep everything on one computer system then? \$\endgroup\$ Commented Nov 8, 2022 at 23:32
  • 1
    \$\begingroup\$ I don't get it. If the Pi would choke on data, why won't the Arduino then? Why is Python mentioned, you can use any language you want on a Pi, nothing forces you to use Python, you are free to use C or C++ if you want. \$\endgroup\$ Commented Nov 9, 2022 at 0:00

1 Answer 1

3
\$\begingroup\$

If you can't do it via i2c, i doubt the Arduino would solve any problems you're actually having.

Computationally, an Arduino is so many times slower than the pi that you would need to be very clever about what you do on that to even measurably reduce the load on the RPI. I don't think your motor controller could even deal with as much commands per second that the load on the RPI would even be in the single digit percentages.

The only advantage of a second processor in the system would be that you could dedicate that to low-latency emergency stop (and other safety-critical) functionality, so that you have less strict requirements on in how many milliseconds the pi must have reacted to something. Having to guarantee low latencies on an application processor costs performance, because instead of doing the computationally most efficient of not interrupting your CPU-intense tasks, you will tell your Linux that it needs to pause whatever process is currently running to service the low-latency software, no matter whether there's actually something to do our not.

But USB is a notoriously high-latency bus, and Arduino a notoriously ill-suited operating system for hard real-time requirements that your proposed architecture just won't have that advantage. It also sounded like you weren't planning to let the Arduino react to any observations it has on its own, but to just use it as long of command buffer - that has no advantages whatsoever.

Honestly, talking USB will probably be more additional CPU load than your saving by not having the RPI do a few realtime priority tasks. So, I'd say, for this round, scratch that Arduino, build it directly on the RPI. Should it later turn out that you need to offload some of the control load off the RPI, then you'll actually have some data on how much that is, what the critical latencies are, and then you can devise an architecture that solves the problem that you'll then be able to quantify. Adding an external microcontroller later is easy. Building a heterogeneous multiprocessor system that you don't actually need is hard.

\$\endgroup\$

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.