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

Reply  Post New Thread
 
Submit Tools LinkBack Thread Tools
Old 06-06-2008, 02:36 AM   #1 (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: 156
Thanked 264 Times in 207 Posts
Signal Generator

Not sure where this goes, but it is basically two duinos. One (the plain chip and crystal) has been programmed in arduino to simulate a vehicle vss and injector signal, and the other is running the mpguino code. The test code is at the bottom. Now it isn't single digit microsecond accurate, but it also isn't limited by the number of timers either. With this approach you can generate a lot of different signals, i.e. buttons, etc. And since both the guino and the signal generator are connected to the computer simultaneously it is quite possible to have a PC program with all kinds of scenarios that tell the signal generator what to generate and get the result from the gunio to see if it is correct.





PHP Code:
//GPL Software 
//cheesey signal generator, made for bench testing the mpguino
//signal generator pins
#define sig1Pin 2   //inj
#define sig2Pin 3   

//overflow counter used by millis()   
extern volatile unsigned long timer0_overflow_count;   
unsigned long lastMicroSeconds=millis() * 1000;
unsigned long microSeconds (void){  
  
unsigned long tmp_timer0_overflow_count
  
unsigned long tmp
  
byte tmp_tcnt0
  
cli(); //disable interrupts 
  
tmp_timer0_overflow_count timer0_overflow_count
  
tmp_tcnt0 TCNT0
  
sei(); // enable interrupts 
  
tmp = ((tmp_timer0_overflow_count << 8) + tmp_tcnt0) * 4;  
  if((
tmp<=lastMicroSeconds) && (tmp<4293967296)) 
    return 
microSeconds();  
  
lastMicroSeconds=tmp;
  return 
tmp;  



unsigned long elapsedMicroseconds(unsigned long startMicroSecondsunsigned long msec ){   
  if(
msec >= startMicroSeconds)   
    return 
msec-startMicroSeconds;   
  return 
4294967295 - (startMicroSeconds-msec);   
}   


/*
metro signal generator notes:
//#define vssPulsesPerMile 10000ul   
//#define microSecondsPerGallon 267857143ul //injector flow rate   
@20mph, 4th gear
~48mpg
~44000uS injector open time per 1/2 second
18 inj pulses per 1/2 second
55 vss pulses per 1/2 second
therefore: 
sig1, off for 2444uS, on for 25333uS
sig2, on for 16000uS, off for 2180uS
*/
unsigned long sig1Start//injector
byte sig1State HIGH//injector 1=closed
unsigned long sig2Start//vss
byte sig2State LOW//vss

#define sig1PinOffTime 2444
#define sig1PinOnTime 25333
#define sig2PinOnTime 16000
#define sig2PinOffTime 2180


void setup (void){    
  
pinMode(sig1Pin,OUTPUT);   
  
pinMode(sig2Pin,OUTPUT);   
}    

void loop (void){    

  
digitalWrite(sig1Pin,sig1State);
  
digitalWrite(sig2Pin,sig2State);
  
sig1Start microSeconds();
  
sig2Start sig1Start;
  while(
true){ 
    
//snapshot of the time variables:
    
unsigned long tmp microSeconds();  
    
unsigned long tmp1 elapsedMicroseconds(sig1Starttmp);  
    
unsigned long tmp2 elapsedMicroseconds(sig2Starttmp);  

    
//sig 1 timing logic
    
if(sig1State==HIGH){
      if (
tmp1>=sig1PinOnTime){
        
sig1Start=tmp;
        
sig1State=LOW;
        
digitalWrite(sig1Pin,sig1State);
      }
    }else{
      if (
tmp1>=sig1PinOffTime){
        
sig1Start=tmp;
        
sig1State=HIGH;
        
digitalWrite(sig1Pin,sig1State);
      }
    }  

    
//sig 2 timing logic
    
if(sig2State==HIGH){
      if (
tmp2>=sig2PinOnTime){
        
sig2Start=tmp;
        
sig2State=LOW;
        
digitalWrite(sig2Pin,sig2State);
      }
    }else{
      if (
tmp2>=sig2PinOffTime){
        
sig2Start=tmp;
        
sig2State=HIGH;
        
digitalWrite(sig2Pin,sig2State);
      }
    }  

    

     
//sig3?  sigX? 

  
}   


__________________
WINDMILLS DO NOT WORK THAT WAY!!!

Last edited by dcb; 06-07-2008 at 11:07 AM..
  Reply With Quote
Alt Today
Popular topics

Other popular topics in this forum...

   
Old 06-08-2008, 02:45 PM   #2 (permalink)
EcoModding EcoModder
 
wikityler's Avatar
 
Join Date: May 2008
Location: Victoria BC
Posts: 68

Gerald - '91 Pontiac Firefly 3dr
Team Metro
90 day: 40.08 mpg (US)
Thanks: 1
Thanked 1 Time in 1 Post
What is the signal logic on the VSS and injector line? I'd like to make an interface for my carputer to do FE calculations.
__________________
  Reply With Quote
Old 06-08-2008, 03:15 PM   #3 (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: 156
Thanked 264 Times in 207 Posts
It is basically a 5 volt square wave defined by these lines in the code:

#define sig1PinOffTime 2444
#define sig1PinOnTime 25333
#define sig2PinOnTime 16000
#define sig2PinOffTime 2180

sig1 (simulating the injector signal) is off for 2444 microseconds and on for 25333 microseconds, roughly.

sig2 (simulating the vss signal) is on for 16000 microseconds and off for 2180 microseconds, roughly.

So you going to start from scratch, or can you help us troubleshoot the guino? It would be downright trivial to send the instant raw data out the serial port on the guino and collect it on the carpc and make sense out of it there. I do it all the time for debugging.
__________________
WINDMILLS DO NOT WORK THAT WAY!!!
  Reply With Quote
Old 06-08-2008, 03:50 PM   #4 (permalink)
EcoModding Apprentice
 
awillard69's Avatar
 
Join Date: Feb 2008
Location: Streamwood, IL
Posts: 105

Dakota - '00 Dodge Dakota Club Cab, Sport
90 day: 18.57 mpg (US)

Jeep - '01 Jeep Wrangler TJ Sport
90 day: 18.46 mpg (US)
Thanks: 0
Thanked 1 Time in 1 Post
You beat me to the end. My 555 is working, but not very precisely. While its accurate, without a scope, I'm having trouble zeroing in on trustworthy streams.

So, let me get this straight, you have a basic ATMEGA168 chip, that you loaded using your Freeduino board, or the load cable, then placed that code loaded chip to your solderless breadboard with the bare bones components for a functioning chip. You then power it from the same place as the MPGuino and tap its outputs.

I may just have to break down and buy some more Freeduinos to catch up.

My soldering iron is heating up so I can migrate my LCD and input interfacing components to a proto shield. I'm trying to make mine look less like a spaghetti ball on the bench.
__________________

  Reply With Quote
Old 06-09-2008, 03:12 PM   #5 (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: 156
Thanked 264 Times in 207 Posts
Quote:
Originally Posted by awillard69 View Post
So, let me get this straight, you have a basic ATMEGA168 chip, that you loaded using your Freeduino board, or the load cable, then placed that code loaded chip to your solderless breadboard with the bare bones components for a functioning chip. You then power it from the same place as the MPGuino and tap its outputs.
That's pretty much it. I bought some 20mhz PDIP atmega 168's and some 16mhz crystals after I cooked one atmega, then wrestled a bootloader on them by putting them in my freeduino board socket and mucking around with the parallel port ICSP programmer (not for the faint of heart), then I could program it via the USB/Serial port on the board and use plain old arduino IDE and code.

NCK had some chips with bootloaders on them, but no crystals, and when I looked they did not have chips in stock, so as hokey and painful as the parallel programmer can be to get working, it has proved to be invaluable. It's brought back a couple chips after experiments that have gone wrong and cost me nothing

Course the real nice thing about this arrangement is that I can create cheap little devices, but anybody with a duino can also use what has been written very easily.

Edit: I was just checking out the iduino and noticed that fundamental logic, http://www.spiffie.org has atmegas with bootloaders preloaded and crystals, as well as a breadboard usb duino kit for $18! I had to get one at that price (plus a couple more atmegas and crystals)
__________________
WINDMILLS DO NOT WORK THAT WAY!!!

Last edited by dcb; 06-09-2008 at 03:19 PM..
  Reply With Quote
Old 06-09-2008, 07:27 PM   #6 (permalink)
EcoModding Lurker
 
Join Date: Jun 2008
Location: NC
Posts: 30

Cxy Hatch - '92 Honda Civic CX

0ftlbs - '05 Honda S2000
Thanks: 0
Thanked 0 Times in 0 Posts
Great work DCB. Thanks for all your help on this project as far as debugging the software (and writing it hahaha).

I may build one of these with my spare board. I always buy spares when it comes to components....I've got a habit....
  Reply With Quote
Old 06-10-2008, 11:10 AM   #7 (permalink)
EcoModding Apprentice
 
awillard69's Avatar
 
Join Date: Feb 2008
Location: Streamwood, IL
Posts: 105

Dakota - '00 Dodge Dakota Club Cab, Sport
90 day: 18.57 mpg (US)

Jeep - '01 Jeep Wrangler TJ Sport
90 day: 18.46 mpg (US)
Thanks: 0
Thanked 1 Time in 1 Post
I got my cluster of wires pushed to the proto shield from NKC. But, then ran into several issues.

The first was the size of the holes are tight for the Zener diodes, or if you have larger watt resistors. Not a big deal, but does require some persuasion and the small area makes it challenging.

The second problem is more of an issue. Basically, the trace across the center of the board for 5V is not connected, just solder pads; the ground is OK.

I contacted NKC and they acknowledged my find. They were prompt, but I would wait for a new generation board before getting another proto shield from them.

All in all, it went great, aside from the issues with "placement on the fly". And, it looks good, piggy backed on the Guino. Still not as compact as a custom PCB setup, but very friendly for plug-and-go with any Freeduino board, snap in, snap out.

I'm waiting for my other Freeduino's to arrive so I can assemble the generator and get back to testing this thing.
__________________

  Reply With Quote
Old 06-15-2008, 12:35 PM   #8 (permalink)
EcoModding Apprentice
 
awillard69's Avatar
 
Join Date: Feb 2008
Location: Streamwood, IL
Posts: 105

Dakota - '00 Dodge Dakota Club Cab, Sport
90 day: 18.57 mpg (US)

Jeep - '01 Jeep Wrangler TJ Sport
90 day: 18.46 mpg (US)
Thanks: 0
Thanked 1 Time in 1 Post
Have you changed or updated your generator code? I've got it running on a 2nd Freeduino, straight inputs, not resistors.

It looks like I'm showing 55-58 mpg. Is that what you are getting?

I show MH 40.0x and MG ~57.

Not related directly to the generator, when I display the CPU % screen, it seems to revert back to the startup, like a reset as the MI reverts back to near 0.

I get it if I cycle left once, or right 6 times.

I'm not quite sure if it's the code somehow resetting the CPU or something else. Version 0.61.

The generator makes it nice to see it actually running.
__________________

  Reply With Quote
Old 06-15-2008, 08:28 PM   #9 (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: 156
Thanked 264 Times in 207 Posts
I've not touched the signal generator code since fixing the 72 minute issue. I do keep messing with the microseconds per gallon and vssTicsPermile though but 57/58 mpg @40mph sound just right for the last version.

re:reset, currently , hitting left button and middle button simultaneously will reset the tank trip, hitting right and middle will reset the current trip. Is it possible that the middle button is getting "fat fingered" when hitting the left or the right button?
__________________
WINDMILLS DO NOT WORK THAT WAY!!!
  Reply With Quote
Old 06-16-2008, 09:16 AM   #10 (permalink)
EcoModding Apprentice
 
awillard69's Avatar
 
Join Date: Feb 2008
Location: Streamwood, IL
Posts: 105

Dakota - '00 Dodge Dakota Club Cab, Sport
90 day: 18.57 mpg (US)

Jeep - '01 Jeep Wrangler TJ Sport
90 day: 18.46 mpg (US)
Thanks: 0
Thanked 1 Time in 1 Post
I've checked and the buttons don't appear to be solder bridged or anything. And the buttons are far enough apart to not likely be fat fingered. But, it also happens if I right button to that screen, also.

But it appears to be resetting the program, ie running setup() again.

With my current configuration, if I press the reset button on the Freeduino the LCD goes "one line" on me - known issue. This doesn't happen, so I'm not quite sure it's a full on restart, but like it's just running setup() again somehow. I went looking through the Guino code, looking for a possible hosed pointer or something, something where a memory address is getting trounced. Nothing jumped out at me. It could be a memory corruption or allocation/deallocation issue within the arduino program code. A bit far fetched maybe. Does it not happen for you?

__________________

  Reply With Quote
Reply  Post New Thread


Thread Tools


Similar Threads
Thread Thread Starter Forum Replies Last Post
Hydrogen Generator Experiment willy57 DIY / How-to 601 08-23-2016 05:53 AM
VSS, tach, injector signal logic wikityler Instrumentation 2 07-20-2008 11:02 PM
New freeway signs.. traffic signal conspiracy Chris D. EcoModding Central 36 06-02-2008 01:51 PM
Opengauge/MPGuino development: Freeduino signal processing dcb OpenGauge / MPGuino FE computer 6 04-16-2008 09:40 AM
Very clever knee brace generator - 5 watts while walking - no extra effort. MetroMPG The Lounge 6 02-09-2008 12:38 AM



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