Motorless stir plate

I'm posting this to respond to a request for the code used to create the circuit in this video

Here you go, arduinoversusevil. I never really finished the code, or took the hardware further than the video.
Kind of like solving a Rubik's cube: once I figured out how to make it work, I got bored with it and shelved it.

/*
Stirplate - controls an array of four electromagnets to spin a teflon 
 encapsulated stirbar in a flask, such as used by homebrewers to culture yeast.
 
 This is based on the basic "FADE" sketch.  Two pairs of magnets create an x and y axis.  
 The pulling force of the magnet swings back and forth from the x to the y axis, 
 the H-Bridge is used to reverse the polarity of each axis when it is at 0 force.
 
 
 This is written to run on an Atmel ATtiny84.  I would suspect it would run equally well 
 on an ATtiny85, but I am not familiar with the process to designate the RESET pin
 to work as an I/O, or the process to refuse should I want to reprogram the chip afterwards.
 
 The information in this thread: http://arduino.cc/forum/index.php/topic,87517.0.html 
 may be useful for anyone who chooses to try this on at ATtiny85.  If you do, please let 
 me know how it comes out.  chuck.falls@gmail.com 
 
 
 
 Software:
 You will need to gather and install all of the support files and libraries as detailed on this page:  http://hlt.media.mit.edu/?p=1695
 
 Hardware:
 (4) electromagnets (Mine are model: ZYE1-P20/15)
 (1) ATmel ATtiny84
 (1) SN754410 
 (1) LM7805 (and filter capacitors of your choosing)
 (1) Switched potentiometer, or a switch and a potentiomter.
 (3) 10uf decoupling capacitors - VCC on the ATtiny84 (pin 1), VCC1 and VCC2 on the SN754410 (pins 8 & 16)
 
 
 */

int xaxis = 6;        //connect to the pin 1 on the SN754410  
int yaxis = 5;        //connect to the pin 9 on the SN754410  
int logicA1 = 8;        //connect to the pin 7 on the SN754410  
int logicA2 = 7;        //connect to the pin 2 on the SN754410  
int logicB1 = 3;        //connect to the pin 10 on the SN754410  
int logicB2 = 4;        //connect to the pin 15 on the SN754410  


int potPin = 0;
int force = 0;    
int fadeAmount = 51;    //3, 5, 15, 17, 51, & 85 should all be acceptable
int delaytime = 1000;
int state = 0;

//
void setup()  { 
  pinMode(xaxis, OUTPUT);
  pinMode(yaxis, OUTPUT);
  pinMode(logicA1, OUTPUT);
  pinMode(logicA2, OUTPUT);  
  pinMode(logicB1, OUTPUT);  
  pinMode(logicB2, OUTPUT);
  pinMode(potPin, INPUT);



  /*this section just turns the magnets on and holds a position for 5 seconds.  This is necessary as there is no magnet upon which to 
  center the stirbar until after the "motor" is turned on and is already spinning.*/
  digitalWrite(logicA1,HIGH);
  digitalWrite(logicA2,LOW);
  digitalWrite(logicB1,HIGH);
  digitalWrite(logicB2,LOW);
  digitalWrite(xaxis, HIGH);    
  digitalWrite(yaxis, HIGH);
  delay(500);



} 


void loop()  { 

  analogWrite(xaxis, force);    
  analogWrite(yaxis, 255-force);    

if (millis()<(20*1000)) delay((20000/millis())+14);
else delay(14);

  // change the force for next time through the loop:
  force = force + fadeAmount;


  if (force == 0 || force == 255)   // if the magnet is aligned withe the x-axis or y-axis
  {
    switchState(); //four states direct the polarity of the magnets
    fadeAmount = -fadeAmount ; //swings the "on" magnet from the y-axis to the x-axis, and then back.
  }
}  



void switchState()
{
  if (state==3) state=0; 
  else state+=1;

  if (state==0)
  {
    digitalWrite(logicA1,HIGH);
    digitalWrite(logicA2,LOW);
  }
  if (state==1)
  {
    digitalWrite(logicB1,LOW);
    digitalWrite(logicB2,HIGH);
  }

  if (state==2)
  {

    digitalWrite(logicA1,LOW);
    digitalWrite(logicA2,HIGH);

  }
  if (state==3)
  {
    digitalWrite(logicB1,HIGH);
    digitalWrite(logicB2,LOW);
  }
}

