Skip to content

solving servo jittering when combine with i2c devices #1572

Closed Answered by ABOSTM
muhammadhusni777 asked this question in Q&A
Discussion options

You must be logged in to vote

Hi @muhammadhusni777 ,
I guess you face real time issue, linked to preemption of servo by I2C:
Servo library is based on HardwareTimer, and it uses Interrupts to change servo pin state.
The interrupt priority of HardwareTimer (and of Servo) is by default defined to:
#define TIM_IRQ_PRIO 3
In parallel, you have your I2C component for which interrupt priority is by default defined to:
#define I2C_IRQ_PRIO 2

Lowest value means higher priority, so I2C has higher priority and will preempt servo. And if I2C traffic is too intensive (or too long, ...) it could impact/delay servo pin state change and thus induce jittering.

So you can try either to:

  • invert priorities by redefining TIM_IRQ_PRIO an…

Replies: 1 comment

Comment options

You must be logged in to vote
0 replies
Answer selected by ABOSTM
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants