Jump to content
Sign in to follow this  
abecedarian

Hercules engine control

Recommended Posts

Since this is a 'new' ECU, I know I have to provide voltage out to sensors. Some of them are 5v so I need to provide that voltage out to them. Knowing the Hercules is 3v3, that voltage will be processed and sent to one ADC input, and the returns from the other sensors will be processed similarly.

 

I'm not worried about 'newb' installations and reverse voltage protection and crap like that since this is for my own use and I'm not quite that stupid, though some may argue ;); if someone tries it and blows up something, it's on them. This will not likely ever be a commercial product. I'm not sure the dev tools, libraries and such would ever allow it without substantial investment.

 

I'm working on a board approximately the same length and twice the width of the Hercules board and I foresee changing the male UP "Booster Pack" headers out for extended "male / female" stackable type, simply because I want the Herc LP on top with my board below.

 

 

 

Anyhow, if anyone has or knows of an Eagle library with MAX9926 IC in it, I'd appreciate the information.

Share this post


Link to post
Share on other sites

... if anyone has or knows of an Eagle library with MAX9926 IC in it, I'd appreciate the information.

Never mind, found MAX9927 on E14, and it's almost the same pinout.

Share this post


Link to post
Share on other sites

I like the idea of plugging the Hercules "on top of" the mainboard too. It lets you have unfettered space to put some kind of LCD boosterpack on top for detailed feedback. I'll get some closer measurements of my headers later...

 

Share this post


Link to post
Share on other sites

@@spirilis - I have a favor to ask: can you confirm somehow that J10, the 30 pin header, pin 29 is 0.425" from J4 pin 1.

 

I ask because I loosely set a single row, 10 pin male header in J10 / positions 25-6. I then tried to set a female header over J4 and the 10 pin header: the female pulls the far end of the 10 pin loose header up like it's bending it to get the pins in. Visually, it looks to be about the width of a physical pin difference, so instead of having exactly 3 pins between J4 and J10, it's 4.25.

 

Not sure I'm making sense. :S

 

Thanks.

Looks like it.  My Messograf pen's caliper reads around 10.8mm (not exact since I'm eyeballing it), which is around .420" or so, so .425" is probably the real value.

Share this post


Link to post
Share on other sites

Since this is a 'new' ECU, I know I have to provide voltage out to sensors. Some of them are 5v so I need to provide that voltage out to them. Knowing the Hercules is 3v3, that voltage will be processed and sent to one ADC input, and the returns from the other sensors will be processed similarly.

 

I'm not worried about 'newb' installations and reverse voltage protection and crap like that since this is for my own use and I'm not quite that stupid, though some may argue ;); if someone tries it and blows up something, it's on them. This will not likely ever be a commercial product. I'm not sure the dev tools, libraries and such would ever allow it without substantial investment.

 

I'm working on a board approximately the same length and twice the width of the Hercules board and I foresee changing the male UP "Booster Pack" headers out for extended "male / female" stackable type, simply because I want the Herc LP on top with my board below.

 

 

 

Anyhow, if anyone has or knows of an Eagle library with MAX9926 IC in it, I'd appreciate the information.

PS, if you don't already have stackable boosterpack headers, check this out:

http://launchpad.mlelectronics.com/

 

Haven't bought from them yet, heard about it from Mark Easley TI.  The pins on those are supposed to be thicker than your typical flimsy stackable headers, probably a great option for replacing a LaunchPad's headers.

Share this post


Link to post
Share on other sites

I like the idea of plugging the Hercules "on top of" the mainboard too. It lets you have unfettered space to put some kind of LCD boosterpack on top for detailed feedback. I'll get some closer measurements of my headers later...

I don't like the idea of 'de-soldering' things, but I'd rather have unfettered access to the buttons and jumpers, and LED's for some status indication.

 

Looks like it. My Messograf pen's caliper reads around 10.8mm (not exact since I'm eyeballing it), which is around .420" or so, so .425" is probably the real value.

Thanks amigo.

Share this post


Link to post
Share on other sites

So, where I'm "at" is a board 'nearly' the same length as the Herc LP, and about 2x wide, with 3v3 stuff on the left (where the Herc board will be) and some 5v0 stuff will interface, along with the 12v stuff on the left.

 

As mentioned, MAX9926 are most likely to be used to read the variable reluctance sensors I have... still researching. ;)

 

Still thinking about the 12v stuff, back-emf from the injectors and other things.

Share this post


Link to post
Share on other sites

So a (maybe not-so) quick run-down of chassis connections, how many conductors....

 

Currently existing and external to the ECU, necessary for safe operation:

- main key switch: 1 wire- supplies power to the entire electrical system, powers everything through a relay / solenoid;

- tilt switch: wired in series with and immediately following the main key switch output, interrupts all power if the bike falls over;

