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

Reply  Post New Thread
 
Submit Tools LinkBack Thread Tools
Old 12-07-2011, 04:03 PM   #1 (permalink)
EcoModding Lurker
 
Join Date: Dec 2011
Location: Lawrenceville, Il
Posts: 6
Thanks: 0
Thanked 0 Times in 0 Posts
Question MPH code?

Hey guys, I've been digging around on the forum in search of a working code that converts vss input to mph. I have found several attempts but all are inaccurate. My personal attempts have been inaccurate as well. You guys have appearently got a pretty accurate code for this somewhere as the Mpguino tells your mph. If anyone has a functional code could you please post it? I am trying to make a logical automatic transmission controller. Thank You

  Reply With Quote
Alt Today
Popular topics

Other popular topics in this forum...

   
Old 12-08-2011, 12:10 PM   #2 (permalink)
EcoModding Lurker
 
Join Date: Oct 2009
Location: Austria
Posts: 28
Thanks: 0
Thanked 1 Time in 1 Post
My Version of MPGuino Code uses this small code. Only change to MPGuino original should be the use of standard math functions:

Code:
unsigned long instantfuelperhour(){
  unsigned long instInjDur = instInjEnd - instInjStart;
  if (instInjDur == 0) return 0;
  return (instInjTot * 3600000000ull) * 1000ull / parms[MICRO_SECONDS_PER_LITER_IDX] / instInjDur;  
}
Works just fine.
  Reply With Quote
Old 12-08-2011, 12:31 PM   #3 (permalink)
EcoModding Lurker
 
Join Date: Dec 2011
Location: Lawrenceville, Il
Posts: 6
Thanks: 0
Thanked 0 Times in 0 Posts
Um I don't see how that code is relevant? I must have been unclear on what I am looking for. I need a standalone code to convert pps into mph. Thanks
  Reply With Quote
Old 12-08-2011, 02:09 PM   #4 (permalink)
EcoModding Lurker
 
Join Date: Oct 2009
Location: Austria
Posts: 28
Thanks: 0
Thanked 1 Time in 1 Post
Oh, I mixed up mph and gph

Code:
unsigned long instantvehiclespeed(){
  if (instant.vssPulses == 0) return 0;
  return 1000000000ul / parms[VSS_PULSES_PER_KM_IDX] * 3600 / (instant.vssPulseLength / instant.vssPulses);
}
But you should have a look in the mpguino code on your own to see how vssPulseLength and vssPulses are measured! It's a lot more than a single code block..
  Reply With Quote
Old 12-08-2011, 03:54 PM   #5 (permalink)
EcoModding Lurker
 
Join Date: Dec 2011
Location: Lawrenceville, Il
Posts: 6
Thanks: 0
Thanked 0 Times in 0 Posts
is it possible to put the codes easily into a single code block?
  Reply With Quote
Old 12-08-2011, 04:21 PM   #6 (permalink)
EcoModding Lurker
 
Join Date: Oct 2009
Location: Austria
Posts: 28
Thanks: 0
Thanked 1 Time in 1 Post
Of course not. The code above calculates the speed from the collected data, but to collected the data you have to put other code inside interrupt service routines, you need some global volatile variables and so on. Thats not like calculating the power of a value which can be written into a single function.

I think you should invest some time in learning about coding for microcontrollers, specialy interrupts, before you continue with your project. Trying to understand to MPGuino code in Arduino language would be a good step
  Reply With Quote
Old 12-08-2011, 11:15 PM   #7 (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
simple block code can be like

top:
poll for a pulse
start counting
poll for another pulse (while counting)
stop counting
compute mph from the count
do something with the mph
goto top

this won't track distance precisely, but with a hall effect vss it will give a snapshot of your speed every loop (with a reed switch you will be all over the place). This is the sort of thing arduino users do, and it has severe limitations, but is good for what you describe maybe.
__________________
WINDMILLS DO NOT WORK THAT WAY!!!
  Reply With Quote
Old 12-09-2011, 12:24 AM   #8 (permalink)
EcoModding Lurker
 
Join Date: Dec 2011
Location: Lawrenceville, Il
Posts: 6
Thanks: 0
Thanked 0 Times in 0 Posts
wo wo wo... why does having a reed switch make it all over the place? My project is an 88 toyota pickup with a chevy motor and trans. The trans is a 4l60e with a relucter gear. Does this mean the trans speed sensor is hall effect? Because I had the dash out of the truck and I've just been using a toyota speedo as my signal generator. It has a 4 pulse per revolution reed switch built in for cruise control. I've just been spinning it with a drill and getting very inaccurate readings. So your saying some of the codes I have written could potentially work with the actual speed sensor even tho they are inaccurate with the reed switch test speedo? Thanks for the reply!!!
  Reply With Quote
Old 12-09-2011, 08:19 AM   #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: 158
Thanked 269 Times in 212 Posts
why?!? I don't know exactly, just from observation. I have to average out several pulse lengths to get a reasonably steady reading from a reed switch.
__________________
WINDMILLS DO NOT WORK THAT WAY!!!
  Reply With Quote
Old 12-09-2011, 08:33 AM   #10 (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
On a side note, I see you are by the wabash river, I've noticed a number of meanders that have isolated pockets of indiana in illinois and vice versa,
Lawrenceville, il - Google Maps

Given their isolation from their parent state, do people still live/use these lumps? And taxes/etc go to indiana? or do they have agreements with the host state for public services? or?

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


Tags
code, mph, speed, transmission, vss





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