Jump to content

Hercules engine control

Recommended Posts

Found an interesting read over here about one way to get crank position and such.


Basically run a timer that resets to zero every time a tooth on the wheel is detected and run a second timer based on that duration and have it scaled to overflow multiple times between teeth and generate interrupts on each overflow. Since the teeth are 11.25 degrees apart, it takes 4 teeth to arrive at a whole number again, which is 45 degrees rotation. I could scale the second counter to interrupt every 0.25 degrees but that would be 360*4 (1480) interrupts per revolution, or 264000 interrupts per second at 11000 RPM; probably doable but extreme.


Another option might be a tooth counter that disables the second timer until the crankshaft is a few teeth from 'target' teeth. Meaning if I know the crankshaft is approaching when the ignition should fire, start counting teeth, work out position then fire when needed and suspend the timer until needed again.


Fuel injection is another story and might need its own timer setup.

Link to post
Share on other sites
  • Replies 81
  • Created
  • Last Reply

Top Posters In This Topic

Top Posters In This Topic

Popular Posts

Looks like absolutely the right guy ended up with the board.

All I need are 12 more characters and I can install some unknown software package.... 

Thought about it some more: I'm an idiot. And if I had a dollar for each time I've had that epiphany, I'd be a rich idiot. I have two VR sensors around, and a single tooth on the flywheel, so can ge

Posted Images

So, if things went like (start and idle situation only):


Main (cam / crank triggers are digital):

0) one timer set to run and cover two continuous revolutions of the engine down to < 300 RPM;

1) engine starts to crank;

2) fuel pump turns on (mechanical pressure control for now);

3) ecu counts crank teeth and establishes RPM- since teeth are 11.25* apart only a few teeth are needed;

4) ecu detects cam tooth, knows engine cycle, injects small amount of fuel to prime the engine, enters run state, ;

5) ecu detects cam tooth, resets crankshaft tooth count;

6) ecu interpolates crankshaft position using timer 'between' crank teeth';

7) ecu samples MAP, CLT, IAT and TPS; calculates future fuel requirements (should be time dependent, see below);

5) ecu detects cam tooth, resets crankshaft tooth count;

6) ecu interpolates crankshaft position using timer 'between' crank teeth';

8) ecu fires spark plug considering 5ms duration leading pulse using OUTMODx 11 / TAxCCRn;

9) ecu fires fuel injectors at leading time / duration, timers are similar to ignition set/reset;

10) go to 5).


Sampling routines (mostly analog, for now), any output exceeding 5v0 rail is clamped to rail:

(ADC ref is 3v0, but ADC inputs are 1/2 divided.)


Sample @ 1mS:

- 5v0 rail sampled, running average;

- Map sampled- smoothing / averaging applied;

- TPS sampled- smoothing / averaging applied;


Sample @ 50mS:

- IAT sampled- smoothing / averaging applied;


Sample @ 1S

- CLT sampled- smoothing / averaging applied.


In essence, 5v0, MAP and TPS are sampled frequently. IAT and CLT are sampled less frequently. May be a problem, I don't know.



Various outputs, I'm thinking of using bits within one variable to indicate status that can be polled in some function / routine.


I.e. consider bytes (or maybe combined uint_16) "injOut", and "ignOut", the structures could be as follows:

injOut bit 0 = ignition 1

injOut bit 1 = ignition 2

injOut bit 2 = ignition 3

injOut bit 3 = ignition 4

ignOut bit 0 = injector 1

ignOut bit 1 = injector 2

ignOut bit 2 = injector 3

ignOut bit 3 = injector 4

Changing any bit would enable or disable that output. The function would be called by an interrupt and if any bit was '1' it would turn the related GPIO on, and if the bit is '0' it would turn the related GPIO off.

Probably a better way to do it, but it hasn't occurred to me yet.

Link to post
Share on other sites
  • 4 weeks later...

You need to pay attention to your switchmode layout. The connection between the ic, diode and inductor needs to be as short as possible. You should only extract the output from the capacitor, not elsewhere on that track.


I have a hercules launchpad board i bought for building an ecu - the n2het was the decider. I played a bit with writing n2het code but got distracted with other things. I'm still not up to speed with the instructions.


Having reverse engineered a few ecus, i can offer the following:


Use software filtering on all inputs - never have more bandwidth than you need.

Bounds check your analog inputs - if they are out of range, flag it and substitute in a nominal value.

Link to post
Share on other sites

With the layout, you've made a great antenna that will radiate. So is this a problem? Yes and no. The losses will probably not be an issue but the radiation may cause indirect problems like stopping gps receivers working or get into your analog signals. If you know someone with a spectrum analyser then they can measure what frequency it radiates at and how much.

Link to post
Share on other sites

