Arduino Stir Plate (digital speed control)

Homebrew Talk - Beer, Wine, Mead, & Cider Brewing Discussion Forum

Help Support Homebrew Talk - Beer, Wine, Mead, & Cider Brewing Discussion Forum:

This site may earn a commission from merchant affiliate links, including eBay, Amazon, and others.
Joined
Jul 24, 2006
Messages
14,260
Reaction score
786
Location
Southwest
I haven't made one, and I'm not sure if I will since I already have a nice stir plate, but I wrote and tested the code today with an LED (sheer boredom), and I have sourced all the parts, so I thought I'd share.

You'll need:
Arduino board ($35)
PWM driver (kit - $12)
12VDC muffin fan (lots of sources - $5)
9-12VDC (500mA min) power supply (electronics store - $5)
10k ohm linear taper potentiometer (electronics store - $1)
2 strong magnets (old hard drive, eBay, science surplus - $1)
An enclosure (cigar box, plastic tub, cardboard box, etc - practically free)
Wire + soldering skills
Glue (epoxy)
USB cable
Computer

Parts total: $69-ish (much cheaper if you have parts laying around or if you elect to use an Arduino kit board instead of the pre-assembled one linked above)

Code:
/*
  Arduino Stir Plate
  Uses PWM to control motor speed
  This is much more efficient and motor friendly than resistive speed controls
  It may also allow slower motor speeds to be achieved
  30 May 08 - Yuri_Rage - www.homebrewtalk.com
*/

int driverPin = 9;  // PWM driver connected to digital pin 9
int potPin = 0;     // potentiometer connected to analog pin 0
int oldValue = 0;   // store an old analog value
int newValue = 0;   // store a new analog value for comparison
float divisor;      // divide analog input by this value
float castFloat;    // for type conversion

/*
   NOTE: Increase minValue to keep the motor from stalling and give higher fidelity adjustment.
         The min value is 0 and will give full range adjustment (including off).
         The max value is 254 and will result in full speed regardless of adjustment.
         A minValue between 20 and 100 should be adequate.
*/
int minValue = 0;  // minimum PWM value - read above

void setup() 
{ 
  divisor = 1024.0 / (255.0 - (float)minValue);  // analog inputs are 10 bit while PWM are 8 bit, so we need some division
  //Serial.begin(9600);                          //uncomment for debugging
} 
 
void loop() 
{ 
  castFloat = (float)analogRead(potPin) / divisor + (float)minValue;  // use the divisor already calculated, then add the min value
  newValue = (int)castFloat;
  if (pow((newValue - oldValue), 2) > 1) { // only change state if the PWM value has changed by more than 1 (simple noise reduction)
    analogWrite(driverPin, newValue);      // make the new PWM value active
    oldValue = newValue;                   // store the new state
    //Serial.print("PWM value: ");         // uncomment for debugging
    //Serial.println(newValue);            // uncomment for debugging
  }
  delay(10);                               // wait a little - no need to run full tilt
}

Sorry, no schematic, but it's pretty simple. You'll wire the potentiometer to analog pin 0 on the Arduino. One of the PWM driver's inputs gets wired to digital pin 9. The fan is powered by the driver board output. The DC source can power both the driver board and the Arduino. I can take a picture of the breadboarded circuit with the LED if anyone is interested.
 
Yeah, I know. But I got another Arduino board for a new project, and I wanted to test it out. This was a simple way to do it.

The cool thing about PWM is that it's very efficient for things like stir plate control. Because it pulses full power in short, rapid bursts, slower motor speeds MIGHT be possible (in comparison to the LM317 circuits or simple potentiometer controls).
 
Well that's certainly one way to do it (and believe me, I'm a microcontroller fan), but you can build a PWM controller with a 555 timer for like <$10. On the one I built, the whole PCB is 1" x 3", and there's about 15-20 components.

PWM definitely does let you get down to nice low motor speeds. The problem you face there is that the motor can sustain movement at that speed, but it can't start up, so you need to kind of jump-start it, which normally involves cranking the speed up higher to start it spinning, and then dropping it back down. On my board, a couple passive components do it automatically by giving it a high duty cycle for a couple seconds on power-up, but you could do the same thing in firmware on your design.
 
Well that's certainly one way to do it (and believe me, I'm a microcontroller fan), but you can build a PWM controller with a 555 timer for like <$10. On the one I built, the whole PCB is 1" x 3", and there's about 15-20 components.
Oops, I meant to mention 555 based circuits as a means of keeping cost down in my original post. I know this particular design is a little bit of overkill. In fact, it's almost a waste of a perfectly good microcontroller board and multi-output driver to use them for something so simple. On the other hand, it would make a great microcontroller intro project.

However, if you've seen my other projects, you know that overkill should probably be my middle name...
 
Actually, I found the RepRap site by looking for thermocouple circuits and PWM examples for Arduino. However, I quickly became fascinated by the RepRap project. I'm not building one, but I may look into it at some point.
 
Resurrect... Yuri, do you think this would work with a pro mini or a lilypad board? That way you can keep costs close to a 555 build and still mess around with arduino.
 
Isn't this overkill? For $70 you can go out and buy a lab stir plate, that warms too! I know winter is long, but...
 
Isn't this overkill? For $70 you can go out and buy a lab stir plate, that warms too! I know winter is long, but...

resepctfully sir, you miss the point of DIY.

Most of the projects I build do NOT save me much, indeed some I'm sure I spent more than retail.

But I had fun tinkering, and learning.
 
resepctfully sir, you miss the point of DIY.

Most of the projects I build do NOT save me much, indeed some I'm sure I spent more than retail.

But I had fun tinkering, and learning.

Ya, you big bully. Jk I'm trying to learn arduino for both work and brewing reasons and this looks like a quick exercise in microcontroller work. At work I'm trying to use an arduino to replace 10 PID circuits in a CEMS and for brewing I'd like to replace a huge control panel with a much smaller arduino control board circuit. Then I can design specific control schemes with times for each brew day and just flash my atmega day of and let my rig ride.
 
resepctfully sir, you miss the point of DIY.

Most of the projects I build do NOT save me much, indeed some I'm sure I spent more than retail.

But I had fun tinkering, and learning.

Don't get me wrong, I love DIY and understand it's about the journey and not necessarily the destination. But there is DIY and then there is reinventing the wheel....

Also, a sort of an aside, but people run to microcontrollers far too often when either discrete components or *gasp* analog *gasp* circuitry are more beneficial to both the pocketbook and to the knowledge locker.
 
Did anyone ever build this? I have an Arduino laying around, and most of the other parts for it. I'm also looking for a project to get into microcontrollers and hobby electronics in general. I have a ham radio license so I've done a few small projects before. My only concern is as mentioned above, if it's not easily adjustable it may be difficult to get the fan to START at a slow speed. I"m guessing the pot is so that this circuit can be adjusted on the fly?

I was also told that by using a processor fan with a PWM control wire it may be possible to get away without using the driver circuit?

Any help would be greatly appreciated, I love electronics but admit I'm not very knowledgeable in the subject.

Edit:

Ok I read through the code a few more times and I think i at least have some idea of what's going on with the pot.
 
I noticed no one has posted here in a while. I'm currently working on building a brewtrroller based on Arduino, but this project also came to mind. As far as cost goes, you can get an Arduino clone from China for less than $4 shipped now!
 
Back
Top