BACK UP GENSET PROGRAMMING

Trying to get the sketch that I uploaded on the uno to print to screen when running ? like if I power up the board the program basically starts generator for 15 min and then shuts off . I would like to be-able to see it in real time on the serial monitor.

What have you done? What problem are you having?

Its just the start of what seems to be an elaborate of ideas for this system . I currently have A onan6.5 nh power plant that runs great still ,but the board went bad on it a while back so I put an uno to the test and decided that it wound be great for a control system .I am off grid with solar so basically I am looking to start the gen set by a few different inputs .lets say call for water ,a input goes high ;run program for x amount of time . call for something else ,program time call be set for other run time length. water 5 mins ,just t prime the tank up ;something else ,say 1 hour for battery charge or even something for 5min for test once a week . keep in mind if I wanted to I could just build the circuit from timers and logic gates but that seems to be a little old school .

gensetfullautojune_2014.ino (1.9 KB)

If you want to see stuff on the screen just put Serial.println("message"); after as many digitalWrite()s as you want.

Remember to put Serial.begin(9600); into setup()

In the longer term, if you want to add features to your program I think your heavy dependence on delay() will cause problems. The Arduino can't do anything else while it is working through the delay() time. You should look at the technique in the Blink Without Delay example sketch and, perhaps, at the extended demo of the technique in the first post of this Thread.

I hope the extended demo will also show the value of splitting code into a series of short functions. As it stands, your code is commendably short but I suspect you will find the need to add to it.

For example I notice that you have nothing in your code to detect a failed start.

...R

did some mods, might be a step further

//
//    FILE: .ino
//  AUTHOR: 
// VERSION: 0.1.00
// PURPOSE: 
//    DATE: 
//     URL:
//
// Released to the public domain
//

// PIN ASSIGNMENTS
int fuelpump = 2;
int coil = 4;   
int starter =6;   
//int choke = 10;   
int contactor = 11; 

unsigned long lastDailyTest = 0;

#include <Servo.h>

void setup() 
{
  Serial.begin(9600);
  
  pinMode(fuelpump, OUTPUT);
  pinMode(coil,OUTPUT); 
  pinMode(starter,OUTPUT); 
  // pinMode(choke,OUTPUT);  
  pinMode(contactor,OUTPUT); 
}


void loop()
{
  if (Serial.available() > 0)
  {
    int c = Serial.read();
    
    if (c == '5') runPump(5);   // 5 minutes
    if (c == 'h') runPump(60);  // hour
  }
  
  if (millis() - lastDailyTest > 86400000UL) 
  {
    lastDailyTest = millis();
    runPump(5);
  }  
}


void runPump(long minutes)
{
  digitalWrite (contactor, HIGH);   // pin 11 engages 110/220 AC contactor
  // choke code here
  digitalWrite(fuelpump, HIGH);     // pin 2 fuelpump on !!
  delay (3000);                     // killing time  3 seconds to prime 
  
  digitalWrite(coil, HIGH);         // pin 4 coil on !!!
  delay(1000);                      // killing time 1 second
  digitalWrite(starter, HIGH);      // pin 6 starter engaged !!!!
  delay(4000);                      // delay for 4 seconds
  digitalWrite(starter, LOW);       // pin 6 disengages starter!!!!! 
  //choke code here ? 
  delay (10000);                    // lets engine warm before engaging contactors !10 seconds 
  digitalWrite (contactor, LOW);    // pin 12 engages 110/220 AC contactor 
  
  delay (minutes * 60000L);   
  
  digitalWrite (contactor, HIGH);    // kill AC contactor
  delay (30000);                     // cool down for 30 sec 
  digitalWrite (coil, LOW);          // kills engine
  digitalWrite (fuelpump, LOW);      // kills fuelpump
}