![]() |
| DISA valve gets closed whenever rpm is below 3800 and there's some load. It's not open at idle. |
Tuesday, October 25, 2011
DISA
This was very easy. I connected a wire from Injector Bank 1 to the DISA ground pin.
The DISA valve is very effective and adds about 10-15 ft-lbs of torque betwen 2500 and 3700 rpms. In fact, I will be adding 5 more DISA valves to the intake in the future to make it extremely powerful!
Thursday, October 20, 2011
MS3X cam input adjustment
If you read the MS3 hardware manual it says this about setting up the MS3X VR conditioner circuit for Hall inputs:
"Turn both pots (R11 and R32) full anti-clockwise - approx five turns. Then turn the top one (R11) two turns clockwise."
I did exactly that and chased my tail until I finally discovered that my cam input wasn't working. The problem was that my car ran great.. the oscilloscope showed that it was running full-sequential and the spark plugs and injectors were firing exactly when they were supposed to, except that the engine was only starting about 50% of the time.
I attributed the starting problems to bad cranking and prime parameters. If it was running full-sequential, how could it not have a good cam signal?
The answer is that it was polling the cam at start and always seeing a "0". If the engine happened to be in that position it started and ran fine. If it was NOT in that position, it didn't start until it fell into that phase. Once it started it was full-sequential by happenstance.
Here's what I found when I took a closer look at the MS3X VR conditioner circuit:
The bottom line is that you should turn R11 clockwise until you have 2 volts on pin 3 of U7A
"Turn both pots (R11 and R32) full anti-clockwise - approx five turns. Then turn the top one (R11) two turns clockwise."
I did exactly that and chased my tail until I finally discovered that my cam input wasn't working. The problem was that my car ran great.. the oscilloscope showed that it was running full-sequential and the spark plugs and injectors were firing exactly when they were supposed to, except that the engine was only starting about 50% of the time.
I attributed the starting problems to bad cranking and prime parameters. If it was running full-sequential, how could it not have a good cam signal?
The answer is that it was polling the cam at start and always seeing a "0". If the engine happened to be in that position it started and ran fine. If it was NOT in that position, it didn't start until it fell into that phase. Once it started it was full-sequential by happenstance.
Here's what I found when I took a closer look at the MS3X VR conditioner circuit:
![]() |
| The VR conditioner circuit. |
![]() |
| Input is a 0 to 5v square wave. After it goes through transistor Q2 it becomes a 1 to 4V square wave. Arrows show circuit test points. |
![]() |
| This is the resulting signal and the threshold at the comparator (OpAmp U7A). With R11 turned twice clockwise, the threshold isn't sufficient to trigger the output. |
![]() |
| R11 turned 3 1/2 turns clockwise. Threshold is now high enough to trigger and the output becomes correct. The minimum turns on R11 for the threshold to trip was about 2 3/4. |
![]() |
| U7A pin 3. R11 sets the threshold voltage on this pin, should be around 2 volts. |
Thursday, October 13, 2011
MAT correction
I've been driving back and forth to work running VE Analyzer each way. I've noticed that my table looks different after driving in the cold morning air compared to the corrections I get driving home in warmer air. Ideally it would be the same no matter what the temperature is. I need to work on my MAT correction!
The amount of fuel injected is influenced by the Ideal Gas Law which is proportional to temperature in degrees Kelvin.
So if 50F = 283 Kelvin and 80F= 299 Kelvin then Megasquirt would want to inject 283/299 or about 6 1/2% less gas at the warmer temps.
Problem is, What seems great in theory isn't exactly what's happening in the engine and Megasquirt seems to over correct and run too lean at warmer temps.
There are 3 tools to correct that:
The amount of fuel injected is influenced by the Ideal Gas Law which is proportional to temperature in degrees Kelvin.
So if 50F = 283 Kelvin and 80F= 299 Kelvin then Megasquirt would want to inject 283/299 or about 6 1/2% less gas at the warmer temps.
Problem is, What seems great in theory isn't exactly what's happening in the engine and Megasquirt seems to over correct and run too lean at warmer temps.
There are 3 tools to correct that:
![]() |
| MAT correction table applies a straight % correction based entirely on the temperature. It adds a little gas back at warm temps were the ideal gas law takes it away. |
Monday, October 10, 2011
Working on a reliable start
There's only a few variables that can be changed for starting and a majority of them I've been able to copy from the OEM ECU. Spark advance and dwell are easy. Priming pulsewidth is relatively easy. What's been kicking my arse is the cranking PW. In order to make some sense of when it starts and when it doesn't start, I've been logging each start with the CLT temp, and cranking pulsewidth and putting it in the "Yes" or "No" category if it starts on the first try.
EDIT: At the time the graph was discouraging because it made it look like starting was a 50-50 affair. In retrospect, it really was a 50-50 affair because the cam signal wasn't working. If the motor was in the right phase it started and ran great, if it was in the wrong phase it just didn't start... It was 50-50. When it did start, it ran full-sequential which made me think the cam signal was fine.
It was never a starting problem, it was a comparator threshold voltage problem.
EDIT, Dec 2011. My remaining starting issue was caused by the fact that my starting circuit transistor was losing biasing under low-battery conditions, mainly when it was cold. Since I re-build that little circuit it's started 100% of the time on the first crank!
EDIT: At the time the graph was discouraging because it made it look like starting was a 50-50 affair. In retrospect, it really was a 50-50 affair because the cam signal wasn't working. If the motor was in the right phase it started and ran great, if it was in the wrong phase it just didn't start... It was 50-50. When it did start, it ran full-sequential which made me think the cam signal was fine.
It was never a starting problem, it was a comparator threshold voltage problem.
EDIT, Dec 2011. My remaining starting issue was caused by the fact that my starting circuit transistor was losing biasing under low-battery conditions, mainly when it was cold. Since I re-build that little circuit it's started 100% of the time on the first crank!
Wednesday, October 5, 2011
Closed-loop idle
This has taken me a while to figure-out, and I still don't understand how Megasquirt does PID for closed-loop idle. Here's how mine looks at the moment.
Here are some thoughts on the different fields:
Idle Open Duty % and Idle Closed Duty %. These set the limit for how high and how low the code will let the duty cycle go. It will never let the IAC valve move past either value. It also uses the difference between the two values as a scaling function, so 50-20 will scale and respond differently than 20-90, even though your valve may never go beyond 50%.
Closed Loop PID Gains. "I" has the most effect on steady-state error, "P" effects how quick it responds. "D" should prevent overshoot. These don't always work that way. I also found that setting idle response when the motor is warm will lead to oscillations when the motor is cold. It needs to be stable for both!
Min Duty for PID% This is supposed to be the closed position of the valve, but I don't understand the difference between this and Idle Closed Duty %. I think it will not go below whichever one is higher of the two so what's the point?
RPM with valve open/closed. This has little to do with RPMs with the valve closed or open; this should just be galled "Gain". With a smaller difference between the RPMs the Gain will be higher. The lower number needs be less than your idle by a few hundred, the higher number higher than idle. That's it.
PID control interval. The biggest problem I have with tuning the PID is steady-state error. I think some of that has to do with the choice of control interval. The conventional wisdom is that "faster is better", but classic control theory says you shouldn't sample more than about 1/10 - 1/20 of the settling time. The engine doesn't respond that quickly and if it ramps in 2 seconds and settles in 4 that would give a 200ms sampling time, at the very minimum. I think lower sampling times just increase the error due to rounding and lack of resolution in integer variables. With sampling below 80ms, I had terrible steady-state error and could never get idle within 100rpms of target without dramatically increasing I which caused instability.
With 300ms sampling time, I find that idle is better overall with no negative effects. My idle reaches the target, it has slight overshoot and nice response time. It's very liveable for day-to-day driving.
EDIT: Since this post I have upgraded to Alpha 14 code, which has revised and more functional PID code.
Here are some thoughts on the different fields:
Idle Open Duty % and Idle Closed Duty %. These set the limit for how high and how low the code will let the duty cycle go. It will never let the IAC valve move past either value. It also uses the difference between the two values as a scaling function, so 50-20 will scale and respond differently than 20-90, even though your valve may never go beyond 50%.
Closed Loop PID Gains. "I" has the most effect on steady-state error, "P" effects how quick it responds. "D" should prevent overshoot. These don't always work that way. I also found that setting idle response when the motor is warm will lead to oscillations when the motor is cold. It needs to be stable for both!
Min Duty for PID% This is supposed to be the closed position of the valve, but I don't understand the difference between this and Idle Closed Duty %. I think it will not go below whichever one is higher of the two so what's the point?
RPM with valve open/closed. This has little to do with RPMs with the valve closed or open; this should just be galled "Gain". With a smaller difference between the RPMs the Gain will be higher. The lower number needs be less than your idle by a few hundred, the higher number higher than idle. That's it.
PID control interval. The biggest problem I have with tuning the PID is steady-state error. I think some of that has to do with the choice of control interval. The conventional wisdom is that "faster is better", but classic control theory says you shouldn't sample more than about 1/10 - 1/20 of the settling time. The engine doesn't respond that quickly and if it ramps in 2 seconds and settles in 4 that would give a 200ms sampling time, at the very minimum. I think lower sampling times just increase the error due to rounding and lack of resolution in integer variables. With sampling below 80ms, I had terrible steady-state error and could never get idle within 100rpms of target without dramatically increasing I which caused instability.
With 300ms sampling time, I find that idle is better overall with no negative effects. My idle reaches the target, it has slight overshoot and nice response time. It's very liveable for day-to-day driving.
EDIT: Since this post I have upgraded to Alpha 14 code, which has revised and more functional PID code.
Monday, October 3, 2011
On static timing, Hall and VR.
I had the static timing set at 324 degrees which is the middle of the 54th tooth after tooth #1. That worked well and I didn't think it was very far off but I still wanted to verify with a timing light to make it more-better.
A note on timing lights and the M54: The TDC mark is on the damper which is difficult to see from the top of the engine. I would remove the engine-driven fan and the radiator shroud to make it easier. Mark the TDC line on the damper with some yellow paint or anything to make it more visible. Do the same with the reference mark on the block. I was able to see the timing marks with the timing light easily by using an inspection mirror held behind the radiator. Shine the timing light down at the mirror, the light will reflect 90 degrees into the damper. My mirror had a diameter of about 2 inches.
I used an "old-fashion" timing light that did not have the adjustable advance knob- I just don't trust those. I used one that only triggered at the spark with advance set to 0 degrees.
Result: I found that my true TDC was 325.7; 1.7 degrees more retard.
A possible explanation is that I am using a VR sensor which reads the middle of the tooth, but the M54 crank-mounted sensor wheel is designed for a Hall sensor which reads the edge of the tooth. The distance from the middle to the edge of a tooth is 1.5 degrees so my error makes sense. I've always thought Hall reads the leading edge, but this would seem to indicate that Hall reads the trailing edge. Dunno..
324 degrees is the theoretical setting.
My measured VR sensor setting is 325.7
Gurov has a Hall sensor and his measurement is 325 degrees.
On an M50, the tooth wheel is already made for VR so I would think 324 is correct but check with a timing light.
A note on timing lights and the M54: The TDC mark is on the damper which is difficult to see from the top of the engine. I would remove the engine-driven fan and the radiator shroud to make it easier. Mark the TDC line on the damper with some yellow paint or anything to make it more visible. Do the same with the reference mark on the block. I was able to see the timing marks with the timing light easily by using an inspection mirror held behind the radiator. Shine the timing light down at the mirror, the light will reflect 90 degrees into the damper. My mirror had a diameter of about 2 inches.
I used an "old-fashion" timing light that did not have the adjustable advance knob- I just don't trust those. I used one that only triggered at the spark with advance set to 0 degrees.
Result: I found that my true TDC was 325.7; 1.7 degrees more retard.
A possible explanation is that I am using a VR sensor which reads the middle of the tooth, but the M54 crank-mounted sensor wheel is designed for a Hall sensor which reads the edge of the tooth. The distance from the middle to the edge of a tooth is 1.5 degrees so my error makes sense. I've always thought Hall reads the leading edge, but this would seem to indicate that Hall reads the trailing edge. Dunno..
324 degrees is the theoretical setting.
My measured VR sensor setting is 325.7
Gurov has a Hall sensor and his measurement is 325 degrees.
On an M50, the tooth wheel is already made for VR so I would think 324 is correct but check with a timing light.
Starting fuel
I spent the weekend with the stock ECU measuring the prime and cranking pulsewidths for different temperatures. I started with a hot, running engine and pulled the fuel pump fuse and until it stalled, then pulled all 6 COP plugs to keep it from starting.
I recorded the block temperature and scoped the injector signal for 8 seconds of cranking. The raw data looks like this:
![]() |
| Raw PW of prime and cranking PW vs temperature. |
My thought was that it would be easy to translate this into Megasquirt and I would have a car that starts just like stock.. set the cranking ign to 0 BTDC, prime and crank like OEM and Blammo! I would have an engine that starts like stock.
The problem is that the OEM ECU doesn't inject a constant cranking PW like Megasquirt does.
![]() |
| Cranking fuel decreases with the cranking time. Which to use for Megasquirt?? |
![]() |
| OEM fuel curves for start. Prime, first injection event and the 5th injection. This data has 1 second subtracted for injector latency. |
![]() |
| My current cranking fuel. I will certainly tweak it but it's Ok so far. |
Subscribe to:
Comments (Atom)














