[Part 4] Computer Programming Design

"Using an infrared light source and infrared phototransistor was a bad idea since it catches up all the ambient lights. It not only disrupts the sensor measurements but also the fluctuating reading depending on the ambient light condition makes the programming extremely hard and unreliable. If I had a chance to do all this again, I would use a specific-wavelength sensitive photodiodes/transistors."

So I have changed the previous BS2 stamp to BS2pe microcontroller so it can be interfaced with the thermocouple module I purchased. The following pictures show a fully installed thermocouple and a K-type wire connected to it.

The thermocouple module (also shown in the Part 3) is shrink-wrapped. The purpose of this is to not let the thermocouple wires disconnected by external tensile force, if in case it's there and,second of all, to prevent the module from being mechanically damaged while the lid is closed. Notice that the wires are also tied up to the crystal heat sink. I had one more safety measure to prevent the wires from getting disconnected from the module which involves utilizing unused soldering holes. See picture below.

This additional knob will do the job. 

The BS2pe microcontroller module comes mounted on a small red board. It's physical layout of the pins are identical to the BS2 stamp which makes it a perfect substitute for it. The new CPU provides a good compatibility with the thermocouple module.

Finally moving on to the programming section. The programming for reading the phototransistors inside should reflect the hardware design inside. Therefore, I have made a brief measurements of phototransistor readings at different flow rates starting from 1.2 gpm to 3.8 gmp in steps of 0.2 gpm.

The program should appropriately correlate a correct flow rate at each of laser and infrared phototransistor readings. Notice that there are two graphs for each sensor reading. The ones labeled as "LOFF" were measured when the ambient light was turned off whereas the ones with "LON" were measured when the light was turned on. Therefore, basically the difference between the corresponding "LOFF" and "LON" graphs represents upper and lower bounds of fluctuating sensor readings.

The objective for the programming is,
1. The device should operate reliably independent of the ambient light condition.
2. The device should achieve the goal #1 without an ambient light sensor which is physically defect by design.
3. GPM readings correspending to the true flow rate value need not be accurate.

The tolerance goal for the flow rate reading was set for 0.2 gpm. Now, the safety threshold for the flow rate is 2.5 gpm as specified by the manufacturer. Therefore by design consideration, the location of the laser diode is determined so that it is most sensitive around this flow rate. The effect of this sensitivity can actually be seen in the above graph where there is a significant drop in the laser phototransistor readings. 

The basic programming logic is the following.

IF "laser reading drops below 11000," then,
     IF "laser reading is between 11000 and 9500," then "the current gpm is 2.6"
     IF "laser reading is between   9500 and 8000," then "the current gpm is 2.8"

This logic has a serious flaw since the condition specified in this way can be satisfied by other flow rates. This is where the infrared phototransistor readings come into play. Notice that the third "IF" condition above can be satisfied by flow rates around 3.0. I can prevent this by imposing more strict conditions,

IF "laser reading drops below 11000," then,
     IF "the above laser condition" AND "infrared reading is XXX," then "the gpm is 2.6"
     IF "the above laser condition" AND "infrared reading is XXX," then "the gpm is 2.8"

Even after this, I admit that there are some possibilities of misreading gpm for which I had to do minor tweaks by trial and error. In any case, it turned out in the end that I had successfully made it work correctly as I intended.

The picture above shows up the internal mechanism of the peteometer which reveals a laser diode on the top right (red dot), a thirty-degree laser scatterer/reflector, and below it, there is an infrared light source shown as a violet dot in the picture. One can also see the a two-digit 7-segment display at the bottom right. All the LED pixels were lit to make sure that the display is fully-functioning.

This is a fully assembled, fully operational version hooked up to our opti-temp. The segment display shows up a correct flow rate of 3.5 gpm at a test run.

No comments: