Off Grid Backup Engine Automation

Hey Folks,

My wife and I live off the grid, and have for 16 years and counting. While wind and sun provide most of our electrical needs there are times when we must use our Kubota EL-300 diesel engine to recharge the battery bank. Attached to the Kubota is a large frame alternator which I externally control the output via a large wire wound rheostat feeding the rotor. My thinking is that an Arduino is perfectly suited to control this setup.

The Arduino would have to constantly monitor the 12 volt battery bank voltage when active. If the voltage falls below 11.5 volts for over 20 seconds the self start Arduino program needs to initiate. At that point the currently manual employed set of relays will advance the throttle to the full open position and stop, activate the glow plug for 10 seconds and send a signal to crank the engine. If the engine fails to start the program needs to wait 20 seconds and retry. If after 4 such attempts and the engine still fails to start an alarm needs to sound and the program must stop all starting efforts. If the engine starts then end the glow plug and start cycle and then the program needs to wait for about 2 minutes for the engine to warm up. At that point the charging relay needs to engage. When the battery voltage reaches 13.5 volts the Arduino needs to close the throttle and disengage the charging relay. Then the program needs to return to simple battery monitoring in anticipation of repeating the process.

All this is now manually controlled except for the engine run detection. We simply listen for the engine to fire off. I have a set of relays in the engine room which are activated by grounding switches from inside our house. Two LEDs in our house indicate fully open and fully closed throttle which are driven by reed switches at the engine. The throttle position is driven by a geared DC motor and a relay H. bridge which is also remotely controlled from the house. Aside from an engine run condition detection all the sensors and relay activation is in place and fully functional.

So, my questions are these. What is a good method to detect a running engine? A flapper on the exhaust? A hall effect sensor with a samll magnet on the flywheel, which would also serve to generate an rpm reading? Other?

Inside our hose we have both an analogue voltage meter, which is always active, and an LM3914 that is only operational while using the engine to charge the batteries. I have a 5v buzzer attached to the 14 volt led pin of the LM3914 now so as to avoid over charging and tripping the inverter. Could the outputs of an LM3914 serve as a voltage monitor with no LEDs but rather function as inputs for the Arduino?

Thanks all,

RS

I overlooked an oil pressure monitor, which should shut down the engine if the pressure drops.

RS

Here’s some code I have been playing with today. Keep in mind this is the first and only sketch I have ever attempted, and I know it is in a very rough state. Much needs to be done yet, but I think I have a good start. Comments?

/* Arduino sketch to automate and control the backup changing system using a Kubota diesel 
 *  engine and a large frame alternator via remote control using an LM 3914 as a voltage sensor
 *  and relays for actions. Oil, engine running and temperature sensors need to be employed and are not currently
 *  installed. 18 November, 2016 
 */

int erun = 13; //detect engine run on pin D13**
int glow = 12;  // glow plug signal on pin D12
int charge = 11; // engage charging relay on pin D11
int T+ = 10 // runs throttle position until full open on pin D10
int T- = 9 // runs throttle position until full closed on pin D9
int openT = 8 // detects full open throttle on pin D8
int closeT = 7 // detects closed throttle on pin D7
int oil = 6 // detects oil pressure** on pin D6
int temp = 5 // detects engine temp too high** on pin D5
int lowV = 4 // detects battery voltage low on pin D4
int highV = 3 // detects battery voltage high on pin D3
int start = 2 //sends signal to start engine on pin D2
//** indicates no such sensor now exists.
// May need a fuel level analog input but not critical
// Need buzzer analog pin mapping

void setup()
{
  pinMode(erun, INPUT_PULLUP); // detects if engine is running or not
  pinMode(glow, OUTPUT); // sends signal to activate glow plug
  pinMode(charge, OUTPUT); // sends signal to engage charging
  pinMode(T+, OUTPUT); //sends signal to advance throttle to wide open
  pinMode(T-, OUTPUT); // sends signal to close throttle
  pinMode(openT, INPUT_PULLUP); // detect open throttle
  pinMode(closeT, INPUT_PULLUP); // detect closed throttle
  pinMode(oil, INPUT_PULLUP); // detect oil pressure
  pinMode(temp, INPUT_PULLUP); // detect over temperature
  pinMode(lowV, INPUT_PULLUP); // detect battery voltage low
  pinMode(highV, INPUT_PULLUP); // detect battery voltage high
  pinMode(start, OUTPUT); // sends signal to start engine 

//still need to define analog pins for buzzer and maybe fuel gauge 
}

void loop()
{
 if (digitalRead(lowV == LOW);   // read battery low condition on pin D4 11.5 volts
 delay (20000); // delay for 20 seconds and check voltage again
}
{if (digitalRead(lowV == LOW);
 // if starting sequence is initiated a buzzer on analog pin must sound!
 digitalWrite(T+, HIGH); // start open throttle
}
{
  if (digitalRead(openT == LOW); //read when throttle is full open on pin D10
  digitalWrite(T+, LOW); // stop throttle opening
}
{
  if (digitalRead(openT == LOW); //if throttle has opened
  digitalWrite(glow, HIGH): // energize glow plug relay
  delay (10000); // wait 10 seconds
  digitalWrite(start, HIGH); // send starter signal
  digitalRead(erun == HIGH);
  if (digitalRead(erun == LOW); // here is where I need a loop to run 4 times if engine fails to fire  //of the same starting sequence or sound alarm if all attempts fail.
}
  digitalWrite(charge, HIGH);
}
{
  if (digitalRead(highV == LOW);
  digitalWrite(closeT, HIGH)
}
// Then the sketch needs to go back and start looping in auto detect mode.

Good start.

But, your delay() things will stop the program in its tracks until the delay expires. If you want more like real time, you’ll need to google “blink without delay” or check this pdf:

<LINK_TEXT text="https://cdn-learn.adafruit.com/download … art-1.pdf
">https://cdn-learn.adafruit.com/downloads/pdf/multi-tasking-the-arduino-part-1.pdf
</LINK_TEXT>

Also, I’m pretty sure that your “if’s” will not work as you have them.

if 1=1 then;

does not determine whether you execute the next statement. The semicolon effectively terminates the option to do or not to do the next statement:

Consider:

if 1=1 then
   do_something;
do_something_else;  // this is NOT under "IF" control because it's beyond the terminating semicolon

This could also be done like this:

if 1=1 then do_something;

A multi-statement “if” would look like this:

if 1=1 then {  // curly brace begins a block of statements
   multiple_thing1;  // IS under "IF" control
   multiple_thing2;  // is ALSO under "IF" control
}  // closing curly brace end the block

Yes! I know just enough about the code structures to be frustrated. Thanks DanV. I will work on the sketch and post an update.

RS

ETA: Should I drive MOSFets, or power transistors, with my outputs so as to not overload the Nano?

I would definitely use something between the Nano outputs and the devices. I don’t have a preference but do like optoisolators since the provide the opportunity for relatively complete isolation, circuit-wise.

Would this product be able to “listen” to the sound from my Kubota engine and be used to detect the running condition distinct from the noise of just being cranked over? Is the device rugged enough to withstand an engine room environment? If it would serve these functions I have a new wish list item, and can actually help support Spark Fun! So?

Sound transducer:

https://www.sparkfun.com/products/12642

RS

theropod:

I have a saying “if you want to make a better radio, start with a better antenna.” So if you want to detect an engine running, detect the work it does. i.e., detect motion, not incidental noise. The best solution would be to monitor the motion of the output shaft.

Yes, I have been thinking on this overnight. Either a reflective IR pair, or a magnet and hall effect sensor. I could place either on the altenator pulley instead of the flywheel, and it would detect a failed belt as well. If there was no input on cranking the feedback could sound an alarm and halt the sketch. Balance wouldn’t be upset as badly as if the flywheel had a magnet attached. I could use the signal to give me a tach too after doing the math on the pulley ratio… The slide belt tensioner would make an easy firm mount for a hall effect sensor.

Having the engine and charging system in place for since we started living here I am not rushing this project. We have been getting by just fine without the automation until now. This is both a luxury and long term dream I want to see to fruition. If this community can provide a platform from which others can gain from my (our) endeavors all the better.

I have been working on my code over the past couple days. After thinking about it some I have decided to build a Murphy system. Not that I don’t trust the Arduino, but I want to build in a low oil pressure, high temperature, sensing system that will shut down the engine even if the Arduino dies. All I need to do is send the a Arduino a signal that something has gone south. I think a simple set of switches that will activate the throttle close side of the relay H bridge to shut off the engine is the safer choice.

Here’s my plan: A N/O low oil pressure switch which will energize a relay that will activate the close the throttle H bridge when the pressure falls to a given point. When the throttle closed detection reed switch, already in place, activates it will disconnect that throttle close side of the H bridge along with the charge, start and glow plug relays. When that relay trips there is a signal sent to the Arduino to alert it to the fault. This would also work for the over temperature and low fuel alarms/faults. This would reduce the Arduino input pin use.

RS

I have decided to attack this with two Arduinos. One will monitor the engine and mechanical functions and one will control the charging system. This way I can have a redundant set of sensors to tell that Arduino more than just whether the engine is running or not. A spring loaded exhaust flapper with a long lever arm and magnet/reed switch. A cooling fan flapper with an IR pair. An IR pair sensing the turning of the belt via bright spot reflection. Finally a magnet/Hall effect sensor mounted to the pulley/fan of the alternator. I can also monitor oil pressure, coolant temperature, fuel level and a few other functions with Arduino one, and have pins left over. This could make the sketches more manageable having two distinct objectives without addressing every pin on one Arduino.

The second Arduino would monitor the batteries, control the start/throttle/charge/shutdown. Arduino one would just need to tell Arduino two if there was a fault with the engine, and provide a positive signal of a running engine, and work as a multi level independent Murphy switch.