Subject: Successful test of the RPM module. Finally.
From: Rotary Engine
Date: 7/17/2010, 6:56 AM
To: AAA Put this in the To box


This is a module that reads a mag pick up looking
at the starter teeth on a fly wheel to quickly
determine RPM to the nearest rev in less than
a second. I used Craig Smith function generator
to simulate the flywheel pickup.

I have been working hard on it for about week
to get the bugs out of the hardware and software.
The wiring and logic mistakes were the hardest
to find.

Here is the software. A lot of the stuff in here
will not be needed in the final program as it is just
diagnostic for debugging purposes. There will be some
minor changes in the PC board as I will add the LM311
mag sensor chip and fix one or two wiring mistakes
on my part. The program uses the super fast ZBasic read
a port Register Dot instruction that is capable of reading a
port in less than a microsecond.


public x as long
public RPM as byte
Public hour as byte
Public minute as byte
Public seconds as single
Public pin88 as byte

Sub Main()
Register.DDRH = &H00  ' set the direction
Register.PORTH = &H00 ' turn off pullups

Call PutPin(87, ZXOutputHigh)
Call PutPin(89, ZXOutputHigh)
Call PutPin(86, ZXOutputHigh)   'enable

for x = 1 to 50000000
pin88 = Getpin(88)
If pin88 = 0 then
Call getval
end if
next
End Sub


Sub getval ()
Call PutPin(86, ZXOutputLow)   'disable the counter
Call GetTime(hour, minute, seconds) 'time stamp not needed.
debug.print hour;               'all not  needed.
debug.print " " & Minute;
debug.print " " & seconds;
debug.print " x = " & x        'loop counter not needed
RPM = Register.PinH            'read the port
debug.print "RPM = " & RPM     'display it on notebook

Call PutPin(89, ZXOutputLow)    'reset latch low does it
Call PutPin(89, ZXOutputHigh)  '
Call PutPin(87, ZXOutputHigh)  'reset count
Call PutPin(87, ZXOutputLow)     'reset
Call PutPin(86, ZXOutputHigh)   'enable

end sub

The entire program takes about 10 msec to run as
it is now but that will be cut way down in the final
implementation. One of the big time consumers is
sending the data to the notebook. My old notebook
is limited to 19,600 baud so that will also be reduced
with a more modern and faster USB port.

Eliminating the time stamp alone will kill
at least 5 ms. Note the few different types
of instructions necessary. Typical of most
programs. Mostly just PutPin()

The sample period will be adjusted for the
number of teeth on the flywheel with the pot.
All this is going on the back ground and
will not be needed for each rev of the
motor.

Paul Lamar
-- 
The Rotary Engine NewsLetter. Powered by Linux.
ACRE NL web site. http://www.rotaryeng.net
Youtube key word PaulLamar2
Copyright 1998-2010 All world wide rights reserved.