Subject: Good News. Bascom now available on Arduino
From: rotaryeng
Date: 8/13/2014, 9:05 PM
To: AAA-rotaryeng



ARDUINO boards/chips are programmed with a bootloader.  The
developers of the ARDUINO finally implemented the STK500V2
communications protocol. This protocol is supported by Atmel and of
course by BASCOM.

Select the ARDUINO STK500V2 programmer in BASCOM programmer options
to use this communications protocol.

A board like the MEGA2560 R3 uses this communications protocol and
probably all newer AVR based ARDUINO boards will support this
protocol.

BASCOM AVR is superior to Arduino IDE. Bascom is simpler and much
more flexible. In fact, Bascom is the language used by the majority
of hobbyists.

C is more for professionals.

https://www.youtube.com/watch?v=Ppdpp4pqeQc$regfile = "attiny26.dat"

Simple blink program. Think of the LED's as injectors.

$crystal = 1000000 $hwstack = 32 $swstack = 8 $framesize = 24

Config PORTA = Output Config PORTB = Output

RED Alias PORTB.0 YEL Alias PORTB.1 GRN Alias PORTB.2

Begin:

Red = 1 : Yel = 0 : Grn = 0 Wait 1

Red = 0 : Yel = 1 : Grn = 0 Wait 1

Red = 0 : Yel = 0 : Grn = 1 Wait 1

Goto Begin


The first section sets up the chip, then we need to configure the
two ports. A port can be an INPUT or an OUTPUT. Since we want to run
some LEDs, we set the port to be an OUTPUT. May as well define them
all at one time... so we did.

The next section is where we define the pin names. I don't know
about you... but I would forget which pin the RED LED was connected
to, or the green, or the yellow. I don't feel like typing in
*PORTB.0* for the first pin every time... so we told the software
that it's name was "RED". Now all we need to do is reference it by
it's name.

Once defined, if we make them equal a "1" the LED will turn ON, and
if we make it equal to a "0" it would turn OFF. The next series of
lines defines how we want the LEDs to be set, then waits 1 second.
(The *WAIT* command.)

After we change the state of the LEDs 3 times... we jump back to the
beginning and do it all over again... over and over.

This is simple enough for every one and a simple open source EFI is
very doable.

Paul Lamar

------------------------------------------------------------------------

A programing language can be over whelming at first glance.

The way to proceed is cherry pick only the instructions you need to
do the job. Here is a book on the Bascom language.

You need to know:

1. How to set a bit in a port that turns on an injector

2. How to read an analog value in from a MASS airflow sensor

3. How to use WAIT as a delay to keep the injector on for a specific time. See the
program source code above.

4. How to handle hardware interrupts.

This basically is all you need and a little math for a simple EFI
that will run the engine. You also need a stand alone ignition of
course.

If you put a potentiometer in parallel with the mass air flow sensor
that will provide a leaning function. Just like the leaning control
on aircraft engines. When the pot knob is set to full rich the
injector width is set for about 10 pounds of air to one pound of
fuel. When full lean it should be about 18 to 1.

To keep it simple the program checks the mass airflow every half
second and adjust the mixture over and over again.

The simple way to do this is use an external 50 cent CMOS 555 osc
oscillating at two cycles per second (2 Hertz in the silly French
system :)) and connect it to a hardware interrupt pin. It is not
timed fuel injection. It is  called batch mode and works fine for an
aircraft engine. Tracy's EFI system was batch mode.



Paul Lamar


Paul,

No need for the extra timer. Just check MAF in your loop. I don't
think it matters if the flow is adjusted every 5ms or 500ms.

Henry

The trouble is how does the program know 500 ms has elapsed? There
is no ON TIME hardware interrupt in Bascom like there is in QB as far
as I know at this point in time. (Pardon the pun)

Obviously the more you pulse the injector the more fuel you get.

Send me the BASIC source code of what you have in mind.


Paul Lamar



I am thinking along the lines of your 555 injector, together with a

BASIC computer.

* The BASIC computer continues to monitor the MAF sensor, and from
there, it knows the flow rate of air per second. * It also knows the
rpm, * It can calculate amount of fuel needed in x number of m.sec.
of injector on time per revolution. * Assuming that you have a
voltage to pulse width table for the 555 timer, the computer can send
an analogue signal to control the 555 timer. * Each ignition trigger
will also trigger the 555 timer, giving the exact amount of fuel.

Mission accomplished.

Regarding inputs, we can use an analogue signal to inform the BASIC
computer what the rpm is by using A to D converter, and then do a
table lookup to find the current rpm. Much easier to do than digital
measurements. We can calibrate the sensor before installation to get
accurate rpm from the analogue signal.

With CHT, we can even implement auto leaning! Or, simply use another
VR to supply the BASIC computer with in indicator on how much fuel
to lean.

Henry

That certainly reduces the processor software over head sitting in a
wait loop for the injector on time. That frees up the processor time
for all sorts of new jobs.

Here are some old schematics on the scheme.



Paul Lamar


Last thing on your list. 5 degree per spark and 6 in a row on smart
coil trigger.

Not sure if you can do it in BASIC as I don't know the capability of.
But here is what I am thinking.

* Create a variable frequency pulse generator using 555. Try to make
the frequency go up with RPM. (proportional to the rpm voltage you
have for rpm calculation) It does not have to have an exact multiple,
but closer is better.


* Feed the pulses generated to a counter on the BASIC computer.


* Generate interrupts on CAS wheel. I understand there are 12 teeth
per complete cycle of 720 degrees. This will give you a interrupt
every 60 degrees.


* Upon interrupt, latch the counter value and reset the counter. This
is the count for 60 degrees. Divide the value by 12 to get the value
for 5 degrees, 10 to get 6 degrees, etc.


* Now create a PWM generator either in the BASIC computer,or create
outside circuit to do this.

1. A 6 count counter, used to limit the number of sparks.
2. A PWM, or pulse width generator, used to generate time for 5 degrees.

The initial ignition trigger is used to reset the free running PWM
generator, and the 6 count counter limits the number of sparks per
trigger.

You can easily change the separation between sparks by changing the divider.

Any accumulated error on the free running PWM generator is removed
when it is reset by the trigger signal.

We have a very simple system that can definitely run very well at
steady state, as in an aircraft. Not sure how fast you need the
reaction time to be when it is running in a race car.

Since there is a missing tooth. You will have to write some logic to
discard huge difference in count from cycle to cycle to account for
the missing tooth. So simply remembers the large count, and checks it
again on the next interrupt, and see if there is really a big change
or not. Once you find the position of the missing teeth, you can add
logic in your BASIC to ignore the position when it becomes really
large. (Or take advantage of the coil trigger signal)

Henry


If you have a 2nd gen CAS you can remove the drive gear by
removing the roll pin and power it with an electric motor
capable of running 10,000 RPM and see if it works
with your hardware and software. Tall order.

The optical sensor I am now using turns on and off in 20 nano seconds.

Take a look at the LM1815 .

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-2014 All world wide rights reserved.