Subject: Porgramming help offer - was PicAXE paradigm shift in EFI
From: Rotary Engine
Date: 12/16/2007, 6:00 PM
To: AARotary Engine



Hello Paul

Well it sounds like I am not the only person getting lost as soon as you
start using computer terms and acronyms. A picaxe is something I use on
the farm to clear bush with, for instance.

I bought your cooling book, and it would be so nice if you, or your
helper, skivvy, or whoever, could write a "how to" manual to do this
picaxe stuff. I understand the thinking behind the system and think it
will be wonderful in it's simplicity, but I know diddly squat about the
tech stuff you discuss. A note or article with: ----no. 1: Go buy this and
that at such a store----no.2: Do this and that to such and so------ I
think you get the idea.

I realise you are a very busy man, but you are also a lot more clever than
the majority of us (me, anyway), and we (I) would also like to participate
in implementing all the wonderful ideas.

Thanks for all the god work and ideas.

Erik Snyman
Messina
South Africa.


Google is your best friend.
Well several companies have expressed an interest in selling a kit
so be patient. We should nail down a kit in a couple of months.

In the mean time automotive pumps, pressure regulators and injectors
should
all be available in SA as EFI is universally used on cars world wide.

No PicAXE distributer in SA yet but if you can do biz in the UK or
Australia
there are several options. Which do you prefer?

http://www.tech-supplies.co.uk/
http://www.rapidonline.com/
http://www.microzed.com.au/

I am sure http://www.digikey.com/ has the rest of the parts needed
and ships world wide. http://en.wikipedia.org/wiki/Digi-Key

Paul Lamar ...No rotor no motor.

I would like to help in any way I can with computer and or programming
issues, including
individualized help with BASIC or the C language. These are the two most
suitable
languages for the project, in my opinion.

If you are not interested in learning a programming language, you can stop
reading this now.

My bias is for the C language. Lots of engineers like BASIC, but
professional
programmers, including me, much prefer C. In an effort to avoid a language
war,
I won't go into why. Suffice it to say that either BASIC or C is suitable.

CAUTION: if you wish to learn C, do not buy a PICAXE setup. You will need
a PIC setup instead. See below for what to get, and where to get it. I do
not
sell any of this myself, all I offer is advice. All the sensors and other
devices
will work with either language. (The advice is probably not worth any more
than
what you paid for it.)

As a teacher of programming languages, it is my belief that both languages
are
about equal in ease of learning, provided an integrated development
environment is
available. (I have taught both as well as FORTRAN and others.) An integrated
development environment is a great productivity tool.
For the a student it is almost a must, as it takes most of the complexity
out
of the development cycle. The development cycle becomes: edit, press a
couple
of buttons, and presto! it runs. Or not. Depending on the correctness of
the code. Usually not. As you are probably aware, computer problems
are called bugs. This goes back to the first (or at least one of the first)
electronic
(vacuum tube) computers. The one in question was at the Los Alamos
Scientific
Laboratory. The computer stopped working one day. Eventually the problem
was found: a moth was stuck in the circuitry! Thus the first bug was
actually a bug!
This is where a debugger comes in. A debugger is used to find out what is
going
wrong. It allows you to look inside the micro controller, at the value of
variables,
and to follow the logic of the code step by step. It is basically a window
into the
micro controller that allows you to see what is going on.

In the Computing Science community it is generally considered harmful to use
the GOTO statement in non-trivial programs. If you choose to learn or write
in BASIC, I hope you have or get a BASIC version that allows you to
avoid using the GOTO statement.

Avoiding the GOTO is done by using one of a number of other constructs,
e.g.,
for, while, if-then-else, etc. I offer the following experience as an
argument:
A long time ago I was teaching C, among other courses, at a community
college
in the evening. At the time I was working for Bell Labs, and this was
a give-back to the community as the pay was lousy. One of my students did
not
believe me when I told him that I thought he would be unable to complete his
term
project (50% of the total grade) since he was using GOTOs. Since the project
program had several hundred lines of code in it and he did not want to do
the
extensive changes needed, he chose to continue to attempt to get it to
run correctly while still using the GOTO statements. Just one more little
change ...
Unfortunately, he failed to get it running by the end of the term; I offered
to give him
6 months to finish it, but he never did. I guess his ego got in the way and
was unable
to admit that the general consensus of the community is correct: GOTOs ARE
BAD.

