Pages: [1] 2   Go Down
Author Topic: Automatic engine/generator control  (Read 5042 times)
0 Members and 2 Guests are viewing this topic.
Corvallis, Montana
Offline Offline
Newbie
*
Karma: 0
Posts: 6
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

I am a newbee
I live "off grid" in western Montana and would like to use the Arduino to start a diesel engine/generator and charge a battery bank.

I would like to detect when the battery bank is low and automatically start the charging cycle. I feel sure there is someone out there that has created the code to do this job but don't know where to look. Any help would be greatly appreciated.
Logged

0
Offline Offline
Tesla Member
***
Karma: 148
Posts: 9754
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

You need to provide specifics of the electrical and mechanical controls for your equipment and how they operate before code can be suggested.
Logged

Consider the daffodil. And while you're doing that, I'll be over here, looking through your stuff.   smiley-cool

Corvallis, Montana
Offline Offline
Newbie
*
Karma: 0
Posts: 6
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Thanks for responding to my call for help.

The goal is to have the Yanmar diesel engine start automatically when the battery voltage reaches the low voltage set point (22 VDC). The battery bank is made up of 2 strings of 20 cells each of NiFe batteries with each string wired in series to provide 600 Amp Hours @ 24 volts DC. Fully charged when 33 volts is reached. These batteries need to charge at a C5 rate or 120 amps @ 33 volts.

The starting sequence:
    when the battery voltage drops <= set point
    glow plugs on for 90 seconds
    starter spins engine for 30 seconds
     if engine does not start
         try again in 60 seconds
      try this routine 3 times then sound alarm if engine does not start

     if engine starts
          when engine oil pressure > 5 psi ... shut off starter
          set engine warm up to 750 RPM for 3 minutes
          monitor engine oil pressure and water temp
               shut down engine if oil pressure drops or water temp goes too high
          read generator amp output via signal from shunt
          read generator volts
     when battery volts reach 33 VDC
          reduce engine RPM for 3 minutes
          shut down engine
Ideally the program will report to the computer screen
          engine rpm
          amps and volts output
          engine oil pressure and temp
          engine run time for this session
          total amp hours generated

This might be more information than you need but will give a better idea of what I am trying to achieve.

Thanks in advance for any and all help

Mac
Logged

Offline Offline
Newbie
*
Karma: 0
Posts: 13
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

33 volts is high for a 24 volt alternator to put out.
Logged

Greenville, IL
Offline Offline
Edison Member
*
Karma: 15
Posts: 1330
Warning Novice on board! 0 to 1 chance of errors!
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset


 Arduino voltmeter
http://www.google.com/search?q=arduino%20voltmeter&ie=utf-8&oe=utf-8&aq=t&rls=org.mozilla:en-US:official&client=firefox-a&source=hp&channel=np

tachometer
http://www.google.com/search?q=arduino%20voltmeter&ie=utf-8&oe=utf-8&aq=t&rls=org.mozilla:en-US:official&client=firefox-a&source=hp&channel=np#hl=en&client=firefox-a&hs=URL&rls=org.mozilla:en-US%3Aofficial&channel=np&sclient=psy-ab&q=arduino+tachometer&oq=arduino+tacho&aq=0&aqi=g4&aql=1&gs_l=serp.1.0.0l4.53134.56178.0.57990.14.14.0.0.0.7.1128.4938.0j7j1j2j0j3j0j1.14.0.eish.1.0.0.JFd-r3sMr1U&pbx=1&bav=on.2,or.r_gc.r_pw.r_qf.,cf.osb&fp=5878b6447359618&biw=1024&bih=638&safe=images

Oil pressure
http://www.google.com/search?q=arduino%20voltmeter&ie=utf-8&oe=utf-8&aq=t&rls=org.mozilla:en-US:official&client=firefox-a&source=hp&channel=np#hl=en&client=firefox-a&hs=H7f&rls=org.mozilla:en-US%3Aofficial&channel=np&sclient=psy-ab&q=arduino+oil+pressure&oq=arduino+oil+pressure&aq=f&aqi=g2&aql=1&gs_l=serp.12..0l2.0.0.2.15032.0.0.0.0.0.0.0.0..0.0.eish.1.0.0.viNBCgLIt-I&pbx=1&bav=on.2,or.r_gc.r_pw.r_qf.,cf.osb&fp=5878b6447359618&biw=1024&bih=638&safe=images
Logged


New Jersey
Offline Offline
Faraday Member
**
Karma: 72
Posts: 3763
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

This would be a good candidate for a state machine - search the forums for examples.

Edit: Such as this one: http://arduino.cc/forum/index.php/topic,106335.0.html
« Last Edit: June 18, 2012, 12:38:57 pm by wildbill » Logged

