Accel Variable

  • 57 Replies
  • 3199 Views
*

Offline Rx7man

  • Crazy guy
  • Hero Member
  • *****
  • 908
  • Jack of all trades
    • '94 Dodge dually
Re: Accel Variable
« Reply #30 on: August 29, 2015, 09:13:12 AM »
I might still be missing it!
Quote
The assumption is float test = int 1 + int 2; is a float, when its coming in as ints, to me shows inequal types. I would expect float test = (float) (int 1 + int 2);

The conversion from int to float is what I think they call a widening conversion, meaning you'll never get an overflow or lose precision in the conversion, which is probably why they don't warn about it, it's perfectly safe to do implicitly... though the arduino IDE is rather rudimentary.  I've been getting to know Atmel Studio... I like it but it has some things that peeve me to no end with autocomplete
'94 dodge, Colt Cam, head worked, NV5600, 3.55's, SB clutch, Ford manual hubs w. hawk brakes, custom flatdeck, custom aluminum bumper, cab off restoration, totally new engine, Mahle pistons @19:1..HE351VE with 67mm turbine and 67x95mm compressor
440hp/1000 ft lb @ 2400 RPM

*

Offline hakcenter

  • developer
  • Hero Member
  • *****
  • 623
    • 1998 12v Ram
Re: Accel Variable
« Reply #31 on: August 29, 2015, 04:13:19 PM »
lol you are haha.

While its true that you can do it, and it seems to go away from the white papers so to speak from Arduino. That's not what I'm really talking about anymore.

Context is what I'm getting after. When I see two int variables doing math, I see int math. When I see two Strings doing stuff, I think Strings. When I see char arrays I think char, does that make sense ? Without a typecast, to me it looks wrong. You take unequal types and try to equate them without a typecast, throws all kinds of errors in other IDEs for similar languages. Java, c#, etc. And while the compiler can and will make it happen, without the typecast only the original author knows the intent behind it.

Like for instance, in java you can't just take a int and print it to string. You have to add it to a string, or typecast it.

Code: [Select]
int test = 15;
String output = "Value of test : ";
String final_output = output;
final_output += test;
^^ generally will throw an error of unequal types, sometimes strings get away with things that other datatypes don't in certain IDEs.

Code: [Select]
int test = 15;
String output = "Value of test : ";
String final_output = output + String.of(test);
or
String final_output = output + ((String) test);

*

Offline Rx7man

  • Crazy guy
  • Hero Member
  • *****
  • 908
  • Jack of all trades
    • '94 Dodge dually
Re: Accel Variable
« Reply #32 on: August 29, 2015, 09:02:41 PM »
OK, I think I get what you're after.  I usually don't care so much about the type as long as its a numerical type, and a widening conversion
'94 dodge, Colt Cam, head worked, NV5600, 3.55's, SB clutch, Ford manual hubs w. hawk brakes, custom flatdeck, custom aluminum bumper, cab off restoration, totally new engine, Mahle pistons @19:1..HE351VE with 67mm turbine and 67x95mm compressor
440hp/1000 ft lb @ 2400 RPM

*

Offline me78569

  • Sr. Member
  • ****
  • 268
Re: Accel Variable
« Reply #33 on: September 12, 2015, 07:58:11 PM »
ive finally gotten a couple minutes to look over this all in depth.

Is the top end accel tuning not in your 1.1.2 code?   
2000 Dodge 2500 quad-cab 5.9 Cummins slt, homebuilt 47re revmax 3.5 messed with vb, Quad adr iquad, 4" tbe , pureflow 150 gph. he351ve in the works 100hp DFI inj

*

Offline hakcenter

  • developer
  • Hero Member
  • *****
  • 623
    • 1998 12v Ram
Re: Accel Variable
« Reply #34 on: September 13, 2015, 01:03:53 AM »
No I'm not sure it's 100% stable yet

*

Offline me78569

  • Sr. Member
  • ****
  • 268
Re: Accel Variable
« Reply #35 on: September 13, 2015, 09:55:36 AM »
alright,

Thanks


I the top end stuff in my code.

Code: [Select]
        if (curved){  //End pos of 17cm  start 16cm
                 if (turbo_rpm <= 120000) { vane_position = 458 - TPS_range;} //************************
            else if (turbo_rpm <= 128000) { vane_position = 416 - TPS_range;} //************************
            else if (turbo_rpm <= 140000) {
                     if (turbo_accel[2] > 20){vane_position = last_vane_position - 5;}
                else if (turbo_accel[2] < -20){vane_position = last_vane_position + 5;}
                else {vane_position = last_vane_position;}
          }
        }
        // Overrun protection
      if (turbo_rpm > 140000){ 
        if (turbo_accel[2] > 0){
          if (!curvea) {vane_position -= 5;}         //this will creep the vane position more open each code cycle if turbo rpms are above 140,000 if not in curvea ( perf mode defined by "F_watchpot" tab)
        }
        else {vane_position = last_vane_position;}
      }
   }