With the layout, you've made a great antenna that will radiate. So is this a problem? Yes and no. The losses will probably not be an issue but the radiation may cause indirect problems like stopping gps receivers working or get into your analog signals. If you know someone with a spectrum analyser then they can measure what frequency it radiates at and how much.

I'd have to check, but I think the Anritsu I have here does Spec-An, just need an appropriate antenna... and the circuit too. But, the stock EFI system the bike had fired the low impedance injectors and the drivers were a board removed from the processor, which was mated to the IO board via ribbon-like cables. Logic board is the one on the right, in the picture below, and the injector drivers are those two transistors mounted to the side of the case, on the lower left side of the picture.



Still working things out though, so any suggestions and observations and comments are welcomed.



Link to post
Share on other sites

Oh, and the processors are marked ND079753-0030 and ND079753-0021.

Apparently they are an 8XXX based processor. Also, there's a D8253C-5 chip which is a 3 x 16 bit timer chip and according to the datasheet for that it is intended for 8080 type processors. Since development of the CX500TC started in the mid-1970's, it using an 8080 derived chip seems plausible.

Link to post
Share on other sites

Ordered the Ampseal 35 plug from Mouser... ~$17 including shipping.

That'll be helpful for mock-ups, to make sure the plug won't interfere with the LP position... but it looks like it might since the Hercules LP is a tad longer than the Tiva or F5529 LPs are. Fortunately, there's room to move the LP headers if necessary.


I also assume there will be some changes to routing necessary.

Link to post
Share on other sites

The eprom had no code - just tables it seems. The processor is probably 8048 based. These usually didn't have any form of code protection. It's interesting that there is two 48pin chips - maybe one is the rom. You need around 4k of code to anything useful.

The a/d is probably done using a dual slope technique as was common in ecus back then. The GPz1100 box used a 6803 based chip that did fuel only. I built a board that put the cpu in a different boot mode and had it execute code from an external eprom that dumped the rom code. I did the same with a Mitsubishi Cordia ecu that used a similar cpu.


The ignition is the critical parameter for getting extra power - with tighter control, you can run the engine closer to detonation. Modern engines would destroy themselves with the crude ignition systems of times gone by.

Link to post
Share on other sites

Honestly, not sure what to think about the two chips. Searching the number 079753 suggests they are both processors- other chips from ND with those numbers are mentioned as being used in RX7, Miata and other vehicles. It's possible they're made by ND and contain mask ROM.


In other news, the Ampseal connector came in and it looks like there's not quite enough room for the Hercules board. Easy enough fix though.


And for S&G, I laid down the Connected LP and it would work with the LP on top and the Ampseal below the board. Ethernet would be somewhat unnecessary, but I digress. :D

Link to post
Share on other sites
  • 3 months later...

I don't have a processor on the board yet- need to find the Eagle file for it.

I'd like feedback for what's done already, and the vias with routed traces to them are simple place-holders for the sensors and SPI. And the upper side of the 33814 chip is I/O for switching things. I'd need level translators for those, and SPI, to convert that from 5v to 3v3.


Top ground fill layer ripped for better visibility:


Was going to upload Eagle brd and sch files for what I have but apparently I'm not permitted to? So, zipped it is.



In case you're wondering:

CXPEFI = CX (my motorcycle) Programmed Electronic Fuel Injection; AG = processor AGnostic; A = revision... though I'm probably way past "Z" regarding revisions.


Nutshell summary:

P-Channel FET (IFR9530) for reverse polarity protection; SMBJ40 for transient protection; 3A Polyfuse; cute LED's to let you know you screwed up. :)


MC33814 chip:

- controls 2 IGBT's for ignition (top-left), with the two logic level signals brought out to the connector, the thought being the IGBT's and such would be an 'optional' part for those that may want to use normal, inductive coils.

- controls Lambda / O2 narrow band heater (D-PAK mosfet near bottom right) so closed loop operation at cruise velocities can be used.

- fires two high-impedance fuel injectors.

- controls 2 external relays for power distribution (or some alternative) purposes.

- provides tachometer and MIL (malfunction indicator lamp) outputs.

- reads crankshaft variable reluctance sensor and provides that signal to the MCU.

- provides filtered / protected 5v to the sensors.


MAX9924 chip:

- senses camshaft variable reluctance sensor signal and sends that to the MCU for engine phase detection purposes.


I'd love to use the TMS570LS0432 / Hercules chip, or even the LP, but there's no documentation available (that I can find, at least) regarding the hardware angle generator (HWAG), and that would be perfect for firing the time-critical events (ignition and injection)- similar functionality to the Freescale eTPU module.


To-do's include figuring out RTC, barometric sense and SD card, the former and latter purely for data logging, the programming interface, and the interface to the dashboard- probably I2C.

Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

  • Create New...