Megasquirt ECU tuning and calibration using TunerStudio. Use when working with Megasquirt engine management systems for: (1) VE table tuning and fuel map optimization, (2) Ignition timing maps and spark advance, (3) Idle control and warmup enrichment, (4) AFR target tuning and closed-loop feedback, (5) Sensor calibration (TPS, MAP, CLT, IAT, O2), (6) Acceleration enrichment and deceleration fuel cut, (7) Boost control and launch control setup, (8) Datalog analysis and troubleshooting, (9) Base engine configuration and injector setup, (10) MSQ tune file analysis and safety review, (11) Any Megasquirt/TunerStudio ECU tuning tasks.
Guidance for tuning Megasquirt engine management systems using TunerStudio software.
Megasquirt calculates fuel delivery using:
Pulse Width = Required Fuel × VE% × MAP × AFR Target Correction × Air Density × Warmup × Accel Enrichment × Other Corrections
Required Fuel is the base injector pulse width at 100% VE, 100kPa MAP, standard temperature.
| Table | Purpose | Typical Resolution |
|---|---|---|
| VE Table | Volumetric efficiency vs RPM/MAP | 16×16 or 12×12 |
| AFR Target | Desired air-fuel ratio vs RPM/MAP | 12×12 |
| Spark Advance | Ignition timing vs RPM/MAP | 12×12 or 16×16 |
| Warmup Enrichment | Fuel correction vs coolant temp | 10-20 points |
| TPS-based Accel | Accel enrichment vs TPSdot | 10-20 points |
| MAP-based Accel | Accel enrichment vs MAPdot | 10-20 points |
Before tuning, verify:
Calibrate sensors before tuning:
Method 1: Wideband O2 Feedback
Method 2: Calculate from Measured AFR
New VE = Current VE × (Measured AFR / Target AFR)
Tuning Order:
Set targets based on application:
| Condition | Target AFR | Lambda |
|---|---|---|
| Idle | 13.5-14.5 | 0.92-0.99 |
| Light Cruise | 14.5-15.5 | 0.99-1.06 |
| Part Throttle | 13.5-14.5 | 0.92-0.99 |
| WOT Naturally Aspirated | 12.5-13.0 | 0.85-0.88 |
| WOT Turbo/Supercharged | 11.5-12.5 | 0.78-0.85 |
Base Settings:
Typical Spark Advance Table (Naturally Aspirated):
Knock Considerations:
Idle Valve PWM Settings:
Idle Target RPM Table:
Afterstart Enrichment:
Warmup Enrichment Curve:
TPS-based (Alpha-N blending):
MAP-based (for MAP-dot systems):
Cold Multiplier:
Open Loop:
Closed Loop (if supported):
| Parameter | What to Watch |
|---|---|
| RPM | Stability, limiter hits |
| MAP | Response to throttle, leaks |
| AFR (wideband) | Deviation from target |
| EGO Correction | Should stay within ±10% |
| CLT | Reaches operating temp |
| IAT | Heat soak effects |
| Spark Advance | Matches table |
| Injector PW | Headroom, max duty cycle |
| TPS | Smooth operation, TPSdot |
Lean at Tip-In:
Rich at Decel:
Idle Hunting:
Knock at High Load:
Rev Limiter:
Overboost Protection:
Lean Cut:
The skill can analyze .msq tune files to identify safety issues, optimization opportunities, and configuration problems.
Run the analysis script on any MSQ file:
python3 scripts/analyze_msq.py your_tune.msq
Or provide the tune file content directly for analysis.
Option 1: Paste the file content (Recommended)
.msq file in a text editor (it's plain text)Option 2: Upload the file
.msq file directlyOption 3: Provide a file path (if running locally)
python3 scripts/analyze_msq.py /path/to/your/tune.msq
Security Restrictions for Script Usage:
.msq extension are accepted../) are blockedOption 4: Share key sections If the file is large, paste specific sections you're concerned about:
[veTable1] section for fuel map review[sparkTable1] for ignition timing[afrTable1] for AFR targets[revLimiter] for safety limits"Review this MSQ file for safety issues before I start my engine: [paste content]"
"Check my VE table - does anything look suspicious? [paste veTable section]"
"Analyze my ignition timing map for knock risk: [paste sparkTable section]"
"I just updated my AFR targets, review them: [paste afrTable section]"
Safety Checks:
Configuration Review:
Optimization Opportunities:
Example Analysis Output:
📋 VE Table
----------------------------------------
⚠️ VE table has very low values (15.0) - check for empty/untuned cells
📊 12 cells have >30% jumps from neighbors - consider smoothing
✓ VE table range: 15.0 - 105.0 (avg: 62.3)
📋 Ignition Timing
----------------------------------------
⚠️ High ignition advance (48°) - verify on dyno with knock detection
✓ Spark advance range: 8° - 48° BTDC
SUMMARY
============================================================
🚨 CRITICAL ISSUES: 0
⚠️ WARNINGS: 2
✓ Suggestions: 4
ℹ️ Notes: 1
High Priority:
Medium Priority:
Low Priority:
Before First Start:
You: "Review this base tune before I start the engine"
AI: [Runs analysis, flags safety issues]
After Changes:
You: "I just updated my VE table, check it"
AI: [Analyzes for anomalies, suggests smoothing]
Before Dyno/Track:
You: "Review my tune before high load testing"
AI: [Checks timing, AFR, safety limits, injector headroom]
For detailed documentation, see:
Injector Duty Cycle:
DC% = (Injector PW / Injection Period) × 100
Keep under 85% for safety margin.
Required Fuel Calculation:
Required Fuel (ms) = (Engine CC × 5) / (Number of Injectors × Injector CC/Min) × 2
(The ×2 accounts for 2 rotations per cycle)
Airflow Estimation:
MAF (g/s) ≈ (RPM × Displacement × VE% × MAP/100) / (2 × 60 × R × Temp)
Before starting engine:
During tuning: