Hi Ben,
Below are snippets of code and functions to drive the 7366.
It probably needs a few more comments to make it obvious.
-mike
ps I was very wowwed by your ferrari/4 project!
#include
' 7366 encoder interface pins
#define ENC_MISO 10
#define ENC_MOSI 9
#define ENC_SS_B 12
#define ENC_SCK 11
#define ENC_INDEX 8
' 7366 encoder interface opcodes
#define ENC_CLR $00
#define ENC_RD $40
#define ENC_WR $80
#define ENC_LOAD $C0
' 7366 encoder interface registers
#define ENC_NONE $00
#define ENC_MDR0 $08
#define ENC_MDR1 $10
#define ENC_DTR $18
#define ENC_CNTR $20
#define ENC_OTR $28
#define ENC_STR $30
'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
' write_7366
'
' writes a command to the 7366
'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
sub write_7366 ( opcode, register, dat, ln )
dim i as integer
dim ci as integer
ENC_DATAOUT$(0) = opcode + register
for i = 1 to ln
ENC_DATAOUT$(i) = dat >>(ln-i)*8 and $FF
next i
SPIOUT( ENC_SS_B, ENC_SCK, ENC_MOSI, 0, ln+1, ENC_DATAOUT$ )
endsub
'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
' read_7366
'
'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
function read_7366 ( opcode, register, ln )
dim datain as integer
dim i as integer
ENC_DATAOUT$(0) = opcode + register
' (CSpin, INpin, CLKpin, OUTpin, LSBfirst, OUTcnt, BYREF
OUTlist as STRING, INcnt, BYREF INlist as STRING)
SPIIN( ENC_SS_B, ENC_MISO, ENC_SCK, ENC_MOSI, 0, 1, ENC_DATAOUT$, ln,
ENC_DATAIN$ )
datain = 0
for i = 0 to ln-1
datain = datain + (ENC_DATAIN$( i ) << (ln-i-1)*8)
' print " ", i , ENC_DATAIN$( i ) , ENC_DATAIN$( i ) <<
(ln-i-1)*8, datain, 1 << i, (ln-i-1)*8
next i
' print ENC_DATAIN$(0), ENC_DATAIN$(1), ENC_DATAIN$(2), ENC_DATAIN$(3)
return datain
endfunction
'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
' init_7366
'
' initialize the 7366 encoder interface chip. Places it into a known state
'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
sub init_7366
dim cntr_value as integer
dim dtr_value as integer
write_7366( ENC_CLR, ENC_MDR0, 0, 0 )
write_7366( ENC_CLR, ENC_MDR1, 0, 0 )
write_7366( ENC_CLR, ENC_STR, 0, 0 )
write_7366( ENC_CLR, ENC_CNTR, 0, 0 )
write_7366( ENC_WR, ENC_MDR0, $83, 1 ) ' $03= x4 quad count mode,
$10= DTR to CNTR when index=0, async index
write_7366( ENC_WR, ENC_MDR1, $00, 1 ) ' 4 byte counter mode,
enable counting, no flags
' write_7366( ENC_CLR, ENC_CNTR, 0, 0 )
write_7366( ENC_WR, ENC_DTR, -park_angle*2, 4 )
write_7366( ENC_LOAD, ENC_CNTR, 0, 0 )
end sub
''''''''''''''''''''''''''''''''''''''''''''''''
''''''''''''''''''''''''''''''''''''''''''''''''
sub measure_angle
dim value as integer
dim diff as integer
dim save_time as integer
dim angle_meas_str$ (10)
dim angle_speed_str$ (10)
value = read_7366( ENC_RD, ENC_CNTR, 4 )
value = -value/2 ' negate the angle so as to make +ve angle for
+ve elevation
. . .
''''''''''''''''''''''''''''''''''''''''''''''''
''''''''''''''''''''''''''''''''''''''''''''''''
Engine management system
-
YahooArchive
- Posts: 1462
- Joined: Fri Oct 19, 2012 5:11 am
Re: Engine management system
Hi Roger,
Sorry I got my email replies swapped. I was truly impressed with your
project.
Molding your own o-rings!
The trickiest thing about those chips from LSI was finding a
distributor. Let me know
if you want to get hold of these chips and I'll see if I can track down
where I got mine from.
-mike
Sorry I got my email replies swapped. I was truly impressed with your
project.
Molding your own o-rings!
The trickiest thing about those chips from LSI was finding a
distributor. Let me know
if you want to get hold of these chips and I'll see if I can track down
where I got mine from.
-mike
-
YahooArchive
- Posts: 1462
- Joined: Fri Oct 19, 2012 5:11 am
Re: Engine management system
Thanks for the complements Mike.
I got all excited for a moment then when I saw all that code. Did you manage to
source from LSI in the UK, assuming you're in the UK of course?
"basicnode" wrote: "Rather than trying to use the CPU to time
pulses, the counter/timer hardware would probably be a better match" – sounds
like Bruce aggress on separate hardware which is quite reassuring. Do you have
any info such as number of IOs etc on the SuperPRO yet Bruce?
I got all excited for a moment then when I saw all that code. Did you manage to
source from LSI in the UK, assuming you're in the UK of course?
"basicnode" wrote: "Rather than trying to use the CPU to time
pulses, the counter/timer hardware would probably be a better match" – sounds
like Bruce aggress on separate hardware which is quite reassuring. Do you have
any info such as number of IOs etc on the SuperPRO yet Bruce?
-
YahooArchive
- Posts: 1462
- Joined: Fri Oct 19, 2012 5:11 am
Re: Engine management system
Hi Roger,
Very interesting project. With respect to your ignition control problem you
should check out the ECU (Electronic Control Unit) used to control the rmp of
the gas jet turbines used by the model airplane hobbiests. These engines are
running at speeds at 200 - 300.000 rpm. The ECU measures in a pid closed loop
the rpm and engine temperature and based on the speed input open/closed the fuel
input. Description and schematics for diy ECU can easily be found on the web and
could easily adapted to control your 1/4 scale Ferrari engine.
pixeltje
Very interesting project. With respect to your ignition control problem you
should check out the ECU (Electronic Control Unit) used to control the rmp of
the gas jet turbines used by the model airplane hobbiests. These engines are
running at speeds at 200 - 300.000 rpm. The ECU measures in a pid closed loop
the rpm and engine temperature and based on the speed input open/closed the fuel
input. Description and schematics for diy ECU can easily be found on the web and
could easily adapted to control your 1/4 scale Ferrari engine.
pixeltje
-
YahooArchive
- Posts: 1462
- Joined: Fri Oct 19, 2012 5:11 am
Re: Engine management system
Hi pixeltje
That set me thinking for a moment but with my very limited knowledge of gas
turbines, there aren't any timed events that have to happen at specific phases
of rotation are there?
Once it's ignited and able to run without its starter the flame is constant,
there's no ignition and the fuel feed is constant but flow / pressure variable
dependant on throttle and other factors so it doesn't need to necessarily
calculate required fuel at 200,000 times per minute presumably ....
What do you think? I'd be interested to have a look at any schematics if you
know of any – I do appreciate any input, so many thanks pixeltje
Roger
That set me thinking for a moment but with my very limited knowledge of gas
turbines, there aren't any timed events that have to happen at specific phases
of rotation are there?
Once it's ignited and able to run without its starter the flame is constant,
there's no ignition and the fuel feed is constant but flow / pressure variable
dependant on throttle and other factors so it doesn't need to necessarily
calculate required fuel at 200,000 times per minute presumably ....
What do you think? I'd be interested to have a look at any schematics if you
know of any – I do appreciate any input, so many thanks pixeltje
Roger
-
YahooArchive
- Posts: 1462
- Joined: Fri Oct 19, 2012 5:11 am
Re: Engine management system
Roger,
I live in California, but I'm currently in the UK (Poole) for a week so
I don't have my distributor
info. However I just noticed that
http://www.usdigital.com/products/interfaces/ics/ does ship internationally.
I agree with others, it's best to use external counter timers to do this
sort of thing. For me having a single counter/timer chip
with a serial interface to save ARMWeb pins was important. Not using up
cpu horsepower doing fine resolution timing was a
secondary consideration.
My application was a solar collector mirror controller with web
interface, and the rpm is 1 cycle/day
-mike
I live in California, but I'm currently in the UK (Poole) for a week so
I don't have my distributor
info. However I just noticed that
http://www.usdigital.com/products/interfaces/ics/ does ship internationally.
I agree with others, it's best to use external counter timers to do this
sort of thing. For me having a single counter/timer chip
with a serial interface to save ARMWeb pins was important. Not using up
cpu horsepower doing fine resolution timing was a
secondary consideration.
My application was a solar collector mirror controller with web
interface, and the rpm is 1 cycle/day
-mike
-
YahooArchive
- Posts: 1462
- Joined: Fri Oct 19, 2012 5:11 am
Re: Engine management system
Hi Roger,
Take a look at this web site for some details regarding the requirements for
jet turbine ecu. the latter controls the fuel intake based on the required
turbine revolution (=speed) and allowed jet temperature. At start up ,it
also controls the glow plug (= ignition phase).
http://www.5bears.com/ecu.htm
Pixeltje
PS
http://www.autoshop101.com/forms/h20.pdf this a short illustrated
description of EFI by Toyota and the next link give all details about a diy
EFI:
http://www.bgsoflex.com/megasquirt.html
Take a look at this web site for some details regarding the requirements for
jet turbine ecu. the latter controls the fuel intake based on the required
turbine revolution (=speed) and allowed jet temperature. At start up ,it
also controls the glow plug (= ignition phase).
http://www.5bears.com/ecu.htm
Pixeltje
PS
http://www.autoshop101.com/forms/h20.pdf this a short illustrated
description of EFI by Toyota and the next link give all details about a diy
EFI:
http://www.bgsoflex.com/megasquirt.html
-
YahooArchive
- Posts: 1462
- Joined: Fri Oct 19, 2012 5:11 am
Re: Engine management system
Hi Mike
Thanks once again....
Things will go quiet for a while now – Girlfriend with scissors says it's either
the power lead on my PC or sensitive parts of my anatomy unless I finish (or
does she mean start!) packing as we move house on Thursday.
Thanks to everyone for their contribution and back soon, hopefully with
genitalia intact!
Roger
Thanks once again....
Things will go quiet for a while now – Girlfriend with scissors says it's either
the power lead on my PC or sensitive parts of my anatomy unless I finish (or
does she mean start!) packing as we move house on Thursday.
Thanks to everyone for their contribution and back soon, hopefully with
genitalia intact!
Roger