The setup will be for an Arduino UNO board, 8 channel optocoupler and 2 amp 36 v power supply. i have already written most of the code needed to run it. The 8 wires from the ecu wil connect to the 8 channel optocoupler on the no side and the eight wires from the injectors will connect to the cc side of the relay board. we will not use the can bus wires. The crankshaft sensor wire will go to the uno board and the 8 relays inputs will connect to the 8 pins on the uno board. there are 12v hot wires and 2 grnd wires that can be used for the power supply and the output of the 36v will connect to the positive side of the injector wires. This wil allow constant power to the injectors and then the grnd side will be toggled to make the connections during operation. Here is a simplified version of the code to put on the uno board and it has not been tested, #include <EEPROM.h>
// Define relay module pins
const int relayPins[] = {2, 3, 4, 5, 6, 7, 8, 9};
// Crankshaft signal pin with internal pullup resistor
const int crankshaftPin = 10;
// Pulse width and timing settings
const int pulseWidthDelay = 3; // 3 ms
const int timingDelay = 15; // 15 ms
// Variable to store the last used injector index
int lastUsedInjectorIndex = 0;
void setup() {
// Set relay pins as OUTPUT
for (int i = 0; i < 8; i++) {
pinMode(relayPins, OUTPUT);
}
// Set crankshaft pin as INPUT with internal pullup resistor
pinMode(crankshaftPin, INPUT_PULLUP);
// Initialize Serial communication for debugging
Serial.begin(9600);
// Retrieve last used injector index from EEPROM
lastUsedInjectorIndex = EEPROM.read(1);
}
void loop() {
// Read the crankshaft signal
int crankshaftSignal = digitalRead(crankshaftPin);
// Assuming HIGH signal indicates a tooth and LOW indicates a gap
if (crankshaftSignal == HIGH) {
// Determine which injector to engage based on the tooth count
int toothCount = (millis() / 15) % 60;
int injectorIndex = (toothCount / 15) % 8;
// Engage the corresponding injector by activating the relay
digitalWrite(relayPins[injectorIndex], HIGH);
// Update the last used injector index
lastUsedInjectorIndex = injectorIndex;
// Add delay for pulse width
delay(pulseWidthDelay);
// Turn off all injectors
for (int i = 0; i < 8; i++) {
digitalWrite(relayPins, LOW);
}
// Add delay for timing delay
delay(timingDelay);
}
}
// Define relay module pins
const int relayPins[] = {2, 3, 4, 5, 6, 7, 8, 9};
// Crankshaft signal pin with internal pullup resistor
const int crankshaftPin = 10;
// Pulse width and timing settings
const int pulseWidthDelay = 3; // 3 ms
const int timingDelay = 15; // 15 ms
// Variable to store the last used injector index
int lastUsedInjectorIndex = 0;
void setup() {
// Set relay pins as OUTPUT
for (int i = 0; i < 8; i++) {
pinMode(relayPins, OUTPUT);
}
// Set crankshaft pin as INPUT with internal pullup resistor
pinMode(crankshaftPin, INPUT_PULLUP);
// Initialize Serial communication for debugging
Serial.begin(9600);
// Retrieve last used injector index from EEPROM
lastUsedInjectorIndex = EEPROM.read(1);
}
void loop() {
// Read the crankshaft signal
int crankshaftSignal = digitalRead(crankshaftPin);
// Assuming HIGH signal indicates a tooth and LOW indicates a gap
if (crankshaftSignal == HIGH) {
// Determine which injector to engage based on the tooth count
int toothCount = (millis() / 15) % 60;
int injectorIndex = (toothCount / 15) % 8;
// Engage the corresponding injector by activating the relay
digitalWrite(relayPins[injectorIndex], HIGH);
// Update the last used injector index
lastUsedInjectorIndex = injectorIndex;
// Add delay for pulse width
delay(pulseWidthDelay);
// Turn off all injectors
for (int i = 0; i < 8; i++) {
digitalWrite(relayPins, LOW);
}
// Add delay for timing delay
delay(timingDelay);
}
}