Picaxe Chemistry Colorimeter

Uploaded

Submitted by: nickcinquino Project Website: N/A

Description

PICAXE 14M2 Chemistry Colorimeter with LCD Display
Nick Cinquino 9/10/13

The stereotype of the crazed chemist running around with a smoking flask, glassware everywhere, is long gone.

A modern analytical chemist is more of a computer/electronics specialist, keeping wildly complex and sensitive electronic instruments tuned, calibrated and happy.

A fairly simple analytical instrument is the Colorimeter. It shines a tight wavelength of light through a sample (usually liquid) and detects how much light has been absorbed by the sample.

Once calibrated, you can tell how much of an analyte is in an unknown sample.

An excellent explanation of colorimeters, with mathematics, can be found online here: http://khimiya.org/pdfs/EKHIMIYA_18_6_SOROURADDIN.pdf I wanted a colorimeter with integrated LCD display of the amount of light absorbed, keeping it as simple as possible.

A Picaxe 14M2 chip was ideal to control the light source, take the analog sensor input data and manipulate it, and control an LCD display in 4-bit mode.

My future use will be to analyse swimming pool water for chlorine content, using orthotolidine as the color development reagent..

The photos of the “absorbance cell”, the block that holds the cuvette (square plastic test tube, available through ebay) shows that it is simply constructed; the CdS sensor and LED holder block are hot-glued to the fiberglass framework, separated by spare cuvettes.

I coated it with black paint, but that was insufficient, light was still leaking in.

It needs to be light-tight for steady readings, so an outer layer of electrical tape did the trick.

Any color of LED can be used for the source, I started with red, to use with green food color solutions.

Note from the referenced paper that photo intensity is an important part of the equation; the LED is operating fairly dimly.

Future work will include transferring the circuit to a Picaxe 20M2, so it can selectively control a 3-color RGB LED.

It would be nice to be able to send selected readings out to the serial terminal window as well.

When you have the circuit together, and all of the cuvettes and calibration solutions ready, the procedure is to first check that the zero reading is good.

Turn off the switch to shut off the LED, and check the LCD reading. It should be 0.

Next, place a cuvette with clear clean water into the cell, and adjust the 10K ohm pot until the display reads 100.

We now have a range of 0 to 100, for no light to full light.

Next run your samples, in cuvettes. Note the readings, and chart your results.

The colorimeter is now calibrated; bring on the unknown! A mystery with this circuit: the results, when charted, are linear.

I expected a curve, and when charting logarithmically, then it would be linear.

I will be investigating to find out why it’s linear now.

Following is the code to download to the 14M2. It is painfully long, literally using most of the Picaxe’s memory. I’m sure there are more efficient ways of writing this.

Thank God for the copy/paste function! Copy and paste it into your Picaxe programming editor…avoid typing it all out! Special thanks to P. Beard, who published the code that allows a 14M2 to control a 16X2 LCD display.

The 16X2 displays are available through ebay for $3-4, very cheap. Plastic cuvettes are also reasonably priced through ebay.

'LCD 4 bit mode test
'NJC %T Colorimeter 9/4/2013
#picaxe 14m2
main:
symbol LCD_D4 = pinB.4
symbol LCD_D5 = pinB.3
symbol LCD_D6 = pinB.2
symbol LCD_D7 = pinB.1
symbol LCD_E = B.5
symbol LCD_RS = C.0
output c.1
output c.2
input c.3
input c.4
output c.2
readadc c.4, b9
debug b9
if pin3=1 then
  high c.2
endif
if pin3=0 then
  low c.2
endif
if b9 => 208 then thigh
if b9 => 206 then t104
if b9 => 204 then t102
if b9 => 202 then t101
if b9 => 200 then t100
if b9 => 198 then t99
if b9 => 196 then t98
if b9 => 194 then t97
if b9 => 192 then t96
if b9 => 190 then t95
if b9 => 188 then t94
if b9 => 186 then t93
if b9 => 184 then t92
if b9 => 182 then t91
if b9 => 180 then t90
if b9 => 178 then t89
if b9 => 176 then t88
if b9 => 174 then t87
if b9 => 172 then t86
if b9 => 170 then t85
if b9 => 168 then t84
if b9 => 166 then t83
if b9 => 164 then t82
if b9 => 162 then t81
if b9 => 160 then t80
if b9 => 158 then t79
if b9 => 156 then t78
if b9 => 154 then t76
if b9 => 152 then t75
if b9 => 150 then t74
if b9 => 148 then t73
if b9 => 146 then t72
if b9 => 144 then t71
if b9 => 142 then t70
if b9 => 140 then t69
if b9 => 138 then t68
if b9 => 136 then t67
if b9 => 134 then t66
if b9 => 132 then t65
if b9 => 130 then t64
if b9 => 128 then t63
if b9 => 126 then t62
if b9 => 124 then t61
if b9 => 122 then t60
if b9 => 120 then t59
if b9 => 118 then t58
if b9 => 116 then t57
if b9 => 114 then t56
if b9 => 112 then t55
if b9 => 110 then t54
if b9 => 108 then t53
if b9 => 106 then t52
if b9 => 104 then t51
if b9 => 102 then t50
if b9 => 100 then t49
if b9 => 98 then t48
if b9 => 96 then t47
if b9 => 94 then t46
if b9 => 92 then t45
if b9 => 90 then t44
if b9 => 88 then t43
if b9 => 86 then t42
if b9 => 84 then t41
if b9 => 82 then t40
if b9 => 80 then t39
if b9 => 78 then t38
if b9 => 76 then t37
if b9 => 74 then t36
if b9 => 72 then t35
if b9 => 70 then t34
if b9 => 68 then t33
if b9 => 66 then t32
if b9 => 64 then t31
if b9 => 62 then t30
if b9 => 60 then t29
if b9 => 58 then t28
if b9 => 56 then t27
if b9 => 54 then t26
if b9 => 52 then t25
if b9 => 50 then t24
if b9 => 48 then t23
if b9 => 46 then t22
if b9 => 44 then t21
if b9 => 42 then t20
if b9 => 40 then t19
if b9 => 38 then t18
if b9 => 36 then t17
if b9 => 34 then t16
if b9 => 32 then t15
if b9 => 30 then t14
if b9 => 28 then t13
if b9 => 26 then t12
if b9 => 24 then t11
if b9 => 22 then t10
if b9 => 20 then t9
if b9 => 18 then t8
if b9 => 16 then t7
if b9 => 14 then t6
if b9 => 12 then t5
if b9 => 10 then t4
if b9 => 8 then t3
if b9 => 6 then t2
if b9 => 4 then t1
if b9 =< 2 then t0

