The aim of the circuit is to allow a huge input amplitude voltage range for easy installation and support for VR type engine(or wheel) phase(which has RPM info of course) sensors.
History: the former inferior optocoupler circuit
GenBoard/VerTwo used the same optocouple based circuit that was used in motorola-megasquirt. Even though it went through several iterations in the ancestors, the circuit is not very good.
An input trigger needs:
- better if the hysteresis increases with input signal amplitude (adaptive hysteresis)
- protection from input spikes
The optocoupler could also provide total isolation, but it's not required, nor used here: the input and output GNDs are actually connected. Protection from input spikes is not a big deal, it can be solved with well sized resistors, caps and diodes, which are needed anyway.
GenBoard v3.0 early revisions (never manufactured) had 2 selectable solutions:
- optocoupler based circuits like the original, but two of them (with a nice 8-pin SMD part with 2 darlington optocouplers)
- and 2 generic OPA based circuits with hysteresis that could be configured as amplifier as well.
After comparisons, the optocoupler based circuit was dropped, since it cannot cope with the basic requirements: no hysteresis. Even though it definitely works with difficult installation and software filtering, but why not do better?. Read below.
So a professional solution with the LM1815 chip was implemented, which can handle any type of InputTrigger (although the resistor-values depend on type). 2 channels of them, of course.
After reading the datasheet and inspecting proven applications like
We put 2 instances of a similar circuit on GenBoard/VerThree PCB.
The LM1815 is not very cheap:
- footprint: Jorgen can make an ECU with beyond motorola megasquirt functionality in about a DB37 case, which could only host about 4 LM1815 circuits.
- price ~ 3 Euro for 1 chip (1 channel) + external components + assembly + PCB footprint etc..
But it's a very good and proven solution. Something similar is used in EDIS module for EDISIgnition (so those using EDIS will not need to use the LM1815 on GenBoard/VerThree).
The input amplitude range is amazing in any case: it can clamp upto +-3mA, the external resistos must be sized according to this (but never belive me, read datasheet).
That means that without the external voltage divider it can trigger on a 200mV .. 50V peak2peak signal. 200 mV is small enough: you can acquire it with a few turns around a HV wire.
I have a wire with 2*470k resistors in it, in series. I can plug into the wall which is in Europe 230V effective (+-400V peak) and trigger GenBoard/VerThree with it: 50Hz reads as 1500 RPM (at least for 4 cyl, since this depends on config).
High Voltage input: ignition transformer primary (not secondary!) side
LM1815 based VR circuit can be used for coil-setups (the wire going to the transformer primary of an alien ignition) too: it is recommended to use an external (or onboard) voltage divider with a 900..1000k (eg. made from 2*470k in series) and a 100k to GND. This divides the max 400V (rather 200V normally, when sparkplug is there on the secondary) peak2peak signal to about 36V peak2peak (1/11).
- batch-injection: engine phase is not very interesting
- capture the factory-based ignition-advance map against a position signal
Triggering on falling edge not ideal for directly tapping transformer primary
Unfortunately the falling edge is triggered, but this is not very good: the rising edge would be much better, since there is only one rising edge, with significant amplitude. Normally there is a smaller and bigger falling edge, and the smaller wants to be neglected (and is in fact, due to the adaptive histeresys, but not ideal). Look at the textual scope snapshot for the why there are 2 falling edges:
- 12V => small falling edge (that should be neglected by trigger)
- 2V (IGBT pulls down voltage to charge the coil - this is the dwell period as you know) appr. 2V => big (and only) rising edge
- 250V (or more, if sparkplug is disconnected, and 380V clamping takes effect) => big falling edge
- 12V back to original resting state (and the cycle starts over, the small falling edge is next!!!)
Therefore some people feel more comfortable to wind a few turns around the coil wires (primary or secondary is better?) and trigger from there. A scope comes handy.
VR sensing without the LM1815 chip
This is only for the curious, since the LM1815 circuit is very nice and proven, and used all over the project, eg. there is 2 channels on GenBoard/VerThree PCB, 2 channels on InputTrigger/AudiTrigger (and on small round WideBand meter unit).
Earlier we tried smaller footprint OPA circuits with success (ask Dave), although we did not do very intensive tests.
A very simple basic comparator circuit built from OPA (with Schmitt-trigger histeresys input, any analog introduction books have the circuit example):
using with HALL sensor
- use the jumper to bypass the LM1815 circuit (no need to populate the LM1815 in fact, but doesn't hurt). The HALL output must be pulled up to 5V not 12V!
- OR use an input cap from the HALL output (C88, C89 10uF non-polarity 35V sound fine) so the signal seen by LM1815 goes below zero. Note that the information about the rising edge is lost this way.
Schmitt input helps or hurts
As irc discussion shows, this is kindof tricky for a HALL sensor.
- we set the threshold energy. We do that exactly the same way wether with Schmitt or without: with RC (values might slightly depend on input voltage-threshold level). Appr RC=5..22usec is acceptable and provides significant noise immunity. Too high RC causes unwanted delay that shifts the trigger angle (slightly) in function of RPM (can be corrected in sw in the worst case - if you tune your ignadv yourself this does not effect the result, just the exact absolute reading).
- if the threshold was reached by normal trigger pulse, it's fine
- If the treshold (that we set to our liking above ) was reached due to noise (interrupt flag has been set, a Schmitt would not clear the interrupt flag), we want the seen signal to return as fast as it can, so we can test in SW if we like, and neglect the interrupt. If the treshold we set is reached, interrupt is fired wether with Schmitt trigger or normal input: the Schmitt trigger just prevents detecting that it was a noise not a real pulse
Even though the Schmitt trigger makes things slightly worse for the trigger edge (by stopping possible improvements by SW), in practice (with reasonably set RC) the reasonable noise level is more than one amplitude lower than what would cause problem (and the need for more sophisticated sw filtering is not yet proven) .
I recommend an experiment:
- self stim from an unused (config.act_wot_channel=)S259.. pin to trigger1 (or a stimulator if you like, but the self-stim is perfect for this)
- use the mst3f msp7a (msq..) command for a slowish trigger: coil-type, nx100 RPM
- make a long dual-wire: close to each other
- one is the trigger
- other is ignition transformer primary. A real ignition transformer should be used, with realistic size sparkgap on the secondary side. This is the worst signal in the system the trigger can see around (be coupled with).
- alternatively noise can be injected from a 50..60Hz (eg. from a 9V AC wall transformer; or other signal) with a voltage divider
- on the sending side (at S259 output) use a low frequency lowpass filter to simulate a slow HALL-edge. Anything below 1000Hz is unrealistic (but can be tried as experiment) because that slow rise would cut the HALL signal at 6000 RPM. Appr. 1000Hz cutoff freq provides the worst case realistic signal-slew-rate. That causes several degrees of ignition error at 6000RPM (6000RPM=200Hz trigger signal: 1000Hz means appr. signal rise time of 15..18 crankdegrees). Normally the falling edge from a HALL sensor slew-rate is like that of a 30..100kHz signal, but the rising edge is slower, as of an appr. 8..50 kHz signal.
- use the standard RC filter (10k and 2.2nF) on the receiving side (trigger1 end of the long wire)
- use mde40 and capture the binary timestamps in TerminalProgram as on InputTrigger/TriggerLog
The above experiment would show behaviour at the other edge (eg. rising edge, if only falling is configured to fire an interrupt).
If we see a problem, we might consider a mega88 or a tiny on v3.3. While it's much more expensive than a 74AHCT132PW, it merges InputTrigger/AudiTrigger (allows 135-1 type), and allows sampling both trigger-edges for even a 60-2 HALL-setup. (Both trigger-edges can be sampled for upto 36-1 with current HW without significant sw-mods).
Note that to support any argument, things have to be summarized. Irc does not make that possible, so irc is not suitable to support any but the most trivial arguments. In fact the lack of summarization can (and often does) stop you from finding any good support statement for what you feel is right (which can be right).
The ideal solution would be DSP-like analog processing of the trigger signal. Might be possible on the ARM, but not feasible on AVR.
See GenBoard/VerThree schematic
See also InputTrigger/AudiTrigger