common_code
Differences
This shows you the differences between two versions of the page.
Both sides previous revisionPrevious revisionNext revision | Previous revision | ||
common_code [2015/10/22 12:19] – [Performance] hakcenter | common_code [2015/10/30 12:54] (current) – hakcenter | ||
---|---|---|---|
Line 20: | Line 20: | ||
\\ ''< | \\ ''< | ||
\\ ''< | \\ ''< | ||
- | \\ ''< | ||
\\ ''< | \\ ''< | ||
\\ ''< | \\ ''< | ||
\\ ''< | \\ ''< | ||
\\ ''< | \\ ''< | ||
+ | \\ ''< | ||
**Minimum and Maximum Vane Positions** | **Minimum and Maximum Vane Positions** | ||
Line 31: | Line 31: | ||
**Vane Positions** | **Vane Positions** | ||
- | \\ ''< | + | \\ ''< |
- | \\ ''< | + | \\ ''< |
+ | \\ ''< | ||
\\ ''< | \\ ''< | ||
\\ ''< | \\ ''< | ||
Line 51: | Line 52: | ||
\\ ''< | \\ ''< | ||
\\ ''< | \\ ''< | ||
- | \\ ''< | + | \\ ''< |
\\ ''< | \\ ''< | ||
- | \\ ''< | + | \\ ''< |
- | \\ ''< | + | \\ ''< |
- | \\ ''< | + | \\ ''< |
- | \\ ''< | + | \\ ''< |
**Turbo** | **Turbo** | ||
Line 76: | Line 77: | ||
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. | ||
< | < | ||
- | | + | |
- | turbo_accel[0] = ((turbo_rpm - last_turbo_rpm[0]) | + | if (timer % 10 == 0) { |
+ | turbo_accel[0] = (int) (turbo_rpm - last_turbo_rpm[0]) | ||
last_turbo_rpm[0] = turbo_rpm; | last_turbo_rpm[0] = turbo_rpm; | ||
if (timer % 100 == 0) { | if (timer % 100 == 0) { | ||
- | | + | turbo_accel[1] = (int) (turbo_rpm - last_turbo_rpm[1]) |
- | | + | |
last_turbo_rpm[1] = turbo_rpm; | last_turbo_rpm[1] = turbo_rpm; | ||
} | } | ||
if (turbo_rpm < top_end_rpm) { turbo_accel[2] = turbo_accel[1]; | if (turbo_rpm < top_end_rpm) { turbo_accel[2] = turbo_accel[1]; | ||
+ | } | ||
</ | </ | ||
\\ **<fc # | \\ **<fc # | ||
Line 95: | Line 97: | ||
// ----- | // ----- | ||
// Idle Section | // Idle Section | ||
- | idle_check = false; | ||
if (turbo_rpm <= idle_rpm) { | if (turbo_rpm <= idle_rpm) { | ||
- | vane_position = idle_position; | ||
idle_mode = true; | idle_mode = true; | ||
idle_walkdown_mode = false; | idle_walkdown_mode = false; | ||
} else { | } else { | ||
idle_mode = false; | idle_mode = false; | ||
- | if (idle_walkdown_mode) { vane_position = last_vane_position - quarter_cm; } else { vane_position = turbo_curve[0]; | ||
} | } | ||
+ | if (turbo_accel[2] <= 2) { vane_position = idle_position; | ||
} else { | } else { | ||
// ----- | // ----- | ||
// Curve section | // Curve section | ||
- | | + | if (turbo_rpm < idle_walkdown_rpm) { |
- | if (turbo_rpm | + | if (turbo_accel[2] <= 2) { |
- | if (idle_walkdown_mode) { vane_position = last_vane_position - quarter_cm; } | + | |
+ | | ||
+ | | ||
+ | } else { | ||
+ | | ||
+ | } | ||
+ | } else { | ||
+ | | ||
+ | } | ||
+ | } | ||
else if (turbo_rpm <= curve_rpm[1]) { vane_position = map(turbo_rpm, | else if (turbo_rpm <= curve_rpm[1]) { vane_position = map(turbo_rpm, | ||
else if (turbo_rpm <= curve_rpm[2]) { vane_position = 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, | else if (turbo_rpm <= curve_rpm[3]) { vane_position = map(turbo_rpm, | ||
else { vane_position = map(turbo_rpm, | else { vane_position = map(turbo_rpm, | ||
+ | if (turbo_accel[2] > 2) { idle_walkdown_mode = false; } | ||
} | } | ||
</ | </ | ||
Line 155: | Line 165: | ||
Cruise mode tries to keep turbo rpm within 47,500 to 52,500. Roughly 5,000 total rpm difference. | Cruise mode tries to keep turbo rpm within 47,500 to 52,500. Roughly 5,000 total rpm difference. | ||
< | < | ||
+ | byte counter = 0; | ||
+ | byte adjustment = 0; | ||
+ | |||
void cruise() { | void cruise() { | ||
- | if (turbo_rpm > 55000) { vane_position -= one_cm; } | + | if (turbo_rpm > 55000) { |
- | if (turbo_rpm > 52500) { vane_position -= half_cm; } | + | adjustment |
+ | | ||
+ | if (turbo_rpm > 52500) { | ||
+ | adjustment = half_cm; | ||
+ | counter++; | ||
+ | } | ||
+ | if (counter > 3) { | ||
+ | counter = 0; | ||
+ | | ||
+ | | ||
if (vane_position <= min_position) { vane_position = min_position; | if (vane_position <= min_position) { vane_position = min_position; | ||
- | if (turbo_rpm < 47500) { vane_position += quarter_cm; } | + | if (turbo_rpm < 47500) { |
+ | | ||
+ | counter = 0; | ||
+ | | ||
if (vane_position >= cruise_position) { vane_position = cruise_position; | if (vane_position >= cruise_position) { vane_position = cruise_position; | ||
+ | constrain(vane_position, | ||
} | } | ||
</ | </ | ||
* When turbo rpm is under 47,500 vane position is set to variable **<fc # | * When turbo rpm is under 47,500 vane position is set to variable **<fc # | ||
- | * When turbo rpm is over 52,500 vane position decreases every 100ms until turbo rpm is finally within bounds. | + | * When turbo rpm is over 52,500 vane position decreases every ~400ms |
---- | ---- | ||
Line 176: | Line 202: | ||
vane_position = max_position; | vane_position = max_position; | ||
} | } | ||
+ | constrain(vane_position, | ||
} | } | ||
</ | </ | ||
Line 212: | Line 239: | ||
} | } | ||
} | } | ||
+ | } else if (turbo_rpm > top_end_rpm) { | ||
+ | if (vane_position - 5 >= last_vane_position || vane_position + 5 <= last_vane_position) { final_vane_position = vane_position; | ||
} | } | ||
// Update last_vane_position | // Update last_vane_position | ||
Line 228: | Line 257: | ||
void keep_time() { | void keep_time() { | ||
timer++; | timer++; | ||
- | // Update vane_position every 10ms 100k+ / 25ms 60k - 100k / 50ms 0 - 60k | + | // Update vane_position every 10ms 100k+ / 25ms 60k - 100k / 100ms 0 - 60k |
if (timer % 10 == 0 && turbo_rpm > top_end_rpm) { update_vane_position = true; } | if (timer % 10 == 0 && turbo_rpm > top_end_rpm) { update_vane_position = true; } | ||
else if (timer % 25 == 0 && turbo_rpm > curve_rpm[4]) { update_vane_position = true; } | else if (timer % 25 == 0 && turbo_rpm > curve_rpm[4]) { update_vane_position = true; } | ||
- | else if (timer % 50 == 0) { update_vane_position = true; } | + | else if (timer % 100 == 0) { update_vane_position = true; } |
// Update turbo_accel before calculating vane_position | // Update turbo_accel before calculating vane_position | ||
if (timer % 10 == 0) { | if (timer % 10 == 0) { | ||
- | | + | turbo_accel[0] = (int) (turbo_rpm - last_turbo_rpm[0]) |
- | | + | |
last_turbo_rpm[0] = turbo_rpm; | last_turbo_rpm[0] = turbo_rpm; | ||
if (timer % 100 == 0) { | if (timer % 100 == 0) { | ||
- | | + | turbo_accel[1] = (int) (turbo_rpm - last_turbo_rpm[1]) |
- | | + | |
last_turbo_rpm[1] = turbo_rpm; | last_turbo_rpm[1] = turbo_rpm; | ||
} | } | ||
Line 245: | Line 272: | ||
} | } | ||
// Modes | // Modes | ||
- | if (timer % 100 == 0) { calculate_modes(); | + | if (timer % 100 == 0 && turbo_rpm < top_end_rpm) { calculate_modes(); |
// Calculate vane_position | // Calculate vane_position | ||
- | if (update_vane_position) { update_vane_position = false; | + | if (update_vane_position) { |
- | if (serial_out) { | + | |
- | | + | |
- | if (turbo_rpm > top_end_rpm && timer % 10 == 0) { serial_output(); | + | if (serial_out) { serial_output(); |
} | } | ||
if (timer == 1000) { timer = 0; } | if (timer == 1000) { timer = 0; } | ||
} | } | ||
</ | </ |
common_code.txt · Last modified: 2015/10/30 12:54 by hakcenter