- start switch: 1 wire- 12v supply to the starter, via solenoid, and is also a signal to the ECU that the engine is cranking to start;

- neutral switch: wired in series following the start switch, closed if the bike is in neutral;

- clutch switch: wired in parallel with the neutral switch, closed if the clutch lever is pulled.

 

 

Sensors and other devices, and connections to the ECU:

- manifold absolute pressure (MAP): 3 wires- power, ground signal, mounted within the ECU;

- throttle position sensor (TPS): 3 wires- power, ground, signal (basically a potentiometer);

- intake air temperature (IAT): 2 wires- power and signal;

- coolant temperature (CLT): 2 wires- power and signal;

- crankshaft position (x2): 2 (x2) wires- variable reluctance sensor generates AC voltage as 'teeth' pass by;

- crankshaft index: 2 wires- variable reluctance sensor generates AC voltage as a 'tooth' passes by;

- camshaft position: 2 wires- variable reluctance sensor generates AC voltage as 'teeth' pass by;

- fuel pump relay: 1 wire- voltage to turn relay on;

- warm-up regulator / air bypass valve relay: 1 wire- voltage to turn relay on;

- fuel injector power relay: 1 wire- voltage to supply 12v to injectors;

- fuel injector controls: 2 wires (1 per injector) to ground injectors and cause them to discharge fuel;

- ignition coil power relay: 1 wire- voltage to turn 12v supply to ignition coils on;

- ignition coil triggers: 2 wires (1 per coil) to supply logic level signals to cause the ignition coils to 'fire'.

 

> Power to TPS, IAT and CLT will be supplied by a 5v regulator internal to the ECU. The signals from those sensors, as well as the 5v regulator's output used as a reference, will provide (hopefully) accurate data to be used for calculating how much fuel should be delivered to the engine.

 

> Crankshaft position will be detected using the N2HET module's quadrature encoder: 2 VR (variable reluctance) sensors will detect the teeth on a gear mounted to the crankshaft providing 'relative' position information as well as direction (don't want the engine running backwards, right?); another VR sensor (existing) will detect a single tooth on the flywheel in order to provide the 'index' signal and thus allow determining absolute crankshaft position.

 

> Engine 'phase', as in 'intake', 'compression', 'power' and 'exhaust' strokes, will be detected by a VR sensor mounted to the camshaft.

 

I'm conflicted as to whether or not measuring barometric air pressure and temperature is important since I'll be measuring the intake manifold air temperature and pressure already... which I think would be sufficient- air density entering the engine determines how much fuel to add.

Share this post


Link to post
Share on other sites

@@abecedarian , that is a lot of variables!

 

Do you have code and or algorithms that you will be working off of? Or are you starting from scratch with respect to the firmware?

 

Looks like it is going to be an interesing (and if it was me, an extremely challenging) project.  :)

Share this post


Link to post
Share on other sites

@@abecedarian , that is a lot of variables!

 

Do you have code and or algorithms that you will be working off of? Or are you starting from scratch with respect to the firmware?

 

Looks like it is going to be an interesing (and if it was me, an extremely challenging) project.  :)

I'll be looking at Stingray 3 and rusefi for inspiration.

Both are ARM-based, the former ARM7TDMI (processor agnostic, I believe) and the latter is STM32F4 (ARM M4F).

 

The basics are more complicated than it appears, I believe.

For instance....

Fuel injector duration: fuelInjectorDuration = injectorDuration[RPM,TPS,MAP]; 3-dimension table relating RPM, throttle position and manifold pressure with each entry storing how long the injector should be open, can be 'byte' sized entries since values will be 0 to less than 100ms.

Ignition timing: timingIgnition[RPM,TPS,MAP]; 3-dimension table relating RPM, throttle position and manifold pressure with each entry storing when the coils should fire, can be 'byte' sized entries since they will range from 0 to 40 degrees.

Fuel injector timing: timingFuelInjector[RPM]; adjusts injector 'timing' so the injector is done spraying fuel just before the intake valve closes, can be 'byte' sized since they will be from 0 to 255.

 

The big issue with the above are the indices, which can range from 0-11000 for RPM and 0-4095 for TPS and MAP, so those indices will need scaling and that will reduce resolution. Therefore some interpolation will be needed if an index falls between values. I have to work that out.

 

Then there are 'correction factors':

Coolant temperature: correctionCLT[CLT], where CLT is the temperature of the sensor and the value is a + or - offset.

Intake air temperature: correction[iAT], where IAT is the temperature of the sensor and the value is a + or - offset.

Share this post


Link to post
Share on other sites

Since timing is pretty critical I would imagine the downside to a software bug could be a new engine... :o

Timing is critical... to a point, and how long the engine is run in that state.

 

'Late' ignition timing is not so much a problem as 'early'.

