Automating a Centrifuge

The Revolutionary Science RS-102 is an inexpensive centrifuge. A rotary switch that selects between 4 modes: off, pulse, 6,000 RPM, and 10,000 RPM. The pulse mode will runs 10,000 RPM as long as the switch is held in that position.

Materials

Tools

Steps

  1. Remove the screws on the bottom of the centrifuge. Remove the bottom plate.

  2. Use a flat screw driver to pry off the front knob. Underneath are two screws. Remove them.

  3. Extract the circuit board from inside the centrifuge. (Don't cut any wires.)

  4. Explore the circuit board. Let's number the switch terminals 1 to 4 in clockwise order when looking at the front of the switch. Terminal 2 receives a rectified 120V AC input voltage. Terminal 3 is connected to the input when 6,000 RPM is selected. Terminals 1 and 4 are connected to the input when 10,000 RPM is selected.

  5. Solder two wires to terminal 2, one wire to terminal 3, and one wire to terminal 4.

  6. Connect a Grove relay two the wires connecting terminals 2 and 3. Connect the relay to pin 2 on your Arduino.

  7. Connect another relay two the wires connecting terminals 2 and 4. Connect the relay to pin 4 on the Arduino.

  8. Upload the code below to the Arduino. Use the serial console to send slow, fast, and stop commands.

Arduino Code

// A simple centrifuge control sketch.
// For more info visit: http://www.modularscience.com/app/doc/autoCentrifuge
// Use the serial console to send the following commands: slow, fast, stop


// pin definitions
#define SLOW_RELAY_PIN 2
#define FAST_RELAY_PIN 4


// info about the current incoming command
#define MAX_COMMAND_LEN 5
char command[ MAX_COMMAND_LEN + 1 ]; // leave room for zero terminator
int commandPos = 0;
boolean commandDone = false;


// run once on startup: set up serial and output pins
void setup() {
  Serial.begin( 9600 );
  pinMode( SLOW_RELAY_PIN, OUTPUT );
  pinMode( FAST_RELAY_PIN, OUTPUT );
  digitalWrite( SLOW_RELAY_PIN, LOW );
  digitalWrite( FAST_RELAY_PIN, LOW );
}


// run repeatedly as long as Arduino is powered
void loop() {

  // check for incoming commands (from the serial port)
  checkForCommands();

  // if a command is done, run it
  if (commandDone) {
    if (strcmp( command, "slow" ) == 0) {
      digitalWrite( SLOW_RELAY_PIN, HIGH );
      digitalWrite( FAST_RELAY_PIN, LOW );
      Serial.println( "slow" );
    } else if (strcmp( command, "fast" ) == 0) {
      digitalWrite( FAST_RELAY_PIN, HIGH );
      digitalWrite( SLOW_RELAY_PIN, LOW );
      Serial.println( "fast" );
    } else if (strcmp( command, "stop" ) == 0) {
      digitalWrite( SLOW_RELAY_PIN, LOW );
      digitalWrite( FAST_RELAY_PIN, LOW );
      Serial.println( "stop" );
    }
    commandDone = false;
  }
}


// check for incoming commands (from the serial port)
void checkForCommands() {
  while (commandDone == false && Serial.available()) {

    // append character to command
    char c = Serial.read();
    if (c >= ' ' && commandPos < MAX_COMMAND_LEN) {
      command[ commandPos ] = c;
      commandPos++;
    }

    // handle newline/return to indicate end of command
    if (c == 10 || c == 13) {
      if (commandPos) {
        command[ commandPos ] = 0;
        commandDone = true;
      }
      commandPos = 0;
    }
  }
}