Still messing with it, but the turbo no longer "overreacts" to shaft speed above 140,000.  I don't really like that shaft speeds get up that high, but I am working the curve down. 

The accel variable is VERY useful. 
2000 Dodge 2500 quad-cab 5.9 Cummins slt, homebuilt 47re revmax 3.5 messed with vb, Quad adr iquad, 4" tbe , pureflow 150 gph. he351ve in the works 100hp DFI inj

*

Offline hakcenter

  • developer
  • Hero Member
  • *****
  • 623
    • 1998 12v Ram
Re: Accel Variable
« Reply #36 on: September 13, 2015, 02:07:21 PM »
Glad to see more than me using it.

*

Offline me78569

  • Sr. Member
  • ****
  • 268
Re: Accel Variable
« Reply #37 on: September 13, 2015, 02:47:18 PM »
Yep,

Its works really well.  It solves the prior issue of shaft speed being over 140k, but it was decreasing in speed, but the vanes were still opening. 

Very handy.   

Still working on moving the top limit down some to 130ish, but right now it stays pretty steady at 140,000. 


I cannot believe how much difference there is with this turbo at sea level.  So much easier to manage down there compared to up here.  The top is was much easier to keep at or below 130k
2000 Dodge 2500 quad-cab 5.9 Cummins slt, homebuilt 47re revmax 3.5 messed with vb, Quad adr iquad, 4" tbe , pureflow 150 gph. he351ve in the works 100hp DFI inj

*

Offline hakcenter

  • developer
  • Hero Member
  • *****
  • 623
    • 1998 12v Ram
Re: Accel Variable
« Reply #38 on: September 25, 2015, 01:34:18 PM »
A little bit more watching and I'll integrate it pretty soon.

I've been setting my idle to 40 (full open). Then snapping closed to 880 on take off. It's working pretty good, using the accel to keep it at idle when rpms fall then slightly increase over idle.. which would make it bounce back into 880. So making sure the turbo isn't accelerating while waiting at idle seems to be working pretty good!

Code: [Select]
          // -----
          // Idle Section
          idle_check = false;
          if (turbo_rpm <= idle_rpm) {
            vane_position = idle_position;
            idle_mode = true;
            idle_walkdown_mode = false;
          } else {
            idle_mode = false;
            if (idle_walkdown_mode) {
              if (last_vane_position >= min_position + two_cm) { vane_position = last_vane_position - two_cm; } else { vane_position = min_position; }
            } else if (turbo_accel[2] > 1){ vane_position = turbo_curve[0]; }
          }

*

Offline hakcenter

  • developer
  • Hero Member
  • *****
  • 623
    • 1998 12v Ram
Re: Accel Variable
« Reply #39 on: October 07, 2015, 06:47:38 PM »
So I've fallen on this so far, anyone else is welcome to try it out as long as you have the accel variable

Code: [Select]
      if (turbo_rpm <= curve_rpm[4]) {
        if (turbo_rpm <= curve_rpm[0]) {
          // -----
          // Idle Section
          idle_check = false;
          if (turbo_rpm <= idle_rpm) {
            idle_mode = true;
            idle_walkdown_mode = false;
          } else {
            idle_mode = false;
          }
          if (turbo_accel[2] <= 2) { vane_position = idle_position; } else { vane_position = turbo_curve[0]; }
        } else {
          // -----
          // Curve section
               if (idle_walkdown_mode) {
                 if (last_vane_position >= min_position + half_cm) { vane_position = last_vane_position - half_cm; } else { vane_position = min_position; }
               }
          else if (turbo_rpm <= curve_rpm[1]) { vane_position = map(turbo_rpm, curve_rpm[0], curve_rpm[1], turbo_curve[0], turbo_curve[1]); }
          else if (turbo_rpm <= curve_rpm[2]) { vane_position = turbo_curve[1]; }
          else if (turbo_rpm <= curve_rpm[3]) { vane_position = map(turbo_rpm, curve_rpm[2], curve_rpm[3], turbo_curve[1], turbo_curve[2]); }
          else { vane_position = map(turbo_rpm, curve_rpm[3], curve_rpm[4], turbo_curve[2], turbo_curve[3]); }
        }
      } else if (turbo_rpm < top_end_rpm) {
        vane_position = map(turbo_rpm, curve_rpm[4], top_end_rpm, turbo_curve[3], turbo_curve[4]);
      } else {
        // -----
        // TOP End Control Section

also this at the back end of the section

Code: [Select]
  // Default Full Open Position if no RPM signal
  } else { vane_position = min_position; }
  if (turbo_rpm < idle_walkdown_rpm && idle_check) {
    idle_check = false;
    idle_walkdown_mode = true;
  }
  if (turbo_rpm > idle_walkdown_rpm && !idle_check) {
    idle_check = true;
    idle_walkdown_mode = false;
  }
  // Keep vane position within constraints
  constrain(vane_position, min_position, max_position);
}

I'll probably finalize it later by making the walkdown rpm slightly higher and check against acceleration instead of rpm.

So far the off idle response is super awesome, and I haven't had an issue with it going 40 > 800 and back and forth so seems about right atm. I'll update to 1.3.0 after maybe another month and running it.

*

Offline hakcenter

  • developer
  • Hero Member
  • *****
  • 623
    • 1998 12v Ram
Re: Accel Variable
« Reply #40 on: October 22, 2015, 11:00:05 AM »
If I get a chance to drive my truck I'll probably release 1.2.0 with the variable added this weekend.

*

Offline Rx7man

  • Crazy guy
  • Hero Member
  • *****
  • 908
  • Jack of all trades
    • '94 Dodge dually
Re: Accel Variable
« Reply #41 on: October 23, 2015, 09:34:24 AM »
cool :)
'94 dodge, Colt Cam, head worked, NV5600, 3.55's, SB clutch, Ford manual hubs w. hawk brakes, custom flatdeck, custom aluminum bumper, cab off restoration, totally new engine, Mahle pistons @19:1..HE351VE with 67mm turbine and 67x95mm compressor
440hp/1000 ft lb @ 2400 RPM

*

Offline me78569

  • Sr. Member
  • ****
  • 268
Re: Accel Variable
« Reply #42 on: October 27, 2015, 10:07:12 PM »
Gonna read through it in a next couple days. 
2000 Dodge 2500 quad-cab 5.9 Cummins slt, homebuilt 47re revmax 3.5 messed with vb, Quad adr iquad, 4" tbe , pureflow 150 gph. he351ve in the works 100hp DFI inj

*

Offline hakcenter

  • developer
  • Hero Member
  • *****
  • 623
    • 1998 12v Ram
Re: Accel Variable
« Reply #43 on: October 30, 2015, 10:57:31 AM »
I had to try it

Code: [Select]
void setup() {
  // put your setup code here, to run once:
Serial.begin(115200);
int var1 = 1;
int var2 = 2;
float var3 = var1;
float var4 = var2;

float var5 = var1/var2; //returns 0   the types are integers
float var6 = var3/var2; // should return 0.5, one of the
float var7 = var3/var4; //returns 0.5, both are floats

Serial.println(var5);
Serial.println(var6);
Serial.println(var7);


}

void loop() {
  // put your main code here, to run repeatedly:

}

returns:
0
0.5
0.5

int to float conversion is done implicitly in var3=var1, you don't need to specify it

I thought I would ressurect this post rx7man.

I had to typecast back to int, otherwise values were ALL over the place, 0, 255, etc...
Code: [Select]
turbo_accel[0] = (int) (turbo_rpm - last_turbo_rpm[0]) / 10.0f;
    last_turbo_rpm[0] = turbo_rpm;
    if (timer % 100 == 0) {
      turbo_accel[1] = (int) (turbo_rpm - last_turbo_rpm[1]) / 100.0f;
      last_turbo_rpm[1] = turbo_rpm;
    }
Figure that one out.

Looks like float math only goes up, not down. ie: ints can go up to floats, but floats can't be pressed down to ints without typecasting. I know a 'duh' moment, but wondering how smart the compiler really is.

*

Offline Rx7man

  • Crazy guy
  • Hero Member
  • *****
  • 908
  • Jack of all trades
    • '94 Dodge dually
Re: Accel Variable
« Reply #44 on: October 31, 2015, 01:16:36 AM »
very weird... I've never needed to, and my example did work, but it is good practice to do it explicitly because you will notice it, while you may not notice an implicit one
'94 dodge, Colt Cam, head worked, NV5600, 3.55's, SB clutch, Ford manual hubs w. hawk brakes, custom flatdeck, custom aluminum bumper, cab off restoration, totally new engine, Mahle pistons @19:1..HE351VE with 67mm turbine and 67x95mm compressor
440hp/1000 ft lb @ 2400 RPM