Hi,
I'm trying the Parallax CO Gaz sensor for a project :
http://www.parallax.com/Store/Sensors/AllSensors/tabid/760/CategoryID/46/List/0/SortField/0/Level/a/ProductID/547/Default.aspx
I haven't found anyone using this one with the Arduino but it comes with a basic stamp program so I decided to give it a go... but it doesn't work (the only thing I get is the ** ALARM **).
In the program description, there is two phases, the first one is PURGE and the second one is SENSE. For the first one, it states that "the first phase is the PURGE phase where the heater element is turned on at a full 5V." but in the basic stamp program I see LOW HSW (the heater pin) to turn the heater on...
Also,I'm not sure to understand the second phase properly, the description says "run ~1.4V for 90 seconds" :
LOW HSW ' Turn Heater ON
PAUSE 15 ' For 15 mS
INPUT HSW ' Turn Heater OFF
PAUSE 3 ' For 3 mS
LOW HSW is like for digitalWrite (HSW_pin, LOW) and INPUT is to make a pin as an input which I'm not sure to understand in this situation. Could that be a simple analogWrite (HSW_pin, 75) for the second phase and an analogWrite (HSW_pin, 255) for the first phase ?
Thanks for any help or tips using this kind of sensors !
So here is the complete Basic Stamp code :
' -----[ I/O Definitions ]-------------------------------------------------
HSW PIN 0 ' Heater Switch Control
ALR PIN 1 ' Alarm Input Sense
' -----[ Variables ]-------------------------------------------------------
index VAR Word ' Counter Variable
' -----[ Program Code ]----------------------------------------------------
Main:
DO
LOW HSW ' Turn Heater ON
FOR index = 59 TO 0 ' Count Down 60 Seconds
DEBUG HOME, "PURGE MODE...", DEC2 index, " "
PAUSE 1000 ' 1 Second Pause
NEXT
index = 1710 ' Approximately 90 Seconds
DO ' Of Iterations On BS2
DEBUG HOME, "SENSE MODE...", DEC2 index / 19
LOW HSW ' Turn Heater ON
PAUSE 15 ' For 15 mS
INPUT HSW ' Turn Heater OFF
PAUSE 3 ' For 3 mS
index = index - 1 ' Decrement Counter
IF ALR = 1 THEN ' Check For Alarm Condition
DEBUG " ***ALARM***" ' Display Alarm Condition
ELSE
DEBUG " " ' Clear Alarm Condition
ENDIF
LOOP UNTIL index = 0 ' End Of Sense Mode Loop
LOOP
And here is my Arduino version :
// Parallax CO Gas Sensor
int HSW_pin = 3; // the heater output pin (PWM)
int ALR_pin = 4; // the alarm input pin
int ALR_val = 0;
int counter = 0; // a counter
int index = 60;
void setup(){
pinMode (ALR_pin, INPUT);
pinMode (HSW_pin, OUTPUT);
Serial.begin (9600);
delay(100);
}
void loop (){
analogWrite (HSW_pin, 255); // it says LOW (0 V) in the program but 5V in the description ?
for (index; index>0; index--){
Serial.print ("Purge mode :");
Serial.print (index);
Serial.println (" seconds");
delay (1000);
}
index = 1710;
while (index > 0){
Serial.print ("Sense mode ...");
Serial.println (index/19);
analogWrite (HSW_pin, 75); // Is this 1.4V ?
index --;
ALR_val = digitalRead (ALR_pin);
if (ALR_val == 1){
Serial.println ("***** ALARM *****");
} else {
Serial.println (" ");
}
}
}