Jump to content

Ghostchips 1920-26 ford T bucket (of rust)


Recommended Posts

  • 2 weeks later...
  • Replies 69
  • Created
  • Last Reply

Top Posters In This Topic

Top Posters In This Topic

Don't mind this, it's just a basic, primitive tune i spent the afternoon adjusting

// constants won't change. Used here to set a pin number:
const int coil1 = 3;
const int coil2 = 5;
const int coil3 = 7;
const int coil4 = 9;

const int sensorPin1 = A4;
const int sensorPin2 = A1;
const int sensorPin3 = A2;
const int sensorPin4 = A3;

int sensorValue = 0;

int sensorThreshold = 200;
int sensorMax = 0;

// Variables will change:
volatile int coilState = LOW;
volatile int coilPin = LOW;

volatile int sparkTriggerDelayActive = false;     //added this to try & see if i can delay spark at low RPM.
volatile int sparkTriggerDelay = 0;
volatile unsigned long rpmCurrMicros= 0;
volatile unsigned long rpmOldMicros = 0;
volatile int sensor1TriggerCounter = 0;           // counter for the number of button presses
volatile int sensorTriggerState = false;         // current state of the button
volatile int lastsensorTriggerState = true;     // previous state  of the button/sensor in this case.

// constants won't change:
// Generally, you should use "unsigned long" for variables that hold time
// The value will quickly become too large for an int to store

const long dwell = 10;        // but this is how long the "points" are open, open longer reduces duty cycle of coils.

// constants won't change:
const long coilCharge = 2;           // interval at which to charge coil (milliseconds)

void setup() {
  // put your setup code here, to run once:
  Serial.begin(9600);
  pinMode(coil1, OUTPUT);
  pinMode(coil2, OUTPUT);
  pinMode(coil3, OUTPUT);
  pinMode(coil4, OUTPUT);
  pinMode(A4, INPUT_PULLUP);
  pinMode(A1, INPUT_PULLUP);
  pinMode(A2, INPUT_PULLUP);
  pinMode(A3, INPUT_PULLUP);
}

void activateCoilsIfLow(uint8_t inPin, uint8_t outPin)
{
 volatile unsigned long timestamp = 0;
 sensorTriggerState = true;
   if (analogRead(inPin) <= sensorThreshold)
   {
    if (lastsensorTriggerState = (false))
    {
      delay(sparkTriggerDelay);
      lastsensorTriggerState = true;
    }
    else
     {
      coilState = HIGH;
      coilPin = HIGH;
      digitalWrite(outPin, HIGH);
    
      timestamp = millis();
                                          
      while (coilState == HIGH && coilPin == HIGH && (timestamp + coilCharge) > millis());  //Busy wait
   
     digitalWrite(outPin, LOW);
      coilPin = LOW;
      timestamp = millis();

      while (coilState == HIGH && coilPin == LOW && (timestamp + dwell) > millis());
 
      coilState = LOW;
      coilPin = LOW;
    }
  }
  else if (analogRead(inPin) >= sensorThreshold)
  {
    sensorTriggerState = false;
    if (sensorTriggerState != lastsensorTriggerState)
    {
      rpmOldMicros = rpmCurrMicros;
      rpmCurrMicros = micros();
      lastsensorTriggerState = false;
      rpmConsultRatioTable();
    }
  }
}

void loop() {
  activateCoilsIfLow(sensorPin1, coil1);
  activateCoilsIfLow(sensorPin3, coil3);
  activateCoilsIfLow(sensorPin2, coil4);
  activateCoilsIfLow(sensorPin4, coil2);
}

