Skip to content

Commit

Permalink
Miata knock sensor (#258)
Browse files Browse the repository at this point in the history
* WIP page

learning how to use github (^:

* Update Miata-Knock-Sensor.md

* Update Miata-Knock-Sensor.md

* Update Miata-Knock-Sensor.md

* Added photos

Organized spacing

* Update Miata-Knock-Sensor.md

* Update Miata-Knock-Sensor.md

* Updating fw install troubleshooting notes

added info for updates prior to fome 2312

* Update Miata-Knock-Sensor.md

* Update 04-HT-Updating-The-Firmware.md

* Update docs/02-Intro-Start-Here/04-HT-Updating-The-Firmware.md

Co-authored-by: Nathan Schulte <[email protected]>

* Update docs/02-Intro-Start-Here/04-HT-Updating-The-Firmware.md

fails build -- case sensitive

* Update docs/11-Vehicle-Specific/Mazda-MX5-Miata/Miata-Knock-Sensor.md

* Update docs/11-Vehicle-Specific/Mazda-MX5-Miata/Miata-Knock-Sensor.md

* Update docs/11-Vehicle-Specific/Mazda-MX5-Miata/Miata-Knock-Sensor.md

* Update docs/11-Vehicle-Specific/Mazda-MX5-Miata/Miata-Knock-Sensor.md

* fix new markdown lint

---------

Co-authored-by: OrchardPerformance <[email protected]>
Co-authored-by: Nathan Schulte <[email protected]>
Co-authored-by: Nathan Schulte <[email protected]>
  • Loading branch information
4 people committed May 3, 2024
1 parent f320c07 commit 4cc7533
Show file tree
Hide file tree
Showing 16 changed files with 134 additions and 1 deletion.
28 changes: 27 additions & 1 deletion docs/02-Intro-Start-Here/04-HT-Updating-The-Firmware.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ console**, which is capable of flashing firmware to supported ECUs and is the re
The FOME console is included with each firmware release, and bundles can be downloaded from [the release
page](https://github.com/FOME-Tech/fome-fw/releases).

After extracting the bundle contents, navigate to the `console/` directory and run the FOME console program (e.g.
After extracting the bundle contents, navigate to the 'drivers/' directory and install the drivers. After, navigate to the `console/` directory and run the FOME console program (e.g.
`fome_console.exe` if using Windows). After first confirming **TunerStudio is not running**, connect the ECU to the
computer. FOME console will automatically detect the board and present similar to the display below.

Expand Down Expand Up @@ -68,3 +68,29 @@ as shown here) to load the preset for your vehicle (**not the button to *Reset f

Once the preset has been loaded, you can either start tuning or load your tune from the older firmware versions under
*File > Load Tune (msq)*. After that, the update is complete!

## Troubleshooting updates prior to release FOME 2312

If an error persist during the DFU update for release 2312 a manual driver update may be required.

When the FOMEconsole prompts with a ConfigManagerErrorCode=28 proceed by opening Device Manager. Look for the following device "STM32 BOOTLOADER" It may be under 'Other Devices'.

![image](Updating-FW/stm32drivererror.png)

Right click STM32 BOOTLOADER and select 'Update Drivers'

![image](Updating-FW/updatedriver.png)

Select 'Browse my computer for drivers' and proceed to Browse and have windows update the drivers for STM32 BOOTLOADER by directing it to 'Drivers/silent_st_drivers/'

Proceed to unplug the ECU and retry the install. If another DFU update error persist such as "Data mismatch found at address" or "looks like ECU didn't reboot to OpenBLT"

![image](Updating-FW/datamismatcherror.png)

Proceed to unplug the ECU and retry the install. At this point, the FOME console should have detected the ECU as OpenBLT Bootloader. Proceed by updating the firmware "Manual OpenBLT Update"

![image](Updating-FW/openblt.png)

If prompted with Update completed successfully, proceed with power cycle. From this release onwards the ECU can be updated using OpenBLT and should not require any manual driver installs.

![image](Updating-FW/openbltsuccess.png)
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/02-Intro-Start-Here/Updating-FW/openblt.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
107 changes: 107 additions & 0 deletions docs/11-Vehicle-Specific/Mazda-MX5-Miata/Miata-Knock-Sensor.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,107 @@
# Miata Knock Sensor Upgrade

## Installation of Knock sensor

For __NA6 & NA8__ there is a M10x1.25 threaded blind hole that should be utilized for a knock sensor located above the Factory Oil Pressure sending unit below the intake manifold. You can access this with the intake manifold installed.

There are two steps required to install a __Bosch KS4-P__ sensor onto a 90-97 Miata block.

1. __Create clearance for the Knock Sensor__
- Utilizing the factory Mazda oil pressure sender unit
- Install a 1/8 BPST spacer (male to female)
- Relocate using Oil sender remote mount kit
- Replace OEM sender unit with a Pressure Transducer
- Adapt from 1/8 BPST to Required fitting type (make sure to account for the spacing of the knock sensor)

2. __Mounting the knock sensor to the block and torquing it to 20nm.__
- Given the engine's M10x1.25 specs, options include employing a M10x1.25 threadsert with a M8 X 1.25 Internal Thread, crafting a custom M10x1.25 to M8x1.25 threaded stud, or using a m8x1.25 Allen Bolt and using a Die to cut m10x1.25 threads onto the external section of the bolt head.

For __NB models__, a factory knock sensor is pre-installed on the block. However, replacing it with a Bosch KS4-P knock sensor can offer a broader frequency bandwidth for knock detection. To make the switch, similar steps apply, necessitating the use of a M10x1.25 threadsert with a M8 X 1.25 Internal Thread, a custom M10x1.25 to M8x1.25 threaded stud, or a M8x1.25 allen nolt with threads cut using a die onto the bolt head's external section. Once the Knock Sensor is torqued to the block, wiring it into the correct pinout on the ECU is the subsequent step.

Wiring might entail additional pins and connectors depending on the Miata's model year. Below are the pinouts for the current rev of ecu’s:

- 90-95 – 2P
- 96-97 – 1S
- NB1 – 1S
- NB2 – 4M

## Overview of the Block

![image](<Knock Sensor/block overview 1.png>)
![image](<Knock Sensor/block overview 2.png>)
![image](<Knock Sensor/block overview 3.png>)
![image](<Knock Sensor/block overview 4.png>)
![image](<Knock Sensor/block overview 5.png>)

## Tuner studio Setup

When knock occurs due to factors like advanced ignition timing or high cylinder pressures, the sensor detects these vibrations. The ECU then adjusts ignition timing to prevent further knock. This constant monitoring and adjustment help protect against damage. To set this up requires the following steps:

__Summary of knock detection and protection:__

1. Enable the knock sensor and calculate the knock frequency using an approximation formula.
2. Remove ignition timing from the ignition map, adjust other parameters to prevent pre-detonation events.
3. Record a log of engine performance and knock sensor levels across full RPM range.
4. Restore the tune and maps to its original configuration.
5. Review log data to create a baseline curve for knock detection.
6. Adjust knock retard aggression to determine the level of response.
7. Set up the Max Knock Retard table to define maximum allowable ignition timing retardation.

:::warning
The following steps assumes your ECU is running the latest release of FOME (2312)
:::

1. __Enable the knock sensor__, and calculate the estimated knock filter frequency (kHz). For now, configure the first setting “cylinder bore” as 0.00mm.

- An adequate approximation formula for Knock Frequency is “Knock Frequency = 900,000/(π {'*'} 0.5 {'*'} cylinder bore diameter )”
- Once the approximated knock frequency is calculated, use the second-order harmonics of the estimated frequency. The second-order frequency are multiples of the original calculated frequency. So twice the Knock Frequency. We do this to increase sensitivity, improve signal to noise ratio, and general “robustness” in frequency analysis.
- For now, Set knock detection window start to 0.00, This feature is for advanced users only.

- This formula is derived from the relationship between the speed of sound, the bore diameter, and the frequency of knock waves. It assumes that the speed of sound is approximately constant and that the knock waves travel at a specific angle through the combustion chamber. As an example, the NA6’s estimated knock frequency is 7300 Hz or 7.3kHz & its 2nd order harmonic would be 14.60Khz.

:::danger
The next few steps assume your car is running well enough to take a low-load full rpm log to define the engine knock threshold curve.
:::
:::info
An engine knock threshold curve shows how the sensitivity of knock sensors changes with engine speed. It's a graph where the horizontal axis represents engine speed (in RPM) and the vertical axis shows the knock sensor's sensitivity level (in dBV). Tuning this curve ensures the ECU reacts appropriately to protect the engine while maximizing performance.
:::

<!-- markdownlint-disable MD029 -->
2. __Start by removing ignition timing__ from the ignition map, an approach is to remove 3 degrees of timing, increase octane rating, decrease boost and any other parameters that can contribute to pre-detonation events.

3. __Record a log at a minimum of 100 Samples per second from idle to redline__ (Under Communications/Data Rate). This can be performed in a few ways. The better the Data, the better the Threshold curve:
- On Jack stands with slight load applied such as brakes
- Driving on the road in a controlled fashion

4. __Restore the tune back to the previous configuration__ (for example, add 3 degrees of ignition timing).

5. __Review the log in MegaLog Viewer and generate a scatter plot__ of the “Knock: Current Level” vs RPM:
- Ideally the plot is the low-load noise of the engine throughout the whole rpm range. It should look something like this below.
- Further filtering can be applied in megalog viewer to remove high manifold pressure and deceleration noise. Use these expressions to help analysis the measured data.
- Deceleration : “ [RPM-4]{'<='}[Field.RPM]&&[TPS]{'<'}50 “
- High Load : “ [Ign: Load]>60 “
![image](<Knock Sensor\knock current vs rpm.png>)
- Once the above plot for your engine has been generated, we can use this data to create a plot that will be used in Tunerstudio’s table on the bottom right. This is a baseline curve, further logs can be taken and more data reduction can used to refine the curve.
- The curve used in Tunerstudio should fit over the top of the low-load noise and also be “tight” to the measured data. As shown below, the orange scater is all the data less than 60kpa and the grey is a curve can be used as a baseline threshold in Tunerstudio.
- An active system is better than one missing low level knocks
![image](<Knock Sensor\knock threshold curve fitted.png>)
![image](<Knock Sensor\Software knock.png>)

6. __Set up the Response of the Knock controller’s parameter “Knock retard aggression”__ A generalized rule of thumb would be 5% is considered adequate where as 15% being very aggressive:
- The knock retardation amount is determined by calculating the distortion from the optimal ignition timing, multiplying it by the configured knock retard aggression percentage to determine the desired retardation, and then applying this retardation to the current knock retardation value.

7. __Set up the Max Knock Retard table__:
- The max knock table defines the maximum allowable knock values that the knock controller can use to retard ignition timing, with the Y-axis representing ignition load, the X-axis engine speed in RPM, and the Z-axis indicating the degree of timing retardation permitted for each combination of load and speed.
![image](<Knock Sensor\max retard allowable.png>)

## Conclusion

Installing a knock sensor in a Mazda Miata involves accessing a threaded hole above the oil pressure sending unit under the intake manifold. For models NB and onwards, a factory-installed knock sensor is available, but upgrading to a Bosch KS4-P sensor broadens the frequency bandwidth for better knock detection. Installation requires creating clearance for the sensor and mounting it to the block, followed by wiring it into the correct pinout on the ECU. Once installed, the knock sensor continuously monitors knock events, allowing the ECU to adjust ignition timing and prevent damage from subsequent knock events. Setting up knock detection involves calculating the knock frequency, recording engine performance logs, and adjusting parameters such as knock retard aggression and the Max Knock Retard table to optimize engine protection and performance.

## Knock Sensor Part list

| Knock | Bosch - Off the Shelf | |
| --- | --- | --- |
| Bosch KS4-P | 0 261 231 173 | FCP Euro 2-Pin RB-Kp.1 (F02U.B00.966-01) or 0 261 231 188 Ballenger 2-Pin Jetronic (D261.205.288-01) [LK-2 Connector] |
| Bosch KS4-R | 0 261 231 218 | eBay 2-Pin RB-Kp.1 or 0 261 231 223 eBay 2-Pin RB-Kp.3 (F02U.B00.967-01) |
| Bosch KS-1-S | 0 261 231 120 | FCP Euro Amazon 2-Pin RB-Kp.1 (F02U.B00.966-01) or 2-Pin Jetronic (D261.205.288-01) [LK-2 Connector] |

0 comments on commit 4cc7533

Please sign in to comment.