Go Down

Topic: jeep kart fuel injection works...... mostly (Read 228 times) previous topic - next topic

turbothis

i got the install done and the engine runs smooth and starts very fast
it revs good but rich for  now. i have the kart powering the UNO by the USB.
if i have the UNO powered by the laptop and try to start the kart by that, it does not start
i think i need to power it by the round 12V plug

pretty stocked so far

i notice when the laptop is powering the UNO it will read teh TPS voltage but does not add up the pulse time
it will only add in the first adder but not the rest

Code: [Select]
byte Hall =     2;           // Digital Input pin for rotation sensor, one pulse per revolution
byte injector = 6;           // Digital Output Pin for turning on the injector solenoid
byte TPS =     A0;           // Analog Input Pin for the throttle
int  pulse_time;             // Duration of injector pulse
int  analog_voltage;

void setup() {

   Serial.begin(9600);                       
   pinMode(Hall, INPUT_PULLUP);
   pinMode(TPS, INPUT);
   pinMode(injector, OUTPUT);

   delay (100);                          //  wait for fuel pressure
   digitalWrite(injector,HIGH);          //  start primer
   delay (10);
   digitalWrite(injector,LOW);           //  end primer


void loop() {

  while (digitalRead(Hall)==LOW) {}       // Do nothing until the sensor goes high

  analog_voltage=analogRead(TPS);         // engine load by throttle positioning

  pulse_time=6;                           // idle ms
 
  if      (analog_voltage>= 150) pulse_time+=4;        // adding up fuel by throttle position
  else if (analog_voltage>= 250) pulse_time+=4;       
  else if (analog_voltage>= 350) pulse_time+=3;       
  else if (analog_voltage>= 450) pulse_time+=2;     
  else if (analog_voltage>= 550) pulse_time+=1;         
  else if (analog_voltage>= 650) pulse_time+=1;       
  else if (analog_voltage>= 750) pulse_time+=1;       
  else if (analog_voltage>= 850) pulse_time+=1;       
  else if (analog_voltage>= 950) pulse_time+=1;       

  Serial.println(pulse_time);                     // bunch of jibberish to ponder
  Serial.println(analog_voltage);

  digitalWrite(injector,HIGH);                    // Turn the injector on
  delay(pulse_time);                              // Amount of time to leave the injector on
  digitalWrite(injector,LOW);                     // Turn the injector off

   while (digitalRead(Hall)==HIGH){}              // Wait for LOW
 
}  // End of loop()
every post is to learn about hall sensor and/or encoder input
then produce speed and/or position information
then use this for some outputs  in either digital and/or PWM . 
easy right? thanks for helping.........

Blackfin

Look at your if/else structure. Suppose the value of analog_voltage is 450.

Your first test (is it greater than or equal to 150?) is true and so all other adders are ignored.


turbothis

#2
Nov 12, 2019, 12:48 am Last Edit: Nov 12, 2019, 01:39 am by turbothis
ok  so it does only one of the conditions.
for some reason i thought it was adding them all up as it gets past there threshold


EDIT
ooooooooooo i see, so it needs a better way to add in there.

something more like? would this be adding up each one that is true into the pulse time?

Code: [Select]
pulse_time=6;                           // idle ms
 
  while  (analog_voltage>= 150) pulse_time+=1;        // adding up fuel by throttle position
  while  (analog_voltage>= 250) pulse_time+=1;       
  while  (analog_voltage>= 350) pulse_time+=1;       
  while  (analog_voltage>= 450) pulse_time+=1;     
  while  (analog_voltage>= 550) pulse_time+=1;         
  while  (analog_voltage>= 650) pulse_time+=1;       
  while  (analog_voltage>= 750) pulse_time+=1;       
  while  (analog_voltage>= 850) pulse_time+=1;       
  while  (analog_voltage>= 950) pulse_time+=1;       
every post is to learn about hall sensor and/or encoder input
then produce speed and/or position information
then use this for some outputs  in either digital and/or PWM . 
easy right? thanks for helping.........

turbothis

video proof
https://www.youtube.com/watch?v=9PuMH3NZ1u4
every post is to learn about hall sensor and/or encoder input
then produce speed and/or position information
then use this for some outputs  in either digital and/or PWM . 
easy right? thanks for helping.........

turbothis

every post is to learn about hall sensor and/or encoder input
then produce speed and/or position information
then use this for some outputs  in either digital and/or PWM . 
easy right? thanks for helping.........

turbothis

#5
Nov 12, 2019, 02:14 am Last Edit: Nov 12, 2019, 02:19 am by turbothis
ok is this better, closer or even possible?


Code: [Select]

int  analog_voltage;
int  pulse_time;

void loop() {
for (pulse_time=6; analog_voltage>= 150;pulse_time+=2;)
     break
for (pulse_time=6; analog_voltage>= 250;pulse_time+=2;)
     break
for (pulse_time=6; analog_voltage>= 350;pulse_time+=2;)
     break
}



every post is to learn about hall sensor and/or encoder input
then produce speed and/or position information
then use this for some outputs  in either digital and/or PWM . 
easy right? thanks for helping.........

Blackfin

Not sure what that's trying to do. How about:

Code: [Select]
const byte Hall =     2;           // Digital Input pin for rotation sensor, one pulse per revolution
const byte injector = 6;           // Digital Output Pin for turning on the injector solenoid
const byte TPS =     A0;           // Analog Input Pin for the throttle

int 
    analog_voltage;
byte
    nowHall,
    lastHall;
bool
    bInjFiring;   
unsigned long
    pulse_time,
    tInj;
   
//first table assumes TPS reads low when closed; no additional fuel is needed to +4mS at WOT
const unsigned long
    BasePulseWidth = 6000,
    tps_map[] = { 0, 1000, 1000, 1000, 1000, 2000, 3000, 4000, 4000 };

//original table; TPS reads 0V at WOT?
//unsigned long byte tps_map[] = { 4000, 4000, 3000, 2000, 1000, 1000, 1000, 1000, 1000 };

void setup()
{
   Serial.begin(9600);                       
   
   pinMode(Hall, INPUT_PULLUP);
   lastHall = digitalRead( Hall );
   
   pinMode(TPS, INPUT);   
   pinMode(injector, OUTPUT);

   delay (100);                          //  wait for fuel pressure
   digitalWrite(injector,HIGH);          //  start primer
   delay (10);
   digitalWrite(injector,LOW);           //  end primer

   bInjFiring = false;
   
}//setup

void loop()
{
    nowHall = digitalRead(Hall);
    if( nowHall != lastHall )
    {
        lastHall = nowHall;
        if( nowHall == HIGH )
        {
            //turn on the injector
            bInjFiring = true;
            digitalWrite( injector, HIGH );
            tInj = micros();

        }//if
        else
        {
            //idle base pulse
            pulse_time = BasePulseWidth;
            //open TPS adjustment
            analog_voltage=analogRead(TPS);                 // engine load by throttle positioning
            int idx = map( analog_voltage, 0, 0123, 0, 8 );
            while( idx )
                pulse_time += tps_map[idx--];
                           
        }//else
       
    }//if

    if( bInjFiring )
    {
        if( micros() - tInj >= pulse_time )
        {
            digitalWrite( injector, LOW );
            bInjFiring = false;
           
        }//if
       
    }//if
   
}//loop


What is your TPS output voltage when closed? WOT?

turbothis

#7
Nov 12, 2019, 05:19 am Last Edit: Nov 12, 2019, 05:24 am by turbothis
Tps will print about 135 at idle and 900 + some change at full throttle

I just need some conditions of the tps input that increase the fuel delay that i can adjust.
This is a delay amount per crank rotation
So far i am amazed at how well it runs with very little input.

every post is to learn about hall sensor and/or encoder input
then produce speed and/or position information
then use this for some outputs  in either digital and/or PWM . 
easy right? thanks for helping.........

turbothis

#8
Nov 12, 2019, 06:19 pm Last Edit: Nov 12, 2019, 06:19 pm by turbothis
i spent some time running your code and tuning some of it
the motor seems to run pretty rich even after cutting fuel way down.
the UNO shuts down after about 10 seconds so i think i need to get that done now
i have some opto isolator boards coming soon
i have some big Schottky diodes now though
not 100% how to implement them

 SB5100-T 100V 5A

every post is to learn about hall sensor and/or encoder input
then produce speed and/or position information
then use this for some outputs  in either digital and/or PWM . 
easy right? thanks for helping.........

turbothis

man! i did some reading and successfully put this together and it runs great! for minutes.....
why is black fins soo much more agressive to the UNO?????

Code: [Select]
byte Hall =     2;           // Digital Input pin for rotation sensor, one pulse per revolution
byte injector = 6;           // Digital Output Pin for turning on the injector solenoid
byte TPS =     A0;           // Analog Input Pin for the throttle
int  pulse_time;             // Duration of injector pulse
//int  analog_voltage;         // TPS input
const int tpsmin = 150;
const int tpsmax = 1000;

void setup() {

   Serial.begin(9600);                       
   pinMode(Hall, INPUT_PULLUP);
   pinMode(TPS, INPUT);
   pinMode(injector, OUTPUT);

   delay (300);                          //  wait for fuel pressure
   digitalWrite(injector,HIGH);          //  start primer
   delay (50);
   digitalWrite(injector,LOW);           //  end primer


void loop() {
   while (digitalRead(Hall)==LOW){}                        // do nothing
   
  int analog_voltage=analogRead(TPS);                      // engine load by throttle positioning
  int load = map(analog_voltage, tpsmin, tpsmax, 0, 5);
  pulse_time=6;                                            // idle ms

  switch (load)
  {
    case 0:
     pulse_time+=0;
     break;

    case 1:
     pulse_time+=3;
     break;

    case 2:
     pulse_time+=5;
     break;

    case 3:
     pulse_time+=6;
     break;

    case 4:
     pulse_time+=7;
     break;

    case 5:
     pulse_time+=8;
     break;
  }
         
  Serial.println(pulse_time);                     // bunch of jibberish to ponder
  Serial.println(load);

  digitalWrite(injector,HIGH);                    // Turn the injector on
  delay(pulse_time);                              // Amount of time to leave the injector on
  digitalWrite(injector,LOW);                     // Turn the injector off

   while (digitalRead(Hall)==HIGH){}              // Wait for LOW
every post is to learn about hall sensor and/or encoder input
then produce speed and/or position information
then use this for some outputs  in either digital and/or PWM . 
easy right? thanks for helping.........

Blackfin

why is black fins soo much more agressive to the UNO?????
I don't know what you mean.


turbothis

#11
Nov 12, 2019, 07:11 pm Last Edit: Nov 12, 2019, 07:13 pm by turbothis
well yours if i rev it up some, the UNO will turn off or reset or something
mine just sits there and runs forever.

i need to get some kind of gauge on the UNO to see its injector pulse output and load input
then if the gauges say nothing then the UNO shut off?

anything in my code that can be made better?
i guess like millis instead of delay
every post is to learn about hall sensor and/or encoder input
then produce speed and/or position information
then use this for some outputs  in either digital and/or PWM . 
easy right? thanks for helping.........

Blackfin

I noticed an error in my code but am not sure it plays a role in what you're seeing.

This:

Code: [Select]
int idx = map( analog_voltage, 0, 0123, 0, 8 );

was intended to be

Code: [Select]
int idx = map( analog_voltage, 0, 1023, 0, 8 );


Also, how clean is your Hall sensor input signal? Any chatter/noise during transitions?

turbothis

i did see that and adjusted it to 1000
i have a scope but dont know how to use it for crap! :o
every post is to learn about hall sensor and/or encoder input
then produce speed and/or position information
then use this for some outputs  in either digital and/or PWM . 
easy right? thanks for helping.........

turbothis

every post is to learn about hall sensor and/or encoder input
then produce speed and/or position information
then use this for some outputs  in either digital and/or PWM . 
easy right? thanks for helping.........

Go Up