Compare commits

...

6 Commits

Author SHA1 Message Date
Bouletmarc c19ea5e393
Update V1.3 2023-02-05 23:58:09 -05:00
Bouletmarc f46e2489ae
Update README.md 2023-02-05 23:50:36 -05:00
Bouletmarc 01ad3f990a
Add files via upload 2023-02-05 23:49:42 -05:00
Bouletmarc e9bc3891e5
Update README.md 2023-02-05 23:43:51 -05:00
Bouletmarc 326de88562
Update README.md 2023-02-05 23:42:59 -05:00
Bouletmarc 291040f05e
BMCOP Update file for V1.3 developement board 2023-02-05 23:31:43 -05:00
11 changed files with 10110 additions and 355 deletions

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,263 @@
{
"author": {
"email": "bouletmarc@hotmail.com",
"name": "Marc-Andre Boulet"
},
"description": {
"EN": "CAM job description goes here."
},
"output_type": "zip",
"outputs": [
{
"format_specifier": {
"decimal": 3,
"integer": 3
},
"output_type": "drill",
"outputs": [
{
"drills": {
"NPTH": true,
"PTH": true,
"VIA": true
},
"filename_format": "%N.TXT",
"layers": {
"from": 1,
"to": 16
},
"name": "Drills and Holes",
"type": "excellon"
}
]
},
{
"filename_prefix": "gerber",
"format_specifier": {
"decimal": 4,
"integer": 3
},
"generate_job_file": true,
"output_type": "gerber",
"outputs": [
{
"advanced_options": {
"mirror": false,
"offset_x": 0,
"offset_y": 0,
"rotate": false,
"upside_down": false
},
"board_outline": false,
"config": {
"description": "Slot drill/holes/outline",
"file_function": "Other"
},
"filename_format": "%N.GML",
"layers": [
20,
46
],
"milling": false,
"name": "Slot drill/holes/outline",
"polarity": "positive",
"type": "gerber_layer"
},
{
"advanced_options": {
"mirror": false,
"offset_x": 0,
"offset_y": 0,
"rotate": false,
"upside_down": false
},
"board_outline": false,
"config": {
"description": "Bottom solder paste for stencil",
"file_function": "Other"
},
"filename_format": "%N.GBP",
"layers": [
20,
32
],
"milling": false,
"name": "Bottom solder paste for stencil",
"polarity": "positive",
"type": "gerber_layer"
},
{
"advanced_options": {
"mirror": false,
"offset_x": 0,
"offset_y": 0,
"rotate": false,
"upside_down": false
},
"board_outline": false,
"config": {
"description": "Bottom solder mask",
"file_function": "Other"
},
"filename_format": "%N.GBS",
"layers": [
20,
30
],
"milling": false,
"name": "Bottom solder mask",
"polarity": "positive",
"type": "gerber_layer"
},
{
"advanced_options": {
"mirror": false,
"offset_x": 0,
"offset_y": 0,
"rotate": false,
"upside_down": false
},
"board_outline": false,
"config": {
"description": "Bottom silk",
"file_function": "Other"
},
"filename_format": "%N.GBO",
"layers": [
20,
122
],
"milling": false,
"name": "Bottom silk",
"polarity": "positive",
"type": "gerber_layer"
},
{
"advanced_options": {
"mirror": false,
"offset_x": 0,
"offset_y": 0,
"rotate": false,
"upside_down": false
},
"board_outline": false,
"config": {
"description": "Bottom copper",
"file_function": "Other"
},
"filename_format": "%N.GBL",
"layers": [
16,
17,
18,
20
],
"milling": false,
"name": "Bottom copper",
"polarity": "positive",
"type": "gerber_layer"
},
{
"advanced_options": {
"mirror": false,
"offset_x": 0,
"offset_y": 0,
"rotate": false,
"upside_down": false
},
"board_outline": false,
"config": {
"description": "Top solder paste for stencil",
"file_function": "Other"
},
"filename_format": "%N.GTP",
"layers": [
20,
31
],
"milling": false,
"name": "Top solder paste for stencil",
"polarity": "positive",
"type": "gerber_layer"
},
{
"advanced_options": {
"mirror": false,
"offset_x": 0,
"offset_y": 0,
"rotate": false,
"upside_down": false
},
"board_outline": false,
"config": {
"description": "Top solder mask",
"file_function": "Other"
},
"filename_format": "%N.GTS",
"layers": [
20,
29
],
"milling": false,
"name": "Top solder mask",
"polarity": "positive",
"type": "gerber_layer"
},
{
"advanced_options": {
"mirror": false,
"offset_x": 0,
"offset_y": 0,
"rotate": false,
"upside_down": false
},
"board_outline": false,
"config": {
"description": "Top silk",
"file_function": "Other"
},
"filename_format": "%N.GTO",
"layers": [
20,
112,
121
],
"milling": false,
"name": "Top silk",
"polarity": "positive",
"type": "gerber_layer"
},
{
"advanced_options": {
"mirror": false,
"offset_x": 0,
"offset_y": 0,
"rotate": false,
"upside_down": false
},
"board_outline": false,
"config": {
"description": "Top copper",
"file_function": "Other"
},
"filename_format": "%N.GTL",
"layers": [
1,
17,
18,
20
],
"milling": false,
"name": "Top copper",
"polarity": "positive",
"type": "gerber_layer"
}
],
"version": "X2"
}
],
"timestamp": "2019-08-22T20:43:49",
"type": "EAGLE CAM job",
"units": "metric",
"version": "8.6.0"
}

