JET ENGINE STARTER SEQUENCE

Hello all! I am currently building a jet engine and have decided to automate the startup sequence. I am using 4 relays, which are all common 5v. The way it works is it starts up in the following sequence

  1. Oil pump and fuel pump turn on
  2. Red LED (indicates pumps are on) turns on
  3. White LED (indicates starting sequence is activated);
  4. Motor and igniter turn on (LOW because of common 5v)
  5. Wait 100 seconds
  6. Igniter and motor turn off (Now HIGH)
  7. white LED turns off (indicating the end of the start sequence)
  8. green LED turns on (indicating the engine is resuming normal operation)

THIS CODE WORKS******

int OILPUMP = 13;
int FUELPUMP = 12;
int MOTORSTART = 11;
int IGNITER = 10;
int redled = 6;
int greenled = 7;
int whiteled = 8;

/*
This is the start up sequence for Evan McLain's jet engine
All rights reserved
*/


void setup() {

 pinMode(OILPUMP, OUTPUT);
 pinMode(FUELPUMP, OUTPUT);
 pinMode(MOTORSTART, OUTPUT);
 pinMode(IGNITER, OUTPUT);
 pinMode(redled, OUTPUT);
 pinMode(whiteled, OUTPUT);
 pinMode(greenled, OUTPUT);
}


void loop() {
 digitalWrite(OILPUMP, LOW);   // turn the OIL PUMP on
 delay(1000);              // wait for a second
 digitalWrite(FUELPUMP, LOW);    // turn the FUEL PUMP on
 digitalWrite(redled, HIGH);    // RED LED ON R= Pumps on
 delay(1000);              // wait for a second
 digitalWrite(whiteled, HIGH);    // WHITE LED ON W= motor and igniter on
 digitalWrite(MOTORSTART, LOW);   // turn the MOTOR START on
 delay(1000);              // wait for a second
 digitalWrite(IGNITER, LOW);   // turn the IGNITER on
 delay(100000);            // wait for 100 sec
 digitalWrite(MOTORSTART, HIGH);   // turn the MOTOR START off
 digitalWrite(IGNITER, HIGH);   // turn the IGNITER off
 digitalWrite(whiteled, LOW);    // WHITE LED OFF W= motor and igniter on
 digitalWrite(greenled, HIGH);    // GREED LED ON G= engine in normal operation
 while(true);
}

now that the engine is physically on, i would like it to compare a temperature reading, to prevent emergency overheating.

Ive written a code, but i am not sure how i need to make it so it will compare the temp at the same time the system is running. The code CANNOT restart (so i have put a while inside the loop). Later on i put the start sequence into the void setup so it would only run once, however it will not leave the emergency sequence…

THIS DOES NOT WORK*****

int OILPUMP = 13;
int FUELPUMP = 12;
int MOTORSTART = 11;
int IGNITER = 10;
int redled = 6;   // RED LED ON R= Pumps on
int greenled = 7; // GREED LED ON G= engine in normal operation
int whiteled = 8; // WHITE LED OFF W= motor and igniter on
int emergency = 5; // EMERGENCY SHUTOFF  
#define THERMISTORPIN A0 
#define SERIESRESISTOR 10000   
/*
This is the start up sequence for Evan McLain's jet engine
All rights reserved
*/


void setup() {
 // initialize digital pin 13 as an output.
 pinMode(OILPUMP, OUTPUT);
 pinMode(FUELPUMP, OUTPUT);
 pinMode(MOTORSTART, OUTPUT);
 pinMode(IGNITER, OUTPUT);
 pinMode(redled, OUTPUT);
 pinMode(whiteled, OUTPUT);
 pinMode(greenled, OUTPUT);
 pinMode(emergency, OUTPUT);
 Serial.begin(9600);
 
 
 digitalWrite(OILPUMP, LOW);   // turn the OIL PUMP on
 delay(1000);              // wait for a second
 digitalWrite(FUELPUMP, LOW);    // turn the FUEL PUMP on
 digitalWrite(redled, HIGH);    // RED LED ON R= Pumps on
 delay(1000);              // wait for a second
 digitalWrite(whiteled, HIGH);    // WHITE LED ON W= motor and igniter on
 digitalWrite(MOTORSTART, LOW);   // turn the MOTOR START on
 delay(1000);              // wait for a second
 digitalWrite(IGNITER, LOW);   // turn the IGNITER on
 delay(100000);            // wait for 100 sec
 digitalWrite(MOTORSTART, HIGH);   // turn the MOTOR START off
 digitalWrite(IGNITER, HIGH);   // turn the IGNITER off
 digitalWrite(whiteled, LOW);    // WHITE LED OFF W= motor and igniter on
 digitalWrite(greenled, HIGH);    // GREED LED ON G= engine in normal operation
 
}


void loop()
{
 float reading;
 reading = analogRead(THERMISTORPIN);
 int temp = (reading-530);
 Serial.print("Temp "); 
 Serial.println(temp);
 
 if(temp > 400);
 {
  digitalWrite(FUELPUMP,HIGH);
  digitalWrite(greenled,LOW);
  
  digitalWrite(emergency, HIGH);
  delay(1000);
  digitalWrite(emergency,LOW);
  delay(1000);
  digitalWrite(emergency, HIGH);
  delay(1000);
  digitalWrite(emergency,LOW);
  delay(1000);
  digitalWrite(emergency, HIGH);
  delay(1000);
  digitalWrite(emergency,LOW);
  delay(1000);
 }
}

***********(My temp code)

I dont know a way around this, but basically I have a thermistor hooked up to A0 which works when only running the serial print to show my “temp”
float reading;

 reading = analogRead(THERMISTORPIN);
 int temp = (reading-530);         <<<< The -530 is to get the number as close to null as i can
 Serial.print("Temp "); 
 Serial.println(temp);

What i really need is the startup to turn on WHILE comparing the temperature, and if it reaches above analog 400, it would turn off ONLY the green led and fuel pump (cutting off all fuel from the combustion chamber). But leave on both the red led, and the oil pump. Then the “emergency led” (blue) would begin to flash From there i would manually turn off all else. I really need help and i am stuck in a hard spot. Please help!

  • Evan

Perhaps use an interrupt.
As I understand it, interrupts work on selected inputs on some Arduino but in that instance your analog upper limit could trip say a relay or transistor switch feeding the interrupt pin for example and give you the required input to do your emergency shut off or whatever.

Perhaps don't use an interrupt.
Very definitely do get rid of all the calls to delay() and implement a state machine.

When I started reading your original Post I thought it was a model of how to describe a process. But when I looked at the “Does not work” code I realized that the description was completely missing the requirement for a wait period between steps.

Using delay() to provide the waiting period is OK within setup() because it just runs straight through and only runs once.

But don’t use delay() to manage timing within loop() as the Arduino can do nothing useful during the period of the delay. Instead use millis() to manage timing as illustrated in several things at a time.

Don’t consider using an interrupt until you are competent at the other aspects of Arduino programming.

Write a clear step-by-step description of what you want to happen in loop(). Use the same style as in your original Post, but don’t forget to include all timing requirements. You may be interested in Planning and implementing a program.

…R

FSstudios1:
THIS CODE WORKS******

I cannot believe that. If FUELPUMP, MOTORSTART and IGNITER are switched ‘ON’ by setting the pin LOW, they will switch ‘ON’ as soon as the pin is set to OUTPUT in the setup() function. Most likely you forgot some settings in the setup() function of these three pins.

Besides of that, your task is just implementing a ‘sequential control’ logic without using delay(), so that many different tasks can be executed at the same time.

I tried a bit and can provide some demo sketch that provides two tasks:

  • sequential control of your jet engine
  • printing a one second timing on Serial
int OILPUMP = 13;
int FUELPUMP = 12;
int MOTORSTART = 11;
int IGNITER = 10;
int redled = 6;
int greenled = 7;
int whiteled = 8;

/*
This is the start up sequence for Evan McLain's jet engine
All rights reserved
*/

  
void setup() {
 Serial.begin(9600);
 pinMode(OILPUMP, OUTPUT);
 pinMode(FUELPUMP, OUTPUT);
 pinMode(MOTORSTART, OUTPUT);
 pinMode(IGNITER, OUTPUT);
 pinMode(redled, OUTPUT);
 pinMode(whiteled, OUTPUT);
 pinMode(greenled, OUTPUT);
}

// data structure for one pin state switching
struct sq_control_t {byte pin; byte state; unsigned long waitTime;};

sq_control_t sq_control[]={
 {0,0,0}, // first do-nothing-step, zero duration
 {OILPUMP , LOW, 1000}, // switch LOW and wait 1000 ms
 {FUELPUMP , LOW, 0},  // switch LOW and zero wait
 {redled, HIGH, 1000}, // switch HIGH and wait 1000 ms
 {whiteled , HIGH, 0}, // and so on and so on
 {MOTORSTART , LOW, 1000},
 {IGNITER , LOW, 100000L},
 {MOTORSTART , HIGH, 0},
 {IGNITER, HIGH, 0},
 {whiteled, LOW, 0},
 {greenled, HIGH, -1}, // time does not matter, last step is executed forever
};

#define NUMSTEPS (sizeof(sq_control)/sizeof(sq_control[0]))

int currentStep;
unsigned long stepStartTime;

void sequentialControl()
{
  if (millis()-stepStartTime>=sq_control[currentStep].waitTime)
  {
    if (currentStep<NUMSTEPS-1) 
    {
      stepStartTime+= sq_control[currentStep].waitTime;
      currentStep++;
      digitalWrite(sq_control[currentStep].pin, sq_control[currentStep].state);
      Serial.print("Step: ");Serial.println(currentStep); 
    }
  }
}



void timing()
{
  static unsigned long lastSecondMillis;
  if (millis()-lastSecondMillis>=1000)
  {
    lastSecondMillis+=1000;
    Serial.print("Time: ");Serial.println(lastSecondMillis/1000);
  }
}

void loop() {
  sequentialControl();
  timing();
}

All switching data for pin, state and duration are in a struct array named ‘sq_control’.
If several steps are to be executed at the same time, just define some steps with 0 waitTime before actually a waitTime is needed.

jurs your code helped alot, however, how would i implement my temperature code into this to run at the same time, or more of a question is as to where i would insert it.?

As for the rest, thank you for trying to help, I am very proficient in LabView, and somewhat proficient in c++ but i still have trouble understanding state machines on arduino..

FSstudios1:
jurs your code helped alot, however, how would i implement my temperature code into this to run at the same time, or more of a question is as to where i would insert it.?

You can rename the function 'timing()' to 'readTemperature()' and insert your code there.

If you want one temperature reading each second, just replace the line

Serial.print("Time: ");Serial.println(lastSecondMillis/1000);

with your code for reading and displaying temperature.

It works flawlessly! Thank you soooooooo much jurs!!!

int OILPUMP = 13;
int FUELPUMP = 12;
int MOTORSTART = 11;
int IGNITER = 10;
int redled = 6;
int greenled = 7;
int whiteled = 8;
int emergency = 5;
#define THERMISTORPIN A0 
#define SERIESRESISTOR 10000  
/*
This is the start up sequence for Evan McLain's jet engine
All rights reserved
*/

  
void setup() {
 Serial.begin(9600);

 pinMode(OILPUMP, OUTPUT);
 pinMode(FUELPUMP, OUTPUT);
 pinMode(MOTORSTART, OUTPUT);
 pinMode(IGNITER, OUTPUT);
 pinMode(redled, OUTPUT);
 pinMode(whiteled, OUTPUT);
 pinMode(greenled, OUTPUT);
 pinMode(emergency,OUTPUT);
}

// data structure for one pin state switching
struct sq_control_t {byte pin; byte state; unsigned long waitTime;};

sq_control_t sq_control[]={
 {0,0,0}, // first do-nothing-step, zero duration
 {OILPUMP , LOW, 1000}, // switch LOW and wait 1000 ms
 {FUELPUMP , LOW, 0},  // switch LOW and zero wait
 {redled, HIGH, 1000}, // switch HIGH and wait 1000 ms
 {whiteled , HIGH, 0}, // and so on and so on
 {MOTORSTART , LOW, 1000},
 {IGNITER , LOW, 100000L},
 {MOTORSTART , HIGH, 0},
 {IGNITER, HIGH, 0},
 {whiteled, LOW, 0},
 {greenled, HIGH, -1}, // time does not matter, last step is executed forever
};

#define NUMSTEPS (sizeof(sq_control)/sizeof(sq_control[0]))

int currentStep;
unsigned long stepStartTime;

void sequentialControl()
{
  if (millis()-stepStartTime>=sq_control[currentStep].waitTime)
  {
    if (currentStep<NUMSTEPS-1) 
    {
      stepStartTime+= sq_control[currentStep].waitTime;
      currentStep++;
      digitalWrite(sq_control[currentStep].pin, sq_control[currentStep].state);
      Serial.print("Step: ");Serial.println(currentStep); 
    }
  }
}



void timing()
{
  static unsigned long lastSecondMillis;
  if (millis()-lastSecondMillis>=1000)
  {
    lastSecondMillis+=1000;
   int reading = analogRead(THERMISTORPIN);
   int temp = (reading-530);        // <<<< The -530 is to get the number as close to null as i can
   Serial.print("Temp "); 
   Serial.println(temp);
   
   if(temp > 400)
  {
   digitalWrite(FUELPUMP,HIGH);
   digitalWrite(OILPUMP, LOW);
   digitalWrite(IGNITER, HIGH);
   digitalWrite(MOTORSTART, HIGH);
   digitalWrite(whiteled, LOW);
   digitalWrite(greenled, LOW);
   digitalWrite(emergency,HIGH);
   delay(1000);
   digitalWrite(emergency,LOW);
   delay(1000);
   digitalWrite(emergency,HIGH);
   delay(1000);
   digitalWrite(emergency,LOW);
   delay(1000);
  }
 }
}

void loop() {
  sequentialControl();
  timing();
  
}