Probably the easiest way for me to explain
EFI software is to look at the early
Megasquirt software written in straight forward
assemble language. Assembly language is a very mechanical
thing. It is well adapted to controlling mechanical
devices. Assembly language is close to a one to one correspondence
between computer instructions and computer operations. Assembly language
programming also gives direct access to key machine features such
as sensors and injectors.
Computers are set up like post offices. There
are many numbered boxes. Each box is an address.
The boxes can also have names such as "bank".
It is easier for the programmer to remember
"bank" than box #8765. These boxes are also
known as memory locations.
MAP sensors look just like a PO box after the analog
data is converted to digital. The analog to digital
converter (ADC) is a black box electronic device that takes
in a zero to 5 volt analog voltage and puts a number 0 to 63
into a PO box maybe called the MapSensorBox. This is called
memory mapped Input Output or I/O for short.
Let me give you a simple example.
The LDA instruction moves 8 bits of data (64 combinations of
eight zeros and ones 01001110) from one specified box to another.
Here is what it looks like on paper in the program listing.
LDA MapSensorBox
Translated it means LoaD (really copy) what is in the MapSensorBox
to another box called the Accumulator box. This instruction
could take way less than one micro second (usec) to complete
in a fast computer. One will know exactly HOW FAST in case
time to achieve something is important to one. That is
usually the case when controlling a high speed machine
such as an engine.
This is probably the most frequently used instruction
you will find. With several more simple instructions
like this, one can write programs that do useful things.
Especially if one is controlling a machine.
That is all there is to it. No more complicated than
that. In the next lesson we will cover the STA instruction.
Another highly used instruction.
Lesson 2 ----------------------------------------------------------
Before we get to the STA instruction we need a bit more info
on LDA. I lied.
There is another aspect to the LDA instruction and that
is a thing called addressing modes. What we have shown
so far is only one of several options for the LDA instruction.
The first copies data from a box anywhere in memory and that
includes input boxes. Probably the most used of all the
four LDA addressing modes and the one you have learned so far.
Another mode is called the immediate mode. Lets say
I wanted to enter a number directly into the A box.
I would use this form:
LDA #$06
The # (pound sign) tells the assembler program the next number
it sees in the listing is the number one wants to load into the A box.
The dollar sign means it is a decimal number in the range
of 0 to 63. The computer really only deals with binary
numbers. The assembler program reads the decimal number
from our listing and converts it to a binary number.
If I wanted to load the A box with a binary
number directly I would use this form. A binary number composed
of ones and zeros. The % sign tells the assembler program
it is a binary number.
LDA #%00001000
The fourth bit is set reading from right to left. (Unfortunately
ass backwards :)) Handy if we want to set one or more bits
in some box someplace including a hardware output box.
Here is a table that converts decimal numbers to binary.
We will get into the other more advanced modes later.
Paul Lamar
Paul,
You aren't saying
LDA #%00001000
is equal to
LDA #$06
are you?
6 (decimal or hex) is 110 in binary.
Matt-
No! It would be LDA #%00000110
Good going Matt! Your paying attention.
My ultimate goal here is to show how to use
a single chip computer to rapidly fire a multiple capacitor..
capacitor discharge ignition system. Perhaps advance
the spark as well.
Lesson 3 ------------------------------------------------------
The STA instruction works exactly like the LDA instructing
except it copies what ever number is in it to a memory location
box or an output box.
Lets say I wanted to fire an injectors. Output boxes
have 8 wires coming out of them. Lets number them 1 to 8
corresponding to bit numbers from right to left.
I'll connect my injector to wire 1 which is also bit 1.
Here is all it takes to fire the injector #1.
LDA #%00000001
STA InjectorControlBox
That's it!
To fire injector #2:
LDA #%00000010
STA InjectorControlBox
And so on up to 8 injectors.
Or we can trigger coils the same way.
Up to 8 coils at various times.
OK so far so good. If you want to fool around with
this and you can spare $50 for education uses you can buy
one of these boards that comes with a bunch of software
including an assembler. It is connected to your USB port
and you use your computer to program it. It has a bunch
stuff on it like LED that you can write programs to blink
them in different manners to give you confidence that
your programs are working.
I'll order one tomorrow so I can help you and use it to write
a sophisticated capacitor discharge ignition system software
to go along with our super simple 555 fuel injection system.
The one I'll get is the DEMO9S08QG8E with 512 memory boxes
and 8 analog to digital converters. We will not need all those
features but they are there if we want to add something trick
in the future. Put this thing in a box and you can use it as
THE ignition system in your airplane. It is cheap enough
you can afford 2. One as back up.
It is also powerful enough to work as an aircraft engine
EFI system if you decide to go that route.
BTW this is an enormously creative medium and only limited
by your imagination. There are zillion things that can be done
with one of these things. I made a friend who had a 3 year old very
bright son. I taught him assemble language when he was 14.
He was a millionaire before he was 30. He invented a machine
that converted movie film to video in real time. The movie
industry broke down his door.
---------------------------------------------------------
The board is on its way and should be here in 3 days.
A computer needs to make decisions based on certain
conditions that might occur such as: is it time to fire
the spark plugs? They can do this at least two ways.
They can ask a question over and over again by
checking the angular position of the e-shaft.
Is it 22 degrees BTDC or not? That would require
a true e-shaft sensor that put the angle in an inbox.
LDA inbox.
Over and over again.
Kind of a waste of time and true high speed angle sensors
are rare and expensive.
The other way it can do it is interrupt the execution
of the program when the crank angle sensor triggers and
have it go to section of software that fires the plugs
called a subroutine.
LDA #%00000001 'plugs on rotor one.
STA FireTheplugsControlBox
RTS
When it is done firing the plugs it jumps back into
the program where it left from and continues.
This is called Jump to SubRoutine or JSR for short.
Returning is RTS ReTurn from Subroutine.
This capability is built into the vast majority of computers
including the one you are using now.
BTW I am doing this with a small cheap computer because I think it is easier
than dumping bunch of capacitors through a coil one right after another
with hardware. Also we may need ignition retard for starting and
ignition advance for fuel efficiency. Klaus tells me he uses up to
39 degrees BTDC at cruise power and super lean fuel mixtures. His airplane
gets up to 100 MPG for that and other reasons. We could do that mechanically
with a slotted timing plate but if we have a computer anyway we might
as well use that.
Lesson 5 ------------------------------------------------------------
If anybody wants a manual on this low end processor download it from
here. Here is what you are looking for: MC9S08QG8.pdf It is in the
category of a data sheet.
http://www.freescale.com/webapp/search/Serp.jsp?QueryText=&fsrch=1&isAdvanceSearch
=false&showCustomCollateral=false&RELEVANCE
=true&Documentation=Documentation%2F10010Ksd1nd%60%60Data+Sheets&fromTrng
=false&showAllCategories=false&fromPSP=false&SelectedAsset
=Documentation&pageNum=5&assetLocked=false&assetLockedForNavigation
=false&isResult=false&searchSessionId=f87fdf1237897483772.4&fromDAP
=false&fromWebPages=false&isTree=false&isFromFlex=false&pageSize=25&isComparison=false
Unfortunately you have to string all these together as the FreeScale site is huge.
Don't be over whelmed by the shear number of instruction and addressing modes.
One can write useful applications using a small fraction of all these instruction
and hardware features. Our ignition system will only require a small fraction
of the features built in to this $3 part. Not a whole heck of a lot more
for a complete aircraft EFI system.
Feel free to ask questions no matter how dumb it might appear.
It is a lot easier than it looks. This is a VERY simple computer.
The A box is called a register as are all the I/O boxes.
Here is a jpg of the basic registers we will be using.
The two I/O registers (not shown yet) are general purpose both input and output
capable. They must be set up as either input or output when the computer
is first turned on.
Paul Lamar
--
The Rotary Engine NewsLetter. Powered by Linux.
ACRE NL web site.
http://www.rotaryeng.net
Youtube key word UTUBPLEASE
Copyright 1998-2008 All world wide rights reserved.