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

Reply  Post New Thread
 
Submit Tools LinkBack Thread Tools
Old 02-16-2010, 02:59 PM   #31 (permalink)
EcoModding Apprentice
 
Join Date: Jan 2010
Location: Newark, DE
Posts: 143

'91 CRX - '91 Honda CRX DX
90 day: 34.91 mpg (US)
Thanks: 0
Thanked 14 Times in 14 Posts
Alright, I tried the interrupt approach... it works beautifully. I hooked my '168 up with the 20x4 LCD, took it to school (I'm an EE student) and fed it a TTL-level square wave from a decent function generator. It measures pulsewidths down to about 16 s (in 4 s increments as per the micros() function) on a 15 kHz square wave. I confirmed the readings with an oscilloscope.
At shorter durations/higher frequencies, the code would still spit out readings, but they weren't accurate. Somewhere between 16 and 20 kHz, the readings would start fluctuating all over the place. 15 kHz with a short enough duty cycle would result in a reading stuck at 12 s, despite the actual duration being shorter. I assume these limitations are a matter of the time it takes to execute the interrupt code.

The code:
Code:
#include <LiquidCrystal.h>

void displayUpdate(unsigned long present, unsigned long toggle, unsigned long interval, unsigned long total);

void interruptZero();

LiquidCrystal lcd(4,7,5,8,9,10,11);

unsigned long presentTime;
unsigned long onToggleTime;
unsigned long intervalTime;
unsigned long totalTime;
unsigned long lastUpdate;


void setup()
{
  lcd.begin(20,4);      //initialize display
  lcd.clear();
  pinMode(2,INPUT);    //set pin 2 to receive pwm signal
  attachInterrupt(0,interruptZero,CHANGE);   //declare the interrupt and set it to run any time the pin (#2) state changes
}


void loop()
{
  presentTime = micros();     //make note of the present time for display purposes
  
  if(presentTime > (lastUpdate + 100000))   //update display every 10th of a second
  {
    displayUpdate(presentTime,onToggleTime,intervalTime,totalTime);
    lastUpdate = presentTime;
  }
}


void interruptZero()
{
  if(digitalRead(2)>0)    //if the PWM input pin is high when interrupt called, update onToggleTime
  {
    onToggleTime = micros();
  }
  else                    //otherwise, update intervalTime and calculate totalTime
  {
    intervalTime = micros() - onToggleTime;
    totalTime = totalTime + intervalTime;
 }
}


void displayUpdate(unsigned long present, unsigned long toggle, unsigned long interval, unsigned long total)  //display update sub
{
 lcd.setCursor(0,0);
 lcd.print("clock: ");
 lcd.print(present);
 
 lcd.setCursor(0,1);
 lcd.print("togPoint: ");
 lcd.print(toggle);
 
 lcd.setCursor(0,2);
 lcd.print("interval:          ");
 lcd.setCursor(10,2);
 lcd.print(interval);
 
 lcd.setCursor(0,3);
 lcd.print("tally: ");
 lcd.print(total);
}

  Reply With Quote
Alt Today
Popular topics

Other popular topics in this forum...

   
Old 02-19-2010, 03:02 AM   #32 (permalink)
EcoModding Apprentice
 
gtkid2002's Avatar
 
Join Date: Feb 2009
Location: USA - WA
Posts: 110

The Bug - '69 Volkswagen Bug Base
Thanks: 6
Thanked 0 Times in 0 Posts
Got the seeeduino mega today, and the screen. Right now the mega is displaying the standard "Hello World" Of a blinking 10mm led. I also get to do all of this on a Mac, so hopefully that will make things easier, although I can switch to a windows computer just as easily. I'll start doing the soldering and whatnot tomorrow after I get the screen wired up, as that's my biggest concern. I just got the idea to use an old IDE cable for the wiring to keep things neat. Horray for old parts!


Anyways, I'm going to be running the basic mpguino with a large speed setting added on. I'll dig into the coding tomorrow after I get out of class, and then I'll install it.

Woo!

Oh yeah just as a side topic, was anybody surprised at how -small- these things are? I expected something four-six inches wide, not something smaller than my HTC Touch! (which is a crap phone by the way).
__________________
I suck at coding! Woo!

1969 VW Bug - Daily Driver
1975 VW Baja - Current Project
Priors:
1989 Honda Prelude Si 4WS (RIP)
1995 Honda Prelude Si (Traded)
1980 Fiat Spider 2000 (Sold)
  Reply With Quote
Old 02-19-2010, 06:23 AM   #33 (permalink)
EcoModding Lurker
 
Join Date: May 2008
Location: Big City
Posts: 9
Thanks: 0
Thanked 3 Times in 2 Posts
Hope this will help you all

multidisplay - Project Hosting on Google Code
  Reply With Quote
Old 02-19-2010, 08:45 PM   #34 (permalink)
EcoModding Apprentice
 
gtkid2002's Avatar
 
Join Date: Feb 2009
Location: USA - WA
Posts: 110

The Bug - '69 Volkswagen Bug Base
Thanks: 6
Thanked 0 Times in 0 Posts
Wow. That multidisplay is pretty awesome. That's what I was actually shooting for, but I'm basing mine off of the Mega, and I won't have that many thermocouples. That and I'm betting that it's based off performance, but still wow.

I've almost got the whole thing wired up. My wiring job is horrible, but I really don't care that much for the time being. I can always go back and revise it after a while.

I've switched the code for big instant mpg to big instant mph for the time being, as my primary purpose for this is to replace my defunct speedometer.


Anyways, here's a picture of what I've gotten done in four hours.


Not as much as I would have hoped, but whatever. I'll finish soldering tonight and start installing it, or at least finding a case for the screen. I probably won't be able to get the sensors or the bigger screen for a while, but I will be able to play with the code more, and I will hopefully be able to hook this up to the tach to display rpm as well, as my rpm gauge reads 8k when the engine is off, and reads 2k when it is bouncing off the rev limiter.

But anyways, It's a start!


UPDATE:
Got the thing wired, and the screen has a nice red glow. And no text. I'm gonna be doing more research later tonight, but if anybody "happens" to see this before I get to find the HELP! Pages, and knows what's up, lemmie know please.
__________________
I suck at coding! Woo!

1969 VW Bug - Daily Driver
1975 VW Baja - Current Project
Priors:
1989 Honda Prelude Si 4WS (RIP)
1995 Honda Prelude Si (Traded)
1980 Fiat Spider 2000 (Sold)

Last edited by gtkid2002; 02-19-2010 at 10:01 PM.. Reason: Update:Deadscrean
  Reply With Quote
Old 02-19-2010, 10:08 PM   #35 (permalink)
EcoModding Apprentice
 
Join Date: Aug 2009
Location: terra firma
Posts: 138
Thanks: 4
Thanked 24 Times in 22 Posts
Wow. Why have the breadboard in the middle? Here's what my seeeduino looks like (sadly, its only a 168). The one-inch cat5 wires are pretty rigid, and keep the LCD standing upright. The 2-pin header (vss + injector) right next to the mini-usb port is a glue-on addition.


If you plan to use the instantrpm(), i think the only thing that's needed is a zero-division check at the top of the function. e.g.:

