Main Menu

Accel Variable

Started by hakcenter, July 27, 2015, 10:41:54 PM

Rx7man

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 dually,  67/67 HE351VE, NV5600, ~600hp
'93 ECLB 47RH, new toy truck, H pump project, 1000hp goal, 300K miles
93 XCLB auto, bone stock, 350K miles
93 XCLB 5spd, bone stock, 100K miles

hakcenter

#31
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.


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.



int test = 15;
String output = "Value of test : ";
String final_output = output + String.of(test);
or
String final_output = output + ((String) test);
TS2009 Deḇarim 8:2
"And you shall remember that יהוה your Elohim led you all the way these forty years in the wilderness, to humble you, prove you, to know what is in your heart, whether you guard His commands or not.

Rx7man

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 dually,  67/67 HE351VE, NV5600, ~600hp
'93 ECLB 47RH, new toy truck, H pump project, 1000hp goal, 300K miles
93 XCLB auto, bone stock, 350K miles
93 XCLB 5spd, bone stock, 100K miles

me78569

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

hakcenter

No I'm not sure it's 100% stable yet
TS2009 Deḇarim 8:2
"And you shall remember that יהוה your Elohim led you all the way these forty years in the wilderness, to humble you, prove you, to know what is in your heart, whether you guard His commands or not.

me78569

alright,

Thanks


I the top end stuff in my code.

        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

hakcenter

Glad to see more than me using it.
TS2009 Deḇarim 8:2
"And you shall remember that יהוה your Elohim led you all the way these forty years in the wilderness, to humble you, prove you, to know what is in your heart, whether you guard His commands or not.

me78569

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

hakcenter

#38
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!


          // -----
          // 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]; }
          }
TS2009 Deḇarim 8:2
"And you shall remember that יהוה your Elohim led you all the way these forty years in the wilderness, to humble you, prove you, to know what is in your heart, whether you guard His commands or not.

hakcenter

So I've fallen on this so far, anyone else is welcome to try it out as long as you have the accel variable


      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


  // 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.
TS2009 Deḇarim 8:2
"And you shall remember that יהוה your Elohim led you all the way these forty years in the wilderness, to humble you, prove you, to know what is in your heart, whether you guard His commands or not.

hakcenter

If I get a chance to drive my truck I'll probably release 1.2.0 with the variable added this weekend.
TS2009 Deḇarim 8:2
"And you shall remember that יהוה your Elohim led you all the way these forty years in the wilderness, to humble you, prove you, to know what is in your heart, whether you guard His commands or not.

Rx7man

'94 dually,  67/67 HE351VE, NV5600, ~600hp
'93 ECLB 47RH, new toy truck, H pump project, 1000hp goal, 300K miles
93 XCLB auto, bone stock, 350K miles
93 XCLB 5spd, bone stock, 100K miles

me78569

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

hakcenter

#43
Quote from: Rx7man on August 26, 2015, 03:29:24 PM
I had to try it

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

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.
TS2009 Deḇarim 8:2
"And you shall remember that יהוה your Elohim led you all the way these forty years in the wilderness, to humble you, prove you, to know what is in your heart, whether you guard His commands or not.

Rx7man

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 dually,  67/67 HE351VE, NV5600, ~600hp
'93 ECLB 47RH, new toy truck, H pump project, 1000hp goal, 300K miles
93 XCLB auto, bone stock, 350K miles
93 XCLB 5spd, bone stock, 100K miles