Pages: [1]   Go Down
Author Topic: Thermocouple - continuous stepper speed control  (Read 1202 times)
0 Members and 1 Guest are viewing this topic.
East Coast, USA. (PA)
Offline Offline
Newbie
*
Karma: 7
Posts: 29
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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.


Thanks!

Logged

If architects designed buildings like programmers wrote code, the first woodpecker to come along would be the end of civilization.

0
Offline Offline
Faraday Member
**
Karma: 16
Posts: 2855
ruggedcircuits.com
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

In general, 3ms is a "long" time for things like temperature computations. I'm guessing you're just going to be adding temperature readings to a running sum and taking the average?  That's very little work compared to what 3ms affords you.

See the BlinkWithoutDelay example sketch for how to make things happen at precise intervals.

Beyond that, you can dig into interrupt-based processing for even finer control. But I doubt that will be necessary for your application.

--
The Rugged Motor Driver: two H-bridges, more power than an L298, fully protected
Logged

Copenhagen, Denmark
Offline Offline
Edison Member
*
Karma: 33
Posts: 1226
Have you testrun your INO file today?
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

3ms is oooodles of time to compute temperature - which I assume is taken an analog reading or two, doing some math -multiply etc, even fancy functions, to map the analog read into a "temperature".

I suspect your worry is keeping the steps. Look at the blink-without-delay example. The same technique enable you to send steps to your motor at intervals determined by the delta to the last millis() og micros(), after having "wasted" a lot of CPU doing the calculation.

The only thing to watch out for is doing Serial output, it will block your loop, unless done in small writes.
Logged

East Coast, USA. (PA)
Offline Offline
Newbie
*
Karma: 7
Posts: 29
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Aha! I forgot about millis() entirely.

I Don't think Serial output will be used. I'll have to output to a 16x2 parallel display, though, and i'm not sure how the "mbed.h" and "TextLCD.h" libraries function so they may cause some problems.

Thanks for the suggestions!







Logged

If architects designed buildings like programmers wrote code, the first woodpecker to come along would be the end of civilization.

Pages: [1]   Go Up
Jump to: