Go Back   EcoModder Forum > EcoModding > Instrumentation > OpenGauge / MPGuino FE computer
Register Now
 Register Now
 

Reply  Post New Thread
 
Submit Tools LinkBack Thread Tools
Old 04-16-2008, 11:12 AM   #31 (permalink)
dcb
needs more cowbell
 
dcb's Avatar
 
Join Date: Feb 2008
Location: ÿ
Posts: 5,038

pimp mobile - '81 suzuki gs 250 t
90 day: 96.29 mpg (US)

schnitzel - '01 Volkswagen Golf TDI
90 day: 53.56 mpg (US)
Thanks: 158
Thanked 269 Times in 212 Posts
Quote:
Originally Posted by MetroMPG View Post
So ... the external resistor isn't strictly needed for that tutorial?
Absolutely correct If your button is connecting the pin to ground, then no it isn't needed. Save your self a component and use the built in pullup resistor.

__________________
WINDMILLS DO NOT WORK THAT WAY!!!
  Reply With Quote
Alt Today
Popular topics

Other popular topics in this forum...

   
Old 04-16-2008, 11:20 AM   #32 (permalink)
Batman Junior
 
MetroMPG's Avatar
 
Join Date: Nov 2007
Location: 1000 Islands, Ontario, Canada
Posts: 22,530

Blackfly - '98 Geo Metro
Team Metro
Last 3: 70.09 mpg (US)

MPGiata - '90 Mazda Miata
90 day: 54.46 mpg (US)

Even Fancier Metro - '14 Mitsubishi Mirage top spec
90 day: 70.75 mpg (US)

Appliance car Mirage - '14 Mitsubishi Mirage ES (base)
90 day: 62.14 mpg (US)
Thanks: 4,078
Thanked 6,978 Times in 3,613 Posts
OK - thanks.
__________________
Project MPGiata! Mods for getting 50+ MPG from a 1990 Miata
Honda mods: Ecomodding my $800 Honda Fit 5-speed beater
Mitsu mods: 70 MPG in my ecomodded, dirt cheap, 3-cylinder Mirage.
Ecodriving test: Manual vs. automatic transmission MPG showdown



EcoModder
has launched a forum for the efficient new Mitsubishi Mirage
www.MetroMPG.com - fuel efficiency info for Geo Metro owners
www.ForkenSwift.com - electric car conversion on a beer budget
  Reply With Quote
Old 04-16-2008, 10:13 PM   #33 (permalink)
Batman Junior
 
MetroMPG's Avatar
 
Join Date: Nov 2007
Location: 1000 Islands, Ontario, Canada
Posts: 22,530

Blackfly - '98 Geo Metro
Team Metro
Last 3: 70.09 mpg (US)

MPGiata - '90 Mazda Miata
90 day: 54.46 mpg (US)

Even Fancier Metro - '14 Mitsubishi Mirage top spec
90 day: 70.75 mpg (US)

Appliance car Mirage - '14 Mitsubishi Mirage ES (base)
90 day: 62.14 mpg (US)
Thanks: 4,078
Thanked 6,978 Times in 3,613 Posts
Quote:
Originally Posted by dcb View Post
Sorry, I couldn't resist playing with the lcd. The library didn't work for me, wound up poking at it in arduino ide till I got somewhere.
My LCD arrived today.

Can you point me in the right direction (links?) to play around with it? It sounds from your experience like it's not straightforward.
__________________
Project MPGiata! Mods for getting 50+ MPG from a 1990 Miata
Honda mods: Ecomodding my $800 Honda Fit 5-speed beater
Mitsu mods: 70 MPG in my ecomodded, dirt cheap, 3-cylinder Mirage.
Ecodriving test: Manual vs. automatic transmission MPG showdown



EcoModder
has launched a forum for the efficient new Mitsubishi Mirage
www.MetroMPG.com - fuel efficiency info for Geo Metro owners
www.ForkenSwift.com - electric car conversion on a beer budget
  Reply With Quote
Old 04-17-2008, 01:16 AM   #34 (permalink)
dcb
needs more cowbell
 
dcb's Avatar
 
Join Date: Feb 2008
Location: ÿ
Posts: 5,038

pimp mobile - '81 suzuki gs 250 t
90 day: 96.29 mpg (US)

schnitzel - '01 Volkswagen Golf TDI
90 day: 53.56 mpg (US)
Thanks: 158
Thanked 269 Times in 212 Posts
Well, I didn't get anywhere with the 4 bit library, and it was getting annoying recompiling the library for a bunch of trial and error, so I tried this:
http://www.arduino.cc/cgi-bin/yabb2/...m=1160586800/0

I didn't get results at first and don't recall everything that was involved (predefined timings was one of the gotchas). But here are my current pin assignments and the mpguino display code. It does a good job of highlighting the sequence of events but the delays do need to be redone as status checks and pushed back into the lcd library. Note, with this code I had to hit the reset button after downloading the script or powering up sometimes.
Code:
LCD	arduino
1	ground
2	5v
3	digital 6
4	digital 4
5	digital 0
6	digital 5
7	not connected
8	not connected
9	not connected
10	not connected
11	digital 7
12	digital 8
13	digital 12
14	digital 13
15	5v
16	ground
Code:
int DI = 4; // register select RS
int RW = 0; 

int db4=7; int db5=8; int db6=12; int db7=13;
int contrast=6;
int Enable = 5; 
 
 
void tickleEnable() 
{ 
 // send a pulse to enable 
 digitalWrite(Enable,HIGH); 
 delayMicroseconds(1);  // pause 1 ms according to datasheet 
 digitalWrite(Enable,LOW); 
 delayMicroseconds(1);  // pause 1 ms according to datasheet 
}  
 
void cmdWriteSet() 
{ 
 digitalWrite(Enable,LOW); 
 delayMicroseconds(1);  // pause 1 ms according to datasheet 
  digitalWrite(DI,0); 
  digitalWrite(RW,0); 
} 
void LcdCommandWrite(int value)  
{ 
 int i = 0; 
 
    digitalWrite(db7, value & 128); 
    value <<= 1; 
    digitalWrite(db6, value & 128); 
    value <<= 1; 
    digitalWrite(db5, value & 128); 
    value <<= 1; 
    digitalWrite(db4, value & 128); 
    value <<= 1; 
    cmdWriteSet(); 
    tickleEnable(); 

    digitalWrite(db7, value & 128); 
    value <<= 1; 
    digitalWrite(db6, value & 128); 
    value <<= 1; 
    digitalWrite(db5, value & 128); 
    value <<= 1; 
    digitalWrite(db4, value & 128); 
     value <<= 1; 
    cmdWriteSet(); 
    tickleEnable(); 
} 
 
void LcdDataWrite(int value)  
{ 
 int i = 0; 
  
 digitalWrite(DI, HIGH); 
 digitalWrite(RW, LOW); 
   
    digitalWrite(db7, value & 128); 
    value <<= 1; 
    digitalWrite(db6, value & 128); 
    value <<= 1; 
    digitalWrite(db5, value & 128); 
    value <<= 1; 
    digitalWrite(db4, value & 128); 
  value <<= 1; 

    tickleEnable(); 
 
    digitalWrite(db7, value & 128); 
    value <<= 1; 
    digitalWrite(db6, value & 128); 
    value <<= 1; 
    digitalWrite(db5, value & 128); 
    value <<= 1; 
    digitalWrite(db4, value & 128); 
value <<= 1; 
    tickleEnable(); 
    delay(5);
} 
 
void setup (void)  
{ 
 pinMode(Enable,OUTPUT); 
 pinMode(RW,OUTPUT); 
 pinMode(DI,OUTPUT); 
 pinMode(db4,OUTPUT); 
 pinMode(db5,OUTPUT); 
 pinMode(db6,OUTPUT); 
 pinMode(db7,OUTPUT); 
 
 delay(100); 
 LcdCommandWrite(0x2c);  // function set: 
  delay(64);             // 4-bit interface, 2 display lines, 5x7 font 
                        // other interaces: 
                        // 0x20 = 4 bit, 1 display line 
 
 LcdCommandWrite(0x06);  // entry mode set: 
                        // increment automatically, no display shift 
 delay(20);                       
 LcdCommandWrite(0x0c);  // display control: 
                        // turn display on, cursor on, no blinking 
 delay(20);                       
 LcdCommandWrite(0x01);  // clear display, set cursor position to zero   
 
 delay(100);                       
LcdCommandWrite(0x80);  // set dram to zero (necessary?
 delay(20);       

 analogWrite(contrast,75);
 delay(20);       

} 
  int i='0';
 
void loop (void)  
{ 
   
  delay(500);                  // stop the program for some time 

  LcdCommandWrite(0x01);  // set cursor position to zero   
  delay(20);                      
  firstDisplay(); 
 
boolean asc=true;
  while(true){
    for(int x = 0; x < 256; x++){
     analogWrite(contrast,x);
     delay(8);
    }
    for(int x = 255; x >0; x--){
     analogWrite(contrast,x);
     delay(8);
    }
  };
} 
 


void firstDisplay() 
{ 
//     LcdDataWrite(value); 
     LcdDataWrite('O'); 
     LcdDataWrite('P'); 
     LcdDataWrite('E'); 
     LcdDataWrite('N'); 
     LcdDataWrite('G'); 
     LcdDataWrite('A'); 
     LcdDataWrite('U'); 
     LcdDataWrite('G'); 
     LcdDataWrite('E'); 
LcdCommandWrite(0xC9);  // C0 would be start of second line
 delay(20);       

     LcdDataWrite('M'); 
     LcdDataWrite('P'); 
     LcdDataWrite('G'); 
     LcdDataWrite('U'); 
     LcdDataWrite('I'); 
     LcdDataWrite('N'); 
     LcdDataWrite('O'); 
 }
__________________
WINDMILLS DO NOT WORK THAT WAY!!!

Last edited by dcb; 04-17-2008 at 01:23 AM..
  Reply With Quote
Old 04-17-2008, 09:44 AM   #35 (permalink)
dcb
needs more cowbell
 
dcb's Avatar
 
Join Date: Feb 2008
Location: ÿ
Posts: 5,038

pimp mobile - '81 suzuki gs 250 t
90 day: 96.29 mpg (US)

schnitzel - '01 Volkswagen Golf TDI
90 day: 53.56 mpg (US)
Thanks: 158
Thanked 269 Times in 212 Posts
Here is a data sheet on the LCD controller. The LCD itself has a 5x10 character format.
http://www.electronic-engineering.ch...cd/hd44780.pdf

One of the possible tweaks might be to create custom characters that use the whole 5x8 character box. They could be larger numbers perhaps for easier reading or maybe custom characters to conserve display real estate , i.e. MPG might have this in front of it instead of three characters:
(Note, just realized the lcd is 5x8, not 5x10!!!)

(just using paintbrush at 800% zoom)

I don't know how many user defined characters are on this display yet, however.
__________________
WINDMILLS DO NOT WORK THAT WAY!!!

Last edited by dcb; 05-01-2008 at 12:59 AM.. Reason: changed 5x10 to 5x8
  Reply With Quote
Old 04-22-2008, 12:23 AM   #36 (permalink)
FuelSipper
 
Join Date: Mar 2008
Location: Dallas, TX
Posts: 99

HondaHokie - '95 Honda Accord DX 4 door
90 day: 26.91 mpg (US)
Thanks: 0
Thanked 8 Times in 3 Posts
I've gotten my LCD to work. It actually is a pretty nice display. Can't wait to see it posting some real data. dcb, i like the little fading feature you setup in the code.

Last edited by larrydag; 04-22-2008 at 12:30 AM..
  Reply With Quote
Old 04-22-2008, 08:27 AM   #37 (permalink)
dcb
needs more cowbell
 
dcb's Avatar
 
Join Date: Feb 2008
Location: ÿ
Posts: 5,038

pimp mobile - '81 suzuki gs 250 t
90 day: 96.29 mpg (US)

schnitzel - '01 Volkswagen Golf TDI
90 day: 53.56 mpg (US)
Thanks: 158
Thanked 269 Times in 212 Posts
Very Cool

The only thing to add to it is LCD pin 15 (Backlight power) should probably be controlled by an arduino pin and a transistor, so you can controll the brightness from a menu option, and turn off the LED when the ignition is off.
__________________
WINDMILLS DO NOT WORK THAT WAY!!!
  Reply With Quote
Old 04-22-2008, 10:05 AM   #38 (permalink)
FuelSipper
 
Join Date: Mar 2008
Location: Dallas, TX
Posts: 99

HondaHokie - '95 Honda Accord DX 4 door
90 day: 26.91 mpg (US)
Thanks: 0
Thanked 8 Times in 3 Posts
Do you mean turn off the LCD when the ignition is off? I assume you mean that you would want a pin to turn off the LCD when you want to release the keys from the igninition. Otherwise you want the LCD to stay on when you cut the engine during P&G'ing. Is this correct?

Otherwise why not use a power source from the car that cuts off when the keys are in the OFF position.

Last edited by larrydag; 04-22-2008 at 10:12 AM..
  Reply With Quote
Old 04-22-2008, 09:29 PM   #39 (permalink)
dcb
needs more cowbell
 
dcb's Avatar
 
Join Date: Feb 2008
Location: ÿ
Posts: 5,038

pimp mobile - '81 suzuki gs 250 t
90 day: 96.29 mpg (US)

schnitzel - '01 Volkswagen Golf TDI
90 day: 53.56 mpg (US)
Thanks: 158
Thanked 269 Times in 212 Posts
You have a point about the key, I had kill switch in my head so it didn't occur to me that folks might be turning off the ignition.

I need to list out my assumptions I think.

1. The arduino is powered by battery power. Because:
A. there are a limited number of eeprom writes, the trips should be saved when the key is turned off, but the arduino can't do that if you are turning off it's power also.

B. there are some sleep modes for the arduino that it could utilize when the ignition is off, but I don't think the drain will be terribly noticable.

2. The arduino should sense the ignition power, Because:
A. it needs to write out the current state of the trips to the eeprom on the ignition off event.

B. If the arduino has control of the LED Backlight (i.e. fancy schmancy menu brightness option) it can turn it off on the ignition off event and save ~200 milliamps. This adds one component (transistor) to the design. Switching it with the ignition directly will add one component in the form of a resistor to limit the current, and not give user control.

So I was thinking have the arduino turn off the LED, since the arduino was already connected to ignition power (in my head) and it was a simple task to have a menu driven brightness. The LCD only takes about ~4ma so I'm not worried about it yet.

But, maybe, it just has to be a (hokey) delay thing. Like if the car hasnt shown any rpm or travelled any distance in, say, 10 minutes, then it saves the trips in their 10 minutes ago state, and turns off the backlight? Saves us a ignition power pin.
__________________
WINDMILLS DO NOT WORK THAT WAY!!!
  Reply With Quote
Old 04-29-2008, 12:18 AM   #40 (permalink)
dcb
needs more cowbell
 
dcb's Avatar
 
Join Date: Feb 2008
Location: ÿ
Posts: 5,038

pimp mobile - '81 suzuki gs 250 t
90 day: 96.29 mpg (US)

schnitzel - '01 Volkswagen Golf TDI
90 day: 53.56 mpg (US)
Thanks: 158
Thanked 269 Times in 212 Posts
button interrupts have been sorted out.

Phew, finally got the buttons to be read reliably with interrupts in arduino IDE. No polling required, though we might want to elaborate on the debouncing at some point. This also means there are a lot more pins for doing external interrupts with than arduino allows "out of the box", though only pins 2&3 do RISING/FALLING, the rest are state change, not a big deal.


Code:
#include <avr/interrupt.h>    
#include <avr/io.h>  

int lbuttonPin = 17; // Left Button, on analog 3 
int mbuttonPin = 18; // Middle Button, on analog 4 
int rbuttonPin = 19; // Right Button, on analog 5 

//button signals are inverted (internal pullup resistor), so true is not pressed
boolean  lbutton = true;
boolean  mbutton = true;
boolean  rbutton = true;
 
//attach the interrupt 
ISR( PCINT1_vect ){ 
  PCICR &= !(1 << PCIE1);//disable interrupts in the interrupt
  if (!digitalRead(lbuttonPin)) lbutton = false;
  if (!digitalRead(mbuttonPin)) mbutton = false;
  if (!digitalRead(rbuttonPin)) rbutton = false;
  PCICR |= (1 << PCIE1);
} 
 
void setup() { 
  Serial.begin(9600);
  pinMode( lbuttonPin, INPUT ); 
  pinMode( mbuttonPin, INPUT ); 
  pinMode( rbuttonPin, INPUT ); 

//"turn on" the internal pullup resistors
  digitalWrite( lbuttonPin, HIGH); 
  digitalWrite( mbuttonPin, HIGH); 
  digitalWrite( rbuttonPin, HIGH); 

//low level interrupt stuff
  PCICR |= (1 << PCIE1); 
  PCMSK1 |= (1 << PCINT11); 
  PCMSK1 |= (1 << PCINT12); 
  PCMSK1 |= (1 << PCINT13);   
} 
 
void loop() {    
  //print out what buttons have been pressed
  if(!lbutton) Serial.print("lbutton");
  Serial.print(",");
  if(!mbutton) Serial.print("mbutton");
  Serial.print(",");
  if(!rbutton) Serial.print("rbutton");
  Serial.println("");
  
  //reset the buttons
  lbutton = true;
  mbutton = true;
  rbutton = true;
  
  delay(500);
}

__________________
WINDMILLS DO NOT WORK THAT WAY!!!
  Reply With Quote
Reply  Post New Thread






Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2024, vBulletin Solutions Inc.
Content Relevant URLs by vBSEO 3.5.2
All content copyright EcoModder.com