'Early' ignition timing is most commonly known as the pinging and detonation that can occur with lean mixtures or if the engine has overheated and is definitely bad, no matter what... unless you have a lean burn engine that can tolerate it.

'Late' ignition timing will drive up exhaust gas temperatures and can hurt the exhaust valves, but at the same time is good for spooling up a turbocharger since the fuel will continue burning as it leaves the cylinders and enters the turbo, but it is hard on the exhaust valves and can lead to pre-ignition, where the air/fuel mixture spontaneously ignites when introduced into the cylinder.

 

 

Fuel injection timing, meaning the relation between when the fuel injector 'injects' and if intake valve is open or closed, is not so much an issue. Ideally, the injector would finish spraying just before the intake valve closes, and if possible, not start spraying until just before the intake valve opens, so no fuel sits in the intake. Not likely to happen here, though, so some fuel will puddle on the backside of the valve. Might mean the mixture is a little rich, but whatever it is, it has to live. ;)

 

 

Besides things like the ignition timing, and how long fuel injectors are open there isn't much else too critical, so to speak.

Share this post


Link to post
Share on other sites

I should probably elaborate and say "everything is critical" but nothing other than ignition and injector open time are "time critical".

 

Ignition events HAVE to occur at the proper time, and include compensation for coil dwell time, which is 5ms for the coils (LS2 type) I will be using. I will need to know at what crankshaft position the coils should fire, and calculate at what position they should be triggered; this is RPM dependent, obviously, and subtract that from calcs. At 11000 RPM (absolute redline RPM I will program for), each cylinder would be at top-dead center 183.3 times per second, but only has to fire every-other revolution so therefore would fire approximately 92 times per second. I think that's feasible with some room to spare. ;)

 

Injection will be another story though since the injectors will have to be open long enough to inject enough fuel. Still working on that math but the stock ECU did it, so why can't I, right? ;)

 

 

I'm also contemplating PWM the fuel pump to control fuel pressure, as opposed to a physical pressure regulator. The benefit being able to control FP electronically; the downside being non-recirculating fuel will be 'hotter', as in temperature. Probably not as much an issue on a motorcycle as it would be a car, though. This would also allow a lower volume / higher filtration filter can be used though, too, as opposed to a filter that MUST allow full flow through it at all times. Something else to work out. ;)

 

 

Anyone interested? Just started working on things....

Header J3 (BPXL layout, left side, looking down) pin assignments....

Sensor signals pass through op-amps with 0.5x gain to limit voltages to 0-2.6 (0-5.2v actual):

J3 / pin 3 = SENS_REF (reference of V_OUT to external sensors)

J3 / pin 4 = MAP_ADC (return signal from MAP sensor, sensor is on-board)

J3 / pin 5 = TPS_ADC (return signal from TPS sensor, sensor is off-board)

J3 / pin 6 = IAT_ADC (return signal from IAT sensor, sensor is off-board)

J3 / pin 7 = CLT_ADC (return signal from CLT sensor, sensor is off-board)

 

Still need to figure out where to route the outputs from the MAX9926 chips, outputs to ignition drivers (logic level so might only need simple transistors), and injector drivers. Haven't decided on low or high impedance injectors so low is probably the best option since the drivers for them can drive high impedance injectors with little issue.

 

Might need some logic-level translation for the VR sensor / MAX9926 chips; I must review and work on that.

Share this post


Link to post
Share on other sites

What I'm thinking is this:

 

Key goes on and main relay is energized. This sends power to the 'tilt' switch and if the bike is 'upright' the tilt switch provides power to the ECU.

 

The "ECU" then starts doing some basic self-tests. If there is an issue, the ECU will not enable fuel injection, and maybe not ignition either. Maybe have LED's visible through the case indicating where a fault may lie, i.e. MAP, TPS, CLT, IAT values out of expected range, signifying a short to ground or V+ (I'm buffering those through an op-amp so shouldn't have an issue with those conditions... I hope.)?

 

So, if everything is okay, the ECU turns the fuel pump on to pressurize the system, then sits and waits for the 'Start' signal. When "Start" is received the fuel pump is turned on again, and the ECU starts checking position sensors, eventually getting a lock on crankshaft position and engine phase and can then start calculating how much fuel to inject and when to fire the spark plugs.

 

Then the engine auto-magically runs... :D

 

'Side notes':

- the main system relay, controlled by the key will provide 12v to the fuel pump / relay, ignition coils, injectors and 'tilt' switch.

- the ECU will switch grounds in order to control the fuel pump relay and injectors.

- the ECU will provide a logic-level (0-5v) signal to fire the ignition coils- bring the signal 'high' then goes 'low' to fire the coil.

- I haven't decided on cold-start things but my bike uses a bi-metallic strip to control a valve that bypasses the throttle when cold. So my use case is to give that power when the engine is running, most likely power in parallel across the fuel pump relay.

 

I'm open to suggestions. ;)

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

×