Propane+gap igniter+TempSensor

Writing code to check if the oil temp is to cold or hot and fire the torch if it is and shut it off if its not this is just the basic of it working I need to implement more sensors and checks to verify if the torch is currently running or not but I would like to know if my approach is heading in the right direction. Also I’m using a gap igniter with a 12v to 5v converter hooked to a relay to light the torch does this sound safe? :slight_smile:

void loop()
{
// read the sensor:
TempSetSensorValue = analogRead(SetTempInPin);
OilTemp = thermocouple.readCelsius();
const int OilTempMin = TempSetSensorValue - 7;
const int OilTempMax = TempSetSensorValue + 7;
if (OilTemp < OilTempMin) {
do
{
Serial.print(‚ÄúFiring Torch‚ÄĚ );
delay(1000);
motor.step(300, FORWARD, DOUBLE);
delay(2000);
digitalWrite(sparkPin, HIGH);
delay(1000);
digitalWrite(sparkPin, LOW);

} while (OilTemp < OilTempMax);
}
else if (OilTemp > OilTempMax) {
Serial.print(‚ÄúShutdown Torch‚ÄĚ );
motor.step(300, BACKWARD, DOUBLE);
}

but I would like to know if my approach is heading in the right direction.

Maybe. What is the motor doing?

Motor is turning on and off the propane

Seems to me that you probably need a way to tell whether you have successfully lit the torch, keep retrying the igniter as necessary for as long as is safe, give up and close the valve if you can't get it to light within the allowed time.

yea im still trying to figure out how its going to tell if the torch is lite or not either flame sensor, thermocouple on the torch itself or lp sensor

Do i have to be redundant for it to keep checking the temp sensors:

void loop()
{
// read the sensor:
TempSetSensorValue = analogRead(SetTempInPin);
TempSetSensorValue = map(TempSetSensorValue, 0, 1023, 325, 700);
OilTemp = thermocouple.readFarenheit();
int OilTempMin = TempSetSensorValue - 7;
int OilTempMax = TempSetSensorValue + 7;

if (OilTemp < OilTempMin){
do
{
if (torchon = false){
Serial.print(‚ÄúFiring Torch‚ÄĚ);
delay(1000);
motor.step(300, FORWARD, DOUBLE);
delay(2000);
digitalWrite(sparkPin, HIGH);
delay(1000);
digitalWrite(sparkPin, LOW);
torchon = true;
}
else if (torchon = true){
TempSetSensorValue = analogRead(SetTempInPin);
TempSetSensorValue = map(TempSetSensorValue, 0, 1023, 325, 700);
OilTemp = thermocouple.readFarenheit();
int OilTempMin = TempSetSensorValue - 7;
int OilTempMax = TempSetSensorValue + 7;
}
}

while (OilTemp < OilTempMax);
}
else if (OilTemp > OilTempMax) {
Serial.print(‚ÄúShutdown Torch‚ÄĚ );
motor.step(300, BACKWARD, DOUBLE);
torchon = false;
}

I would add a propane gas sensor (max time propane is detected) as well as the flame sensor. A emergency spring-loaded mechanically activated (or a thermometer too) gas flow cutting and fire extinguishing panic button is probably a good idea and maybe double all important sensors onto another arduino. I'd make sure this works from "wall"(can't find a better word now) electricity and make sure it has enough battery backup to safely survive a couple normal blackout periods(depends on where you live) an maybe send you a twitter message when this happens, maybe better spam twitter with WARNING OF DOOM!!) (I'm assuming your using the torch to heat oil for heating, cooking... something you usually use so might be forgotten plugged in...)

Yeah, sounds real safe. Your "favorite" neighbors next xmas gift assuming your house is still in the neighborhood XD.

Look for a bi-metal strip or spiral like in a thermostat. Bi-metal strip bends with temperature, just put some contacts and that alone can regulate the gas.

Maybe use an IR detector to keep an eye on the flame?

BTW::: would it be safe in a crash when hot oil may meet with open flame? If this is for a vehicle, it's probably better than burning oily rags under the block to warm up but put the fire out once she's running warm, right? So add a mechanical interlock to keep that system off when said vehicle moves.

This is going to control a hot rubber melter that will melt rubber blocks at 500 degree's it is a trailer unit that is pulled by a truck they no longer make parts for this unit, it needs to keep rubber melted while driving. Sorry for not posting about the project, It will never be activated while moving until im 100% its got all the failsafe's it needs and deserves.

The unit holds 100 gallons of rubber the rubber is heated by oil inside the structure of the unit which is heated by a single propane torch. I was gonna try to power with batteries size doesnt matter as the melter is huge so being discrete with tiny batteries is not an issue. The unit takes a few hours to get up to temperature for the rubber to melt so bringing it to a jobsite then firing it up wastes allot of time.

I decided on the spark gap igniter i need something somewhat rugged however if anyone has any other idea's for electronic ignition I am all ears!! Being as the unit will be going at highway speeds it needs to detect if blame gets blown out and refire at highway speeds.

I think i got it! Hows this look!?

#include <AFMotor.h>
#include <Adafruit_MAX31855.h>
#include <LiquidCrystal.h>

//pin definitions
const int SetTempInPin = A0; // Analog input pin that the potentiometer is attached to
const int sparkPin = 13;

int TempSetSensorValue = 0; // value read from the pot
int OilTemp = 0;
AF_Stepper motor(200, 2);

int thermoDO = 9;
int thermoCS = 10;
int thermoCLK = 2;
Adafruit_MAX31855 thermocouple(thermoCLK, thermoCS, thermoDO);
//end pin definitions

boolean torchon = false;

void setup()
{
pinMode(sparkPin, OUTPUT);
Serial.begin(9600); // set up Serial library at 9600 bps
motor.setSpeed(60); // 60 rpm
delay(500);
}

void checktemp()
{
TempSetSensorValue = analogRead(SetTempInPin);
TempSetSensorValue = map(TempSetSensorValue, 0, 1023, 325, 700);
OilTemp = thermocouple.readFarenheit();
}

void loop()
{
// read the sensor:
checktemp();
int OilTempMin = TempSetSensorValue - 7;
int OilTempMax = TempSetSensorValue + 7;
Serial.println(TempSetSensorValue);
Serial.println(OilTemp);
Serial.println(torchon);
delay(500);

while (OilTemp <= OilTempMin)
{
if (torchon == false)
{
Serial.println(‚ÄúFiring Torch‚ÄĚ);
delay(1000);
Serial.println(‚ÄúTurning LP On‚ÄĚ);
motor.step(300, FORWARD, DOUBLE);
motor.release();
delay(2000);
Serial.println(‚ÄúIgnition‚ÄĚ);
digitalWrite(sparkPin, HIGH);
delay(1000);
digitalWrite(sparkPin, LOW);
torchon =!torchon;
}
else if (torchon == true)
{
Serial.println(‚ÄúReading Temp‚ÄĚ);
checktemp();
//TempSetSensorValue =
//analogRead(SetTempInPin);
//thermocouple.readFarenheit();
//TempSetSensorValue = map(TempSetSensorValue, 0, 1023, 325, 700);
// OilTemp = 50;
// int OilTempMin = TempSetSensorValue - 7;
// int OilTempMax = TempSetSensorValue + 7;
//OilTemp = 1000;
Serial.println(TempSetSensorValue);
Serial.println(OilTemp);
delay(500);
}
}

while (OilTemp >= OilTempMax && (torchon == true))
{
Serial.println(‚ÄúShutdown Torch‚ÄĚ );
motor.step(300, BACKWARD, DOUBLE);
motor.release();
torchon = !torchon;
}

delay(1000);
}

Seems broadly along the right lines, although I’d be tempted to use a state machine to handle the different conditions (burner off, lighting burner, burner on).

Thank you for your advice!! FiniteStateMachine.h?

frost777: yea im still trying to figure out how its going to tell if the torch is lite or not either flame sensor, thermocouple on the torch itself or lp sensor

The flame should freaking glow IR like a spotlight even if it looks invisible to you. You can feel the heat. That's massive to an IR detector. Any lack of flame should be obvious.

Use a cheap IR detector or use the 2-pin, slower but cheap "led as a light sensor" trick.

Can you tie a shutoff into a collision detector plus status light(s) and restart button? There's different tilt switches if you don't have collision detect, like an airbag system.

Hows this look!?

I don’t like the mix of global and local variables. The checkTemp() function should return a value - the temperature it found, rather than setting a global variable.

 if (torchon == false)
 {
  torchon =!torchon;
}
 else if (torchon == true)
 {
 }

If torchon is not false, can it be anything other than true?

This is a lot cleaner:

if(!torchon)
{
   // do stuff
   torchon = true;
}
else
{
  // do other stuff
}

Proper posting of code is done with the # icon above the smile faces, and is done AFTER using Tools + Auto Format.

Thanks for your reply paul reading your code:

if(!torchon)

Does this automatically assume !torchon is false because I need it to fire the torch only if its not on? Also I did the checktemp function because i didnt know if i had to repeat the globals inside of the if true statement so i should have it return a value then assign the value a local variable? Also in checktemp is looking at what the temp should be from pot and what the temp is currently

thanks for your help im new and learning a lot!!!

Does this automatically assume !torchon is false because I need it to fire the torch only if its not on?

if(torchon == true) evaluates to true if torchon is true. if(turchon) evaluates to true if torchon is true. So, the == true part is not needed. The corollary for false is !torchon (not torchon).

so i should have it return a value then assign the value a local variable?

Exactly.

Also in checktemp is looking at what the temp should be from pot and what the temp is currently

Suppose digitalRead() also sent a serial message and logged on to a server and sent an e-mail to your wife about your girlfriend. You'd really expect that function to have a different name, wouldn't you?

It really doesn't matter what the name is, as long as it adequately describes what the function does.

Of course, any time you need to use And in a function name, that's a sure sign that the function is doing too much.

You should have two separate functions, getSetPoint() and getCurrentTemperature(). Neither cares about what the other is doing, so one function is not a good idea.

Touche my man! i love it thanks!!

Getting compile error on this because of return TempSetSensorValue;

#include <AFMotor.h>
#include <Adafruit_MAX31855.h>
#include <LiquidCrystal.h>

//pin definitions
int SetTempInPin = A0;  // Analog input pin that the potentiometer is attached to
int sparkPin =  13;


        // value read from the pot

AF_Stepper motor(200, 2);

int thermoDO = 9;
int thermoCS = 10;
int thermoCLK = 2;
Adafruit_MAX31855 thermocouple(thermoCLK, thermoCS, thermoDO);
//end pin definitions

boolean torchon = false;

void setup()
{  
  pinMode(sparkPin, OUTPUT);
  Serial.begin(9600);           // set up Serial library at 9600 bps
  motor.setSpeed(60);  // 60 rpm
  delay(500);  
}

void getSetTemp()
{
  int TempSetSensorValue = 0;
  TempSetSensorValue = analogRead(SetTempInPin);
  TempSetSensorValue = map(TempSetSensorValue, 0, 1023, 325, 700);
  return TempSetSensorValue;
 }
 
void getCurrentOilTemp()
{
 int OilTemp = 0;
 OilTemp = thermocouple.readFarenheit();
 return OilTemp;
 }

void loop()
{
 int SetTemp = 0;
 SetTemp = getSetTemp();
 int OilTemp;
 OilTemp = getCurrentOilTemp();
 int OilTempMin = OilTemp - 7;
 int OilTempMax = OilTemp + 7;
 Serial.println(SetTemp);
 Serial.println(OilTemp);
 Serial.println(torchon);

while (OilTemp <= OilTempMin)
{
 if (!torchon)
 {
  Serial.println("Firing Torch");
   delay(1000);
     Serial.println("Turning LP On");
  motor.step(300, FORWARD, DOUBLE);
  motor.release();
   delay(2000);
   Serial.println("Ignition");
  digitalWrite(sparkPin, HIGH);
   delay(1000);
  digitalWrite(sparkPin, LOW);
  torchon = true;
}
 else
 {
  
     }
}
  
  while (OilTemp >= OilTempMax && torchon)
  {
   Serial.println("Shutdown Torch" );
    motor.step(300, BACKWARD, DOUBLE);
    motor.release();
   torchon = !torchon; 
 }
  
                    
}
void getSetTemp()
{
  int TempSetSensorValue = 0;
  TempSetSensorValue = analogRead(SetTempInPin);
  TempSetSensorValue = map(TempSetSensorValue, 0, 1023, 325, 700);
  return TempSetSensorValue;
 }

A void type function does not return a value. An int type function returns an int.

your so fast paul i was about to edit my foolishness i just found that answer man i cant wait to get this stuff down!!! :D