Accel Variable

  • 57 Replies
  • 3201 Views
*

Online hakcenter

  • developer
  • Hero Member
  • *****
  • 623
    • 1998 12v Ram
Accel Variable
« on: July 27, 2015, 10:41:54 PM »
I'm trying not to butcher up me's thread.. so

I've been working on this variable for the last day.. finally got some time to sit down today and simulate rpm at constant rates and come up with actual working math.

Can't multiply that was totally wrong... lol. So far I'm at this

Code: [Select]
if (timer % 10 == 0) {
    turbo_accel[2] = (turbo_rpm - last_turbo_rpm) / 10;
    last_turbo_rpm = turbo_rpm;
  }
Time it takes to compute
Code: [Select]
60uS
16uS
16uS
20uS
20uS
16uS
16uS
16uS
16uS
20uS
60uS

vs some bitwise with 32ms average, polling at 16ms

Code: [Select]
if (timer % 2 == 0) {
    if (accel_timer == 8) {
      if (alternate_accel) {
        turbo_accel[0] = (turbo_rpm - last_turbo_rpm) >> 4;
        alternate_accel = false;
      } else {
        turbo_accel[1] = (turbo_rpm - last_turbo_rpm) >> 4;
        alternate_accel = true;
      }
      turbo_accel[2] = (turbo_accel[0] + turbo_accel[1]) >> 1;
      last_turbo_rpm = turbo_rpm;
    }
    accel_timer++;
    if (accel_timer > 8) { accel_timer = 1; }
  }
Time it takes to compute
Code: [Select]
12uS
4uS
4uS
4uS
4uS
4uS
4uS
4uS
8uS
4uS
4uS
4uS
4uS
4uS
4uS
4uS
12uS

thoughts ?

*

Online hakcenter

  • developer
  • Hero Member
  • *****
  • 623
    • 1998 12v Ram
Re: Accel Variable
« Reply #1 on: July 28, 2015, 10:17:12 PM »
Required setup changes

Code: [Select]
// Turbo
int minimum_turbo_rpm = 1000;
long turbo_rpm = 0;
long last_turbo_rpm = 0;
int turbo_accel[3] = { 0,0,0 };

// Timer2 Variables
unsigned int timer = 0;
boolean alternate_accel = false;
byte accel_timer = 0;
boolean update_vane_position = false;

changing rpm from unsigned, to basically signed, so math can go negative... argh annoying to try to figure that out.

Code: [Select]
  else if (timer % 50 == 0) { update_vane_position = true; }
  // Update turbo_accel before calculating vane_position
  if (timer % 2 == 0) {
    if (accel_timer == 8) {
      if (alternate_accel) {
        turbo_accel[0] = (turbo_rpm - last_turbo_rpm) >> 4;
        alternate_accel = false;
      } else {
        turbo_accel[1] = (turbo_rpm - last_turbo_rpm) >> 4;
        alternate_accel = true;
      }
      turbo_accel[2] = (turbo_accel[0] + turbo_accel[1]) >> 1;
      last_turbo_rpm = turbo_rpm;
    }
    accel_timer++;
    if (accel_timer > 8) { accel_timer = 1; }
  }
  // Modes
  if (timer % 100 == 0) { calculate_modes(); }

^ def the way to calc it at super fast rates... hopefully its a useful variable

*

Offline Rx7man

  • Crazy guy
  • Hero Member
  • *****
  • 908
  • Jack of all trades
    • '94 Dodge dually
Re: Accel Variable
« Reply #2 on: July 29, 2015, 11:14:02 AM »
I think it will be useful :)
'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

*

Online hakcenter

  • developer
  • Hero Member
  • *****
  • 623
    • 1998 12v Ram
Re: Accel Variable
« Reply #3 on: August 16, 2015, 10:47:56 AM »
Updating it to
Variables
Code: [Select]
// Turbo
unsigned int minimum_turbo_rpm = 1000;
long turbo_rpm = 0;
long last_turbo_rpm[2] = { 0,0 };
int turbo_accel[3] = { 0,0,0 };

// Timer2 Variables
unsigned int timer = 0;
boolean update_vane_position = false;
Code
Code: [Select]
  if (timer % 10 == 0) {
    // Division by 10
    turbo_accel[0] = ((turbo_rpm - last_turbo_rpm[0]) * 205) >> 11;
    last_turbo_rpm[0] = turbo_rpm;
    if (timer % 100 == 0) {
      // Division by 100
      turbo_accel[1] = ((turbo_rpm - last_turbo_rpm[1]) * 164) >> 14;
      last_turbo_rpm[1] = turbo_rpm;
    }
    if (turbo_rpm < top_end_rpm) { turbo_accel[2] = turbo_accel[1]; } else { turbo_accel[2] = turbo_accel[0]; }
  }

I was poking around at it, and it didn't seem to do exactly what I wanted, especially in the transition from 100ms > 10ms serial output. It could only be 10ms and still be accurate but it won't necessarily reflect the rpm changes that you see.. I'll probably refine it one more time with a good drive but wanted to make note of it here and update the common code to reflect the small changes.

*

Online hakcenter

  • developer
  • Hero Member
  • *****
  • 623
    • 1998 12v Ram
Re: Accel Variable
« Reply #4 on: August 17, 2015, 02:57:47 PM »
Accel variable seems to be working as expected now. Probably going to use it for tuning the top end curve. I've noticed that shaft speed acceleration peters out depending on where you tuned it.

I was tuning it for 3rd gear, and it barely reaches into 130k land and creeps back, but once I'm in 4th or higher, I can't get over 125k, so I'll probably tune the curve in my highest gear, then relate turbo acceleration > 50rpm/ms goto a bigger vane position.. something like that

*

Online hakcenter

  • developer
  • Hero Member
  • *****
  • 623
    • 1998 12v Ram
Re: Accel Variable
« Reply #5 on: August 17, 2015, 04:26:41 PM »
Here's my 3rd gear
Code: [Select]
CPOS : 740 | APOS : 740 | RPM :  37560 | Accel :    0 | Mode : Normal | 159
CPOS : 740 | APOS : 741 | RPM :  37620 | Accel :    0 | Mode : Normal | 157
CPOS : 739 | APOS : 741 | RPM :  37740 | Accel :    1 | Mode : Normal | 156
CPOS : 740 | APOS : 740 | RPM :  37260 | Accel :   -5 | Mode : Normal | 156
CPOS : 739 | APOS : 740 | RPM :  38040 | Accel :    7 | Mode : Normal | 156
CPOS : 739 | APOS : 740 | RPM :  37740 | Accel :   -4 | Mode : Normal | 152
CPOS : 739 | APOS : 739 | RPM :  38340 | Accel :    6 | Mode : Normal | 158
CPOS : 737 | APOS : 738 | RPM :  39480 | Accel :   11 | Mode : Normal | 158
CPOS : 736 | APOS : 737 | RPM :  39900 | Accel :    4 | Mode : Normal | 159
CPOS : 737 | APOS : 736 | RPM :  39780 | Accel :   -2 | Mode : Normal | 148
CPOS : 736 | APOS : 736 | RPM :  40140 | Accel :    3 | Mode : Normal | 162
CPOS : 735 | APOS : 735 | RPM :  40740 | Accel :    6 | Mode : Normal | 160
CPOS : 733 | APOS : 733 | RPM :  42540 | Accel :   18 | Mode : Normal | 155
CPOS : 733 | APOS : 732 | RPM :  42480 | Accel :   -1 | Mode : Normal | 156
CPOS : 732 | APOS : 732 | RPM :  42720 | Accel :    2 | Mode : Normal | 162
CPOS : 730 | APOS : 732 | RPM :  44220 | Accel :   15 | Mode : Normal | 161
CPOS : 729 | APOS : 729 | RPM :  45060 | Accel :    8 | Mode : Normal | 162
CPOS : 728 | APOS : 729 | RPM :  45780 | Accel :    7 | Mode : Normal | 166
CPOS : 726 | APOS : 728 | RPM :  46800 | Accel :   10 | Mode : Normal | 162
CPOS : 724 | APOS : 726 | RPM :  48300 | Accel :   15 | Mode : Normal | 163
CPOS : 722 | APOS : 722 | RPM :  50040 | Accel :   17 | Mode : Normal | 166
CPOS : 719 | APOS : 722 | RPM :  52140 | Accel :   21 | Mode : Normal | 177
CPOS : 716 | APOS : 717 | RPM :  54180 | Accel :   20 | Mode : Normal | 189
CPOS : 713 | APOS : 714 | RPM :  56280 | Accel :   21 | Mode : Normal | 203
CPOS : 710 | APOS : 712 | RPM :  58260 | Accel :   19 | Mode : Normal | 193
CPOS : 707 | APOS : 709 | RPM :  60120 | Accel :   18 | Mode : Normal | 213
CPOS : 705 | APOS : 707 | RPM :  61620 | Accel :   15 | Mode : Normal | 206
CPOS : 703 | APOS : 704 | RPM :  63300 | Accel :   16 | Mode : Normal | 205
CPOS : 699 | APOS : 700 | RPM :  65940 | Accel :   26 | Mode : Normal | 196
CPOS : 692 | APOS : 693 | RPM :  69480 | Accel :   35 | Mode : Normal | 204
CPOS : 682 | APOS : 685 | RPM :  74280 | Accel :   48 | Mode : Normal | 212
CPOS : 672 | APOS : 675 | RPM :  79200 | Accel :   49 | Mode : Normal | 220
CPOS : 662 | APOS : 664 | RPM :  84420 | Accel :   52 | Mode : Normal | 226
CPOS : 651 | APOS : 654 | RPM :  89760 | Accel :   53 | Mode : Normal | 219
CPOS : 640 | APOS : 642 | RPM :  95340 | Accel :   55 | Mode : Normal | 238
CPOS : 627 | APOS : 630 | RPM : 101940 | Accel :   66 | Mode : Normal | 253
CPOS : 620 | APOS : 623 | RPM : 105120 | Accel :   54 | Mode : Normal | 131
CPOS : 619 | APOS : 620 | RPM : 105960 | Accel :   84 | Mode : Normal | 23
CPOS : 618 | APOS : 619 | RPM : 106620 | Accel :   66 | Mode : Normal | 27
CPOS : 617 | APOS : 618 | RPM : 107520 | Accel :   90 | Mode : Normal | 24
CPOS : 616 | APOS : 617 | RPM : 108060 | Accel :   54 | Mode : Normal | 28
CPOS : 615 | APOS : 616 | RPM : 108780 | Accel :   72 | Mode : Normal | 24
CPOS : 614 | APOS : 615 | RPM : 109800 | Accel :  102 | Mode : Normal | 31
CPOS : 613 | APOS : 614 | RPM : 110460 | Accel :   66 | Mode : Normal | 29
CPOS : 612 | APOS : 613 | RPM : 111300 | Accel :   84 | Mode : Normal | 29
CPOS : 611 | APOS : 612 | RPM : 111960 | Accel :   66 | Mode : Normal | 25
CPOS : 610 | APOS : 611 | RPM : 112500 | Accel :   54 | Mode : Normal | 25
CPOS : 610 | APOS : 610 | RPM : 113100 | Accel :   60 | Mode : Normal | 26
CPOS : 609 | APOS : 610 | RPM : 113820 | Accel :   72 | Mode : Normal | 25
CPOS : 607 | APOS : 608 | RPM : 114840 | Accel :  102 | Mode : Normal | 29
CPOS : 604 | APOS : 607 | RPM : 117000 | Accel :  216 | Mode : Normal | 30
CPOS : 605 | APOS : 604 | RPM : 116340 | Accel :  -67 | Mode : Normal | 30
CPOS : 605 | APOS : 605 | RPM : 116760 | Accel :   42 | Mode : Normal | 30
CPOS : 604 | APOS : 605 | RPM : 117660 | Accel :   90 | Mode : Normal | 27
CPOS : 603 | APOS : 603 | RPM : 118320 | Accel :   66 | Mode : Normal | 30
CPOS : 602 | APOS : 603 | RPM : 119160 | Accel :   84 | Mode : Normal | 28
CPOS : 600 | APOS : 602 | RPM : 120000 | Accel :   84 | Mode : Normal | 30
CPOS : 500 | APOS : 600 | RPM : 120660 | Accel :   66 | Mode : Normal | 28
CPOS : 500 | APOS : 500 | RPM : 121620 | Accel :   96 | Mode : Normal | 31
CPOS : 400 | APOS : 500 | RPM : 122340 | Accel :   72 | Mode : Normal | 28
CPOS : 400 | APOS : 400 | RPM : 123240 | Accel :   90 | Mode : Normal | 31
CPOS : 400 | APOS : 400 | RPM : 123660 | Accel :   42 | Mode : Normal | 28
CPOS : 340 | APOS : 400 | RPM : 124200 | Accel :   54 | Mode : Normal | 28
CPOS : 340 | APOS : 340 | RPM : 124380 | Accel :   18 | Mode : Normal | 32
CPOS : 340 | APOS : 340 | RPM : 124440 | Accel :    6 | Mode : Normal | 28
CPOS : 340 | APOS : 340 | RPM : 124200 | Accel :  -25 | Mode : Normal | 32
CPOS : 340 | APOS : 340 | RPM : 124320 | Accel :   12 | Mode : Normal | 28
CPOS : 340 | APOS : 340 | RPM : 124320 | Accel :    0 | Mode : Normal | 28
CPOS : 340 | APOS : 340 | RPM : 124320 | Accel :    0 | Mode : Normal | 28
CPOS : 340 | APOS : 340 | RPM : 124440 | Accel :   12 | Mode : Normal | 29
CPOS : 340 | APOS : 340 | RPM : 124380 | Accel :   -7 | Mode : Normal | 27
CPOS : 340 | APOS : 340 | RPM : 124740 | Accel :   36 | Mode : Normal | 28
CPOS : 340 | APOS : 340 | RPM : 124980 | Accel :   24 | Mode : Normal | 32
CPOS : 340 | APOS : 340 | RPM : 125520 | Accel :   54 | Mode : Normal | 28
CPOS : 340 | APOS : 340 | RPM : 125280 | Accel :  -25 | Mode : Normal | 28
CPOS : 340 | APOS : 340 | RPM : 125040 | Accel :  -25 | Mode : Normal | 32
CPOS : 340 | APOS : 340 | RPM : 125580 | Accel :   54 | Mode : Normal | 29
CPOS : 280 | APOS : 340 | RPM : 126060 | Accel :   48 | Mode : Normal | 28
CPOS : 340 | APOS : 280 | RPM : 125940 | Accel :  -13 | Mode : Normal | 35
CPOS : 340 | APOS : 340 | RPM : 125880 | Accel :   -7 | Mode : Normal | 26
CPOS : 280 | APOS : 340 | RPM : 126180 | Accel :   30 | Mode : Normal | 29
CPOS : 280 | APOS : 280 | RPM : 126480 | Accel :   30 | Mode : Normal | 32
CPOS : 280 | APOS : 280 | RPM : 126540 | Accel :    6 | Mode : Normal | 29
CPOS : 280 | APOS : 280 | RPM : 126780 | Accel :   24 | Mode : Normal | 28
CPOS : 280 | APOS : 280 | RPM : 126720 | Accel :   -7 | Mode : Normal | 29
CPOS : 280 | APOS : 280 | RPM : 126960 | Accel :   24 | Mode : Normal | 32
CPOS : 280 | APOS : 280 | RPM : 127020 | Accel :    6 | Mode : Normal | 29
CPOS : 280 | APOS : 280 | RPM : 127140 | Accel :   12 | Mode : Normal | 29
CPOS : 280 | APOS : 280 | RPM : 127200 | Accel :    6 | Mode : Normal | 28
CPOS : 280 | APOS : 280 | RPM : 126960 | Accel :  -25 | Mode : Normal | 33
CPOS : 280 | APOS : 280 | RPM : 127200 | Accel :   24 | Mode : Normal | 29
CPOS : 280 | APOS : 280 | RPM : 127440 | Accel :   24 | Mode : Normal | 28
CPOS : 280 | APOS : 280 | RPM : 127440 | Accel :    0 | Mode : Normal | 35
CPOS : 280 | APOS : 280 | RPM : 127500 | Accel :    6 | Mode : Normal | 27
CPOS : 280 | APOS : 280 | RPM : 127620 | Accel :   12 | Mode : Normal | 28
CPOS : 280 | APOS : 280 | RPM : 127680 | Accel :    6 | Mode : Normal | 33
CPOS : 280 | APOS : 280 | RPM : 127800 | Accel :   12 | Mode : Normal | 29
CPOS : 280 | APOS : 280 | RPM : 127680 | Accel :  -13 | Mode : Normal | 29
CPOS : 261 | APOS : 280 | RPM : 128160 | Accel :   48 | Mode : Normal | 29
CPOS : 280 | APOS : 280 | RPM : 127980 | Accel :  -19 | Mode : Normal | 29
CPOS : 261 | APOS : 280 | RPM : 128160 | Accel :   18 | Mode : Normal | 31
CPOS : 280 | APOS : 261 | RPM : 127920 | Accel :  -25 | Mode : Normal | 27
CPOS : 240 | APOS : 280 | RPM : 128340 | Accel :   42 | Mode : Normal | 29
CPOS : 254 | APOS : 240 | RPM : 128220 | Accel :  -13 | Mode : Normal | 29
CPOS : 261 | APOS : 268 | RPM : 128160 | Accel :   -7 | Mode : Normal | 29
CPOS : 254 | APOS : 261 | RPM : 128220 | Accel :    6 | Mode : Normal | 29
CPOS : 254 | APOS : 254 | RPM : 128220 | Accel :    0 | Mode : Normal | 32
CPOS : 232 | APOS : 254 | RPM : 128400 | Accel :   18 | Mode : Normal | 26
CPOS : 232 | APOS : 232 | RPM : 128400 | Accel :    0 | Mode : Normal | 29
CPOS : 225 | APOS : 225 | RPM : 128460 | Accel :    6 | Mode : Normal | 30
CPOS : 225 | APOS : 225 | RPM : 128460 | Accel :    0 | Mode : Normal | 29
CPOS : 211 | APOS : 225 | RPM : 128580 | Accel :   12 | Mode : Normal | 29
CPOS : 211 | APOS : 211 | RPM : 128580 | Accel :    0 | Mode : Normal | 29
CPOS : 211 | APOS : 211 | RPM : 128580 | Accel :    0 | Mode : Normal | 29
CPOS : 211 | APOS : 204 | RPM : 128580 | Accel :    0 | Mode : Normal | 32
CPOS : 211 | APOS : 211 | RPM : 128580 | Accel :    0 | Mode : Normal | 27
CPOS : 204 | APOS : 211 | RPM : 128640 | Accel :    6 | Mode : Normal | 29
CPOS : 182 | APOS : 204 | RPM : 128820 | Accel :   18 | Mode : Normal | 29
CPOS : 189 | APOS : 182 | RPM : 128760 | Accel :   -7 | Mode : Normal | 29
CPOS : 196 | APOS : 189 | RPM : 128700 | Accel :   -7 | Mode : Normal | 29
CPOS : 175 | APOS : 196 | RPM : 128880 | Accel :   18 | Mode : Normal | 29
CPOS : 175 | APOS : 175 | RPM : 128880 | Accel :    0 | Mode : Normal | 30
CPOS : 182 | APOS : 175 | RPM : 128820 | Accel :   -7 | Mode : Normal | 29
CPOS : 175 | APOS : 182 | RPM : 128880 | Accel :    6 | Mode : Normal | 29
CPOS : 175 | APOS : 211 | RPM : 128880 | Accel :    0 | Mode : Normal | 29
CPOS : 153 | APOS : 175 | RPM : 129060 | Accel :   18 | Mode : Normal | 32
CPOS : 189 | APOS : 153 | RPM : 128760 | Accel :  -31 | Mode : Normal | 27
CPOS : 182 | APOS : 189 | RPM : 128820 | Accel :    6 | Mode : Normal | 29
CPOS : 160 | APOS : 182 | RPM : 129000 | Accel :   18 | Mode : Normal | 29
CPOS : 182 | APOS : 196 | RPM : 128820 | Accel :  -19 | Mode : Normal | 29
CPOS : 160 | APOS : 182 | RPM : 129000 | Accel :   18 | Mode : Normal | 31
CPOS : 146 | APOS : 160 | RPM : 129120 | Accel :   12 | Mode : Normal | 28
CPOS : 168 | APOS : 146 | RPM : 128940 | Accel :  -19 | Mode : Normal | 30
CPOS : 168 | APOS : 168 | RPM : 128940 | Accel :    0 | Mode : Normal | 27
CPOS : 160 | APOS : 153 | RPM : 129000 | Accel :    6 | Mode : Normal | 28
CPOS : 146 | APOS : 160 | RPM : 129120 | Accel :   12 | Mode : Normal | 30
CPOS : 168 | APOS : 146 | RPM : 128940 | Accel :  -19 | Mode : Normal | 27
CPOS : 146 | APOS : 168 | RPM : 129120 | Accel :   18 | Mode : Normal | 27
CPOS : 153 | APOS : 146 | RPM : 129060 | Accel :   -7 | Mode : Normal | 29
CPOS : 175 | APOS : 124 | RPM : 128880 | Accel :  -19 | Mode : Normal | 29
CPOS : 182 | APOS : 175 | RPM : 128820 | Accel :   -7 | Mode : Normal | 30
CPOS : 153 | APOS : 182 | RPM : 129060 | Accel :   24 | Mode : Normal | 29
CPOS : 160 | APOS : 153 | RPM : 129000 | Accel :   -7 | Mode : Normal | 29
CPOS : 153 | APOS : 160 | RPM : 129060 | Accel :    6 | Mode : Normal | 30
CPOS : 153 | APOS : 153 | RPM : 129060 | Accel :    0 | Mode : Normal | 30
CPOS : 146 | APOS : 153 | RPM : 129120 | Accel :    6 | Mode : Normal | 29
CPOS : 175 | APOS : 146 | RPM : 128880 | Accel :  -25 | Mode : Normal | 33
CPOS : 225 | APOS : 175 | RPM : 128460 | Accel :  -43 | Mode : Normal | 29
CPOS : 254 | APOS : 225 | RPM : 128220 | Accel :  -25 | Mode : Normal | 29
CPOS : 280 | APOS : 280 | RPM : 127740 | Accel :  -49 | Mode : Normal | 29
CPOS : 280 | APOS : 280 | RPM : 126840 | Accel :  -91 | Mode : Normal | 29
CPOS : 340 | APOS : 280 | RPM : 125520 | Accel : -133 | Mode : Normal | 28
CPOS : 400 | APOS : 340 | RPM : 123720 | Accel : -181 | Mode : Normal | 28
CPOS : 500 | APOS : 400 | RPM : 121440 | Accel : -229 | Mode : Normal | 27
CPOS : 602 | APOS : 601 | RPM : 118500 | Accel : -295 | Mode : Normal | 30
CPOS : 605 | APOS : 602 | RPM : 116700 | Accel : -181 | Mode : Normal | 26
CPOS : 607 | APOS : 605 | RPM : 114780 | Accel : -193 | Mode : Normal | 26
CPOS : 610 | APOS : 607 | RPM : 113040 | Accel : -175 | Mode : Normal | 26
CPOS : 611 | APOS : 610 | RPM : 111780 | Accel : -127 | Mode : Normal | 24
CPOS : 613 | APOS : 612 | RPM : 110580 | Accel : -121 | Mode : Normal | 26
CPOS : 615 | APOS : 613 | RPM : 109380 | Accel : -121 | Mode : Normal | 27

*

Online hakcenter

  • developer
  • Hero Member
  • *****
  • 623
    • 1998 12v Ram
Re: Accel Variable
« Reply #6 on: August 17, 2015, 04:26:47 PM »
Here's my 4th gear
Code: [Select]
CPOS : 670 | APOS : 670 | RPM :  80340 | Accel :    5 | Mode : Normal | 228
CPOS : 668 | APOS : 669 | RPM :  81120 | Accel :    7 | Mode : Normal | 222
CPOS : 668 | APOS : 668 | RPM :  81420 | Accel :    3 | Mode : Normal | 225
CPOS : 667 | APOS : 667 | RPM :  81960 | Accel :    5 | Mode : Normal | 223
CPOS : 665 | APOS : 665 | RPM :  82800 | Accel :    8 | Mode : Normal | 220
CPOS : 663 | APOS : 664 | RPM :  83520 | Accel :    7 | Mode : Normal | 213
CPOS : 662 | APOS : 662 | RPM :  84480 | Accel :    9 | Mode : Normal | 221
CPOS : 659 | APOS : 660 | RPM :  85980 | Accel :   15 | Mode : Normal | 223
CPOS : 657 | APOS : 656 | RPM :  86940 | Accel :    9 | Mode : Normal | 227
CPOS : 654 | APOS : 655 | RPM :  88020 | Accel :   10 | Mode : Normal | 222
CPOS : 652 | APOS : 653 | RPM :  89100 | Accel :   10 | Mode : Normal | 236
CPOS : 649 | APOS : 650 | RPM :  90600 | Accel :   15 | Mode : Normal | 227
CPOS : 644 | APOS : 646 | RPM :  93120 | Accel :   25 | Mode : Normal | 236
CPOS : 635 | APOS : 638 | RPM :  97860 | Accel :   47 | Mode : Normal | 257
CPOS : 625 | APOS : 627 | RPM : 102780 | Accel :   49 | Mode : Normal | 259
CPOS : 620 | APOS : 621 | RPM : 105540 | Accel :   78 | Mode : Normal | 105
CPOS : 620 | APOS : 620 | RPM : 105660 | Accel :   12 | Mode : Normal | 25
CPOS : 619 | APOS : 620 | RPM : 106260 | Accel :   60 | Mode : Normal | 25
CPOS : 618 | APOS : 619 | RPM : 107160 | Accel :   90 | Mode : Normal | 23
CPOS : 617 | APOS : 617 | RPM : 107520 | Accel :   36 | Mode : Normal | 28
CPOS : 616 | APOS : 617 | RPM : 108120 | Accel :   60 | Mode : Normal | 24
CPOS : 616 | APOS : 616 | RPM : 108720 | Accel :   60 | Mode : Normal | 26
CPOS : 615 | APOS : 616 | RPM : 109260 | Accel :   54 | Mode : Normal | 26
CPOS : 614 | APOS : 615 | RPM : 109620 | Accel :   36 | Mode : Normal | 25
CPOS : 614 | APOS : 614 | RPM : 110160 | Accel :   54 | Mode : Normal | 24
CPOS : 613 | APOS : 614 | RPM : 110700 | Accel :   54 | Mode : Normal | 26
CPOS : 612 | APOS : 613 | RPM : 111300 | Accel :   60 | Mode : Normal | 28
CPOS : 611 | APOS : 612 | RPM : 111900 | Accel :   60 | Mode : Normal | 25
CPOS : 610 | APOS : 611 | RPM : 112500 | Accel :   60 | Mode : Normal | 26
CPOS : 610 | APOS : 610 | RPM : 113100 | Accel :   60 | Mode : Normal | 25
CPOS : 609 | APOS : 610 | RPM : 113580 | Accel :   48 | Mode : Normal | 29
CPOS : 608 | APOS : 609 | RPM : 114180 | Accel :   60 | Mode : Normal | 30
CPOS : 608 | APOS : 608 | RPM : 114600 | Accel :   42 | Mode : Normal | 29
CPOS : 607 | APOS : 608 | RPM : 115200 | Accel :   60 | Mode : Normal | 26
CPOS : 606 | APOS : 606 | RPM : 115920 | Accel :   72 | Mode : Normal | 30
CPOS : 605 | APOS : 606 | RPM : 116640 | Accel :   72 | Mode : Normal | 33
CPOS : 605 | APOS : 605 | RPM : 116940 | Accel :   30 | Mode : Normal | 24
CPOS : 604 | APOS : 605 | RPM : 117540 | Accel :   60 | Mode : Normal | 30
CPOS : 602 | APOS : 604 | RPM : 118560 | Accel :  102 | Mode : Normal | 27
CPOS : 602 | APOS : 602 | RPM : 118560 | Accel :    0 | Mode : Normal | 26
CPOS : 602 | APOS : 602 | RPM : 119220 | Accel :   66 | Mode : Normal | 28
CPOS : 601 | APOS : 602 | RPM : 119580 | Accel :   36 | Mode : Normal | 26
CPOS : 500 | APOS : 601 | RPM : 120180 | Accel :   60 | Mode : Normal | 32
CPOS : 500 | APOS : 500 | RPM : 120540 | Accel :   36 | Mode : Normal | 26
CPOS : 500 | APOS : 500 | RPM : 121140 | Accel :   60 | Mode : Normal | 28
CPOS : 500 | APOS : 500 | RPM : 121740 | Accel :   60 | Mode : Normal | 29
CPOS : 500 | APOS : 500 | RPM : 121920 | Accel :   18 | Mode : Normal | 26
CPOS : 400 | APOS : 500 | RPM : 122280 | Accel :   36 | Mode : Normal | 27
CPOS : 400 | APOS : 400 | RPM : 122580 | Accel :   30 | Mode : Normal | 32
CPOS : 400 | APOS : 400 | RPM : 122880 | Accel :   30 | Mode : Normal | 28
CPOS : 400 | APOS : 400 | RPM : 122700 | Accel :  -19 | Mode : Normal | 31
CPOS : 400 | APOS : 400 | RPM : 122880 | Accel :   18 | Mode : Normal | 28
CPOS : 400 | APOS : 400 | RPM : 123120 | Accel :   24 | Mode : Normal | 31
CPOS : 400 | APOS : 400 | RPM : 123360 | Accel :   24 | Mode : Normal | 28
CPOS : 400 | APOS : 400 | RPM : 122700 | Accel :  -67 | Mode : Normal | 31
CPOS : 400 | APOS : 400 | RPM : 122580 | Accel :  -13 | Mode : Normal | 28
CPOS : 400 | APOS : 400 | RPM : 122760 | Accel :   18 | Mode : Normal | 32
CPOS : 400 | APOS : 400 | RPM : 122400 | Accel :  -37 | Mode : Normal | 27
CPOS : 400 | APOS : 400 | RPM : 122520 | Accel :   12 | Mode : Normal | 32
CPOS : 400 | APOS : 400 | RPM : 122280 | Accel :  -25 | Mode : Normal | 31
CPOS : 400 | APOS : 400 | RPM : 122460 | Accel :   18 | Mode : Normal | 31
CPOS : 400 | APOS : 400 | RPM : 122460 | Accel :    0 | Mode : Normal | 29
CPOS : 400 | APOS : 400 | RPM : 122280 | Accel :  -19 | Mode : Normal | 29
CPOS : 400 | APOS : 400 | RPM : 122160 | Accel :  -13 | Mode : Normal | 26
CPOS : 400 | APOS : 400 | RPM : 122280 | Accel :   12 | Mode : Normal | 31
CPOS : 400 | APOS : 400 | RPM : 122160 | Accel :  -13 | Mode : Normal | 31
CPOS : 400 | APOS : 400 | RPM : 122040 | Accel :  -13 | Mode : Normal | 24
CPOS : 400 | APOS : 400 | RPM : 122220 | Accel :   18 | Mode : Normal | 32
CPOS : 400 | APOS : 400 | RPM : 122040 | Accel :  -19 | Mode : Normal | 27
CPOS : 400 | APOS : 400 | RPM : 122340 | Accel :   30 | Mode : Normal | 32
CPOS : 400 | APOS : 400 | RPM : 122280 | Accel :   -7 | Mode : Normal | 28
CPOS : 400 | APOS : 400 | RPM : 122280 | Accel :    0 | Mode : Normal | 33
CPOS : 400 | APOS : 400 | RPM : 122280 | Accel :    0 | Mode : Normal | 29
CPOS : 400 | APOS : 400 | RPM : 122280 | Accel :    0 | Mode : Normal | 28
CPOS : 400 | APOS : 400 | RPM : 122340 | Accel :    6 | Mode : Normal | 27
CPOS : 400 | APOS : 400 | RPM : 122220 | Accel :  -13 | Mode : Normal | 32
CPOS : 400 | APOS : 400 | RPM : 122580 | Accel :   36 | Mode : Normal | 27
CPOS : 400 | APOS : 400 | RPM : 122400 | Accel :  -19 | Mode : Normal | 32
CPOS : 400 | APOS : 400 | RPM : 122820 | Accel :   42 | Mode : Normal | 28
CPOS : 400 | APOS : 400 | RPM : 122400 | Accel :  -43 | Mode : Normal | 27
CPOS : 400 | APOS : 400 | RPM : 122880 | Accel :   48 | Mode : Normal | 29
CPOS : 400 | APOS : 400 | RPM : 122820 | Accel :   -7 | Mode : Normal | 28
CPOS : 400 | APOS : 400 | RPM : 122580 | Accel :  -25 | Mode : Normal | 26
CPOS : 400 | APOS : 400 | RPM : 122940 | Accel :   36 | Mode : Normal | 31
CPOS : 400 | APOS : 400 | RPM : 122820 | Accel :  -13 | Mode : Normal | 28
CPOS : 400 | APOS : 400 | RPM : 123000 | Accel :   18 | Mode : Normal | 27
CPOS : 400 | APOS : 400 | RPM : 122820 | Accel :  -19 | Mode : Normal | 29
CPOS : 400 | APOS : 400 | RPM : 123180 | Accel :   36 | Mode : Normal | 27
CPOS : 400 | APOS : 400 | RPM : 122940 | Accel :  -25 | Mode : Normal | 27
CPOS : 400 | APOS : 400 | RPM : 122940 | Accel :    0 | Mode : Normal | 31
CPOS : 400 | APOS : 400 | RPM : 122820 | Accel :  -13 | Mode : Normal | 28
CPOS : 400 | APOS : 400 | RPM : 123180 | Accel :   36 | Mode : Normal | 32
CPOS : 400 | APOS : 400 | RPM : 123060 | Accel :  -13 | Mode : Normal | 28
CPOS : 400 | APOS : 400 | RPM : 123360 | Accel :   30 | Mode : Normal | 31
CPOS : 400 | APOS : 400 | RPM : 123180 | Accel :  -19 | Mode : Normal | 28
CPOS : 400 | APOS : 400 | RPM : 123360 | Accel :   18 | Mode : Normal | 28
CPOS : 400 | APOS : 400 | RPM : 123960 | Accel :   60 | Mode : Normal | 27
CPOS : 400 | APOS : 400 | RPM : 123480 | Accel :  -49 | Mode : Normal | 28
CPOS : 400 | APOS : 400 | RPM : 123540 | Accel :    6 | Mode : Normal | 28
CPOS : 400 | APOS : 400 | RPM : 123600 | Accel :    6 | Mode : Normal | 31
CPOS : 340 | APOS : 400 | RPM : 125160 | Accel :  156 | Mode : Normal | 32
CPOS : 400 | APOS : 340 | RPM : 123780 | Accel : -139 | Mode : Normal | 28
CPOS : 400 | APOS : 400 | RPM : 123900 | Accel :   12 | Mode : Normal | 28
CPOS : 400 | APOS : 400 | RPM : 123780 | Accel :  -13 | Mode : Normal | 32
CPOS : 340 | APOS : 400 | RPM : 124320 | Accel :   54 | Mode : Normal | 27
CPOS : 400 | APOS : 340 | RPM : 123540 | Accel :  -79 | Mode : Normal | 32
CPOS : 400 | APOS : 400 | RPM : 123780 | Accel :   24 | Mode : Normal | 28
CPOS : 400 | APOS : 400 | RPM : 123660 | Accel :  -13 | Mode : Normal | 28
CPOS : 340 | APOS : 400 | RPM : 124080 | Accel :   42 | Mode : Normal | 32
CPOS : 400 | APOS : 400 | RPM : 123900 | Accel :  -19 | Mode : Normal | 32
CPOS : 400 | APOS : 400 | RPM : 123900 | Accel :    0 | Mode : Normal | 27
CPOS : 400 | APOS : 400 | RPM : 123480 | Accel :  -43 | Mode : Normal | 28
CPOS : 400 | APOS : 400 | RPM : 123780 | Accel :   30 | Mode : Normal | 28
CPOS : 340 | APOS : 400 | RPM : 124140 | Accel :   36 | Mode : Normal | 29
CPOS : 340 | APOS : 400 | RPM : 124140 | Accel :    0 | Mode : Normal | 27
CPOS : 340 | APOS : 340 | RPM : 124080 | Accel :   -7 | Mode : Normal | 28
CPOS : 340 | APOS : 340 | RPM : 124140 | Accel :    6 | Mode : Normal | 31
CPOS : 340 | APOS : 340 | RPM : 125820 | Accel :  168 | Mode : Normal | 28
CPOS : 340 | APOS : 340 | RPM : 124260 | Accel : -157 | Mode : Normal | 32
CPOS : 340 | APOS : 340 | RPM : 124200 | Accel :   -7 | Mode : Normal | 28
CPOS : 400 | APOS : 340 | RPM : 123960 | Accel :  -25 | Mode : Normal | 32
CPOS : 340 | APOS : 400 | RPM : 124080 | Accel :   12 | Mode : Normal | 28
CPOS : 340 | APOS : 340 | RPM : 124380 | Accel :   30 | Mode : Normal | 32
CPOS : 340 | APOS : 340 | RPM : 124380 | Accel :    0 | Mode : Normal | 28
CPOS : 340 | APOS : 400 | RPM : 124380 | Accel :    0 | Mode : Normal | 32
CPOS : 340 | APOS : 340 | RPM : 124200 | Accel :  -19 | Mode : Normal | 28
CPOS : 340 | APOS : 340 | RPM : 124320 | Accel :   12 | Mode : Normal | 28
CPOS : 340 | APOS : 340 | RPM : 124080 | Accel :  -25 | Mode : Normal | 31
CPOS : 340 | APOS : 340 | RPM : 124440 | Accel :   36 | Mode : Normal | 28
CPOS : 340 | APOS : 340 | RPM : 124320 | Accel :  -13 | Mode : Normal | 32
CPOS : 340 | APOS : 340 | RPM : 124320 | Accel :    0 | Mode : Normal | 28
CPOS : 400 | APOS : 340 | RPM : 123900 | Accel :  -43 | Mode : Normal | 32
CPOS : 340 | APOS : 400 | RPM : 124260 | Accel :   36 | Mode : Normal | 28
CPOS : 340 | APOS : 340 | RPM : 124320 | Accel :    6 | Mode : Normal | 28
CPOS : 340 | APOS : 340 | RPM : 124200 | Accel :  -13 | Mode : Normal | 32
CPOS : 340 | APOS : 340 | RPM : 124080 | Accel :  -13 | Mode : Normal | 32
CPOS : 340 | APOS : 340 | RPM : 124440 | Accel :   36 | Mode : Normal | 28
CPOS : 340 | APOS : 340 | RPM : 124560 | Accel :   12 | Mode : Normal | 28
CPOS : 340 | APOS : 340 | RPM : 124620 | Accel :    6 | Mode : Normal | 28
CPOS : 340 | APOS : 340 | RPM : 124680 | Accel :    6 | Mode : Normal | 32
CPOS : 340 | APOS : 340 | RPM : 124740 | Accel :    6 | Mode : Normal | 32
CPOS : 340 | APOS : 340 | RPM : 124620 | Accel :  -13 | Mode : Normal | 28
CPOS : 340 | APOS : 340 | RPM : 124740 | Accel :   12 | Mode : Normal | 31
CPOS : 340 | APOS : 340 | RPM : 124740 | Accel :    0 | Mode : Normal | 26
CPOS : 340 | APOS : 340 | RPM : 124800 | Accel :    6 | Mode : Normal | 32
CPOS : 340 | APOS : 340 | RPM : 124740 | Accel :   -7 | Mode : Normal | 28
CPOS : 340 | APOS : 340 | RPM : 124620 | Accel :  -13 | Mode : Normal | 28
CPOS : 340 | APOS : 340 | RPM : 124560 | Accel :   -7 | Mode : Normal | 32
CPOS : 340 | APOS : 340 | RPM : 124380 | Accel :  -19 | Mode : Normal | 28
CPOS : 340 | APOS : 340 | RPM : 124020 | Accel :  -37 | Mode : Normal | 32
CPOS : 400 | APOS : 340 | RPM : 123480 | Accel :  -55 | Mode : Normal | 28
CPOS : 400 | APOS : 400 | RPM : 123420 | Accel :   -7 | Mode : Normal | 28
CPOS : 400 | APOS : 400 | RPM : 123120 | Accel :  -31 | Mode : Normal | 31
CPOS : 400 | APOS : 400 | RPM : 122040 | Accel : -109 | Mode : Normal | 32
CPOS : 500 | APOS : 500 | RPM : 121560 | Accel :  -49 | Mode : Normal | 27
CPOS : 500 | APOS : 500 | RPM : 120720 | Accel :  -85 | Mode : Normal | 31
CPOS : 601 | APOS : 500 | RPM : 119520 | Accel : -121 | Mode : Normal | 33
CPOS : 603 | APOS : 601 | RPM : 118380 | Accel : -115 | Mode : Normal | 24
CPOS : 604 | APOS : 603 | RPM : 117480 | Accel :  -91 | Mode : Normal | 30
CPOS : 606 | APOS : 605 | RPM : 116160 | Accel : -133 | Mode : Normal | 30
CPOS : 607 | APOS : 606 | RPM : 115200 | Accel :  -97 | Mode : Normal | 26
CPOS : 609 | APOS : 607 | RPM : 113940 | Accel : -127 | Mode : Normal | 29
CPOS : 610 | APOS : 609 | RPM : 112980 | Accel :  -97 | Mode : Normal | 29
CPOS : 611 | APOS : 610 | RPM : 111780 | Accel : -121 | Mode : Normal | 28
CPOS : 612 | APOS : 612 | RPM : 111240 | Accel :  -55 | Mode : Normal | 26
CPOS : 613 | APOS : 612 | RPM : 110460 | Accel :  -79 | Mode : Normal | 25
CPOS : 614 | APOS : 613 | RPM : 110160 | Accel :  -31 | Mode : Normal | 24

*

Online hakcenter

  • developer
  • Hero Member
  • *****
  • 623
    • 1998 12v Ram
Re: Accel Variable
« Reply #7 on: August 17, 2015, 04:30:03 PM »
Here's the full log.

The number past the mode, is how many times loop ran between each serial output. What that also includes, is all the timers running, so take that into account.

You can tell that as shaft speed increases, the computational time for loop decreases, so it gets faster as the turbo gets faster.

*

Online hakcenter

  • developer
  • Hero Member
  • *****
  • 623
    • 1998 12v Ram
Re: Accel Variable
« Reply #8 on: August 18, 2015, 10:23:01 PM »
So I kept thinking to myself... That speed on the right is way slow...

I was working on it today and got it up to  2000+ loops per 100ms now...  I forgot what I did! I'll have to compare to the posted code but I think the frequency read was the major slow down going from double to long

So then I increased the array from 64 to 128... And the output got all screwed up and i spent more time trying to figure out what I broke copying and pasting each tab until I figured it out..  So not entirely sure what made it go faster

*

Online hakcenter

  • developer
  • Hero Member
  • *****
  • 623
    • 1998 12v Ram
Re: Accel Variable
« Reply #9 on: August 20, 2015, 12:34:54 AM »
Bark
Code: [Select]
CPOS : 420 | APOS : 420 | RPM : 125760 | Accel :   12 | Mode : Normal | 22
CPOS : 420 | APOS : 420 | RPM : 125700 | Accel :   -7 | Mode : Normal | 21
CPOS : 420 | APOS : 420 | RPM : 125700 | Accel :    0 | Mode : Normal | 22
CPOS : 420 | APOS : 420 | RPM : 125760 | Accel :    6 | Mode : Normal | 21
CPOS : 420 | APOS : 420 | RPM : 125820 | Accel :    6 | Mode : Normal | 22
CPOS : 420 | APOS : 420 | RPM : 125880 | Accel :    6 | Mode : Normal | 21
CPOS : 380 | APOS : 420 | RPM : 126060 | Accel :   18 | Mode : Normal | 22
CPOS : 380 | APOS : 420 | RPM : 126060 | Accel :    0 | Mode : Normal | 21
CPOS : 380 | APOS : 380 | RPM : 126240 | Accel :   18 | Mode : Normal | 22
CPOS : 380 | APOS : 380 | RPM : 126180 | Accel :   -7 | Mode : Normal | 21
CPOS : 380 | APOS : 380 | RPM : 126060 | Accel :  -13 | Mode : Normal | 22
CPOS : 420 | APOS : 380 | RPM : 125940 | Accel :  -13 | Mode : Normal | 21
CPOS : 420 | APOS : 420 | RPM : 125820 | Accel :  -13 | Mode : Normal | 22
CPOS : 420 | APOS : 420 | RPM : 125220 | Accel :  -61 | Mode : Normal | 21
CPOS : 420 | APOS : 420 | RPM : 124800 | Accel :  -43 | Mode : Normal | 21
CPOS : 460 | APOS : 420 | RPM : 123960 | Accel :  -85 | Mode : Normal | 22
CPOS : 460 | APOS : 460 | RPM : 123060 | Accel :  -91 | Mode : Normal | 20
CPOS : 520 | APOS : 460 | RPM : 121980 | Accel : -109 | Mode : Normal | 21
CPOS : 520 | APOS : 520 | RPM : 120600 | Accel : -139 | Mode : Normal | 21
CPOS : 602 | APOS : 520 | RPM : 119100 | Accel : -151 | Mode : Normal | 20
CPOS : 604 | APOS : 602 | RPM : 117540 | Accel : -157 | Mode : Normal | 20
CPOS : 606 | APOS : 604 | RPM : 115860 | Accel : -169 | Mode : Normal | 20
CPOS : 608 | APOS : 607 | RPM : 114240 | Accel : -163 | Mode : Normal | 19
CPOS : 610 | APOS : 608 | RPM : 112920 | Accel : -133 | Mode : Normal | 19
CPOS : 611 | APOS : 610 | RPM : 112200 | Accel :  -73 | Mode : Normal | 19
CPOS : 611 | APOS : 611 | RPM : 112020 | Accel :  -19 | Mode : Normal | 20
CPOS : 612 | APOS : 611 | RPM : 111660 | Accel :  -37 | Mode : Normal | 19
CPOS : 611 | APOS : 611 | RPM : 111960 | Accel :   30 | Mode : Normal | 19
CPOS : 611 | APOS : 611 | RPM : 112080 | Accel :   12 | Mode : Normal | 19
CPOS : 608 | APOS : 611 | RPM : 114240 | Accel :  216 | Mode : Normal | 19
CPOS : 610 | APOS : 608 | RPM : 112980 | Accel : -127 | Mode : Normal | 19
CPOS : 611 | APOS : 610 | RPM : 112320 | Accel :  -67 | Mode : Normal | 19
CPOS : 613 | APOS : 612 | RPM : 110580 | Accel : -175 | Mode : Normal | 19
CPOS : 615 | APOS : 613 | RPM : 108960 | Accel : -163 | Mode : Normal | 19
CPOS : 618 | APOS : 615 | RPM : 107040 | Accel : -193 | Mode : Normal | 18
CPOS : 620 | APOS : 618 | RPM : 105600 | Accel : -145 | Mode : Normal | 18
CPOS : 628 | APOS : 623 | RPM : 101340 | Accel : -130 | Mode : Normal | 70
CPOS : 639 | APOS : 637 | RPM :  95760 | Accel :  -56 | Mode : Normal | 167

Pretty crazy it was caught in a log.

*

Online hakcenter

  • developer
  • Hero Member
  • *****
  • 623
    • 1998 12v Ram
Re: Accel Variable
« Reply #10 on: August 24, 2015, 03:08:54 PM »
Last little bit, to smooth out the acceleration, I've added division arrgh, no way around it though, need the extra resolution.

Code: [Select]
void loop() {
  // Sleep
  unsigned int sleep = 0;
  // Freq Measure
  unsigned long sum[32];
  float final_sum = 0.0f;
  byte count = 0;
  byte i = 0;

  // main loop
  while(1) {
    t1.update();
    t2.update();
    // Freq Measure
    if (FreqMeasure.available()) {
      timing++;
      sleep = 0;
      // average several reading together
      sum[count] = FreqMeasure.read();
      final_sum = 0.0f;
      for (i = 0 ; i < 32 ; i++) { final_sum += sum[i]; }
      // turbo_rpm = Freq(sum / count) * 60
      final_sum = FreqMeasure.countToFrequency(final_sum / 32.0f);
      turbo_rpm = final_sum * 60.0f;
      count++;
      if (count > 31) { count = 0; }
    }
  }
}

I've added this curve tuning to the top end, after the vane has been calculated, to adjust the curve lower based on how fast it is accelerating.

Code: [Select]
        if (turbo_rpm > 122000) {
          if (turbo_accel[2] > 60) { vane_position -= half_cm; }
          if (turbo_accel[2] > 90) { vane_position -= half_cm; }
        }

Seems to work out good. So I've tuned the turbo in final gear, then adjusted these values to help the turbo from overspinning in the lower gears.

*

Offline me78569

  • Sr. Member
  • ****
  • 268
Re: Accel Variable
« Reply #11 on: August 25, 2015, 10:46:56 AM »
nice I am liking that.


Can you explain the

Code: [Select]
final_sum = [color=red]0.0f[/color];
Why the "f" ? 

I am really liking this though.  I need to test it, but life has been and will continue to be nuts for awhile longer here.
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 Rx7man

  • Crazy guy
  • Hero Member
  • *****
  • 908
  • Jack of all trades
    • '94 Dodge dually
Re: Accel Variable
« Reply #12 on: August 25, 2015, 01:15:32 PM »
I think that forces is to be calculated as a float not an int, though I think just defining it as 0.0 rather than 0 does the same thing? and since the variable is declared as a float I don't know if you'd need either.. the times you'd use it are like

Code: [Select]
float p = 2/4; (returns 0 I think since it's doing integer math)
float p = 2.0/4.0; (returns 0.5 as expected as it's forced into floating point math)
'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 #13 on: August 25, 2015, 01:26:58 PM »
got ya.  Thanks!
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

*

Online hakcenter

  • developer
  • Hero Member
  • *****
  • 623
    • 1998 12v Ram
Re: Accel Variable
« Reply #14 on: August 25, 2015, 02:42:46 PM »
Ya you have to force the floating point math, I added the f so it wouldn't be double. Even though in our AVR double/float is the same. The designation is for our eyes.

Also only 1 part has to be float/double to force it into that kind of work.

You can do like

Code: [Select]
float sum = 2 / 3.0f;

Or a really interesting one

Code: [Select]
unsigned int test = (2/3.0) * 100;
float final_test = test / 100.0;
Precision of only 2 digits.. etc. Do some high low byte work or move the decimal around now that you know where it is.. etc.