Well Switch Generator Auto Start

Here is my project idea: when my pressure tank switch tripps I would like to
choke on //I will have a car door lock mechanism connected to choke and run by relays
Generator on
Generator start
If the generator run light is on turn choke off
If the generator light is Off repeat start (max 3 times)
wait 30 seconds for generator to warm up
Turn on well power
Turn on house power
continue till well switch is tripped off
Turn house power off
wait 15 seconds
Turn generator off

I'm having problems figuring out my loops in my sketch. Can someone point me to examples of auto generator start code. Thanks.

Turn on well power
Turn on house power
continue till well switch is tripped off
Turn house power off

Some house consumers like fridges, washing machines or airconditioners might not like this treatment

At least make sure the house isnt already powered before attempting to start the generator.

Off grid system so only thing powered would be the invertor.

Still there are safety issues like having a friend coming while you are on vacation, he turns the inverter on, a power socket blows, inverter's safety cuts its power, unaware friend tries to fix the socket, evil code thinks it's the right moment to start the inverter.
A code that powers on/off a house makes the programmer liable for whatever accidents might happen.

A relay can be switched on by the generator power - so when generator runs, pump is powered directly by generator, when generator does not provide power, pump is powered by inverter. So arduino code needs to check only if inverter is off and pump float switch has turned on (how?) , otherwise delay generator restarts.

Or let the arduino to turn the relay - that powers the pump from inverter or generator - and avoid turning the whole inverter on.


By inverter I assumed you mean solar/wind battery inverter (there are also generators with builtin inverters).

I plan to have it wired so I can switch the system to manual, cutting power to the arduino when I want and manually turning on the well and house power. It will only be auto when I am at the cottage.

breakdown start cycle to each individual step.
Choke might be optional. I think you should look at RPM to know that the motor has started and is running and that the power should be removed from the starter.

In addition I would offer monitoring current usage with a current Transformer. it's something in the cottage is running you may not want to turn power off but rather wait until it is completed and then turn power off that way things like the dishwasher or clothes washer or even refrigerator won't be shut off in the middle of an operation.

scheme doesn't make sense. You only want to power the house when the well tank level is down (vacumn bladder switch is closed)? Then you want to turn generator (house power) off when pump has replenished tank? where does an inverter come into play? What is powered by the inverter (battery supplied) and when?

Makes sense that you need the generator to power the well pump (too much draw for most inverters, unless you have a commercial solar setup driving commercial inverters). But what are you powering in the house that needs to be on only while the well pump is running?

Have a look at Planning and Implementing a Program.

Design your project as a series of separate functions. For example

  • checkWaterPressure()
  • operateStarter()
  • checkEngineRunning()
  • etc etc

As well as making the actual programming easier this will also help clarify the design of the system.

I think the biggest problem will be figuring out a reliable start sequence that can detect when it is appropriate to disconnect the starter motor and whether a second (or third) attempt at starting is required.

...R

Ok the house runs off batteries through invertor. Normally very little load, fridge propane.
I'd like the generator to fill the water tank, while filling it sends power to invertor which charges batteries. Totally off grid.
I have written some code. Not sure how to get it to turn everything off if attempts 3 times to start generator and fail (j=3)
Here is code

int wellSwitchPin=3; //set well switch to pin 3
int chokeOnPin=4; //set choke on to pin 4
int chokeOffPin=5; //set choke off to pin 5
int genOnPin=6; //set generator on to pin 6
int genStartPin=7; //set generator start to pin 7
int genRunlightPin=8; //set generator run light to pin 8
int wellPowerPin=9; //set well power to pin 9
int housePowerPin=10; //set house power to pin 10

void setup() {
// put your setup code here, to run once:
pinMode(chokeOnPin, OUTPUT); //set choke on pin to output
pinMode(chokeOffPin, OUTPUT); //set choke off pin to output
pinMode(genOnPin, OUTPUT); //set generator on pin to output
pinMode(genStartPin, OUTPUT); //set generator start pin to output
pinMode(wellPowerPin, OUTPUT); //set well power pin to output
pinMode(housePowerPin, OUTPUT); //set house power pin to output

}

void loop() {
digitalWrite(wellPowerPin,LOW); //make sure well power is off
digitalWrite(housePowerPin,LOW); //make sure house power is off
digitalWrite(genOnPin,LOW); //turn gen off

if(wellSwitchPin==HIGH && genRunlightPin==LOW){
digitalWrite(genOnPin,HIGH); //turn generator to on
digitalWrite(chokeOnPin,HIGH); //turn the choke on
delay (250); //wait 1/4 second
digitalWrite(chokeOnPin,LOW); //leave choke on
for (int j=1; j<=3; j=j+1);

}

if(wellSwitchPin==HIGH && genRunlightPin==LOW);
{ // Start engine carnk loop
digitalWrite(genStartPin,HIGH); //Crank the starter
delay (5000); //crank for 5 seconds
digitalWrite(genStartPin,LOW); //stop cranking
delay (3000); //wait 3 seconds

if(genRunlightPin==HIGH && wellSwitchPin==HIGH){
delay (2000); //wait 2 seconds while generator warms up with choke on
digitalWrite(chokeOffPin,HIGH); //Turn the choke off 1/4 second pulse
delay (250); //
digitalWrite(chokeOffPin,LOW); //leave choke off
delay (15000); //wait further 15 seconds warm up with choke off
digitalWrite(wellPowerPin,HIGH); //turn power on to the well pump
digitalWrite(housePowerPin,HIGH); //turn power on to the house

}

}
}

Your code looks as if it would work to me. An additional thing I would try (just to get feedback) would be to count the rpm of the motor. This would tell you a number of valuable things like if the engine stops or if it is being overloaded. You could do this by counting the times the engine fires or counting the revolutions of a pulley (I do this with mine). If you use millis() instead of delay it will make your sketch much more flexible to be modified. You could also sense hi side current flow by use of a choke and a Hall effect sensor just for icing on the cake.

I would expect this to cause damage to the starter motor very quickly

digitalWrite(genStartPin,HIGH);   //Crank the starter
delay (5000);                       //crank for 5 seconds
digitalWrite(genStartPin,LOW);    //stop cranking
delay (3000);                      //wait 3 seconds

My 35hp diesel engine only requires the starter to run for about 1 or, at most, 2 seconds. IMHO your Arduino needs to shut off power to the starter motor when the engine starts and not after a period of time.

However, you can easily test this out by manually operating the starter for 5 seconds with a stopwatch in your hand.

When humans start an engine they apply a huge amount of sub-conscious logic to the task.

...R

Thanks have adjusted down to 2 seconds and will monitor when I actually run on the generator.

ddutton:
Thanks have adjusted down to 2 seconds and will monitor when I actually run on the generator.

Sorry if I was not clear in Reply #10. What I was trying to say is that the termination of the operation of the starter motor should NOT be time based.

It should terminate when the motor starts - which means you need a system to detect that. There are lots of variables that may affect how many revolutions of the crankshaft are required before an engine starts on a particular occasion - for example air temperature or humidity or the state of charge of the starter battery. Petrol (gasoline) engines can also have problems with fuel loss in the carburettor in very hot weather so that some part of the cranking time is just pumping petrol to replenish the carburettor.

Of course it might be prudent to have a maximum starter run time to protect the starter motor in case the engine fails to start.

...R

I guess a drop in starter motor current is a good sign the engine is spinning on its own power.

I did a comprehensive auto-starter back in the 00's
And Robin is exactly right, timed ignition-start is not the way to go.

Temperature, quality of fuel and others will affect the ease of starting.

Ideally the starter will make several attempts with different sequence and timing strategies (choke, ignition-on time etc), and determine run state from some form of feedback (RPM, existing 'run' indicator etc)... the sequencing is different for diesel and gas powered engines.

AND MOST IMPORTANTLY
Regardless of manual isolation switches - ALWAYS label outlets or equipment that can be activated automatically - with the dangers and instructions on how to isolate them!

I recently posted a link to my current 3G / SMS controller at www.SL4P.net
It may be worth reprogramming this as a dedicated engine controller... any interested takers?