Arduino WVO ECU on a Breadboard!

I understand that most people will not find this post too exciting … but I am excited!

I have been working on an ECU (electronic control unit or more simply computer) for the WVO system.  My current operating schematic (ECU_schem) is as shown in this post.

I finally got some of the parts laid out on a breadboard and tested it this evening … and it worked!  The Arduino controller and circuit:

  1. controlled an automotive relay (turned it off and on),
  2. monitored the variable resistance from the fuel sending unit (in other words read the level of oil in the WVO tank),
  3. and operated off of a 12 volt battery.
Item 3 is actually of the most concern to me right now because being hooked up to a car’s electrical system is actually a pretty harsh environment for the Arduino.  The alternator generates a lot of spikes and noise that can damage the circuit if not accounted for.  I will be curious to see how this part of the circuit works when connected to the running vehicle.  The parts in the circuit dealing with regulating the voltage from the car include:
  • L1 – an inductive coil that is supposed to reduce electrical noise generated by the alternator (the value for this may be off … I was aiming for 40 microH and wound up with a 100 microH part),
  • D4 – A zener diode that should limit voltage spikes to 15V (apparently the alternator can spike up to 20 volts … which would definitely be bad for the Arduino),
  • D5 – A diode to prevent an incorrectly connected battery from damaging the Arduino,
  • U2 – a 9 volt voltage regulator … this is not necessary for the Arduino as it should be able to regulate the voltage provided after D5 … I wanted a constant 9 volts for any analog inputs I add … the analog inputs use a voltage divider to read a value and if this voltage is variable (like what is coming off the battery) the readings will fluctuate,
  • C1-C4 – Capacitors for the voltage regulator U2.
Item 1 was relatively straight forward.  I am using a digital output from the Arduino to turn on a transistor and switch an automotive relay.  An automotive relay is probably massive overkill for what I am doing … but it is definitely safe.  You could also apparently do the same thing with a MOSFET transistor and skip the relay … I was unsure of this so stuck with the automotive relay.  I will need at least two of these circuits to control the two electric WVO valves.  Some notes on the parts used here:
  • R2 is a pull down resistor that guarantees that if the controller is not working the relay will not click on,
  • D2 is a reverse biased diode that protects against a current spike when the relay is turned off,
  • Q2 is an NPN transistor used with an Arduino digital output pin to switch the relay,
  • R1 limits the current drawn from the Arduino pin,
  • The pin labelled 37 on the automotive relay should read 87.
Item 2, the voltage divider, has been tested and works.  I will probably use a smaller resistor here so that I get a larger range of readings on the Arduino anolog input.  I will need at least 3 of these voltage dividers (on 3 separate input pins to monitor temperature, pressure and oil level).
  • R4 is a series resistor again used to protect the Arduino,
  • R3 is the fixed resistor for the voltage divider and I will probably use a smaller resistor here (300-500 ohms?),
  • R5,R6,R7 are the variable resistors for the voltage dividers for the analog readings. (the sending units)
Not shown in the circuit is the LCD display that I connected to the breadboard.  The LCD that I used is pretty generic and I followed the tutorial at http://arduino.cc/en/Tutorial/LiquidCrystal to get it working.  Ultimately, I want to get the Arduino talking to my Android based phone and I think I will use bluetooth for that initially.  I may leave the LCD in so that there is always some interface to the WVO controller if the phone is not in the car … that also means that I should have a few buttons connected to the controller.
The next step is to solder a board and test it in the car … I am getting closer!
The testing code I used on the Arduino is:
// include library code
#include <LiquidCrystal.h>

// initialize the library with the numbers of the interface pins
LiquidCrystal lcd(12, 11, 5, 4, 3, 2);

  /*
   Proc: lcdInit - Initialize the LCD display
   Returns: initialized LCD object
 
   Initialize a 16x2 LCD display.  The LiquidCrystal
   library works with all LCD displays that are compatible with the 
   Hitachi HD44780 driver. There are many of them out there, and you
   can usually tell them by the 16-pin interface.
 
  The circuit:
 * LCD RS pin to digital pin 12
 * LCD Enable pin to digital pin 11
 * LCD D4 pin to digital pin 5
 * LCD D5 pin to digital pin 4
 * LCD D6 pin to digital pin 3
 * LCD D7 pin to digital pin 2
 * LCD R/W pin to ground
 * 10K resistor:
 * ends to +5V and ground
 * wiper to LCD VO pin (pin 3)

 */

void lcdInit () {
  // set up the LCD's number of columns and rows: 
  lcd.begin(16, 2);

  // Print a message to the LCD.
  lcd.print("Initializing");

  return;
}

void lcdWriteMessage (String str, int iLine)
{
  // set the cursor to column 0, line 1
  // (note: line 1 is the second row, since counting begins with 0):
  lcd.setCursor(0, iLine);
  // print the number of seconds since reset:
  lcd.print(str);
}

/*
 * Notes: 2200 ohm pullup resistor (13 full ; 102 empty)
 *        220 ohm pullup resistor (183 full ; 544 empty)
 *        10 K pullup resistor (1 full ; 22 empty)
 */

int iFuelLevelInput = A0; // a0
int iRelayOutput = 8;     // D8
 
void setup(void) {
  // Setup the pins
  pinMode(iRelayOutput, OUTPUT);
  pinMode(iFuelLevelInput, INPUT);
  
  // We'll send debugging information via the Serial monitor
  Serial.begin(9600);

  // Set the levels of the output pins
  digitalWrite(iRelayOutput, LOW);  
  
  lcdInit();
}
 
void loop(void) {
  int iFuelLevel;
  
  iFuelLevel = analogRead(iFuelLevelInput);  
 
 lcdWriteMessage("Fuel Lvl: ", 0);
 lcd.print(iFuelLevel);
 
  lcdWriteMessage("ON ", 1);
 digitalWrite (iRelayOutput, HIGH);
 delay(1000);
 lcdWriteMessage("OFF", 1);
 digitalWrite (iRelayOutput, LOW);
 delay (1000);
}

Delica WVO Liftoff!


After weeks of work it was pretty anticlimactic … no flames, no loud woosh, no G-force.

On the way into Kamloops this morning (after the engine had warmed up) I flipped the switch labelled WVO (waste vegetable oil) on the dashboard to ‘Oil’ and … nothing happened.  I kept driving down the highway but Sandra and I kept glancing at one another.  Finally, I couldn’t take it anymore, “Do you think its working?”  … Sandra’s reply, “Don’t know”.  It was all I could do not to pull it off the road after 15 kilometres, pop the hood and check to see if the WVO valves were on.

I didn’t pull over … we were running late.  Darfield and Little Fort (we live in Darfield) had a sixteen hour power outage starting yesterday at 3:00 pm (heavy winds … trees on the power lines).  We spent yesterday evening cold and dark, and got up at 3:30 am this morning to rescue Stephen’s fish.  He has already lost a couple of fish and was very worried that the tank would get too cold.  By early morning it was very cold in the house so we did what we could to keep the tank warm.  I am somewhat embarrassed to say that we ended up moving the tank into the car and running it to save the fish … the fish are alive but I do not know what this says about environmental concerns in the face of adversity!  Regardless, I was not going to tell an agitated twelve year old boy to suck it up … life happens.  Of more concern, had it been a little colder outside it would have been more than the fish bailing in favour of fossil fuelled warmth.  Our pipes would have frozen and we would have been in a bit of trouble.  Makes finishing the earthsip in the new year that much more attractive!  It was a bit of a rush this morning when the power came back on to re-prime the water pump and cleanup.  Like I said, we were running late …

The good news is that the diesel gauge did not quiver or drop on our drive in this morning.  So, unless we’ve discovered cold fusion I think the WVO system is working.  We did not notice a significant difference in performance when on WVO; acceleration seemed fine and the engine was steady.  We also drove back on WVO so our total distance on WVO so far is about 180 kilometres.

I really do hope to document the conversion in more detail … hopefully over the next couple of weeks.

I am now thinking about an ECU (electronic control unit) for the WVO system. Initially, I will use it to control/monitor the WVO system (WVO fuel level, valve controls, temperature and pressure).

I am currently using a 3 position toggle to control the valves and in-line heater manually. I have installed a fuel sender in the tank but it is not yet hooked up to anything.

My intention is to use an Arduino controller as the ECU … thinking of hooking it up to an iPod or Android cellphone and use the phone’s touch screen as the display and interface. I’ve also thought about interfacing to the OBD-II plug of the van but not sure how useful this information might be.

Regardless, my initial thoughts for an ECU are summed up in the attached diagram.  It is pretty rough; I have not confirmed parts and I have only shown one switched control output and the analog input to read the fuel sending unit.  But it is a start.  I have also hooked up the fuel sending unit to the Arduino and tested that portion of the circuit … it works. I am not sure how far I will get on this before we start our road trip … there is a lot to do.

 

I’ve now managed to use the words earthship, Arduino and WVO ALL in the same post … life is good!

My first project: talking to a Bluetooth Enabled Arduino Uno

In my last post I described setting up a development environment for working with the Arduino Uno micro controller.

This post describes my first project; getting an Arduino connected to a bluetooth modem to talk to my Android based cell phone.  the parts I used for this project include:

  • 1 x Arduino Uno,
  • 1 x Sparkfun Electronics Bluetooth Mate Silver modem board,
  • 1 x 40 pin connecter,
  • 2 x 220 ohm resistors,
  • 2 x 5mm LED’s (green, yellow),
  • 1 x breadboard,
  • wire connectors,
  • 9 volt DC telephone wall transformer re-wired so that positive voltage is in centre of jack.

The following is an image (done with the Fritzing software package) of my breadboard layout for this project.

My first step was to solder a 6 pin connector (trimmed from the 40 pin connector) to the modem board.  I used a straight pin connector, but it would make more sense to use a 90 degree connector I think.

After the connector was soldered to the modem board I laid out the circuit shown above.

My sketch (the code I used to control the Arduino is included.  Click on this link (boardtest).

I tested the board layout and the code by initially leaving the Rx Tx lines to the modem board disconnected.  I was then able to use the Arduino Serial Monitor to emulate sending and receiving data between the Uno and the modem.  Remember to reset the Serial Monitor to communicate at the same baud rate as is set in the setup() function of the sketch (Serial.begin(115200);).  Otherwise you will just see gibberish on the communication link.

The Sparkfun Electronics modem communicates at 115200 by default.  Unless you change this speed you must match it (as is done in the setup() function).  I struggled with this problem for a long time until I figured it out; the modems were paired and connected, but only gibberish was communicated between the two boards.

After the board was laid out and the sketch was uploaded and tested via the Arduino serial monitor I connected the Tx Rx lines to the modem and connected the Arduino to the external power supply.  I then performed the following steps:

  1. On my cell phone I paired to the Arduino Modem board (passcode 1234),
  2. On my cell phone I launched the btterm application and connected to the modem board. (If this is successful the led on the modem board will go from blinking red to solid green),
  3. I then used the btterm application to send text to the modem and watched the LED’s change from low to high depending on what was pressed.

Eventually it all worked!  The hardest part of this project was getting the modems communicating to each other.

Some references I found on the internet:

  • https://www.orangezebra.eu/wordpress/?p=43
  • http://wiring.org.co/learning/tutorials/bluetooth/
  • https://www.orangezebra.eu/wordpress/?p=73
  • http://arduino.cc/en/Tutorial/Blink
  • http://www.homeroasters.org/php/forum/viewthread.php?thread_id=2154
  • http://www.arduino.cc/cgi-bin/yabb2/YaBB.pl?num=1240951777
  • http://forum.sparkfun.com/viewtopic.php?f=13&t=20344&p=97668#p97668
  • http://www.jhwarren.com/bluetooth-mate/