You are on page 1of 10

1/26/2018 Print Page - Gas Chromatograph

Arduino Forum
Community => Exhibition / Gallery => Topic started by: Harristotle on Apr 28, 2013, 06:13 pm

Title: Gas Chromatograph


Post by: Harristotle on Apr 28, 2013, 06:13 pm

Hi to all.
I would like to present you with my gas chromatograph machine.
It uses a 9mm borosilicate glass pipe filled with silica gel to separate and identify halogenated alkanes,
like dichloromethane and refrigeration gas.
This glass pipe or "column" is placed in an "oven" controlled by an arduino. The oven consists of the
physical copper jacket, a power mosfet to switch a 2.5 ohm (when cold) coil of nichrome wire, and a lm35
temperature sensor.
Sample is fed to the column by injecting 0.1-0.3ml of gas containing the substance of interest into some
silicone tubing attached to an aquarium pump and to the column.
One of dem fancy arduino witchcraft thingies controls the oven, with a PID controller, and senses the
intense blue light made when the column output is fed into a gas flame containing a loop of copper.
(Copper gives a beautiful blue flame with halogenated alkanes - quite different to the green you get from
a copper salt in a flame).
Output is collected from the serial monitor, and cut and pasted into an OpenOffice spreadsheet (MS Excel
would be just as good too, but I haven't tried it) for graphing.

A picture of the setup is shown below:

http://www.screencast.com/t/waz6AdEPccsD

And a circuit diagram can be seen here:

http://www.screencast.com/t/pwdLbebEmC

Code will follow, due to post size limits.

Do enjoy!
Harristotle

Title: Re: Gas Chromatograph


Post by: Harristotle on Apr 28, 2013, 06:15 pm

And here is the code

Code: [Select]
#include <LiquidCrystal.h> // library for AC1602 type 16x2 lcd display

#include <FlexiTimer2.h> // timer library

#include <PID_v1.h> // proportional integral/derivative library for heater

#include <EEPROM.h> // used to store last column temperature

/* Arduino halogenated hydrocarbon Gas Chromatograph


*/
const char version[]="0.2";

/* by Leon Harris

GC performs the following simple functions:

http://forum.arduino.cc/index.php?PHPSESSID=dvo9p5d8a8b4mt7825upuabvi4&action=printpage;topic=163305.0 1/10
1/26/2018 Print Page - Gas Chromatograph

1) Displays welcome message


2) reads default set temperature
3) prompts user to enter set temperature
4) warms column to required temperature then
5) waits for "inject button" to be pushed, then
6) Start timing, and report ldr value, temperature and time
7) Write out value to serial port
8) Reports conditions to lcd

parts
ldr: infinity to 30k
lm35 sensor for column temperature
push button to detect start
red led for running indicator
green led for ready indicator
lcd 2 line Hitachi HD44780 type

Pin Assignments

Analog
A0 column temperature sensor lm35
A1 LDR detector
A2 up/down push buttons; up to 27k, down to 10k pulldown 10k
this gives ADC down = 512 counts, up = 276 counts,
both simultaneously = 592 counts. Use +/-5% in logic

Digital
D2 Run/Stop button
D3 Ready LED (Red)
D4 Busy LED (Green)

D5 lcd DB7, pin 14 of lcd


D6 lcd DB6, pin 13 of lcd
D7 LCD DB5, pin 12 of lcd
D8 LCD DB4, pin 11 of lcd

D10 PWM drive for mosfet heater controller

D11 Enable, pin 6 of lcd


D12 Register Select, pin 4 of lcd

*/

//Globals -> I have the programming equivalent of poor hygiene with my globals:TODO clean up

const int buttonPin = 2; //use an interupt on pin 2 for start button


const int readyLED = 3; // digital pin the heartbeat led is on
const int busyLED = 4; // digital pin the BUSY LED is on
const int columnTempSensor = A0; // front LM35 column sensor
const int detectorLDR = A1; // ldr for detecting green flame
const int setButtons = A2; // ldr for detecting green flame
const int mosfetDrive = 10; // drive pin for heater

volatile int flashpin =1;


volatile int serviceInterrupt = 0;
double temperature;

double epromTemperature; // holds the temperature read from the eprom


int epromaddy=0; // just writes to address 0. Uses var in case I upgrade to a better save record like a struct (ie for
multi-temp runs)

double settemperature;
double input,output; // needed for pid for column heater

int photoDetector;
int runFlag = 1;
unsigned long time;
unsigned long startTime;
int serInLen = 25; // used for Gobetwino
char serInString[25]; // used for Gobetwino

LiquidCrystal lcd(12, 11, 8, 7, 6, 5);


PID myPID(&temperature, &output, &settemperature,2.5,0.2,0, DIRECT); // Kp,Ki,Kd values generated from autotune sketch run
previously
/*

http://forum.arduino.cc/index.php?PHPSESSID=dvo9p5d8a8b4mt7825upuabvi4&action=printpage;topic=163305.0 2/10
1/26/2018 Print Page - Gas Chromatograph

10 Mosfet pwm drive pin for heater


*/

enum stat {
INITIALISING,
WAITING,
RUNNING,
BUSY
};
stat Status;

float getTemp ()
{

float tempTemp;
int aRead=0;
int span=5;
// Temperature is so noisy, this damps it down
for (int i=1; i< span; i++) {
aRead = aRead + analogRead(columnTempSensor);
}

//tempTemp=(5.0 * aRead *100) /1024;


tempTemp=(aRead* 0.4882812) /5;
return (tempTemp); //convert voltage to temperature

void controlTemp() {
// runs PID controller to keep temperature constant

}
int readLDR () {
int numReadings=10;
int rawLight=0;
for (int i=0; i<numReadings; i++) {
rawLight=rawLight + analogRead(detectorLDR);
}
rawLight=rawLight/numReadings;
return (rawLight);
}

void changeStatus()
{
Status=RUNNING;
runFlag=1;
}

// Prints data to console, incsv, where it can be picked up by mouse and fed into excel

void logData( long unsigned value1, int value2, float value3 )


{

Serial.print(value1);
Serial.print(",");
Serial.print(value2);
Serial.print(",");
Serial.println(value3);
// readSerialString(serInString,1000);
// There ought to be a check here for a non 0 return value indicating an error and some error handeling
}

//read a string from the serial and store it in an array


//you must supply the array variable - return if timeOut ms passes before the sting is read
void readSerialString (char *strArray,long timeOut)
{
long startTime=millis();
int i;

while (!Serial.available()) {
if (millis()-startTime >= timeOut) {
return;
}
}
while (Serial.available() && i < serInLen) {
strArray[i] = Serial.read();
i++;

http://forum.arduino.cc/index.php?PHPSESSID=dvo9p5d8a8b4mt7825upuabvi4&action=printpage;topic=163305.0 3/10
1/26/2018 Print Page - Gas Chromatograph
}
}

void flashWaitStatus ()
{
digitalWrite(readyLED, flashpin);
digitalWrite(busyLED,0);
flashpin = !flashpin;
}

void flashBusyStatus ()
{
digitalWrite(readyLED, flashpin);
digitalWrite(busyLED, flashpin);
flashpin = !flashpin;
}

void flashRunStatus ()
{

digitalWrite(busyLED, flashpin);
digitalWrite(readyLED, 0);
flashpin = !flashpin;
serviceInterrupt=1;

void servicePID() {
temperature=double(getTemp());
myPID.Compute();
analogWrite(mosfetDrive, output);
}

void setup()
{

// Set initial welcome message


lcd.begin(16, 2);
// Print Banner
lcd.print("G Chromatograph");
lcd.setCursor(0, 1);
lcd.print("by L Harris V");
lcd.print(version);

delay(2000);
lcd.clear();

Status = INITIALISING;
pinMode(readyLED, OUTPUT);
pinMode(busyLED, OUTPUT);
pinMode(mosfetDrive,OUTPUT); // setup pin 9 for pwm

attachInterrupt(0, changeStatus, CHANGE); // interupt 0 sits on pin D2

Serial.begin(9600);
Serial.print("Gas Chromatograph version " );
Serial.println(version);

// set up column temperature


epromTemperature = double(EEPROM.read(epromaddy)); // get the last stored temp
settemperature = epromTemperature;

while (Status==INITIALISING){
int button=0; // initial value for inc and dec buttons
lcd.setCursor(0, 0);
lcd.print("temp? press both");
lcd.setCursor(0, 1);
lcd.print ("to save)");
lcd.setCursor(12, 1);
lcd.print(settemperature);
button=analogRead(setButtons);
if (button != 0) {
if (button > 500 && button < 530) { // down pressed
settemperature -=1;
delay(200); // for debounce
}

http://forum.arduino.cc/index.php?PHPSESSID=dvo9p5d8a8b4mt7825upuabvi4&action=printpage;topic=163305.0 4/10
1/26/2018 Print Page - Gas Chromatograph
else if (button > 250 && button < 300) { // up pressed
settemperature +=1;
delay(200);
}

else if ( button > 580 && button < 600) { //both pressed - save
Status=BUSY;
if (settemperature != epromTemperature) {
EEPROM.write(epromaddy,settemperature);
}
}
}

lcd.clear();
lcd.print("set temp =");
lcd.print(settemperature);
lcd.print(" oC");
lcd.setCursor(0, 1);
lcd.print("warming column");

//create a pid object to control the column temperature

myPID.SetMode(AUTOMATIC);

Status = BUSY;
FlexiTimer2::set(500, flashBusyStatus); // 500ms period
FlexiTimer2::start();

// just lock us out until the column heats up


while (Status == BUSY) {
servicePID();

if (temperature > settemperature ){


Status = WAITING;
FlexiTimer2::stop();
FlexiTimer2::set(500, flashWaitStatus); // 500ms period
FlexiTimer2::start();

lcd.clear();
lcd.print("column= ");

lcd.print(temperature);
lcd.print(" oC");
lcd.setCursor(0, 1);
lcd.print("Press run");
lcd.blink(); // wants input from us, so blink
}

Serial.println(temperature);

Serial.println("we have reached column temp");

void loop()
{
while (Status==WAITING) {
servicePID();
if ( runFlag == 1) {

Serial.print("column temperature is ");


Serial.println(temperature);
Serial.print("photodetector reading is ");
Serial.println(readLDR());
runFlag=0;
}

http://forum.arduino.cc/index.php?PHPSESSID=dvo9p5d8a8b4mt7825upuabvi4&action=printpage;topic=163305.0 5/10
1/26/2018 Print Page - Gas Chromatograph
/*digitalWrite(readyLED,HIGH);
delay(500);
digitalWrite(readyLED, LOW);
delay(500);
*/
}

if (runFlag==1) {
runFlag=0;
startTime=millis();

FlexiTimer2::stop();
flashpin=0;
flashWaitStatus();

FlexiTimer2::set(1000, flashRunStatus); // 500ms period


FlexiTimer2::start();

lcd.noBlink(); // doesn't want anything, so stop blinking


while (Status == RUNNING)
{
//main running loop goes here

//wait 1 sec

//read ldr
//read temp

if (serviceInterrupt ==1 ){

time=(millis()-startTime)/1000;
temperature=double(getTemp());
photoDetector=readLDR();

logData(time, photoDetector, temperature);

lcd.clear();
lcd.print("temp=");
lcd.print(temperature);
lcd.print(" oC");
lcd.setCursor(0, 1);
lcd.print("detector=");
lcd.print(photoDetector);
lcd.print(" units");

serviceInterrupt=0;
}
servicePID();
//log time since start, ldr, and temp to csv file via Gobetweeno
// later write time and ldr to lcd
//do it all again until status is stopped
}
}

Title: Re: Gas Chromatograph


Post by: robtillaart on Apr 29, 2013, 03:46 pm

Never seen gas chromatography before ! (There are a few nice liquid chromatograph sketches around)

Can you post some "screen shots" of results (xls files) ?

Title: Re: Gas Chromatograph


Post by: Harristotle on May 03, 2013, 04:37 pm

Sure. A chromatogram of dichloromethane at 22 degrees (room temp) and at 55 degrees can be seen
here:

http://forum.arduino.cc/index.php?PHPSESSID=dvo9p5d8a8b4mt7825upuabvi4&action=printpage;topic=163305.0 6/10
1/26/2018 Print Page - Gas Chromatograph

http://screencast.com/t/i5y7MFSh3MG

More details of the detection system can be seen here:


http://www.screencast.com/t/iPuce3g2R

Some more details on the Chemistry and other details can be found here:
http://www.sciencemadness.org/talk/viewthread.php?tid=24110

Thanks for the interest!


H.

Title: Re: Gas Chromatograph


Post by: nitrous on Apr 11, 2014, 04:09 pm

I know this topic is a little old but wanted to ask if you have explored other detector methods.

In particular, SAW technology, (Surface Acoustic Wave) might be an elegant way to improve/expand the
GC project.
Any thoughts on this?

Great project, by the way.

Nitrous

Title: Re: Gas Chromatograph


Post by: Harristotle on Apr 14, 2014, 04:25 pm

Hi Nitrous,
good comment, and yes.
I have been working on integrating into excel with PLX-DAQ - this has mostly been done, and I now have
real time output.

I don't know enough about SAW technologies, but I am interested in the tin oxide types of resistive
sensors, such as Figaro 822 and MCQ-3. They work by an analyte of interest sticking to the SnO (SnO2?)
and changing its resistance. There is also a heater in such devices so that detected substances don't just
"bind, stick and clog" the sensor. It occurs to me that as such a range of substances such as methane to
methanol can be detected by different sensors, that the major difference in these sensors is the possibly
just the temperature that the chip is held at by the resistive heater. My current work is to see if a very
polar sensor (such as Figaro 822, or MCQ-3) can be tuned by "pwm 'ing" the heater pin so that they are
good for testing for other substances. If this is so, you can have a very cheap general sensor for many,
many substances. Other detectors such as FID (thoriated welding rod, methan flame, 2x 9v batteries in
series and a MPS63 or similar high gain darlington) are also possible, but my experiments with these (not
coupled to a column) show a lot of drift, and I have abandoned them for this time while I pursue the
more promising Sn/O sensors.

One thing is for sure: GC, Thin Layer Chromatography and paper chromatography have made their way
into Year 11 Chemistry syllabus in the Australian National Curriculum (2016). I will probably run another
Arduino workshop for my local Science Teachers association on how to build a GC - so I better get off my
bum and finish the project! I am waiting for boards to arrive from ebay right now!
Thanks for your interest.
H.

Title: Re: Gas Chromatograph


Post by: nickec on Feb 27, 2015, 10:52 pm

http://forum.arduino.cc/index.php?PHPSESSID=dvo9p5d8a8b4mt7825upuabvi4&action=printpage;topic=163305.0 7/10
1/26/2018 Print Page - Gas Chromatograph

Excellent work. Thanks for sharing it.

Do you believe that a variation on your work could identify elements in CMNS reactor ash?

Could a variation measure temperature?

I know that spectra vary by temperature and that this fact is used by astronomers.

My reason for asking is that I am helping amateur scientists worldwide to investigate thermogenerator
reactors. Simple alumina tubes filled with metal powders which exhibit as yet unexplained heating.

See the early days of my blog at ni.comli.com (http://ni.comli.com)

Title: Re: Gas Chromatograph


Post by: boudia1978 on Apr 18, 2015, 10:17 am

Hi Harristotle
thank you for your great work, just I have some question about the schematic, about D11 and D12 of
arduino where they are connected in LCD.
and about Gas sensor where is the Pins in arduino?
best regards

Title: Re: Gas Chromatograph


Post by: boudia1978 on May 17, 2015, 10:03 pm

Dear Sir
when I like to upload your code of arduino gas chromo is not work there are problem in your code.
pleas help me

Title: Re: Gas Chromatograph


Post by: Harristotle on Jun 06, 2015, 04:53 pm

Make sure that you are using the correct lcd library for the HD44780, there are a couple of versions out
there and they are not all compatible. Secondly, try adjusting the 10k pot to get good contrast on the
screen.

D12 is RS
D11 is enable

the others are the 4 bit data bus

finally, I don't often visit this thread, so I don't always get replies.

Have fun now!


H.

Title: Re: Gas Chromatograph


Post by: AdonisTheFirst on Oct 27, 2015, 12:04 pm

Hi there Harristottle,
a fascinating journey into "do-it-yourself" science. Well done! You have my admiration. For the moment,
my own interest is at the thought-process level, but I'm tempted to begin experimentation, and your
exploits are a super reference point for me!

http://forum.arduino.cc/index.php?PHPSESSID=dvo9p5d8a8b4mt7825upuabvi4&action=printpage;topic=163305.0 8/10
1/26/2018 Print Page - Gas Chromatograph

A question:
I've thought about doing something similar, from scratch, to your own venture. I started by thinking in
terms of using a small flow rate of propane (cheap, available) as a carrier gas; column = a long copper
tube, with inside coated stationary phase (I thought maybe copper brake pipe?). Coil it, put it in a heated
vessel (air heated, oil bath etc etc) and then "play around" with various detection ideas on the output gas
stream. Perhaps flame ionisation because there's a built-in flammable carrier?!
I also play around with Arduinos and have a lot of fun with them. My primary hobby interest is analysis of
Scotch Whiskey (I know, I know! What a strange interest!)
Such spirits contain small quantities of a large number of "congeners" - various organic compounds. And
it would be highly interesting to begin to understand their distribution/quantity vs the
source/fermentation/distillation conditions.
I have one of those Chinese USB storage 'scopes, so capturing and examination of output changes (even
fast ones from a short column) is unlikely to be a problem!
Your thoughts are most welcome?
As you can see, I have thought much more about the basic structure than the detection mechanism. For
the time being anyway! Though I expect that with the availability of the storage 'scope, own-designed
detectors is probably wide-open territory for experimentation......

Title: Re: Gas Chromatograph


Post by: Johnny010 on Oct 30, 2015, 01:53 pm

How about a DIY spectrometer?

DIY IR SPEC (https://topologicoceans.wordpress.com/2011/03/15/diy-spectro-ii/)

Title: Re: Gas Chromatograph


Post by: Johnny010 on Oct 30, 2015, 02:01 pm

GS-IR machines....I used them plenty in my time as an analytical chemist.

The UV-VIS-IR stuff is not as bad as you may think!

A diffraction grating that is moved through an axis to get different wavelengths of light filtered.
Your detector can then read the individual wavelengths and produce a "graph"/Spectrum of the sample.

(https://upload.wikimedia.org/wikipedia/commons/9/95/Schematic_of_UV-
_visible_spectrophotometer.png)

You can feed the output of your GC along a sample glass tube. This gives a "live" full spectrum analysis of
what you have separated.

The first peak is your usual carrier gas, then you can time the following peaks as they come off to give
retention times. Having the IR/UV/VIS spec gives a better analysis as you can identify multiple chemicals
in one sample.

Title: Re: Gas Chromatograph


Post by: Harristotle on Nov 14, 2015, 02:35 pm

@Adonis,
I also have thought about FID, and the possibility of hacking a small smoke detector as my source for this
!!

I have really enjoyed playing around with ionisation chambers (like this guy:
http://madscientisthut.com/wordpress/daily-blog/easily-make-a-radiation-detector-ion-chamber/) but I
found I had considerable drift with those darlingtons! My wife wont let me anywhere near a milo tin these
days! There are better, temperature compensated circuits though. These chambers go nuts when you put
a candle in them- all those 1+ carbon nanotubes flying around there. It makes you wonder if you could
http://forum.arduino.cc/index.php?PHPSESSID=dvo9p5d8a8b4mt7825upuabvi4&action=printpage;topic=163305.0 9/10
1/26/2018 Print Page - Gas Chromatograph

make a crude, carbon nanotube/buckyball "mass spectrometer" out of a candle and do some cool
chemistry. There is still a lot of fun for the home guy in the shed!

I wondered about taking my silica gel and soaking it in palmitic acid (reflux dilute H2SO4 and soap then
extract into white spirits/pet ether) and then esterify to the -OH groups on the silica gel with
concentrated H2SO4! Voila! C16 column, cheap, cheap.

Sadly I have run out of time to play with this project. I appreciate your interest, and am glad that your
post corresponded to my annual visit back here !!!

Cheers,
H.

SMF 2.1 Beta 1 © 2014, Simple Machines

http://forum.arduino.cc/index.php?PHPSESSID=dvo9p5d8a8b4mt7825upuabvi4&action=printpage;topic=163305.0 10/10

You might also like