void rpmConsultRatioTable()
{
  if (rpmCurrMicros - rpmOldMicros >= 497512) //sub250rpm
    {
      sparkTriggerDelay =0;
    }
  else if (rpmCurrMicros - rpmOldMicros <= 255024) //125rpm
    {
      sparkTriggerDelay =57;                   //prev'55  
    }
  else if (rpmCurrMicros - rpmOldMicros <= 169491) //177rpm
    {
      sparkTriggerDelay =39;                   //prev' 37
    }
  else if (rpmCurrMicros - rpmOldMicros <= 127512) //250rpm
    {
      sparkTriggerDelay =27;                      //at 250 RPM and 45 degree sensor advance, this would be 30ms to TDC, subtract 2ms for coil charging and subtract more m.s. for advance
    }
  else if (rpmCurrMicros - rpmOldMicros <= 85008) //375rpm
    {
      sparkTriggerDelay =16;
    }
  else if (rpmCurrMicros - rpmOldMicros <= 61000) //500rpm
    {
      sparkTriggerDelay =11;
    }
  else if (rpmCurrMicros - rpmOldMicros <= 48000)  //625rpm
    {
      sparkTriggerDelay =7;
    }
  else if (rpmCurrMicros - rpmOldMicros <= 41000) //750rpm
    {
      sparkTriggerDelay =2;
    }
  else if (rpmCurrMicros - rpmOldMicros <= 31500) //just under 1000rpm
    {
      sparkTriggerDelay =0;
    }
}

Posting this here so i can find it later if i'm not home.
Side note: i am probably the only person using milliseconds to determine when to fire the plug compared to using actual degrees.

  • Like 7
  • Thanks 1
Link to post
Share on other sites

Forget that one, the new tune is better.  That one sounded like a series of tiny gearshifts, kind of like an early fast&furious movie.

477826078_exhaustgassensor.thumb.JPG.6ca629cd683ee2a3c2d1b32007f28f71.JPG

Eww why is there a digital thing on my dash?  Oh, if i look closer it's an exhaust temp' sensor.  But the gauge seems to have suffered damage from a 25 volt alternating current charging system.  But it worked for a month so i guess i got enough data...

  • Like 2
  • Thanks 1
Link to post
Share on other sites

/* i have no idea how this works
 *  I gave up in frustration & just starting putting code anywhere, it works?  Umm ok.
 *  
 *  There should be a second scale to test out for diagnostics, it's hidden
 *  by the star slash symbos just like this text is, appers 'greyed out' in my uploader software
 *  (arduino IDE i think it's called?)
 *  Should be the same for you?
 */
 // constants won't change. Used here to set a pin number:
const int coil1 = 3;
const int coil2 = 5;
const int coil3 = 7;
const int coil4 = 9;

const int sensorPin1 = A4;
const int sensorPin2 = A1;
const int sensorPin3 = A2;
const int sensorPin4 = A3;

int sensorValue = 0;
int starterDelay = 10000;
int sensorThreshold = 200;
int sensorMax = 0;

// Variables will change:
volatile int coilState = LOW;
volatile int coilPin = LOW;

volatile unsigned long startingDelayTimer = 0;
volatile int startingDelay = false;
volatile int sparkTriggerDelay = 0;               //added this to try & see if i can delay spark at low RPM.
volatile unsigned long timestamp = 0;
volatile unsigned long rpmCurrMicros= 170000;
volatile unsigned long rpmOldMicros = 0;
volatile int sensorTriggerState = false;         // current state of the button
volatile int lastsensorTriggerState = true;     // previous state  of the button/sensor in this case.

// Generally, you should use "unsigned long" for variables that hold time
// The value will quickly become too large for an int to store

const long dwell = 10;                // but this is how long the "points" are open, open longer reduces duty cycle of coils.
const long coilCharge = 2;           // interval at which to charge coil (milliseconds)

void setup() {
  // put your setup code here, to run once:
  pinMode(coil1, OUTPUT);
  pinMode(coil2, OUTPUT);
  pinMode(coil3, OUTPUT);
  pinMode(coil4, OUTPUT);
  pinMode(A4, INPUT_PULLUP);
  pinMode(A1, INPUT_PULLUP);
  pinMode(A2, INPUT_PULLUP);
  pinMode(A3, INPUT_PULLUP);
  Serial.begin(115200);
}