Newcastle, NSW, Australia
Offline Offline
Newbie
*
Karma: 0
Posts: 33
Just a mechanic
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Interesting project idea!

How are you controlling engine speed of the generator unit?

Also, you'll probably find you'll get oil pressure > 5psi just on the starter, especially when the oil is cold. Might need a higher set point, or use an engine RPM signal or the output of the alternator/generator to signal 'engine started' or 'engine running' to the controller.

Have fun and I look forward to seeing this project progress!
Ryan.
Logged

Corvallis, Montana
Offline Offline
Newbie
*
Karma: 0
Posts: 6
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Thanks for all the response to my request for help.

Regarding the signal from the oil pressure to cut power to the starter ... there are other options that could be used such as RPM of the engine, voltage output from the AC generator, voltage output from the engine alternator, etc. At this point .. don't know which one would be best ... but there are options.

Being a "newbee" I am not familiar with the term "state machine". some education would appreciated

33 volts is what is the ideal for charging my bank of nickle/iron batteries. I plan to obtain this voltage via an AC transformer prior to the rectifier changing to DC

I am currently working on learning some basic code to program the Arduino. Getting the picture on most of it but have hit a glitch on getting the "if" statement to work in my program. Here is my code so far ... any help would be appreciated



/* The goal is to have the Yanmar engine start automatically when the battery voltage reaches the low voltage set point.
The battery bank is made up of 2 strings of 20 cells each of NiFe batteries with each string wired in series
to provide 600 Amp Hours @ 24 volts DC. Fully charged when 33 volts is reached */
 

     
void setup()
  {
    //for (int count = 1; count <= 10; count ++);
 }
 
 
 void loop()
 {
 // for (int count = 1; count <= 3; count ++);
   { 
     int  glowPlug=8;
     int starter = 7;
     int oilPres = 2;
     int count =0;
     
     pinMode(glowPlug, OUTPUT);   // initialize the glowPlug pin as an output (RED).
     pinMode(starter,OUTPUT);     // initialize the starter pin as an output (YELLOW)
     pinMode(oilPres,OUTPUT);     // initialize the engine oil pressure as an output (GREEN)
     
     for ( count = 1; count <= 3; count ++);
      {
           digitalWrite(oilPres, HIGH);    //yellow LED turn on
           delay(800);
           digitalWrite(oilPres, LOW);    //yellow LED turn off
             
           digitalWrite(glowPlug, HIGH);  //red LED turn on
           delay(400);
           digitalWrite(glowPlug, LOW);   // red LED turn off
         
           digitalWrite(starter, HIGH);    //green LED turn on
           delay(300);
           digitalWrite(starter, LOW);    //yellow LED turn off
           delay (2000);
     }
   
   }
 }

Thanks in advance for all your help and encouragement

Mac
Logged

Greenville, IL
Offline Offline
Edison Member
*
Karma: 15
Posts: 1330
Warning Novice on board! 0 to 1 chance of errors!
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset


 First, you need to use code tags. Look for the # button above the smiley faces.
Code:
code goes here


 Here is a general rule for a beginner when writing your code. Keep in mind this rule is just to help you get started. Once you get a better understanding you will find reasons to do things differently. You need to write your code in this format:
Code:
put your definitions here such as:
int  glowPlug=8;

void setup()
{
put anything that says pinMode here:
  pinMode(glowPlug, OUTPUT);   // initialize the glowPlug pin as an output (RED).
}


void loop()
{
  put the code here that you want to run over and over
    digitalWrite(oilPres, HIGH);    //yellow LED turn on
  delay(800);
  digitalWrite(oilPres, LOW);    //yellow LED turn off
}


 I recommend that you start by trying the example called "blink without delay". Really, you should try as many examples that you have the hardware for. They will help you get a quick understanding of how the code works.
Logged


Corvallis, Montana
Offline Offline
Newbie
*
Karma: 0
Posts: 6
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

I have watched a bunch of videos and read a considerable amount regarding Adruino programing. Successfully written code for simple sketches that have worked just fine.

However, have been working on this code for over a week and the only way I could get it to work was with the above code. I understand that this is not the correct procedure but ....

Here is the message I get when I try to compile the following code

I feel sure there is some simple thing I am overlooking but would appreciate any help

Yanmar_start_3:24: error: 'oilPres' was not declared in this scope
Yanmar_start_3:28: error: 'glowPlug' was not declared in this scope
Yanmar_start_3:32: error: 'starter' was not declared in this scope

void setup()
  {
   
     int  glowPlug=8;    //sets glowPlug to pin 8
     int starter = 7;    //sets starter to pin 7
     int oilPres = 2;    //sets oilPress to pin 2
     
     
     pinMode(glowPlug, OUTPUT);   // initialize the glowPlug pin as an output (RED).
     pinMode(starter,OUTPUT);     // initialize the starter pin as an output (YELLOW)
     pinMode(oilPres,OUTPUT);     // initialize the engine oil pressure as an output (GREEN)
  }
 
 
 void loop()
 {         
    // for ( count = 1; count <= 3; count ++);
         
           digitalWrite(oilPres, HIGH);    //green LED turn on
           delay(800);
           digitalWrite(oilPres, LOW);    //green LED turn off
             
           digitalWrite(glowPlug, HIGH);  //red LED turn on
           delay(400);
           digitalWrite(glowPlug, LOW);   //red LED turn off
         
           digitalWrite(starter, HIGH);    //yellow LED turn on
           delay(300);
           digitalWrite(starter, LOW);    //yellow LED turn off
           delay (2000);
 }
 
Logged

New Jersey
Offline Offline
Faraday Member
**
Karma: 72
Posts: 3763
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

The compiler is complaining that those variables aren't declared because you have made them local to setup. This should be better:
Code:
     int  glowPlug=8;    //sets glowPlug to pin 8
     int starter = 7;    //sets starter to pin 7
     int oilPres = 2;    //sets oilPress to pin 2

void setup()
  {
     pinMode(glowPlug, OUTPUT);   // initialize the glowPlug pin as an output (RED).
     pinMode(starter,OUTPUT);     // initialize the starter pin as an output (YELLOW)
     pinMode(oilPres,OUTPUT);     // initialize the engine oil pressure as an output (GREEN)
  }
 
 
 void loop()
 {         
    // for ( count = 1; count <= 3; count ++);
         
           digitalWrite(oilPres, HIGH);    //green LED turn on
           delay(800);
           digitalWrite(oilPres, LOW);    //green LED turn off
             
           digitalWrite(glowPlug, HIGH);  //red LED turn on
           delay(400);
           digitalWrite(glowPlug, LOW);   //red LED turn off
         
           digitalWrite(starter, HIGH);    //yellow LED turn on
           delay(300);
           digitalWrite(starter, LOW);    //yellow LED turn off
           delay (2000);
 }
 
Logged

Corvallis, Montana
Offline Offline
Newbie
*
Karma: 0
Posts: 6
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Thanks for all your help .. Thanks to all of you I have my code working well so far

The next step is to come up with a way to read the RPM of my diesel engine driving the generator. A while back I purchased a hand held RPM meter that seems to work pretty well. A piece of reflective tape is stuck to something that spins (in my case it is attached to the generator drive pulley). There is an opaque red light that comes from the hand held and when aimed at the reflective tape the RPM reading is recorded.

From what I have read there are various ways to receive a signal from a spinning object. However, being a novice at all this and being without any electronic background I need help selecting the best and most economical method to read the RPM that I can feed into the Arduino.

I feel sure there is a logical answer to this challenge and someone in this group has the answer

Thanks in advance for your help
Logged

Offline Offline
Newbie
*
Karma: 1
Posts: 26
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset


From what I have read there are various ways to receive a signal from a spinning object. However, being a novice at all this and being without any electronic background I need help selecting the best and most economical method to read the RPM that I can feed into the Arduino.

IMO the most accurate and inexpensive way to measure RPM is to use a Hall Effect sensor.  These can be purchase for less than 1 USD.  The output is normally open collector and in the presence of a magnetic field will pull the output low.  I use a pullup resistor to get a 0-5v TTL level signal to feed the Arduino.

Keep in mind there are several types of Hall-Effect sensors, so you will need to do some research to get one that is appropriate to your application.
Logged

Offline Offline
Full Member
***
Karma: 0
Posts: 115
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

What model Yanmar are you using?  I would be surprised if it did not already have a sensor for rpm or a hole to put one in.  Check other manuals for more highly integrated units of the same displacement/configuration as even if you have a pretty bare block they probably used the same block casting for more integrated gen sets marine motors etc.  Assuming they did that's probably your best choice to get RPM data.
Logged

Corvallis, Montana
Offline Offline
Newbie
*
Karma: 0
Posts: 6
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

My Yanmar is a 3 cyl with a cast iron block & head that I purchased used. It does not have a governor and I suspect the original use might have been intended for a tractor or some other implement. there is a number  T767
Don't know if this is any help.
The engine came complete with generator, starter, radiator, etc.
Any idea where would I look for a tachometer signal sending unit or a place for the same?
Logged

Pages: [1] 2   Go Up
Jump to: