Hi all,
I am using rosserial on a teensy 4.0 and need to do a few things: control 3 stepper motors in closed loop feedback for position setting, read imu data, and maybe a control servo. What I did so far was use an IntervalTimer to create the PID loops for the stepper motors, but I am also using Paulís encoder library for counting ticks of the 3 Quadrature encoders, which I read each time in the ISRís and send out a pwm to the stepper motor controllers. I also have an interval timer for the IMU which reads data over i2c. The problem I have is in my main loop I eventually have to disable interrupts and copy the global variable data of the IMU to publish over serial as well as take commands given over serial for the pid setpoints. During this interrupt disable phase, I lose ticks and the stepper motor position control drifts off over time and becomes inaccurate. I am considering using the hardware encoder library I found someone had made for the teensy 4.0. Would this ensure no ticks are missed when I disable interrupts? Also, would I benefit by using something like the metro library for reading the imu data (at like 200hz) instead of intervaltimers ?