common_code_v2
Differences
This shows you the differences between two versions of the page.
Both sides previous revisionPrevious revisionNext revision | Previous revision | ||
common_code_v2 [2018/07/02 12:31] – [Cruise] hakcenter | common_code_v2 [2018/07/02 13:28] (current) – [Variables] hakcenter | ||
---|---|---|---|
Line 8: | Line 8: | ||
==== Variables ==== | ==== Variables ==== | ||
**Debug Serial Messages** | **Debug Serial Messages** | ||
- | \\ ''< | + | \\ ''< |
+ | \\ ''< | ||
+ | \\ ''< | ||
**Startup** | **Startup** | ||
Line 30: | Line 32: | ||
\\ ''< | \\ ''< | ||
\\ ''< | \\ ''< | ||
+ | |||
+ | **Boost Mode** | ||
+ | \\ ''< | ||
+ | \\ ''< | ||
+ | \\ ''< | ||
+ | \\ ''< | ||
**Minimum and Maximum Vane Positions** | **Minimum and Maximum Vane Positions** | ||
Line 36: | Line 44: | ||
**Vane Positions** | **Vane Positions** | ||
- | \\ ''< | + | \\ ''< |
- | \\ ''< | + | \\ ''< |
\\ ''< | \\ ''< | ||
- | \\ ''< | + | \\ ''< |
\\ ''< | \\ ''< | ||
\\ ''< | \\ ''< | ||
Line 50: | Line 58: | ||
**Turbo Idle** | **Turbo Idle** | ||
\\ ''< | \\ ''< | ||
- | \\ ''< | + | \\ ''< |
**Turbo Factors** | **Turbo Factors** | ||
Line 66: | Line 74: | ||
\\ ''< | \\ ''< | ||
\\ ''< | \\ ''< | ||
- | \\ ''< | + | \\ ''< |
**Turbo Variables** | **Turbo Variables** | ||
- | \\ ''< | + | \\ ''< |
- | \\ ''< | + | \\ ''< |
- | \\ ''< | + | \\ ''< |
- | \\ ''< | + | \\ ''< |
**CANBUS Variables** | **CANBUS Variables** | ||
Line 101: | Line 109: | ||
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. | ||
< | < | ||
- | | + | |
- | if (timer % 10 == 0) { | + | turbo_accel = (int) (turbo_rpm - last_turbo_rpm) / 100.0f; |
- | turbo_accel[0] = (int) (turbo_rpm | + | last_turbo_rpm = turbo_rpm; |
- | | + | |
- | if (timer % 100 == 0) { | + | |
- | | + | |
- | last_turbo_rpm[1] = turbo_rpm; | + | |
- | } | + | |
- | if (turbo_rpm < top_end_rpm) { turbo_accel[2] = turbo_accel[1]; | + | |
- | } | + | |
</ | </ | ||
- | \\ **<fc # | + | \\ **<fc # |
- | \\ **<fc # | + | |
---- | ---- | ||
==== Idle ==== | ==== Idle ==== | ||
Line 127: | Line 127: | ||
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++; | ||
+ | | ||
+ | idle_counter = 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) { | ||
| | ||
Line 147: | Line 156: | ||
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; | + | if (turbo_accel > 2) { idle_walkdown_mode = false; } |
- | | + | |
</ | </ | ||
---- | ---- | ||
Line 160: | Line 168: | ||
if (port_d & SWITCH_PERFORMANCE) { performance_mode = false; } else { performance_mode = true; } | if (port_d & SWITCH_PERFORMANCE) { performance_mode = false; } else { performance_mode = true; } | ||
if (port_d & SWITCH_BRAKE) { brake_mode = false; } else { brake_mode = true; } | if (port_d & SWITCH_BRAKE) { brake_mode = false; } else { brake_mode = true; } | ||
+ | // if (digitalRead(SPARE_PIN) == LOW) { | ||
+ | // spare_value = 0; | ||
+ | // spare_mode = true; | ||
+ | // } else { | ||
+ | // spare_value = 1; | ||
+ | // spare_mode = false; | ||
+ | // } | ||
// Update current_mode | // Update current_mode | ||
current_mode = 2; | current_mode = 2; | ||
+ | if (boost_mode) { current_mode = 3; } | ||
if (idle_mode) { current_mode = 0; } | if (idle_mode) { current_mode = 0; } | ||
if (idle_walkdown_mode) { current_mode = 1; } | if (idle_walkdown_mode) { current_mode = 1; } | ||
- | if (cruise_mode) { current_mode = 5; } | + | if (cruise_mode) { current_mode = 6; } |
- | if (performance_mode) { current_mode = 6; } | + | if (performance_mode) { current_mode = 7; } |
- | if (brake_mode) { current_mode = 4; } | + | if (brake_mode) { current_mode = 5; } |
- | if (spare_mode) { current_mode = 3; } | + | if (spare_mode) { current_mode = 4; } |
// -- CRUISE MODE -- // | // -- CRUISE MODE -- // | ||
if (cruise_mode && !brake_mode && !performance_mode) { cruise(); } | if (cruise_mode && !brake_mode && !performance_mode) { cruise(); } |
common_code_v2.txt · Last modified: 2018/07/02 13:28 by hakcenter