thigh:b8=72 : goto display ; print HI b7=73 b6=32
t104: b8=48 : goto display ; print 104 b7=52 b6=49
t103: b8=48 : goto display ; print 103 b7=51 b6=49
t102: b8=48 : goto display ; print 102 b7=50 b6=49
t101: b8=48 : goto display ; print 101 b7=49 b6=49
t100: b8=48 : goto display ; print 100 b7=48 b6=49
t99: b8=57 : goto display ; print 99 b7=57 b6=32
t98: b8=57 : goto display ; print 98 b7=56 b6=32
t97: b8=57 : goto display ; print 97 b7=55 b6=32
t96: b8=57 : goto display ; print 96 b7=54 b6=32
t95: b8=57 : goto display ; print 95 b7=53 b6=32
t94: b8=57 : goto display ; print 94 b7=52 b6=32
t93: b8=57 : goto display ; print 93 b7=51 b6=32
t92: b8=57 : goto display ; print 92 b7=50 b6=32
t91: b8=57 : goto display ; print 91 b7=49 b6=32
t90: b8=57 : goto display ; print 90 b7=48 b6=32
t89: b8=56 : goto display ; print 89 b7=57 b6=32
t88: b8=56 : goto display ; print 88 b7=56 b6=32
t87: b8=56 : goto display ; print 87 b7=55 b6=32
t86: b8=56 : goto display ; print 86 b7=54 b6=32
t85: b8=56 : goto display ; print 85 b7=53 b6=32
t84: b8=56 : goto display ; print 84 b7=52 b6=32
t83: b8=56 : goto display ; print 83 b7=51 b6=32
t82: b8=56 : goto display ; print 82 b7=50 b6=32
t81: b8=56 : goto display ; print 81 b7=49 b6=32
t80: b8=56 : goto display ; print 80 b7=48 b6=32
t79: b8=55 : goto display ; print 79 b7=57 b6=32
t78: b8=55 : goto display ; print 78 b7=56 b6=32
t77: b8=55 : goto display ; print 77 b7=55 b6=32
t76: b8=55 : goto display ; print 76 b7=54 b6=32
t75: b8=55 : goto display ; print 75 b7=53 b6=32
t74: b8=55 : goto display ; print 74 b7=52 b6=32
t73: b8=55 : goto display ; print 73 b7=51 b6=32
t72: b8=55 : goto display ; print 72 b7=50 b6=32
t71: b8=55 : goto display ; print 71 b7=49 b6=32
t70: b8=55 : goto display ; print 70 b7=48 b6=32
t69: b8=54 : goto display ; print 69 b7=57 b6=32
t68: b8=54 : goto display ; print 68 b7=56 b6=32
t67: b8=54 : goto display ; print 67 b7=55 b6=32
t66: b8=54 : goto display ; print 66 b7=54 b6=32
t65: b8=54 : goto display ; print 65 b7=53 b6=32
t64: b8=54 : goto display ; print 64 b7=52 b6=32
t63: b8=54 : goto display ; print 63 b7=51 b6=32
t62: b8=54 : goto display ; print 62 b7=50 b6=32
t61: b8=54 : goto display ; print 61 b7=49 b6=32
t60: b8=54 : goto display ; print 60 b7=48 b6=32
t59: b8=53 : goto display ; print 59 b7=57 b6=32
t58: b8=53 : goto display ; print 58 b7=56 b6=32
t57: b8=53 : goto display ; print 57 b7=55 b6=32
t56: b8=53 : goto display ; print 56 b7=54 b6=32
t55: b8=53 : goto display ; print 55 b7=53 b6=32
t54: b8=53 : goto display ; print 54 b7=52 b6=32
t53: b8=53 : goto display ; print 53 b7=51 b6=32
t52: b8=53 : goto display ; print 52 b7=50 b6=32
t51: b8=53 : goto display ; print 51 b7=49 b6=32
t50: b8=53 : goto display ; print 50 b7=48 b6=32
t49: b8=52 : goto display ; print 49 b7=57 b6=32
t48: b8=52 : goto display ; print 48 b7=56 b6=32
t47: b8=52 : goto display ; print 47 b7=55 b6=32
t46: b8=52 : goto display ; print 46 b7=54 b6=32
t45: b8=52 : goto display ; print 45 b7=53 b6=32
t44: b8=52 : goto display ; print 44 b7=52 b6=32
t43: b8=52 : goto display ; print 43 b7=51 b6=32
t42: b8=52 : goto display ; print 42 b7=50 b6=32
t41: b8=52 : goto display ; print 41 b7=49 b6=32
t40: b8=52 : goto display ; print 40 b7=48 b6=32
t39: b8=51 : goto display ; print 39 b7=57 b6=32
t38: b8=51 : goto display ; print 38 b7=56 b6=32
t37: b8=51 : goto display ; print 37 b7=55 b6=32
t36: b8=51 : goto display ; print 36 b7=54 b6=32
t35: b8=51 : goto display ; print 35 b7=53 b6=32
t34: b8=51 : goto display ; print 34 b7=52 b6=32
t33: b8=51 : goto display ; print 33 b7=51 b6=32
t32: b8=51 : goto display ; print 32 b7=50 b6=32
t31: b8=51 : goto display ; print 31 b7=49 b6=32
t30: b8=51 : goto display ; print 30 b7=48 b6=32
t29: b8=50 : goto display ; print 29 b7=57 b6=32
t28: b8=50 : goto display ; print 28 b7=56 b6=32
t27: b8=50 : goto display ; print 27 b7=55 b6=32
t26: b8=50 : goto display ; print 26 b7=54 b6=32
t25: b8=50 : goto display ; print 25 b7=53 b6=32
t24: b8=50 : goto display ; print 24 b7=52 b6=32
t23: b8=50 : goto display ; print 23 b7=51 b6=32
t22: b8=50 : goto display ; print 22 b7=50 b6=32
t21: b8=50 : goto display ; print 21 b7=49 b6=32
t20: b8=50 : goto display ; print 20 b7=48 b6=32
t19: b8=49 : goto display ; print 19 b7=57 b6=32
t18: b8=49 : goto display ; print 18 b7=56 b6=32
t17: b8=49 : goto display ; print 17 b7=55 b6=32
t16: b8=49 : goto display ; print 16 b7=54 b6=32
t15: b8=49 : goto display ; print 15 b7=53 b6=32
t14: b8=49 : goto display ; print 14 b7=52 b6=32
t13: b8=49 : goto display ; print 13 b7=51 b6=32
t12: b8=49 : goto display ; print 12 b7=50 b6=32
t11: b8=49 : goto display ; print 11 b7=49 b6=32
t10: b8=49 : goto display ; print 10 b7=48 b6=32
t9: b8=48 : goto display ; print 9 b7=57 b6=32
t8: b8=48 : goto display ; print 8 b7=56 b6=32
t7: b8=48 : goto display ; print 7 b7=55 b6=32
t6: b8=48 : goto display ; print 6 b7=54 b6=32
t5: b8=48 : goto display ; print 5 b7=53 b6=32
t4: b8=48 : goto display ; print 4 b7=52 b6=32
t3: b8=48 : goto display ; print 3 b7=51 b6=32
t2: b8=48 : goto display ; print 2 b7=50 b6=32
t1: b8=48 : goto display ; print 1 b7=49 b6=32
t0: b8=32 : goto display ; print 0 b7=48 b6=32

display:
  'Initialise LCD
  dirB.1 = 1 : dirB.2 = 1 : dirB.3 = 1 : dirB.4 = 1
  low LCD_RS
  for b1 = 0 to 4
    lookup b1, ($33,$32,$28,$0C,$01), b0
    '(4Bit)(Function 4bit/2line/5x8)(Display On)(Clear Display)
    gosub LCD_send
  next
  high LCD_RS
  for b1 = 0 to 15
    lookup b1, (" % Transmission:"), b0
     gosub LCD_send
  next
  low LCD_RS : b0 = $C0 : gosub LCD_send
  high LCD_RS
  for b1 = 0 to 8
    lookup b1, (" ", b6, b8, b7), b0
    gosub LCD_send
  next
  wait 1
  goto main

LCD_send:
  'Send B0 to LCD
  LCD_D4 = bit4 : LCD_D5 = bit5 : LCD_D6 = bit6 : LCD_D7 = bit7 : pulsout LCD_E, 1
  LCD_D4 = bit0 : LCD_D5 = bit1 : LCD_D6 = bit2 : LCD_D7 = bit3 : pulsout LCD_E, 1
  return

Print Page

Share

Comments

  • Login to leave a comment.