Subject: EFI software 101 Lesson 3
From: Rotary Engine
Date: 3/22/2009, 5:38 PM
To: AAA Put this in the To box

 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.

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.