For those who would like to try the C language, there are a number of
possibilities.
What follows is what I did; you do not have to do the same things.

I bought a PICkit 2 Debug Express from www.microchip.com, the manufacturer
of PIC microcontrollers. If you decide to go this route be sure to get the
Debug Express version with the PIC16F887, #DV164121. There are a variety
of other PICkit 2 versions. Find it at http://www.microchipdirect.com/ and
search
for DV164121.  This under $50 package includes a very capable PIC16F887
microcontroller on a demo board, an integrated development environment, a
CCS
C compiler for the PIC 16F887, a programmer and an in-circuit debugger. A
number
of free software packages are also available, plus a great many helpful
documents.
This package only runs under Windows. I have used this package for several
months
now, and I can find no fault with it. I am really impressed with the C
compiler
optimization and integration.  The development cycle is so quick, I had
trouble
believing it at first-I thought it was operating in interpretive mode, but
it wasn't. This
package includes both C and assembly (not recommended)  tools and tutorials.
Three C compilers. When I bought mine, I got only the CCS compiler.
You will need a C language textbook. That's it: a complete package, although
the
prototyping area is small. No power supply is needed as the demo board runs
off
the USB power. Plug it in and go. The whole thing fits in the palm of your
hand.
You can be running the demo programs or writing your own programming in 5 \
minutes after you install the software. You can learn the whole C language,
or
at least the parts you will need with just this package.

The following hardware will work with either PICAXE/BASIC  or PIC/C.
For more the more ambitious or after you run out of room on the prototype
area,
I would recommend a Jameco www.jameco.com solderless breadboard. (I like
Jameco because if they have what you want it is usually lower in price than
the big
distributors, their catalog is much smaller, and thus easier to find stuff.)
A solderless
breadboard allows you to mount & connect components simply by poking the
stripped end of a wire into a hole. NO SOLDERING! I bought a Jameco
#136901 for $22.89 which is near the top of the line for an unpowered
breadboard.
Get the wire kit (# 19290, $16.59) too, or a spool of wire ($6.59/100ft.).
The kit is
nice because it has a variety of lengths pre-stripped and bent. If you get
the bulk
wire, you will need a wire stripper for 22ga. wire. Jameco has a minimum
electronics
tool kit #119183, $21.95 that will get you started. It includes a wire
stripper :) Probably
not a good idea if you already have a variety of hand tools. Small is good
in
electronics. You will also need a power supply of some kind. The PICAXE and
PIC 16F887 are micropower, so you could get away with a 4.5V battery pack
for a while, but I think a wall transformer power supply and a 5V voltage
regulator
will be more useful in the long run. The regulator is available from
http://world-educational-services.net/ #ET-LM2575-5 for $3.50.
This regulator accepts anywhere from 7V to 40V input, is high efficiency,
and can be used in the airplane. Any wall transformer type of DC power
supply providing a voltage in this range would be OK. I use a 9V one I found
in my
junk box. (I save all the power supplies of equipment that is no longer
useful.)
Contact me for pictures and instructions on hooking it up (email address
at the end of this email). I cut the connector off and used the bare wires
to connect
to the solderless breadboard, but if you prefer, you can get a suitable
power
connector from Jameco. USE A VOLTMETER when hooking up the power!
Reversed power will probably ruin any integrated circuits (ICs) that are
connected.
Before installing any ICs on the breadboard, install all of the power
components
and make sure the +5V is +, not -, and the regulator is working correctly.
If you
do not have a voltmeter, you will definitely need one BEFORE starting to
work
on circuitry. You will need one to work on the electrics in the airplane
too.

If you wish to learn to program and would like my help please email me
directly.
My email address is ddcuster<symbol at>wmv-co.us. I have disguised the email
address so programs that scan the web looking for email addresses won't
recognize
it as an email address. Replace <symbol at> with @.

BASIC can be made to work just as well as C, if you have the right BASIC
setup.
Just a matter of personal preference, mostly.

