User Tools

Site Tools


common_code_v2

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revisionPrevious revision
Next revision
Previous revision
Last revisionBoth sides next revision
common_code_v2 [2018/07/02 13:06] – [Calculate Mode] hakcentercommon_code_v2 [2018/07/02 13:09] – [Accel Variable] hakcenter
Line 101: Line 101:
 The acceleration variable, is computed at 100ms and 10ms, and it represents the turbo rpm acceleration rate in, rpm per ms. The acceleration variable, is computed at 100ms and 10ms, and it represents the turbo rpm acceleration rate in, rpm per ms.
 <code> <code>
-  // Update turbo_accel before calculating vane_position +    //---- Calculate turbo_accel ----/
-  if (timer % 10 == 0) { +    turbo_accel = (int) (turbo_rpm - last_turbo_rpm) / 100.0f; 
-    turbo_accel[0] = (int) (turbo_rpm last_turbo_rpm[0]) 10.0f; +    last_turbo_rpm = turbo_rpm;
-    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; +
-    } +
-    if (turbo_rpm < top_end_rpm) { turbo_accel[2] = turbo_accel[1]; } else { turbo_accel[2] = turbo_accel[0];+
-  }+
 </code> </code>
-\\ **<fc #6495ed>last_turbo_rpm[0]</fc>** is updated every 10ms +\\ **<fc #6495ed>last_turbo_rpm</fc>** is updated every 100ms
-\\ **<fc #6495ed>last_turbo_rpm[1]</fc>** is updated every 100ms+
 ---- ----
 ==== Idle ==== ==== Idle ====
Line 127: Line 119:
             idle_mode = false;             idle_mode = false;
           }           }
-          if (turbo_accel[2] <= 2) { vane_position = idle_position; } else { vane_position = turbo_curve[0]; }+          if (turbo_accel <= 2) { 
 +            idle_counter++; 
 +          } else { 
 +            idle_counter = 0; 
 +            vane_position = turbo_curve[0]; 
 +          } 
 +          if (idle_counter > 1) { 
 +            idle_counter = 2; 
 +            vane_position = idle_position; 
 +          }
         } else {         } else {
           // -----           // -----
           // Curve section           // Curve section
                if (turbo_rpm < idle_walkdown_rpm) {                if (turbo_rpm < idle_walkdown_rpm) {
-                 if (turbo_accel[2] <= 2) {+                 if (turbo_accel <= 2) {
                    if (last_vane_position >= min_position + half_cm) {                    if (last_vane_position >= min_position + half_cm) {
                      idle_walkdown_mode = true;                      idle_walkdown_mode = true;
Line 147: Line 148:
           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 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 { vane_position = map(turbo_rpm, curve_rpm[3], curve_rpm[4], turbo_curve[2], turbo_curve[3]); }
-          if (turbo_accel[2] > 2) { idle_walkdown_mode = false; +          if (turbo_accel > 2) { idle_walkdown_mode = false; }
-        }+
 </code> </code>
 ---- ----
common_code_v2.txt · Last modified: 2018/07/02 13:28 by hakcenter