Notices
ECU Flash

Pseudocode to VB code to display max knock over the ignition map

Thread Tools
 
Search this Thread
 
Old May 18, 2007 | 05:21 AM
  #1  
jcsbanks's Avatar
Thread Starter
Evolved Member
 
Joined: May 2006
Posts: 2,399
Likes: 6
From: UK
Pseudocode to VB code to display max knock over the ignition map

I can read the knocksum, RPM and load no problem. I have myarray defined and displaying as a datagridview that displays the ignition map with its RPM and load axes.

I write what I have in pseudocode below, the stuff marked * help me rewrite to VB - are there VB functions to do this or do I loop through the array and find the nearest site?

dim RPMsites(32) as integer = "500,1000,1500,2000,2500,3000,3500, [etc]
dim loadsites(32) as integer = "0,10,20,30,40,50,60,70,80,90,100,120,140 [etc]

Read knocksum
Read RPM
Read load

RPMsite=getRPMsite(RPM) 'function to lookup what cell position for RPM
loadsite=getloadsite(load) 'function to lookup what cell position for load

if myarray(RPMsite,loadsite)=" "
myarray(RPMsite,loadsite)=knocksum 'if cell unpopulated load with present knocksum
elseif knocksum>myarray(RPMsite,loadsite)
myarray(RPMsite,loadsite)=knocksum 'if knocksum greater than old value, populate with present knocksum
endif

******************

function RPMsite(RPM)

'I need this function to return the RPMsite array position that has the value that is nearest to the RPM value

return RPMsite

'----------------------------

function loadsite(load)

'I need this function to return the loadsite array position that has the value that is nearest to the load value

return loadsite

********************
Reply
Old May 18, 2007 | 08:36 AM
  #2  
JoeBee's Avatar
Evolving Member
 
Joined: Sep 2006
Posts: 152
Likes: 0
From: Germany
You should look (and maybe use) my excel sheet.
Wait... I am searching for the thread...
Reply
Old May 18, 2007 | 08:40 AM
  #3  
JoeBee's Avatar
Evolving Member
 
Joined: Sep 2006
Posts: 152
Likes: 0
From: Germany
... here: https://www.evolutionm.net/forums/sh...d.php?t=251750

By the way: I hate this search pause "Wait 15 seconds for next search bla bla"
Reply
Old May 18, 2007 | 09:34 AM
  #4  
jcsbanks's Avatar
Thread Starter
Evolved Member
 
Joined: May 2006
Posts: 2,399
Likes: 6
From: UK
Thanks, just had a look at the code. Your cell finder is going to put everything in the 3000-3499 RPM range into the 3000 RPM cell, and the 240-249.9 load into the 240 cell. The ECU is putting 2750-3249 into the 3000 RPM cell, and 235-244.9 into the 240 cell.

So to match the behaviour of the ECU we need to work out which is the nearest cell rather than which is the cell it rounds down to. Any ideas on the code for this? Measure the distance from the point to the two nearest cells and work out which is nearer and use that? A clumsy method would be a second lookup table which was half way between the ECU lookup tables, but I don't like that idea.
Reply
Old May 18, 2007 | 10:34 AM
  #5  
AutoXer's Avatar
Evolved Member
iTrader: (1)
 
Joined: Dec 2002
Posts: 804
Likes: 0
From: Logan, WV
Originally Posted by jcsbanks
Thanks, just had a look at the code. Your cell finder is going to put everything in the 3000-3499 RPM range into the 3000 RPM cell, and the 240-249.9 load into the 240 cell. The ECU is putting 2750-3249 into the 3000 RPM cell, and 235-244.9 into the 240 cell.
ecuEdit does the same thing. It drives me a little nuts.
Reply
Old May 18, 2007 | 10:36 AM
  #6  
merkzu's Avatar
Evolving Member
iTrader: (4)
 
Joined: Dec 2006
Posts: 392
Likes: 1
From: Twin Cities, MN
This will subtract each RPM/Load scale value from the logged value, take the absolute value and record the difference. The scale value with the smallest difference wins. So 3600 would use the 3500 cell, 3800 would use the 4000 cell

Code:
        RPM = Selection.Cells(z, 1)
        LoadECU = Selection.Cells(z, 2)
        
        lowestDiff = 15000
        For i = 5 To 19
            a = Sheets("Trace AFR").Cells(i, 2)
            diff = Abs(RPM - a)
            If diff <= lowestDiff Then
                lowestDiff = diff
                Cell = i
            End If
        Next i
        
        lowestDiff = 15000
        For i = 3 To 22
            a = Sheets("Trace AFR").Cells(4, i)
            diff = Abs(LoadECU - a)
            If diff <= lowestDiff Then
                lowestDiff = diff
                Column = i
            End If
        Next i
Attached Files
File Type: zip
MapWalker-EvoIX.zip (31.1 KB, 1 views)

Last edited by merkzu; May 18, 2007 at 10:43 AM.
Reply
Old May 18, 2007 | 10:49 AM
  #7  
galvitron's Avatar
Evolving Member
iTrader: (2)
 
Joined: Sep 2004
Posts: 287
Likes: 0
From: South Bay
^^^ beat me to it.
Reply
Old May 18, 2007 | 12:14 PM
  #8  
jcsbanks's Avatar
Thread Starter
Evolved Member
 
Joined: May 2006
Posts: 2,399
Likes: 6
From: UK
Elegant! Thanks.
Reply
Old May 18, 2007 | 12:31 PM
  #9  
merkzu's Avatar
Evolving Member
iTrader: (4)
 
Joined: Dec 2006
Posts: 392
Likes: 1
From: Twin Cities, MN
This tool seems to select multiple cells sometimes and average them, the values are way off from my logs so I don't think it's doing the same thing as the ecu. I commented out all the code that does that so it only highlights the exact cell hit. The values are a lot closer but still off, by 1-2 degrees on ignition.. has the actual formula been worked out for that?
Reply
Old May 18, 2007 | 03:34 PM
  #10  
jcsbanks's Avatar
Thread Starter
Evolved Member
 
Joined: May 2006
Posts: 2,399
Likes: 6
From: UK
Depends on how accurate the load is, I propose to use the real load for doing this live, rather than using estimated load and offline loading up of log files.

It will be on the same form as the live editable ignition map.
Reply
Related Topics
Thread
Thread Starter
Forum
Replies
Last Post
richardjh
ECU Flash
99
May 24, 2013 01:53 PM
tephra
ECU Flash
32
Sep 15, 2012 09:38 AM
richardjh
09+ Ralliart Engine/Turbo/Drivetrain
156
Apr 30, 2012 05:32 AM
mrfred
ECU Flash
44
Dec 11, 2011 06:01 PM
tephra
Evo X Engine Management / Tuning Forums
14
Aug 23, 2010 08:27 AM




All times are GMT -7. The time now is 03:56 PM.