Aircraft are electrically noisy, and can become very noisy when a wire
breaks or
some other failure happens. So, I will be developing some electronic signal
conditioning circuits to deal with this noise. These I will make
available to anyone who desires them. Most of these employ a low pass
filter.
Microchip provides a design aid (software, free) for active filters.

Good luck with whichever path you choose!

Doc Custer
Retired Software Engineer and sometime Audiologist


All good advice. However I disagree on C.
C is a very terse, cryptic and at the same time verbose language.

Example:
main()
{
unsigned paddr,pdata;

LOOP:
printf("Input port address (hex): ");
scanf("%x",&paddr);
pdata = inp(paddr);
printf("Port(%xh) = %xh\n",paddr,pdata);

goto LOOP;
return 0;
}

See the attached  PicAXE BASIC examples
In fact these four examples are about all you need.
PicAXE BASIC is specifically designed for electromechanical devices.

We already have a C based free EFI system called Megasquirt.
Google it and read the source code.

I rest my case as I do not want to turn this into a C verses
BASIC argument.

Paul Lamar ...No rotor no motor.


Paul

In the December issue of "Nuts and Volts" magazine is the first installment
of
of  "Picaxe Primer".  They provided the following web site that has a lot of
information. http://www.rev-ed.co.uk/picaxe/

Mike Perry
N981MP
Long Ez 13B

Thanks Mike. I usually buy the latest copy of Nuts & Volts every time I am
at a magazine rack that sells them. I have not got around to ordering
a subscription.

Another good magazine is Servo. It has info more pertinent
to our project than Nuts & Volts. www.servomagazine.com
Not as readily available as Nuts & Volts so you probably need
a subscription.

BTW I first learned to program in BASIC three or four years after
C was invented. In the early 70's. I don't know when BASIC was invented. I
learned it on a $5,000 Friden computer the size of a roll top desk. I owned a school
at that time for race car engineers and Friden kindly loaned it to
me for a few years. This was long before the first computer chip came
out around 1975. C was invented around the late 60's early 70's to write
the UNIX O.S. (I think and as I recall). It was used with a teletype
and that is one reason it is so terse. It did not become popular for PC's
until around 1980 or later. BASIC came with the first Apple II around 1975.
My company, Microproducts, developed and sold the first assembly language
symbolic assembler written for the Apple II. Thousands of programs were
written for the Apple II using this assembler and this is one of
the reasons why the Apple II was so successful. C was not on the horizon.

My first multitasking operating system I wrote was in hexadecimal
about 1974 to 1975 for the Kim 1. It took me almost a year. When the
Apple II came out we converted the code to the Microproducts symbolic assembler.

I used that
assembler for years to write real time mechanical control software as you
always knew precisely, down to the nearest microsecond (one millionths of a second),
exactly how long it would take any program to do a specific job. That is something
you cannot say about BASIC or C. We frequently used an oscilloscope to actually
measure the length of time it took to execute a program. This was a double
check on the computer to make sure it was doing its job in the alloted time.
Back in the middle 70's a 6502 computer chip took about one microsecond
to execute one instruction.

The PicAXE has 8,000 microseconds (8 ms) to do the job of reading the manifold
pressure and looking up a value in the mixture table and setting a pulse
width for the injector at 7500 RPM. If it is one computer for all four injectors
in a two rotor the time available is half that as the two rotor fires twice as often.

PicAXE systems really start to pay off when you get to three or more
rotors. In the case of a four rotor you have only 1/4 the time. This is
not strictly true of course as some things only need to be done once and
there are other work around's that can be implemented to save time. It is
just a rough way of looking at the problem. The PicAXE always has that 8 ms
time to work. Consequently a cheap and slow PicAXE computer chip with a BASIC
interpreter can be used. Also the cheap PicAXE can execute four or more machine level
instructions in one microsecond. Not necessarily BASIC or C instructions
however.....machine level instructions! BASIC or C instructions can take up to
a hundred or more machine instructions.

Here is a patent I obtained used by HP to program calculators with
a light pen and a book of instruction labels.

Paul Lamar ...No rotor no motor.

The Rotary Engine NewsLetter. Powered by Linux.
ACRE NL web site. http://www.rotaryeng.net
Copyright 1998-2007 All world wide rights reserved.