void activateCoilsIfLow(uint8_t inPin, uint8_t outPin)
{
   if (analogRead(inPin) <= sensorThreshold)
   {
    sensorTriggerState = true;
    if (lastsensorTriggerState = false)
    {
      lastsensorTriggerState = true;
    }
    else if (lastsensorTriggerState = sensorTriggerState)   //this isn't working with one equal sign.  I'm so lost.
     {
      delayMicroseconds(sparkTriggerDelay);
      coilState = HIGH;
      coilPin = HIGH;
      digitalWrite(outPin, HIGH);
    
      timestamp = millis();
                                          
      while (coilState == HIGH && coilPin == HIGH && (timestamp + coilCharge) > millis());  //Busy wait
   
      digitalWrite(outPin, LOW);
      coilPin = LOW;
      timestamp = millis();

      while (coilState == HIGH && coilPin == LOW && (timestamp + dwell) > millis());
 
      coilState = LOW;
      coilPin = LOW;
    }
  }
  if (analogRead(inPin) >= sensorThreshold)
  {
    sensorTriggerState = false;
    if (sensorTriggerState != lastsensorTriggerState)
    {
      rpmOldMicros = rpmCurrMicros;
      rpmCurrMicros = micros();
            
      if (millis() >= (startingDelayTimer + 10000))
      {
        if ((rpmCurrMicros - rpmOldMicros <=  169491))         //over approx' 177RPM
        {
           startingDelay = true;                               //no longer hold timing advance-retard at full advance, hope you moved the timing lever by now.
        }
        if ((rpmCurrMicros - rpmOldMicros >= 497512))
        {
          startingDelay = false;                               //chances are you have to re-start the engine now. it'll take 10 seconds or more at over 200RPM to act normal again.
          startingDelayTimer = millis();
        }
      }
      if (startingDelay == true)
      {
        rpmConsultRatioTable();
        lastsensorTriggerState = false;
      }
      else
      {
       Serial.print ( " Starter delay period not ended " );
       lastsensorTriggerState = false;
      }
    }
  }
  lastsensorTriggerState = false;           //Why do i need to make that 'false' so many times to avoid it doing weird things?
}


void loop() {
  activateCoilsIfLow(sensorPin1, coil1);
  activateCoilsIfLow(sensorPin3, coil3);
  activateCoilsIfLow(sensorPin2, coil4);
  activateCoilsIfLow(sensorPin4, coil2);
}


void rpmConsultRatioTable()
{
  if (rpmCurrMicros - rpmOldMicros >= 497512) //sub250rpm
    {
      sparkTriggerDelay =0;
      startingDelay = false;
      startingDelayTimer = millis();
    }
  else if ((rpmCurrMicros - rpmOldMicros <= 255024) && (rpmCurrMicros - rpmOldMicros >= 169491)) //125rpm
    {
      sparkTriggerDelay =81000;                     //was 57, then 59 and i don't know what overflow is but i get an error for it here.
      Serial.print ( " RPM 125" );
    }
  else if ((rpmCurrMicros - rpmOldMicros <= 169491) && (rpmCurrMicros - rpmOldMicros >= 127512)) //177rpm
    {
      sparkTriggerDelay =61000;
      Serial.print ( " RPM 177" );
    }
  else if ((rpmCurrMicros - rpmOldMicros <= 127512) && (rpmCurrMicros - rpmOldMicros >= 85008)) //250rpm
    {
      sparkTriggerDelay =41000;                    //was 27  //at 250 RPM and 45 degree sensor advance, this would be 30ms to TDC, subtract 2ms for coil charging and subtract more m.s. for advance
      Serial.print ( " RPM 250" );
    }
  else if ((rpmCurrMicros - rpmOldMicros <= 85008) && (rpmCurrMicros - rpmOldMicros >= 61000)) //375rpm
    {
      sparkTriggerDelay =31000;                 //was 16
      Serial.print ( " RPM 375 " );
      }
  else if ((rpmCurrMicros - rpmOldMicros <= 61000) && (rpmCurrMicros - rpmOldMicros >= 48000)) //500rpm
    {
      sparkTriggerDelay =23000;                 //was 11
      Serial.print ( " RPM 500 " );
    }
  else if ((rpmCurrMicros - rpmOldMicros <= 48000) && (rpmCurrMicros - rpmOldMicros >= 41000))  //625rpm
    {
      sparkTriggerDelay =7000;
      Serial.print ( " RPM 625 " );
    }
  else if ((rpmCurrMicros - rpmOldMicros <= 41000) && (rpmCurrMicros - rpmOldMicros >= 30000)) //750rpm
    {
      sparkTriggerDelay =1670;
      Serial.print ( " RPM 750" );
    }
  else if ((rpmCurrMicros - rpmOldMicros <= 30000) && (rpmCurrMicros - rpmOldMicros >= 25000)) //1000rpm
    {
      sparkTriggerDelay =1670;
      Serial.print ( " RPM 1000 " );
    }
  else if ((rpmCurrMicros - rpmOldMicros <= 25000) && (rpmCurrMicros - rpmOldMicros >= 23076)) //1200rpm
    {
      sparkTriggerDelay =125;
      Serial.print ( "RPM 1200 " );
    }
  else if ((rpmCurrMicros - rpmOldMicros <= 23076) && (rpmCurrMicros - rpmOldMicros >= 22222)) //just under 1300rpm
    {
      sparkTriggerDelay =20;
      Serial.print ( " RPM 1300 " );
    }
  else if (rpmCurrMicros - rpmOldMicros <= 22222)//just over 1300rpm
    {
      sparkTriggerDelay =0;
      Serial.print ( "RPM over 1300" );
    }
}

