I want to precisely control the speed of a stepper motor based on a temperature input from a thermocouple.
The thermocouple reading needs to be averaged over a period of about 2.5s, but the stepper motor must remain functioning at a precise speed while the arduino is reading the thermocouple. (The stepper controls fluid flow in a peristaltic pump, which needs to be carefully adjusted based on temperature of the fluid)
I'm not sure how to maintain the stepper output with any accuracy while also reading the temp input. Would I simply be able to do the temperature calculations in the time (as short as 3ms) between steps? And then how do I still keep the step time constant if i'm doing different calculations between different steps?
I have a pretty decent understanding of many things arduino but the clock and things of critical timing nature are still a bit confusing.