Servo "Ticking" (Because OneWire library disables interrupts)


I'm trying to build a small project with 3 servo motors and 5 temperature sensors of type DS18B20.

I've been able to do this, but I've had trouble reading the sensors.

When reading the sensors, the servo motor suffers interference.

I do not think it's possible to use the libraries together as they are.

It would be necessary to read the sensors during the dead time of the servo motor wave (period that is usually 18 to 19 ms).

Any suggestion?

Thank you!


I found "The Software Servo Library", maybe it will work for me, thank you.

The Software Servo Library can drive servos on all of your pins simultaneously. The API is patterned after the servo library but the code is different. You are not limited to 8 servos, but you must call the SoftwareServo::refresh() method at least once every 50ms or so to keep your servos updating.

... the Arduino Servo library supports up to 12 motors on most Arduino boards and 48 on the Arduino Mega.

Limitations: This library does not stop your interrupts, so millis() will still work and you won't lose incoming serial data, but a pulse end can be extended by the maximum length of your interrupt handles which can cause a small glitch in the servo position. If you have a large number of servos there will be a slight (1-3 degrees) position distortion in the ones with the lowest angular values.

There is also a ServoTimer2 library that (as its name suggests) uses HardwareTimer 2

I'm guessing it is better than software servo though I have never tried software servo.


Doesn't matter which timer you use for servo's, if interrupts are disabled they will get timing jitter - a software library for the servo might be the most reliably approach if you can ensure its called frequently enough.