unsigned long instantrpm(){
if (instInjEnd == instInjStart) return 0ul;
. . . etc . . .


Div-by-0 might never happen anyway but 1 line of code is cheap insurance.
Attached Thumbnails
Click image for larger version

Name:	seeeguino3.jpg
Views:	38
Size:	121.4 KB
ID:	5637   Click image for larger version

Name:	seeeguino2.jpg
Views:	37
Size:	96.5 KB
ID:	5639   Click image for larger version

Name:	seeeguino1.jpg
Views:	34
Size:	112.9 KB
ID:	5640  
  Reply With Quote
Old 02-19-2010, 11:49 PM   #36 (permalink)
EcoModding Apprentice
 
gtkid2002's Avatar
 
Join Date: Feb 2009
Location: USA - WA
Posts: 110

The Bug - '69 Volkswagen Bug Base
Thanks: 6
Thanked 0 Times in 0 Posts
I've got the circuit board in the middle because I was hoping to have the screen further away from the seeeduino, that way I could mount it in one location and have the controller slightly further away for easier access.

I'm still learning on the whole code bit. Seems rather complex to me so far, but I haven't really studied it much.
__________________
I suck at coding! Woo!

1969 VW Bug - Daily Driver
1975 VW Baja - Current Project
Priors:
1989 Honda Prelude Si 4WS (RIP)
1995 Honda Prelude Si (Traded)
1980 Fiat Spider 2000 (Sold)
  Reply With Quote
Old 02-20-2010, 12:04 AM   #37 (permalink)
EcoModding Apprentice
 
Join Date: Jan 2010
Location: Newark, DE
Posts: 143

'91 CRX - '91 Honda CRX DX
90 day: 34.91 mpg (US)
Thanks: 0
Thanked 14 Times in 14 Posts
Quote:
Originally Posted by gtkid2002 View Post
I'm still learning on the whole code bit. Seems rather complex to me so far, but I haven't really studied it much.
Ditto.
Tossing together a display, a few buttons and an input conditioning circuit or two takes me half an hour tops on a breadboard, maybe 3x that to solder it. The software has to interpret the signals you're feeding in to capture the information you want and make sense of it... It's really where the magic happens. Programming a decent user interface adds another layer of complexity on top of that.
  Reply With Quote
Old 02-20-2010, 12:19 AM   #38 (permalink)
EcoModding Apprentice
 
gtkid2002's Avatar
 
Join Date: Feb 2009
Location: USA - WA
Posts: 110

The Bug - '69 Volkswagen Bug Base
Thanks: 6
Thanked 0 Times in 0 Posts
Woo! I'm please. I caught the short on the circuit board between the mega and the screen. You really have to triple check for ANY connections. When I normally solder, I drag a mini-flathead screwdriver inbetween the traces on the circuit boards to make sure no wires are touching when I'm not sure. I normally don't have any problems, but this IDE cable wire has some seriously thin wire threads inside it. ONE slipped by me, and now I get the screen working. It was inbetween pins 2 and 3 on the screen, but it boots, so I don't think I fried anything. Time to install it!

I'll post pictures moar later when I'm done. I have to make a case before I install it at least.


Update number 474032 for the evening: Haha, this is great. Screen works! Buttons don't. I've checked connections, looked for shorts, checked for continuity, and even jiggled random wires. Nothing. It would spaz out when I would drag my finger around the extra pins (22-58) and when I jiggled the wire to PWM pin 6. And now it doesn't. I'm gonna attack it with a soldering iron a few more times, then I give up for a bit.

So, are there any possible compatibility issues I should be looking out for between the standard Arduino and the Seeeduino Mega?
__________________
I suck at coding! Woo!

1969 VW Bug - Daily Driver
1975 VW Baja - Current Project
Priors:
1989 Honda Prelude Si 4WS (RIP)
1995 Honda Prelude Si (Traded)
1980 Fiat Spider 2000 (Sold)

Last edited by gtkid2002; 02-20-2010 at 01:40 AM.. Reason: buttons wont work
  Reply With Quote
Old 02-20-2010, 06:17 PM   #39 (permalink)
EcoModding Apprentice
 
gtkid2002's Avatar
 
Join Date: Feb 2009
Location: USA - WA
Posts: 110

The Bug - '69 Volkswagen Bug Base
Thanks: 6
Thanked 0 Times in 0 Posts
All right. I located the vss on my car, and it works as the Hz setting on my multimeter goes crazy when I spin the wheels, and it produces the 5v when the wheel turns in pulses like it should. The Mpguino still isn't reading -anything-. I'm guessing there is a wonderful load of errors in the code for use on a seeeduino mega, as nothing else is working. So now my car's interior is torn apart and I get to play with the code later. Help on this would be greatly appreciated.

Buttons won't work, and the screen won't display anything other than 00.0 curr mph.
__________________
I suck at coding! Woo!

1969 VW Bug - Daily Driver
1975 VW Baja - Current Project
Priors:
1989 Honda Prelude Si 4WS (RIP)
1995 Honda Prelude Si (Traded)
1980 Fiat Spider 2000 (Sold)
  Reply With Quote
Old 02-20-2010, 09:14 PM   #40 (permalink)
EcoModding Apprentice
 
Join Date: Jan 2010
Location: Newark, DE
Posts: 143

'91 CRX - '91 Honda CRX DX
90 day: 34.91 mpg (US)
Thanks: 0
Thanked 14 Times in 14 Posts
What pin is your VSS pulse on?

  Reply With Quote
Reply  Post New Thread


Thread Tools


Similar Threads
Thread Thread Starter Forum Replies Last Post
MPGuino release one workspace dcb OpenGauge / MPGuino FE computer 1060 09-27-2016 10:56 PM
MPGuino rebooting and freezing also... Power issue? tygertec OpenGauge / MPGuino FE computer 28 04-17-2011 04:05 PM
MPGuino additon? BIG instant speed? gtkid2002 OpenGauge / MPGuino FE computer 11 02-19-2010 08:23 PM
MPGuino installation/setup: 1998 Geo Metro (Pontiac Firefly) MetroMPG OpenGauge / MPGuino FE computer 12 10-11-2009 03:29 PM
Will mpguino show the mileage going up while the engine is off and car is moving? abcdpeterson OpenGauge / MPGuino FE computer 6 06-02-2009 06:14 PM



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