bobxyz
Board Member
- Joined
- Aug 29, 2014
- Location
- Boulder CO
Sorry, I haven't had as much time as expected to work on this project in the last few days, and haven't had time to fully follow all the recent discussions.
I'm still planning on using simple RC circuits, and a couple high-speed switching diodes for inductive clamps, to monitor the EZK/ECU signals. I'd like to keep the added loading on the EZK/ECU signals to only ~10uA to ~50uA, or ~200K ohms to 1M ohm (definitely high impedance). I need to trace the EZK Tq/Load signal driver to see if higher loading can be used since it's the fastest signal of the bunch. I also need to trace the IGN driver because I'd like to measure exact ignition advance, and may need lower RC delay for the desired accuracy.
For grounding, the Arduino board needs to connect only to ground in the EZK, or only to ground in the ECU. Any other connection may add a bad ground loop that might affect normal engine control.
For high speed timing measurements in the Arduino, you need to setup custom PCINT PinChangeINTerrupt code. This will trigger an interrupt routine whenever the logic level of one of the enabled pins changes. The interrupt routine then needs to keep track of the previous and current state to figure out which pin changed.
Here's what I have for the older IGN setup/interrupt code:
I'm still looking at the Arduino capabilities and how to monitor all the signals. I think it will work well, and that I can possibly leave the I2C SDA/SCL pins unused if someone wants to use them for expansion in the future (such as the Sparkfun Qwiic interface).
I'm still planning on using simple RC circuits, and a couple high-speed switching diodes for inductive clamps, to monitor the EZK/ECU signals. I'd like to keep the added loading on the EZK/ECU signals to only ~10uA to ~50uA, or ~200K ohms to 1M ohm (definitely high impedance). I need to trace the EZK Tq/Load signal driver to see if higher loading can be used since it's the fastest signal of the bunch. I also need to trace the IGN driver because I'd like to measure exact ignition advance, and may need lower RC delay for the desired accuracy.
For grounding, the Arduino board needs to connect only to ground in the EZK, or only to ground in the ECU. Any other connection may add a bad ground loop that might affect normal engine control.
For high speed timing measurements in the Arduino, you need to setup custom PCINT PinChangeINTerrupt code. This will trigger an interrupt routine whenever the logic level of one of the enabled pins changes. The interrupt routine then needs to keep track of the previous and current state to figure out which pin changed.
Here's what I have for the older IGN setup/interrupt code:
[in setup section]
// Setup high speed digital inputs
pinMode(4, INPUT); // IGN sparkAdv
// Setup interrupt handlers for high speed signals: rpm (tach), vss, load, inj, spark
PCICR |= 0x04; PCMSK2 = 0x10; // IGN: pin D4, PCINT2_vect (D0-D7)
[in interrupt routine section]
//********************Interrupt Service Routines***********************
// For good info on setting up interrupts, including the pin change interrupts that aren't
// directly supported by the Arduino library, see: http://www.gammon.com.au/interrupts
// Interrupt Service Routine for pin D4, IGN input, PCINT2_vect (D0-D7)
// - enabled via direct interrupt register config in setup() section
// - triggers on both edges of IGN signal
// - Dwell is pulse width
// - Advance is updated here using falling RPM signal edge captured by RPM ISR
ISR(PCINT2_vect) // Pin change interrupt for pins D0-D7 (only D4 enabled)
{
boolean edge;
unsigned long edge_time;
// get interrupt edge and current time
edge_time = micros();
edge = digitalRead(4);
// Measure ignition dwell time as rising to falling pulse width (coil changes when signal is high)
// Measure ignition advance as previous falling RPM edge to falling ign edge
if(edge) {
ign_rise_edge = edge_time;
} else {
ignPeriod = edge_time - ign_rise_edge;
ign_fall_edge = edge_time;
advance = edge_time - rpm_fall_edge;
ign_int_flg = true; // set flag to indicate new ign dwell and advance measurements
}
ign_ints_processed++;
}
I'm still looking at the Arduino capabilities and how to monitor all the signals. I think it will work well, and that I can possibly leave the I2C SDA/SCL pins unused if someone wants to use them for expansion in the future (such as the Sparkfun Qwiic interface).