Nice !!!

Very nice work! But it really isn't "motorless" , you just created a motor in the apparatus.
Does the propeller have a shaft or is it held in place by the magnetic field?

Nice!

Especially since magnetic stirrers are not cheap (every kitchen should have one! I have a couple myself)

The motors (and bearings) are a vulnerable spot on them, and there seems to be a move towards motor-less stirrers (especially in the high end models).

I have considered treating the problem as a stepper motor (reusing a stepper motor without rotor), but has not had the time to do any practical experiments yet.

Yankee:
Very nice work! But it really isn't "motorless" , you just created a motor in the apparatus.

Fair enough. I just called it that to differentiate it from the usual approach used by homebrewers: gluing a salvaged hard drive magnet to a salvaged computer case fan.

Yankee:
Does the propeller have a shaft or is it held in place by the magnetic field?

No shaft, just the field.

A bit old post, but if someone is interested, I'll share my experiences. I built a version of this stirrer myself for beer yeast propagation and use it constantly. My main motivation was to get a cheap, silent and carefree stirrer. I used exactly the same parts with the following modifications:

I used ATtiny85 with success. It is possible without losing the RESET pin. You just need to pull the SN754410 enable pins high with a 10kohm resistor. To control the magnetic field strength, use PWM for 1A and 3A. To control the field direction, simply pull 2A and 4A high or low. However, with this setup you must also invert the PWM signal if you flip the magnetic field direction. ATtiny85 has 5 normal I/O pins and one remains for the speed controlling potentiometer.

The default ATtiny85 PWM frequency is in audible range (490hz) and electromagnets create some annoying electrical noise. I increased the frequency to 32khz with the following instructions:

I also used "theoretically" correct algorithm for rotating the magnetic field (with cosine and sine for X and Y components). Compared to fading, this makes the code simpler and might increase some stability.

However, there are some still some issues left to solve:

Heating. These electromagnets use a quite a bit of power and SN754410 quickly overheats. It doesn't fry but it shuts itself down after a while. Issue solved with a DIP heat sink.

The electromagnets get pretty hot as well. I mounted them on top of a aluminium GPU heat sink but they still get very hot (60-70C). As a result, my liquid in one liter erlenmeyer flask heats up to 31C on top of the plastic stirrer case. I might try some thin styrofoam inside the case but what I gain in heat isolation, I lose in magnetic field strength and stability.

Of course I could use a heating fan but that would be a bit pointless, wouldn't it? I could as well mount magnets on top the fan and use that. I won't give up on this: I accept no moving parts.

Stability. I can run it stable up to 800 RPM for 48 hours. In comparison, commercial lab stirrers can reach 1500 or even 2000 RPM. This lower speed is acceptable for my purposes though.

Some easy ideas for enhancement:

  • Very simple RC-filter to convert PWM to linear voltage for the magnets. Might increase magnetic field stability:
    http://www.instructables.com/id/Analog-Output-Convert-PWM-to-Voltage/
  • RPM display. This is would be very easy to implement. Unfortunately, I have no pins left at the Attiny85
  • Heat fuse just in case these cheap chinese parts overheat and melt down my plastic case when I'm not at home
  • Copper heat sink for better thermal conductivity and less magnetic field interference
  • Cheap hall sensor to detect if stir bar flies out the field and automatic recovery.

And mandatory picture:

Hello,
I know I am kinda necromancing this thread, but I would like to share my experience with the topic:

First, I really like your design for the motorless stirrer. I have recently built one myself, but with slight modifications. I used a dual chanel half bridge to drive to pairs of electromagnets. I used microstepping by PWMing the enable pins on the H-bridge, so that each pair of coils would get a sine wave of current (phase shifted by 90 °). The RPMare adjusted via a potentiometer.

However, I had real trouble to reach a nice stable rotation of the stir bar. I found i extremely hard to adjust the RPM by turning a potentiometer ever so slightly, and at best I was able to reach 600 RPM. However, at most times I didnt manage to get a nice rotation at all and the bar would just jitter.

Have you experienced any difficulties of that sort? And if yes, would you be so kind to share your wisdom?