0

I'm planning a project that will involve multiple serial ports and the Arduino servo library. I have heard that this may cause interrupt conflicts. Are there any simple solutions to this

migrated from electronics.stackexchange.com Nov 7 '18 at 8:42

This question came from our site for electronics and electrical engineering professionals, students, and enthusiasts.

2

I have heard that this may cause interrupt conflicts.

Indeed. The Arduino can only run one interrupt routine at a time, and:

  • Servos use rapidly firing interrupts
  • SoftwareSerial both turns off interrupts while sending (for relatively long periods)
  • SoftwareSerial uses an interrupt for receiving that runs for an extended period

So really you can't use both together.

Options?

  1. Use hardware PWM to drive the servos (There is a library for this somewhere)
  2. Use an external servo PWM driving board (Adafruit do one IIRC)
  3. Don't use SoftwareSerial. IIRC AltSoftSerial is better, though no software serial implementation will ever be particularly good.

The underlying problem is that the low-end Arduinos only have on serial port. If you need to use more than one serial port then you really need to be looking at using a different Arduino - one with multiple serial ports.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy