EcoModder.com

EcoModder.com (https://ecomodder.com/forum/)
-   OpenGauge / MPGuino FE computer (https://ecomodder.com/forum/opengauge-mpguino-fe-computer.html)
-   -   MPH code? (https://ecomodder.com/forum/showthread.php/mph-code-19708.html)

Leviticus6432 12-07-2011 04:03 PM

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

Sebastian 12-08-2011 12:10 PM

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.

Leviticus6432 12-08-2011 12:31 PM

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

Sebastian 12-08-2011 02:09 PM

Oh, I mixed up mph and gph :turtle:

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..

Leviticus6432 12-08-2011 03:54 PM

is it possible to put the codes easily into a single code block?

Sebastian 12-08-2011 04:21 PM

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 :thumbup:

dcb 12-08-2011 11:15 PM

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.

Leviticus6432 12-09-2011 12:24 AM

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!!!

dcb 12-09-2011 08:19 AM

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.

dcb 12-09-2011 08:33 AM

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?


All times are GMT -4. The time now is 06:10 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