Subject: Put this in the EFI email folder.... more about Arrays in and out
From: AAA-rotaryeng
Date: 1/24/2013, 8:39 PM
To: AAA-rotaryeng


I am getting a little practice with 2D arrays in QB64

I have decided to use a 10 by 10 array which is
a little larger than usual for an EFI system.
As I recall Megasquirt uses an 8 by 8.

The array is a look up table. The x axis is the RPM
and the Y axis is the mass airflow.

Arrays have the form of A(xcoord,ycoord) in BASIC.

There will be a xcoord entry about every 75 RPM
and about every 0.5 Volts ycoord from the mass air flow
sensor. About 100 entries total It looks like this.

^ x x x x x x x x x x x x
M x x x x x x x x x x x x
A x x x x x x x x x x x x
F x x x x x x x x x x x x
^ x x x x x x x x x x x x
V x x x x x x x x x x x x
O x x x x x x x x x x x x
L x x x x x x x x x x x x
T x x x x x x x x x x x x
S x x x x x x x x x x x x
...... RPM

x represents a mixture setting or pulse width for the injectors.
I wrote a program to initialize the array to 30
because it is rather tedious to type all that in by
hand. Simple QB64 program. The array will be adjusted
before I run the engine on it. The tuning procedure
is dump the array to a PC and load it into a spreadsheet
program. Edit as needed and ship it back through the
USB to the EFI computer. The next guy that builds
a EFI computer like this will have a head start.
Eventually we will accumulate a bunch of tables that people
can try when they are starting up for the first time.
CLS

This gets loaded into the program in the init area.
It generates the mixture look up table.
It initializes the injector table to 30. Say 3 ms.
The numbers will change when the engine is tuned.
---------------------------------------
CLS
FOR x = 1 TO 10
FOR y = 1 TO 10
A(x, y) = 30
NEXT y
NEXT x

To read the array and send it out the USB port to the PC looks like this.
The purpose is to get it into a spread sheet for editing, storing
and sharing with others.

---------------------------------------------
DIM injwidth AS INTEGER
FOR x = 1 TO 10
FOR y = 1 TO 10
injwidth = A(x, y)
injwidth$ = STR$(injwidth)
PRINT injwidth$,
NEXT y
NEXT x
END
----------------------------------------
The screen print out looks like the attached jpg.

Inject-table-ascii.jpg


Spread sheet programs require ASCII numbers to be in-putted so the
integers that represent injector widths in the array must be converted
to an ASCII characters. AKA character or char for short. If you don't know
what ASCII characters are look them up on google.

The function in QB64 that does this is STR$()
In ARM Mikro BASIC it is "IntToStr".

Attached is a screen capture from the help file on how to use it
and an example. It would be wonderful if the world
standardized BASIC.

All this is very very simple as programming goes.

Paul Lamar


Hey Paul,

If you are using a MAF sensor then you know directly from the voltage
read from the sensor what the mass air flow is.  The RPM has no
consequence in the calculation of the required fuel flow as the flow is
directly proportional to mass air flow.

With that said, seeing that you are using a MAF, why are you creating a
look up table relating MAF to RPM?  All you need to do is add the
appropriate amount of fuel for the amount of air that is flowing no
matter what the RPM may be.  No need for a two dimensional array.  A
simple array will do the job.

Knowing the RPM may come in handy for timing of the fuel injection, but
has no bearing on the amount of fuel required to achieve a combustible
mixture.  The injectors don't have a proportional response.  They are
either on or off.  Only the pulse width matters.

- Mark LaPierre


You are right Mark. It is a good thing you are reading this
and keeping me honest. :) Two heads are better than one. One dimensional  array for minor trim tweaks.  with an A/C eng we don't have to worry
about rapid acceleration.


Paul Lamar

The Rotary Engine News Letter. Powered by Linux.
ACRE NL web site. http://www.rotaryeng.net
You Tube http://tinyurl.com/beqqxas
Copyright 1998-2013 All world wide rights reserved.