Megasquirt ECU Tuning with TunerStudio
Guidance for tuning Megasquirt engine management systems using TunerStudio software.
Core Concepts
Required Fuel Equation
Megasquirt calculates fuel delivery using:
CODEBLOCK0
Required Fuel is the base injector pulse width at 100% VE, 100kPa MAP, standard temperature.
Key Tuning Tables
| 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 |
Tuning Workflow
1. Base Configuration
Before tuning, verify:
- - Engine displacement and cylinder count
- Injector flow rate (cc/min or lb/hr)
- Injector staging (simultaneous, alternating, sequential)
- Required Fuel calculation matches injector size
- Ignition input/output settings match hardware
- Trigger wheel and ignition mode configured
2. Sensor Calibration
Calibrate sensors before tuning:
- - CLT (Coolant Temp): Set resistance values at known temps
- IAT (Intake Air Temp): Similar to CLT
- TPS: Set closed and WOT positions (0-100%)
- MAP: Verify atmospheric reading at key-on
- O2 Sensor: Calibrate wideband controller output range
3. VE Table Tuning (Speed Density)
Method 1: Wideband O2 Feedback
- 1. Enable EGO correction with moderate authority (±15-20%)
- Set realistic AFR targets
- Run engine at steady state (fixed RPM/load cell)
- Allow EGO to correct, note correction percentage
- Adjust VE by inverse of correction (if +10% correction, increase VE by 10%)
- Save and move to next cell
Method 2: Calculate from Measured AFR
CODEBLOCK1
Tuning Order:
- 1. Start with idle region (600-1000 RPM, 30-50kPa)
- Light cruise (1500-2500 RPM, 40-60kPa)
- Part throttle acceleration
- WOT high load
- Transition regions
4. AFR Target Table
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 |
5. Ignition Timing
Base Settings:
- - Set cranking advance (typically 10-20° BTDC)
- Set idle advance (typically 15-25° BTDC)
- Build spark table following engine-specific guidelines
Typical Spark Advance Table (Naturally Aspirated):
- - Low RPM/High Load: 10-20°
- Low RPM/Low Load: 25-35°
- High RPM/High Load: 25-35°
- High RPM/Low Load: 35-45°
Knock Considerations:
- - Reduce timing 1-2° at a time if knock detected
- Add more fuel in knock-prone areas
- Use knock sensor feedback if available
6. Idle Control
Idle Valve PWM Settings:
- - Closed position: PWM at hot idle (typically 20-40%)
- Open position: PWM for cold start (typically 60-80%)
- Cranking position: PWM during start (typically 50-70%)
Idle Target RPM Table:
- - Hot: 700-900 RPM
- Cold (0°C): 1200-1500 RPM
- Interpolate between
7. Warmup Enrichment
Afterstart Enrichment:
- - Duration: 30-200 cycles (engine revolutions)
- Amount: 20-40% additional fuel
- Taper to zero over duration
Warmup Enrichment Curve:
- - -40°C: 150-200%
- 0°C: 120-140%
- 70°C (operating): 100%
8. Acceleration Enrichment
TPS-based (Alpha-N blending):
- - Threshold: 5-10%/sec TPSdot
- Enrichment: 10-30% added fuel
- Decay: 0.5-2 seconds
MAP-based (for MAP-dot systems):
- - Threshold: 10-30 kPa/sec
- Enrichment scales with rate of change
Cold Multiplier:
- - Increase accel enrichment when cold (1.5-3× at -20°C)
Advanced Features
Boost Control
Open Loop:
- - Duty cycle table vs RPM/target boost
Closed Loop (if supported):
- - PID parameters for wastegate control
- Target boost table vs RPM/gear
Launch Control
- - Set RPM limit (typically 4000-6000 RPM)
- Configure retard timing during launch (0-10° BTDC)
- Set fuel/ignition cut method
Flat Shift
- - Maintain throttle during shifts
- Brief fuel/ignition cut at shift point
- Retain boost between gears
Datalog Analysis
Key Parameters to Log
| 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 |
Common Issues
Lean at Tip-In:
- - Increase TPS-based accel enrichment
- Check MAPdot sensitivity
Rich at Decel:
- - Enable deceleration fuel cut (DFCO)
- Set appropriate TPS threshold (typically <10%)
- Set RPM threshold above idle
Idle Hunting:
- - Check for vacuum leaks
- Adjust idle PID gains
- Verify TPS closed position
- Check ignition timing stability
Knock at High Load:
- - Reduce spark advance in affected cells
- Enrich mixture (reduce target AFR)
TunerStudio Specific
Project Setup
- 1. Create new project → select firmware (MS1, MS2, MS3)
- Load base tune (.msq file) or start from default
- Connect to controller (serial, USB, or Bluetooth)
- Sync with controller to load current settings
Tuning Interface
- - Basic/Customize Tuning: Navigate tables
- Table: View/edit individual tables
- Runtime Data: Real-time monitoring
- Datalog: Record and playback logs
Auto-Tune
- - Enable VEAL (VE Analyze Live) with wideband
- Set acceptable AFR range
- Drive through as many cells as possible
- Review and accept changes
- Disable when done
Safety Limits
Rev Limiter:
- - Soft limit: retard timing
- Hard limit: fuel/ignition cut
- Set 200-500 RPM above max desired
Overboost Protection:
- - Fuel cut above target pressure
- Ignition cut option
Lean Cut:
- - Disable injectors if AFR exceeds safe threshold
- Typically 15:1+ under load
MSQ Tune File Analysis
The skill can analyze .msq tune files to identify safety issues, optimization opportunities, and configuration problems.
Using the Analyzer
Run the analysis script on any MSQ file:
CODEBLOCK2
Or provide the tune file content directly for analysis.
How to Provide the MSQ File
Option 1: Paste the file content (Recommended)
- - Open the
.msq file in a text editor (it's plain text) - Copy the entire content
- Paste it directly into the chat: "Analyze this MSQ file: [paste content]"
Option 2: Upload the file
- - If your chat interface supports file attachments, attach the
.msq file directly - The skill will read and analyze it
Option 3: Provide a file path (if running locally)
CODEBLOCK3
Security Restrictions for Script Usage:
- - Only files with
.msq extension are accepted - Path traversal sequences (
../) are blocked - Symbolic links are not allowed
- File must be a regular text file (not binary)
Option 4: Share key sections
If the file is large, paste specific sections you're concerned about:
- -
[veTable1] section for fuel map review - INLINECODE6 for ignition timing
- INLINECODE7 for AFR targets
- INLINECODE8 for safety limits
Example Prompts
CODEBLOCK4
What Gets Analyzed
Safety Checks:
- - 🚨 Critical: AFR targets that could cause engine damage, excessive ignition timing
- ⚠️ Warnings: Rev limiter not configured, suspicious VE values, high injector duty
Configuration Review:
- - Required fuel calculation sanity check
- VE table range and smoothness
- AFR target appropriateness for NA vs forced induction
- Ignition timing ranges and knock risk assessment
- Cranking pulse widths
- Warmup enrichment curve
- Safety limits (rev limiter, overboost)
Optimization Opportunities:
- - Injector duty cycle headroom
- VE table smoothness (sudden jumps)
- Conservative vs aggressive timing maps
Interpreting Results
Example Analysis Output:
CODEBLOCK5
Common Issues Detected
High Priority:
- - No rev limiter configured
- Lean AFR targets under load (>14.0:1 at WOT)
- Ignition timing >45° (severe knock risk)
- Estimated injector duty >90%
Medium Priority:
- - VE values <20 or >120
- Large jumps between adjacent cells (>30%)
- Missing warmup enrichment taper
- Cranking PW too high/low for conditions
Low Priority:
- - Conservative timing that may leave power on table
- Overly rich AFR targets
- Excessive injector headroom
Tune Review Workflow
- 1. Before First Start:
CODEBLOCK6
- 2. After Changes:
CODEBLOCK7
- 3. Before Dyno/Track:
CODEBLOCK8
Reference Materials
For detailed documentation, see:
Quick Reference Formulas
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:
CODEBLOCK11
Safety Checklist
Before starting engine:
- - [ ] Injector flow rate correct in settings
- [ ] Ignition timing verified with timing light
- [ ] Fuel pump primes and holds pressure
- [ ] No fuel leaks
- [ ] Wideband O2 sensor warmed up
- [ ] Emergency fuel/ignition cut accessible
During tuning:
- - [ ] Monitor EGT if available
- [ ] Listen for detonation/knock
- [ ] Watch AFR on transitions
- [ ] Keep VE table changes conservative
- [ ] Save tune frequently with version notes
使用TunerStudio进行Megasquirt ECU调校
使用TunerStudio软件调校Megasquirt发动机管理系统的指南。
核心概念
所需燃油方程式
Megasquirt通过以下公式计算燃油供给量:
脉宽 = 所需燃油 × VE% × MAP × AFR目标修正 × 空气密度 × 暖机 × 加速加浓 × 其他修正
所需燃油是在100% VE、100kPa MAP、标准温度下的基础喷油器脉宽。
关键调校表格
| 表格 | 用途 | 典型分辨率 |
|---|
| VE表 | 充气效率 vs 转速/MAP | 16×16 或 12×12 |
| AFR目标 |
目标空燃比 vs 转速/MAP | 12×12 |
| 点火提前角 | 点火正时 vs 转速/MAP | 12×12 或 16×16 |
| 暖机加浓 | 燃油修正 vs 冷却液温度 | 10-20个点 |
| 基于TPS的加速 | 加速加浓 vs TPS变化率 | 10-20个点 |
| 基于MAP的加速 | 加速加浓 vs MAP变化率 | 10-20个点 |
调校工作流程
1. 基础配置
调校前,请确认:
- - 发动机排量和气缸数
- 喷油器流量(cc/min 或 lb/hr)
- 喷油器喷射方式(同时喷射、交替喷射、顺序喷射)
- 所需燃油计算与喷油器尺寸匹配
- 点火输入/输出设置与硬件匹配
- 触发轮和点火模式已配置
2. 传感器校准
调校前校准传感器:
- - CLT(冷却液温度):在已知温度下设置电阻值
- IAT(进气温度):与CLT类似
- TPS:设置关闭和全开位置(0-100%)
- MAP:在钥匙打开时验证大气压读数
- 氧传感器:校准宽域控制器输出范围
3. VE表调校(速度密度法)
方法1:宽域氧传感器反馈
- 1. 启用EGO修正,修正幅度适中(±15-20%)
- 设置实际的AFR目标值
- 在稳态下运行发动机(固定转速/负载单元)
- 允许EGO进行修正,记录修正百分比
- 按修正的相反方向调整VE(如果修正为+10%,则VE增加10%)
- 保存并移至下一个单元
方法2:根据实测AFR计算
新VE = 当前VE × (实测AFR / 目标AFR)
调校顺序:
- 1. 从怠速区域开始(600-1000 RPM,30-50kPa)
- 轻负荷巡航(1500-2500 RPM,40-60kPa)
- 部分节气门加速
- 全开节气门高负荷
- 过渡区域
4. AFR目标表格
根据应用设置目标:
| 工况 | 目标AFR | 过量空气系数 |
|---|
| 怠速 | 13.5-14.5 | 0.92-0.99 |
| 轻负荷巡航 |
14.5-15.5 | 0.99-1.06 |
| 部分节气门 | 13.5-14.5 | 0.92-0.99 |
| 全开节气门自然吸气 | 12.5-13.0 | 0.85-0.88 |
| 全开节气门涡轮/机械增压 | 11.5-12.5 | 0.78-0.85 |
5. 点火正时
基础设置:
- - 设置启动提前角(通常为上止点前10-20°)
- 设置怠速提前角(通常为上止点前15-25°)
- 根据发动机特定指南构建点火提前角表
典型点火提前角表(自然吸气):
- - 低转速/高负荷:10-20°
- 低转速/低负荷:25-35°
- 高转速/高负荷:25-35°
- 高转速/低负荷:35-45°
爆震考虑因素:
- - 如果检测到爆震,每次减少1-2°点火提前角
- 在易爆震区域增加燃油
- 如果可用,使用爆震传感器反馈
6. 怠速控制
怠速阀PWM设置:
- - 关闭位置:热怠速时的PWM(通常为20-40%)
- 打开位置:冷启动时的PWM(通常为60-80%)
- 启动位置:启动期间的PWM(通常为50-70%)
怠速目标转速表:
- - 热机:700-900 RPM
- 冷机(0°C):1200-1500 RPM
- 之间插值
7. 暖机加浓
启动后加浓:
- - 持续时间:30-200个循环(发动机转数)
- 加浓量:额外增加20-40%燃油
- 在持续时间内逐渐减少至零
暖机加浓曲线:
- - -40°C:150-200%
- 0°C:120-140%
- 70°C(工作温度):100%
8. 加速加浓
基于TPS(Alpha-N混合):
- - 阈值:5-10%/秒 TPS变化率
- 加浓量:额外增加10-30%燃油
- 衰减时间:0.5-2秒
基于MAP(适用于MAP变化率系统):
- - 阈值:10-30 kPa/秒
- 加浓量与变化率成比例
冷机倍率:
- - 冷机时增加加速加浓(-20°C时为1.5-3倍)
高级功能
增压控制
开环:
闭环(如果支持):
- - 废气旁通阀控制的PID参数
- 目标增压表 vs 转速/档位
起步控制
- - 设置转速限制(通常为4000-6000 RPM)
- 配置起步时的延迟点火(上止点前0-10°)
- 设置燃油/点火切断方式
快速换挡
- - 换挡期间保持节气门开启
- 在换挡点短暂切断燃油/点火
- 在档位之间保持增压
数据日志分析
需要记录的关键参数
对节气门的响应,泄漏 |
| AFR(宽域) | 与目标的偏差 |
| EGO修正 | 应保持在±10%以内 |
| CLT | 达到工作温度 |
| IAT | 热浸效应 |
| 点火提前角 | 与表格匹配 |
| 喷油器脉宽 | 余量,最大占空比 |
| TPS | 平稳操作,TPS变化率 |
常见问题
踩油门时过稀:
- - 增加基于TPS的加速加浓
- 检查MAP变化率灵敏度
减速时过浓:
- - 启用减速燃油切断(DFCO)
- 设置适当的TPS阈值(通常<10%)
- 设置高于怠速的转速阈值
怠速游车:
- - 检查真空泄漏
- 调整怠速PID增益
- 验证TPS关闭位置
- 检查点火正时稳定性
高负荷爆震:
- - 减少受影响单元的点火提前角
- 加浓混合气(降低目标AFR)
TunerStudio特定内容
项目设置
- 1. 创建新项目 → 选择固件(MS1、MS2、MS3)
- 加载基础调校文件(.msq文件)或从默认值开始
- 连接到控制器(串口、USB或蓝牙)
- 与控制器同步以加载当前设置
调校界面
- - 基本/自定义调校:导航表格
- 表格:查看/编辑单个表格
- 运行时数据:实时监控
- 数据日志:记录和回放日志
自动调校
- - 使用宽域氧传感器启用VEAL(实时VE分析)
- 设置可接受的AFR范围
- 尽可能多地覆盖单元
- 审查并接受更改
- 完成后禁用
安全限制
转速限制器:
- - 软限制:延迟点火
- 硬限制:燃油/点火切断
- 设置在最大期望转速以上200-500 RPM
过增压保护:
过稀切断:
- - 如果AFR超过安全阈值,禁用喷油器
- 负载下通常为15