/*
void rpmConsultRatioTable()  //Very Retarded, for diagnostic purposes
{
  if (rpmCurrMicros - rpmOldMicros >= 497512) //sub250rpm
    {
      sparkTriggerDelay =0;
      startingDelay = false;
      startingDelayTimer = millis();
      Serial.print ( "RPM Zero" );
    }
  else if ((rpmCurrMicros - rpmOldMicros <= 255024) && (rpmCurrMicros - rpmOldMicros >= 169491)) //125rpm
    {
      sparkTriggerDelay =162000;                     //was 57, then 59
      Serial.print ( "RPM 125" );
    }
  else if ((rpmCurrMicros - rpmOldMicros <= 169491) && (rpmCurrMicros - rpmOldMicros >= 127512)) //177rpm
    {
      sparkTriggerDelay =78000;
      Serial.print ( "RPM 177" );
    }
  else if ((rpmCurrMicros - rpmOldMicros <= 127512) && (rpmCurrMicros - rpmOldMicros >= 85008)) //250rpm
    {
      sparkTriggerDelay =64000;                    //was 27  //at 250 RPM and 45 degree sensor advance, this would be 30ms to TDC, subtract 2ms for coil charging and subtract more m.s. for advance
      Serial.print ( "RPM 250" );
    }
  else if ((rpmCurrMicros - rpmOldMicros <= 85008) && (rpmCurrMicros - rpmOldMicros >= 61000)) //375rpm
    {
      sparkTriggerDelay =32000;                 //was 16
      Serial.print ( "RPM 375" );
    }
  else if ((rpmCurrMicros - rpmOldMicros <= 61000) && (rpmCurrMicros - rpmOldMicros >= 48000)) //500rpm
    {
      sparkTriggerDelay =26000;                 //was 11
      Serial.print ( "RPM 500" );
    }
  else if ((rpmCurrMicros - rpmOldMicros <= 48000) && (rpmCurrMicros - rpmOldMicros >= 41000))  //625rpm
    {
      sparkTriggerDelay =14000;
      Serial.print ( "RPM 652" );
    }
  else if ((rpmCurrMicros - rpmOldMicros <= 41000) && (rpmCurrMicros - rpmOldMicros >= 31500)) //750rpm
    {
      sparkTriggerDelay =2670;
      Serial.print ( "RPM 750" );
    }
  else if (rpmCurrMicros - rpmOldMicros <= 31500) //just under 1000rpm
    {
      sparkTriggerDelay =0;
      Serial.print ( "RPM 1000" );
    }
}*/

 

  • Like 6
  • Thanks 2
  • Haha 1
  • Confused 2
Link to post
Share on other sites
On 28/11/2019 at 20:57, SOHC said:

I gave you like 7 carburetors and you lost them all, did you find the brass ones?

Yes i found enough pieces of bronze ones to make about 80% of one, then faked the rest with bits from the rustiest one i could find.
Not sure why i spent about...50 hours on it?  It's a ...questionable? design, like, Victorian era "I just designed an engine that runs on gas & want to run it on liquid fuel & this is the best I have" design.  Not horrible, just weird.  They have a 'toilet lid' looking flapper in them and a bowl of gas, and tubes, and the flapper not only regulates how much air (yes air) gets sucked into the main jet but opens at speed as a kind of mixing valve?  And doubles as a backfire arrestor.
Weird, logical enough, but horridly old fashioned.
 

 

  • Like 6
  • Thanks 1
Link to post
Share on other sites
  • 2 months later...

Join the conversation

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

Guest
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...