File diff suppressed because it is too large Load Diff

Binary file not shown.

550
BMCop.ino
View File

@ -5,65 +5,81 @@
/ /___/ /_/ // // /___ / /_/ / /| / / ____/ /___/ /_/ / /_/ /
\____/\____/___/_____/ \____/_/ |_/ /_/ /_____/\____/\____/
COIL ON PLUG Script V1.0 for Atmega328P made by Bouletmarc (BMDevs)
COIL ON PLUG Script V1.3 for Atmega328P made by Bouletmarc (BMDevs)
This Coil On Plug script are intended to be used on Honda/Acura 4cylinders cars running on a distributor normally. (Mostly Serie B-D-F-H Engines)
This application samples in two distributor signals, (ICM & CYP), Ignition Control Module & Camshaft Position Positive
It syncs the firing sequence to the specific Cylinder from the CYP signal and then control the firing sequence with the ICM signal.
It activate 4x Digital ouputs pins (used to trigger the coils) depending on which cylinder should fire.
This application samples require two signals, (ICM & FC1 Pin3)
It syncs the firing sequence to the specific Cylinder from the FC1 Pin3 signal and then control the firing sequence to the coils with the ICM signal.
It activate 4x Digital ouputs pins (used to trigger each coils) depending on which cylinder should fire.
Connection wiring:
On the ECU, at the FC1 header location, connect the pin1 to 5V on the arduino
On the ECU, at the FC1 header location, connect the pin3 to D2 on the arduino
On the ECU, at the FC1 header location, connect the pin12 to GND on the arduino
On the ECU, at the big connectors outputs, on the big connector A, CUT the ICM wire going to the body/engine bay and connect the wire coming from the ECU connector to D3 on the arduino
On the Arduino, connect D8 with the ICM wire previously cut going to your body (to power the tachometer)
On the Arduino, connect D4 with the Coil1 5v signal
On the Arduino, connect D5 with the Coil2 5v signal
On the Arduino, connect D6 with the Coil3 5v signal
On the Arduino, connect D7 with the Coil4 5v signal
RPM/SYNC Informations:
-The ICM signal become High state first
-The FC1 signal will trigger 6times High-Low state
-The ICM signal become Low then rapididly High state again
-The FC1 signal will trigger 12times High-Low state
-The ICM signal become Low then rapididly High state again
-The FC1 signal will trigger 4times High-Low state
--The ICM signal become Low then rapididly High state again --> but this time it's to fire the first coil!!
-The FC1 signal will trigger 5-6times High-Low state (depending on ignition timing) between each coils firing
-The FC1 signal doesn't loose timing while under ignition cut circonstances
----------------------------------------------------------------
ICM Signal: ____---------------_-----------------------_-------_-----------_-----------_-----------_-----------_-----------_-----------_
FC1 Signal: ________-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_
----------------------------------------------------------------
***********************************************************************/
#include <digitalWriteFast.h>
// MODIFIABLE PARAMETERS VARS
//bool WastedSpark = true; //wasted spark fire each cylinders on 2x of the 4x stroke rather than only 1x stroke
bool InternalDWellTime = false; //set time to true to spark the coils for the internal DWell time or to false to use the 'external' DWell time incoming from the interrupt
//int MAXDWELL = 2900; //Maximum DWell in Microseconds (Sparking time for coils), this value enter in count only if using the Internal DWell Time
//int MINDWELL = 2100; //Minimum DWell in Microseconds (Sparking time for coils), this value enter in count only if using the Internal DWell Time
//uint16_t BreakpointRPM = 1300; //The Breaking Point RPM where the CYP get offseted on the cylinders syncronization
//const byte fireOrder[] = {4, 2, 1, 3}; //Basicly the firing order 1-3-4-2 can it be offseted!
const byte fireOrder[] = {1, 3, 4, 2}; //Basicly the firing order 1-3-4-2 can it be offseted!
//const byte fireOrder[] = {3, 4, 2, 1}; //Basicly the firing order 1-3-4-2 can it be offseted!
//const byte fireOrder[] = {2, 1, 3, 4}; //Basicly the firing order 1-3-4-2 can it be offseted!
const bool WastedSpark = false; //wasted spark fire each cylinders on 2x of the 4x stroke rather than only 1x stroke
const bool InternalDWellTime = false; //set this to true to spark the coils with the internal DWell times or to false to use the 'external' DWell time incoming from the ICM interrupt
const int DWELL_INTERNAL = 2500; // DWell in Microseconds (Sparking time for coils), this value enter in count only if using the Internal DWell Time
const byte fireOrder[] = {1, 3, 4, 2}; //Basicly the firing order 1-3-4-2 can it be offseted! ##### {4, 2, 1, 3} ##### {3, 4, 2, 1} ##### {2, 1, 3, 4}
// MODIFIABLE OUTPUT PINS (just make sure you aren't using a pins listed in the Inputs Pins bellow
const byte CoilP1 = 3; //Atmega328P=5 ATTiny44=3
const byte CoilP2 = 4; //Atmega328P=6 ATTiny44=4
const byte CoilP3 = 5; //Atmega328P=7 ATTiny44=5
const byte CoilP4 = 6; //Atmega328P=8 ATTiny44=6
const byte CoilP1 = 4; //Atmega328P=4 ATTiny44=3
const byte CoilP2 = 5; //Atmega328P=5 ATTiny44=4
const byte CoilP3 = 6; //Atmega328P=6 ATTiny44=5
const byte CoilP4 = 7; //Atmega328P=7 ATTiny44=6
const byte RPMOut = 8; //Atmega328P=8 ATTiny44=6
//const byte Status = 10; //Atmega328P=10 ATTiny44=8
//#############################################################################################################
// INPUT PINS (DO NOT MODIFY, INPUT PINS ARE SPECIFIC FOR THE INTERRUPTS AND OTHER IMPORTANT FUNCTIONS)
const byte CYP = 2; //Atmega328P=2 ATTiny44=1
const byte IGN = 3; //Atmega328P=3 ATTiny44=2
//const byte WastedSparkIn = 9;//Atmega328P=9 ATTiny44=7
//const byte IntDWellIn = 11; //Atmega328P=9 ATTiny44=7
//#############################################################################################################
const byte FC1_Pin3 = 2; //Atmega328P=2 ATTiny44=1
const byte ICM_Pin = 3; //Atmega328P=3 ATTiny44=2
// VARS (DO NOT MODIFY)
uint8_t CYLINDER = 0;
uint8_t CYLINDERTDC = 1; //Starting sync cylinder
uint8_t SPARKS = 0;
uint8_t SPARKSCYP = 0;
uint8_t SPARKSOUT = 0;
uint16_t RPM = 0;
uint16_t RPM2 = 0;
bool desynced = true;
unsigned long LASTMILLIS = 0;
unsigned long LOWRPMCOUNT = 0;
int DWELL = 2450;
int SyncCount = 0;
int FailSyncTry = 1;
int SyncCountICM = 0;
int LastSyncCount = 0;
int DesyncCount = 0;
const int MaxDesyncTime = 500; //max desync timer in milliseconds
int TestVal = -1;
int TestVal2 = -1;
int TestVal3 = -1;
//unsigned long ontime,offtime,duty;
//float freq,period;
// VARS FOR RPM SERIAL LOGGING
//uint8_t SPARKS = 0;
//uint16_t RPM = 0;
//unsigned long LASTMILLIS = 0;
//#############################################################################################################
// SETUP/STARTING CODES
//#############################################################################################################
void setup() {
CYLINDER = 0;
@ -74,177 +90,43 @@ void setup() {
pinModeFast(CoilP2, OUTPUT);
pinModeFast(CoilP3, OUTPUT);
pinModeFast(CoilP4, OUTPUT);
pinModeFast(RPMOut, OUTPUT);
//pinModeFast(Status, OUTPUT);
//Set Inputs
pinMode(CYP, INPUT);
pinMode(IGN, INPUT);
//pinMode(WastedSparkIn, INPUT_PULLUP);
//pinMode(IntDWellIn, INPUT_PULLUP);
pinMode(FC1_Pin3, INPUT);
pinMode(ICM_Pin, INPUT);
//Attach Interrupts
attachInterrupt(digitalPinToInterrupt(CYP), ISR_CYP, CHANGE);
attachInterrupt(digitalPinToInterrupt(IGN), ISR_IGN, CHANGE);
//attachInterrupt(digitalPinToInterrupt(CYP), ISR_CYP, FALLING);
//attachInterrupt(digitalPinToInterrupt(IGN), ISR_IGN, FALLING);
attachInterrupt(digitalPinToInterrupt(FC1_Pin3), ISR_FC1_Pin3, RISING);
attachInterrupt(digitalPinToInterrupt(ICM_Pin), ISR_ICM_Pin, FALLING);
//Set RPM calculation and Serial logging Timer
SetTimer();
Serial.begin(115200);
}
void SetTimer() {
cli();//stop interrupts
//set timer1 interrupt at 1Hz
TCCR1A = 0;// set entire TCCR1A register to 0
TCCR1B = 0;// same for TCCR1B
TCNT1 = 0;//initialize counter value to 0
//################################################
// set compare match register for 1hz increments
//Formula : ((Clock) / (Prescalar * desired interrupt frequency))
// ((16,000,000) / (1 * (XXX Frequency))
// ((16*10^6)) / (1*1024) - 1 (must be <65536)
//################################################
uint16_t FreqHZ = 5; //frequency in Hz
OCR1A = ((16000000) / (1*(FreqHZ * 1024))) - 1;
// turn on CTC mode
TCCR1B |= (1 << WGM12);
// Set CS10 and CS12 bits for 1024 prescaler
TCCR1B |= (1 << CS12) | (1 << CS10);
// enable timer compare interrupt
TIMSK1 |= (1 << OCIE1A);
//set timer2 interrupt at 8kHz
/*TCCR2A = 0;// set entire TCCR2A register to 0
TCCR2B = 0;// same for TCCR2B
TCNT2 = 0;//initialize counter value to 0
// set compare match register for 8khz increments
OCR2A = 249;// = (16*10^6) / (8000*8) - 1 (must be <256)
// turn on CTC mode
TCCR2A |= (1 << WGM21);
// Set CS21 bit for 8 prescaler
TCCR2B |= (1 << CS21);
// enable timer compare interrupt
TIMSK2 |= (1 << OCIE2A);*/
sei();//allow interrupts
//Set RPM Serial logging Timer
//SetTimer();
//Serial.begin(115200);
}
//###############################################################
ISR(TIMER1_COMPA_vect) {
//Turn off interrupts since we use Serial commands, this also ensure we calculate the RPM when nothing trigger the interrupts (interrupts turned off)
noInterrupts();
// MAIN RUNNING CODES
//###############################################################
void loop() {
delay(1);
CalculateIsSynced();
GetRPM();
//Compare RPM calculated from CYP and RPM calulated from IGN to check if their any difference (differences occurs when the ignition cut get active)
//int DiffRPM = (int) (RPM2 - RPM);
//if (DiffRPM > 1500 || DiffRPM < -1500) {
//SetDecynced();
//}*/
//Serial.println("RPM: " + String(RPM) + "rpm, RPM2: " + String(RPM2) + "rpm");
//Serial.println(CYLINDERTDC);
if (TestVal3 > 0) {
Serial.println("RPM: " + String(RPM) + "rpm, RPM2: " + String(RPM2) + "rpm, " + String(TestVal) + "Cyl, " + String(TestVal2) + "Sparks, " + String(TestVal3) + "Sync");
}
TestVal3 = 0;
//Attach again the interrupts since we finished calculating RPM and possibly sending Serial datas
attachInterrupt(digitalPinToInterrupt(CYP), ISR_CYP, CHANGE);
attachInterrupt(digitalPinToInterrupt(IGN), ISR_IGN, CHANGE);
//attachInterrupt(digitalPinToInterrupt(CYP), ISR_CYP, FALLING);
//attachInterrupt(digitalPinToInterrupt(IGN), ISR_IGN, FALLING);
//Calucalute average DWell time with Engine RPM
//DWELL_INTERNAL = map(RPM, 0, 11000, MAXDWELL, MINDWELL);
}
void GetRPM() {
//Calculate engine RPM
uint16_t Thistime = millis() - LASTMILLIS;
//RPM2 = (((30*1000)/(Thistime)*(SPARKSCYP)) / 1.71);
RPM2 = (((30*1000)/(Thistime)*(SPARKSCYP * 4)) / 1.666); //New FC1 Port Pin4 Method
RPM = ((30*1000)/(Thistime)*SPARKS) / 1.666;
/*uint16_t FakeRPM = (((SPARKS*1000)/Thistime)*60); //How much spark in a minutes
float Divider = (float) ((FakeRPM/SPARKS) / 150.0);
RPM = (FakeRPM / Divider) * 0.92;
int OtherDivider = 1;
if (RPM > 3100) OtherDivider = 2;
uint16_t FakeRPM2 = ((((SPARKSCYP*4 * OtherDivider)*1000)/Thistime)*60); //How much spark in a minutes
float Divider2 = (float) ((FakeRPM2/(SPARKSCYP*4 * OtherDivider)) / 150.0);
RPM2 = (FakeRPM2 / Divider2) * 0.92;*/
LASTMILLIS = millis();
//Serial.println(String(SPARKSCYP));
SPARKS = 0;
SPARKSCYP = 0;
//Serial.println(String(Thistime));
//Set RPM #1 (RPM from ICM Wire Signal)
/*ontime = pulseIn(IGN,HIGH);
offtime = pulseIn(IGN,LOW);
period = ontime+offtime;
freq = 1000000.0/period;
duty = (ontime/period)*100;
if (duty > 0 && duty < 100) {
RPM = freq * 27;
}
//Serial.println(String(offtime));
//Set RPM #2 (RPM from CYP Wire Signal)
//ontime = pulseIn(CYP,LOW);
//offtime = pulseIn(CYP,HIGH);
ontime = pulseIn(CYP,HIGH);
offtime = pulseIn(CYP,LOW);
period = ontime+offtime;
freq = 1000000.0/period;
duty = (ontime/period)*100;
if (duty > 0 && duty < 100) {
//RPM2 = (freq * 27) * 4;
//RPM2 = (freq * 27);
RPM2 = (freq * 27) * 8; //Pin#4
//RPM2 = (freq * 27) / 6 ; //Pin#3
}*/
//Get WastedSparks
/*if (digitalRead(WastedSparkIn) == LOW) {
WastedSpark = true;
}
if (digitalRead(WastedSparkIn) == HIGH) {
WastedSpark = false;
}*/
//Get InternalDWell
/*if (digitalRead(IntDWellIn) == LOW) {
InternalDWellTime = true;
//Calucalute average DWell time with Engine RPM
DWELL = map(RPM, 0, 11000, MAXDWELL, MINDWELL);
}
if (digitalRead(IntDWellIn) == HIGH) {
InternalDWellTime = false;
}*/
//Set Engine Not running (Low RPM detected)
void CalculateIsSynced() {
if (!desynced) {
if (RPM2 < 60) {
//if (RPM < 60 || RPM2 < 60) {
LOWRPMCOUNT++;
if (LOWRPMCOUNT > 8) {
SetDecynced();
LOWRPMCOUNT = 0;
}
if (LastSyncCount == SyncCount) {
DesyncCount++;
}
else {
LOWRPMCOUNT = 0;
if (DesyncCount >= MaxDesyncTime) {
SetDecynced();
}
LastSyncCount = SyncCount;
}
}
@ -252,56 +134,41 @@ void SetDecynced() {
desynced = true;
Ignite_Off();
CYLINDER = 0;
LOWRPMCOUNT = 0;
SyncCount = 0;
SetLED();
SyncCountICM = 0;
DesyncCount = 0;
LastSyncCount = 0;
}
//###############################################################
void loop() {
//GetRPM();
//CheckDesynced();
//Serial.println(String(desynced));
//Serial.println("RPM: " + String(RPM) + "rpm, RPM2: " + String(RPM2) + "rpm");
//delay(1);
}
// COILS FIRING FUNCTIONS
//###############################################################
void SetLED() {
/*if (desynced){
digitalWriteFast(Status, LOW);
}
if (!desynced){
digitalWriteFast(Status, HIGH);
}*/
}
void FIRE_COIL1(){
digitalWriteFast(CoilP1, HIGH);
/*if (WastedSpark) {
if (WastedSpark) {
digitalWriteFast(CoilP4, HIGH);
}*/
}
}
void FIRE_COIL2(){
digitalWriteFast(CoilP2, HIGH);
/*if (WastedSpark) {
if (WastedSpark) {
digitalWriteFast(CoilP3, HIGH);
}*/
}
}
void FIRE_COIL3(){
digitalWriteFast(CoilP3, HIGH);
/*if (WastedSpark) {
if (WastedSpark) {
digitalWriteFast(CoilP2, HIGH);
}*/
}
}
void FIRE_COIL4(){
digitalWriteFast(CoilP4, HIGH);
/*if (WastedSpark) {
if (WastedSpark) {
digitalWriteFast(CoilP1, HIGH);
}*/
}
}
void Ignite_ON() {
@ -320,6 +187,9 @@ void Ignite_ON() {
if (fireOrder[CYLINDER - 1] == 4) {
FIRE_COIL4();
}
//Fire ICM Out for Tachometer
digitalWriteFast(RPMOut, LOW);
}
}
@ -329,148 +199,136 @@ void Ignite_Off() {
digitalWriteFast(CoilP2, LOW);
digitalWriteFast(CoilP3, LOW);
digitalWriteFast(CoilP4, LOW);
digitalWriteFast(RPMOut, HIGH);
}
//###############################################################
void ISR_CYP() {
if(digitalRead(CYP) == LOW) {
//if (desynced) {
TestVal = CYLINDER;
TestVal3 = 555;
CYLINDER = 1;
// INTERRUPTS FC1 AND ICM INPUTS
//###############################################################
void ISR_FC1_Pin3() {
if (desynced) {
CYLINDER = 0;
SyncCount++;
}
else
{
SyncCount++;
//Check if the ICM signal fired the cylinders on the Next pulse (SyncCount==1)
if (SyncCount == 0) {
//if (SPARKSOUT == 4 || SPARKSOUT == 8) {
desynced = false;
SetLED();
SyncCount++;
//}
}
/*}
else {
if (CYLINDER == 1) {
SyncCount = 1;
}
if (CYLINDER != 1) {
if (SyncCount > FailSyncTry) {
//TestVal = CYLINDER;
CYLINDER = 1;
TestVal3 = 444;
}
SyncCount++;
}
}*/
/*if(digitalRead(IGN) == LOW) {
CYLINDER = 4;
}*/
//}
//else {
//if (SPARKSOUT != 4 && SPARKSOUT != 8) {
/*if ((SPARKSOUT == 7 && CYLINDER != 4) || (SPARKSOUT == 9 && CYLINDER != 2) || (SPARKSOUT != 7 && SPARKSOUT != 9)) {
TestVal = CYLINDER;
CYLINDER = 1;
TestVal3 = 333;
}*/
//Check Diff
/*if (SPARKSOUT > 4) SPARKSOUT = SPARKSOUT - 4;
int OffsetCyl = 4 - SPARKSOUT;
int NewCYL = (1 + 4) - OffsetCyl;
if (NewCYL > 4) NewCYL = NewCYL - 4;
if (CYLINDER == NewCYL) {
TestVal3 = 444;
}
else {
TestVal3 = 666;
}
CYLINDERTDC = CYLINDER;*/
//###################################################
/*bool IsLow = digitalRead(IGN) == LOW;
if (CYLINDER != 1 && IsLow) {
TestVal = CYLINDER;
CYLINDER = 1;
TestVal3 = 666;
}
if (CYLINDER != 4 && !IsLow) {
TestVal = CYLINDER;
CYLINDER = 4;
TestVal3 = 444;
}*/
//}
/*if (CYLINDER == 1) {
SyncCount = 1;
}
if (CYLINDER != 1) {
if (SyncCount > FailSyncTry) {
//TestVal = CYLINDER;
CYLINDER = 1;
TestVal3 = 444;
}
SyncCount++;
}*/
/*if (CYLINDER != 4 && CYLINDER != 1) {
TestVal = CYLINDER;
//Increase Cylinder firing on the 5th FC1 pulse, prepare it for when the next ICM pulse will fire.
//If the ignition degree are negative, the ICM will pulse slightly before the 6th FC1 pulse, better prepare it in advance on the 5th pulse!
if (SyncCount == 5)
{
CYLINDER++;
if (CYLINDER > 4) {
CYLINDER = 1;
TestVal3 = 444;
}*/
/*if (CYLINDER != 1) {
TestVal = CYLINDER;
CYLINDER = 1;
TestVal3 = 555;
}*/
//}
//TestVal = CYLINDER;
//TestVal2 = SPARKSOUT;
}
SyncCount = 0;
}
//apply 'sparks' for rpm calculation
SPARKSCYP++;
SPARKSOUT = 0;
//Reset Sync Counting every 6x FC1 pulses
if (SyncCount == 6) {
SyncCount = 0;
}
}
}
void ISR_IGN() {
if(digitalRead(IGN) == LOW && CYLINDER > 0) {
//Fire the specific Cylinder Coil
if (!desynced) {
Ignite_ON();
void ISR_ICM_Pin() {
//START SYNC SEQUENCE
if (desynced)
{
//AFTER 5-6x FC1 PULSE
if (SyncCountICM == 0 && (SyncCount == 5 || SyncCount == 6))
{
SyncCountICM++;
SyncCount = 0;
}
//AFTER 11-12x FC1 PULSE
if (SyncCountICM == 1 && (SyncCount == 11 || SyncCount == 12))
{
SyncCountICM++;
SyncCount = 0;
}
//AFTER 3-4x FC1 PULSE
if (SyncCountICM == 2 && (SyncCount == 3 || SyncCount == 4))
{
SyncCountICM++;
SyncCount = 0;
CYLINDER = 1;
desynced = false;
}
}
if(!desynced && CYLINDER > 0) {
//Fire the specific Cylinder Coil
Ignite_ON();
//Wait for DWell Time
if (InternalDWellTime) {
delayMicroseconds(DWELL); //##############
delayMicroseconds(DWELL_INTERNAL);
}
else {
while (digitalRead(IGN) == LOW) {};
while (digitalRead(ICM_Pin) == LOW) {};
}
//Unfire the Coil, pass to next cylinder and apply 'sparks' for rpm calculation
//Unfire the Coils
Ignite_Off();
CYLINDER++;
SPARKS++; //Used for Engine RPM Calculation
SPARKSOUT++; //Used for Cylinder Resyncing
//Turn back to cylinder #1 if we lost CYP signal
if (CYLINDER > 4) {
CYLINDER = 1;
}
}
/*if(digitalRead(IGN) == HIGH) {
Ignite_Off();
CYLINDER++;
SPARKS++; //Used for Engine RPM Calculation
SPARKSOUT++; //Used for Cylinder Resyncing
//Turn back to cylinder #1 if we lost CYP signal
if (CYLINDER > 4) {
CYLINDER = 1;
}
}*/
}
//#############################################################################################################
//#############################################################################################################
//#############################################################################################################
//#############################################################################################################
//#############################################################################################################
// RPM SERIAL LOGGING CODES
//#############################################################################################################
/*void SetTimer() {
cli();//stop interrupts
//set timer1 interrupt at 5Hz
TCCR1A = 0;// set entire TCCR1A register to 0
TCCR1B = 0;// same for TCCR1B
TCNT1 = 0;//initialize counter value to 0
//################################################
// set compare match register for 1hz increments
//Formula : ((Clock) / (Prescalar * desired interrupt frequency))
// ((16,000,000) / (1 * (XXX Frequency))
// ((16*10^6)) / (1*1024) - 1 (must be <65536)
//################################################
uint16_t FreqHZ = 5; //frequency in Hz
OCR1A = ((16000000) / (1*(FreqHZ * 1024))) - 1;
// turn on CTC mode
TCCR1B |= (1 << WGM12);
// Set CS10 and CS12 bits for 1024 prescaler
TCCR1B |= (1 << CS12) | (1 << CS10);
// enable timer compare interrupt
TIMSK1 |= (1 << OCIE1A);
sei();//allow interrupts
}
//###############################################################
ISR(TIMER1_COMPA_vect) {
//Turn off interrupts since we use Serial commands, this also ensure we calculate the RPM when nothing trigger the interrupts (interrupts turned off)
noInterrupts();
GetRPM();
Serial.println("RPM: " + String(RPM) + "rpm");
//Attach again the interrupts since we finished calculating RPM and possibly sending Serial datas
attachInterrupt(digitalPinToInterrupt(FC1_Pin3), ISR_FC1_Pin3, FALLING);
attachInterrupt(digitalPinToInterrupt(ICM_Pin), ISR_ICM_Pin, RISING);
}
void GetRPM() {
//Calculate engine RPM
uint16_t Thistime = millis() - LASTMILLIS;
RPM = ((30*1000)/(Thistime)*SPARKS) / 1.666;
LASTMILLIS = millis();
SPARKS = 0;
}*/

View File

@ -6,19 +6,28 @@ __*This project are still in Developpement, prototyping it is completly at your
# Introduction
The BMCOP need 2x Signal Inputs pins to acheive triggering all the four(4x) Coils. It require 1x ICM pulse signal (usually yellow/Green wire coming out of A20/A21 output pins on the ECU) and a 'replicated TDC' pulse signal coming from the FC1 header INSIDE the ecu. You'll have to get the signal from the 4th Pins of the FC1 Header counting from the top corner of the ECU. The FC1 Header are usually in the Top Right corner in a USDM OBD1 ECU.
The BMCOP need 2x Signal Inputs pins to acheive triggering all the four(4x) Coils. It require 1x ICM pulse signal (usually yellow/Green wire coming out of A20/A21 output pins on the ECU) and a pulse signal coming from the FC1 header INSIDE the ecu. You'll have to get the signal from the 3rd Pins of the FC1 Header counting from the top corner of the ECU. The FC1 Header are usually in the Top Right corner in a USDM OBD1 ECU.
You have to bring the ICM pulse (from A20/A21) ONLY to the Arduino and nothing else, you have to cut the Wire going to the Distributor. **The tachometer won't display any RPM**, this function wasn't YET implemented during the test. I have added an Output pin for 'RPM OUT' on the prototype board but the function on this pin aren't implemented in the arduino code, it was suposed to duplicate the ICM Signal in order to feed the signal back to the tachometer!
# Connection wiring
The Project (mostly due to schematic design) can only drive 5V coils for now (usually all D17, K20, K24 coils used for the project are 5V, it shouldn't be a big compromise!).
- On the ECU, at the FC1 header location, connect the pin1 to 5V on the arduino
- On the ECU, at the FC1 header location, connect the pin3 to D2 on the arduino
- On the ECU, at the FC1 header location, connect the pin12 to GND on the arduino
- On the ECU, at the big connectors outputs, on the big connector A, CUT the ICM wire going to the body/engine bay and connect the wire coming from the ECU connector to D3 on the arduino
- On the Arduino, connect D8 with the ICM wire previously cut going to your body (to power the tachometer)
- On the Arduino, connect D4 with the Coil1 5v signal
- On the Arduino, connect D5 with the Coil2 5v signal
- On the Arduino, connect D6 with the Coil3 5v signal
- On the Arduino, connect D7 with the Coil4 5v signal
# Parts required to assembled the Prototype PCB
- 4x 1K Ohm 1/6W Resistor
- 4x 2N4148 Diode
- 1x Arduino Nano V3 - 5V - 16Mhz
- 1x 100nF (0.1uF) Capacitor
(required ONLY for the v1.2 and older)
- 1x 100nF (0.1uF) Capacitor
*If you want to Power the Device with 12V:*
- 1x 78M05
- 1x 1N4002 (1N4004, 2N4148 and others diodes above 20V rating will works just as fine for a replacement!)
@ -28,15 +37,16 @@ The Project (mostly due to schematic design) can only drive 5V coils for now (us
# Possible Issues
While testing the project, I experienced miss fires happennning at High RPM but I couldn't finish the project in time before selling the only car I could have developped the project with.
__*The Project is for use at your OWN COMPLETE RISK, IT HAS NOT BEING TESTED/CONFIRMED*__
__*The Project is for use at your OWN COMPLETE RISK*__
The Coils pack I been using during the tests, was D17 used coils and 1x of them had burning marks before I started the project. It's a possibility that the project works flawlessly and the issue I was experiencing during my tests are not at all related to a Programming OR Schematic design issue, that it was a faulty coil on my side BUT be aware that there is chances that you can experience High RPM miss firing happening if the issue wasn't this.
The project has been updated for the V1.3 boards, which now use a different signal for syncing coils (before it was using FC1 pin4, now i've updated the project to use FC1 pin3 signal). It has not been tested personnally since I don't have any cars/engines capable of testing the project on hands, but it should be more confident this time to works arround with it.
__*If you acheive successfull results*__
I'll surely appreciate to get informed of the changes done the the programming or the schematic if there any, and if you would like, you could participate in the developpement of this project by subscribing to Github and yourself 'Push updates request' to this project! I am willing to share Open Source the project I ended up with before selling the only car I could have tested on, please be kindful and let's make this a working Open Source project together.
I'll surely appreciate to get informed of the changes done the the programming codes or the schematic if there is any, and if you would like, you could participate in the developpement of this project by subscribing to Github and yourself 'Push updates request' to this project! I am willing to share Open Source the project I ended up with before selling the only car I could have tested on, please be kindful and let's make this a working Open Source project together.
# BMCOP V1.3 Schematic/Diagram
![alt tag](https://github.com/bouletmarc/BMCOP/blob/main/eagle_1eO5gZZhDL.png)
# BMCOP V1.2 Schematic/Diagram
![alt tag](https://github.com/bouletmarc/BMCOP/blob/main/eagle_2020-12-02_09-09-23.png)

BIN
eagle_1eO5gZZhDL.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 31 KiB