Skip to content

Instantly share code, notes, and snippets.

@100ideas
Created April 13, 2011 22:50
Show Gist options
  • Save 100ideas/918597 to your computer and use it in GitHub Desktop.
Save 100ideas/918597 to your computer and use it in GitHub Desktop.
thermocycles an IRF510 power-MOSFET in a TO-220 package for PCR; from FutureLabCamp-NYC 2011
/*
// This is a basic arduino program to control a PCR thermocycler
// made from a TO-220 IC, such as an IRF510 power-MOSFET. More
// information: http://futurelabcamp.com/2011/nyc-projects
//
// code by Marc Guell and Mac Cowell at FutureLabCamp-NYC 2011
//
// Adapted from "Blink Without Delay" by David A. Mellis
// http://www.arduino.cc/en/Tutorial/BlinkWithoutDelay
*/
//parameters
int N=5;
// linear interpolation for heating & cooling ramp rates
// established empirically with an external temperature probe
// v0.6 - old values below
// double K0=0.002;
// double K0=0.003;
// double K0=0.0028;
// double k0=0.0028
// double k1=0.002
// double k2=0.0034
double K0=0.0022;
double K1=0.0019;
double K2=0.0020;
double K3=0.0023;
double T_denat=95;
double T_anne=55;
double T_exte=72;
int number_cycles=0;
// constants won't change. Used here to
// set pin numbers:
const int heaterPin = 13; // the number of the LED pin
// Variables will change:
int heaterState = LOW;
long previousMillis = 0;
// the follow variables is a long because the time, measured in miliseconds,
// will quickly become a bigger number than can be stored in an int.
long interval = 5000;
//initial setup
void setup() {
// set the digital pin as output:
pinMode(heaterPin, OUTPUT);
fromRT_95(K0);
}
//cycling
void loop()
{
// here is where you'd put code that needs to be running all the time.
number_cycles=number_cycles+1;
if(number_cycles < N)
{
from95_55(K1);
from55_72(K2);
from72_95(K3);
}else
{
heaterState=LOW;
digitalWrite(heaterPin, heaterState);
}
}
void fromRT_95(double k0)
{
long t_ON,t_current;
heaterState = HIGH;
digitalWrite(heaterPin, heaterState);
t_ON=millis();
t_current=t_ON;
while((t_current-t_ON )*k0 < T_denat)
{
t_current=millis();
}
heaterState=LOW;
digitalWrite(heaterPin, heaterState);
}
void from95_55(double k1)
{
long t_ON,t_current;
t_ON=millis();
t_current=t_ON;
while((t_current-t_ON )*k1 < T_anne)
{
t_current=millis();
}
}
void from55_72(double k2)
{
long t_ON,t_current;
t_ON=millis();
t_current=t_ON;
heaterState=HIGH;
digitalWrite(heaterPin, heaterState);
while((t_current-t_ON )*k2 < T_exte)
{
t_current=millis();
}
heaterState=LOW;
digitalWrite(heaterPin, heaterState);
}
void from72_95(double k3)
{
long t_ON,t_current;
t_ON=millis();
t_current=t_ON;
heaterState=HIGH;
digitalWrite(heaterPin, heaterState);
while((t_current-t_ON )*k3 < T_denat)
{
t_current=millis();
}
heaterState=LOW;
digitalWrite(heaterPin, heaterState);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment