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-29-2008, 08:28 AM   #41 (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: 157
Thanked 264 Times in 207 Posts
Same thing, only tighten up the interrupt handler

doing digital reads in an interrupt seems kind of frowned on so I made ISR( PCINT1_vect ) as small as I could in this version. It does exactly the same thing as the previous post, just takes a litle more effort to move the pins around.

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

int lbuttonBit = 8; //  pin17 is a bitmask 8 on port C  
int mbuttonBit = 16; // pin18 is a bitmask 16 on port C  
int rbuttonBit = 32; // pin19 is a bitmask 32 on port C  

//pretend we start with upressed buttons
int buttonpins = lbuttonBit + mbuttonBit + rbuttonBit;

//attach the interrupt 
ISR( PCINT1_vect ){ 
  buttonpins &= PINC;//bypassing digitalRead for interrupt performance
} 
 
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 enable stuff
  PCICR |= (1 << PCIE1); 
  PCMSK1 |= (1 << PCINT11); 
  PCMSK1 |= (1 << PCINT12); 
  PCMSK1 |= (1 << PCINT13);   
  
} 
 
void loop() {    

  //print out what buttons have been pressed
  if(!(buttonpins&lbuttonBit)) Serial.print("lbutton");
  Serial.print(",");
  if(!(buttonpins&mbuttonBit)) Serial.print("mbutton");
  Serial.print(",");
  if(!(buttonpins&rbuttonBit)) Serial.print("rbutton");
  Serial.println("");
  
  //reset the buttons
  buttonpins = lbuttonBit + mbuttonBit + rbuttonBit;

  delay(1000);
}

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

Other popular topics in this forum...

   
Old 04-29-2008, 08:56 AM   #42 (permalink)
Batman Junior
 
MetroMPG's Avatar
 
Join Date: Nov 2007
Location: 1000 Islands, Ontario, Canada
Posts: 21,007

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

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

Winter beater Metro - '00 Chevrolet Metro
90 day: 73.57 mpg (US)
Thanks: 2,821
Thanked 5,668 Times in 2,927 Posts
Man, I'm falling behind (still haven't hooked up my LCD). But happy to see some code (buttons) that I can read at a glance. :P Thanks for commenting it nicely - I've collaborated on other projects before and people never seem to want to comment their stuff properly ("considerately" may be a better word).
__________________
Latest mods test: 15 mods = 15% MPG improvement: A-B test, 2007 Honda Civic 1.8L, 5-speed
Ecodriving test:
Manual vs. automatic transmission MPG showdown: Nissan Micra 1.6L



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 05-01-2008, 12:19 AM   #43 (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: 157
Thanked 264 Times in 207 Posts
update, the display has a 5x8 character box. It looks like there is 8 (not 16)user defined characters.
__________________
WINDMILLS DO NOT WORK THAT WAY!!!

Last edited by dcb; 05-01-2008 at 01:00 AM..
  Reply With Quote
Old 05-01-2008, 01:03 PM   #44 (permalink)
Master EcoModder
 
Join Date: Apr 2008
Location: Earth
Posts: 303

Pushrod - '02 Chevrolet Cavalier
Thanks: 0
Thanked 8 Times in 4 Posts
One thing about non-tactile buttons...

In a car, they get old FAST. Touch screens and the like were cool when they first came out, but they're devoid of any tactile feedback. When I'm driving my car, I want to know that my input was received without having to look at whatever device I'm using. The car itself demands enough of my attention.

Another thing is that I may want to have my finger on the button without actually activating it. For example, on a CD player, if I am scanning through tracks, I want my finger to remain in the same place, but I want to hear a song for a few seconds before I skip it. With touch button, I have to withdraw my finger, then who knows where it's going to float off to with the motion in the car, vibration, etc. Plus holding your arm up in space isn't exactly comfortable. For my scangauge, I might want to reset my trip MPG as I pass a sign post. This requires that I know where my finger is and that I can activate the button at a precise moment, without having to look at it.

GPS devices have a good reason to use touch input. Stereos and MPG gauges do not.

/rant
  Reply With Quote
Old 05-01-2008, 07:37 PM   #45 (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: 157
Thanked 264 Times in 207 Posts
Agreed about the buttons, especially if you want to have your finger on the button for doing some testing/calibration (i.e. hit it right when we pass this mile marker, etc).
__________________
WINDMILLS DO NOT WORK THAT WAY!!!
  Reply With Quote
Old 05-04-2008, 12:30 AM   #46 (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'm not getting a warm fuzzy from my freeduino device and LCD. I tried firing it up again and it took several resets before I got it working again. Is this going to be typical after being off?
  Reply With Quote
Old 05-04-2008, 12:52 AM   #47 (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: 157
Thanked 264 Times in 207 Posts
I've been trying to figure that one out, certainly don't want to leave it like that if it is possible to fix it, but it needs some research/trial and error. I *think* if we put the LCD power (and LED backlight) on a transistor and control the power up so that it is after the duino is up to speed that it might help, don't know for sure. The LCD stuff needs work. I want it to be solid, but there are probably a few folks besides me who could research it.
__________________
WINDMILLS DO NOT WORK THAT WAY!!!
  Reply With Quote
Old 05-04-2008, 01:16 AM   #48 (permalink)
Master EcoModder
 
Join Date: Apr 2008
Location: Earth
Posts: 303

Pushrod - '02 Chevrolet Cavalier
Thanks: 0
Thanked 8 Times in 4 Posts
Got a capacitor on your 5v line? Regulators can only do so much to quiet the noise.

Simplify things...

LCD circuits use very little current. I've got mine powered off an AVR signal pin. With the right RC circuit, you can delay power to the LCD until your micro can stabilize its outputs.
  Reply With Quote
Old 05-04-2008, 07:50 AM   #49 (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: 157
Thanked 264 Times in 207 Posts
The pin power for the LCD (not the LED!!) was a good idea, but no dice, not even with delays, and turning the LCD on and off.

I tried disconnecting the LED power while it booted up, no luck

It seems to boot up better if you hold down the reset button for two seconds, but hell if I'm certain about that or even know why.

The good news (or the bad news) is that it is reproduceable on seperate machines.
__________________
WINDMILLS DO NOT WORK THAT WAY!!!
  Reply With Quote
Old 05-04-2008, 09:43 AM   #50 (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
This could be a good reference.

http://www.uchobby.com/index.php/200...facing-part-1/

  Reply With Quote
Reply  Post New Thread


Thread Tools




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