Introducing The Blue Knock Box.
#1
Introducing The Blue Knock Box.
After some R&D I've come up with a knock light/failsafe system that works on the 8.
Due to other issues it's gone a little stagnant for the moment, but I do have working hardware and code, and since my original intent was to open source this, I'm gonna share what I've got. Sorry if the code is a little rough.
It currently reads knock, normal values are around <200 up to 7k when it goes up to 800-1200. This only allows you to set a threshold of 1200+ for engine cut, but it could save an engine from bad gas/bad tune.
The knock detector works by taking the signal wire off the knock sensor and running it through a 100kohm resistor then a .01uf capacitor to analog pin 1. The hardware is an arduino with a Sainsmart LCD keypad shield.
A 250ohm resistor connected to a digital pin, then connected to the e-shaft will provide the ability to both stop the engine if knock is detected (with a digital write to low or high) or detect RPM/e-shaft position (with the pin mode in digital read). This is not implemented in code, but both functions have been tested independently.
Currently the keys on the LCD keypad are unreadable because of hack I used to get sample rate up(necessary to filter out engine noise). It should be possible to fineness multiplexing the pins, but a small delay must be added to let the MUX flip and values go to normal.
The Goertzel algorithm is implemented sloppy with lots of floats. Needs to be converted to long/int math for faster speed.
I will work on this more as time permits, but right now I have an 8 in the driveway that's taking up a lot of my time.
Due to other issues it's gone a little stagnant for the moment, but I do have working hardware and code, and since my original intent was to open source this, I'm gonna share what I've got. Sorry if the code is a little rough.
It currently reads knock, normal values are around <200 up to 7k when it goes up to 800-1200. This only allows you to set a threshold of 1200+ for engine cut, but it could save an engine from bad gas/bad tune.
The knock detector works by taking the signal wire off the knock sensor and running it through a 100kohm resistor then a .01uf capacitor to analog pin 1. The hardware is an arduino with a Sainsmart LCD keypad shield.
A 250ohm resistor connected to a digital pin, then connected to the e-shaft will provide the ability to both stop the engine if knock is detected (with a digital write to low or high) or detect RPM/e-shaft position (with the pin mode in digital read). This is not implemented in code, but both functions have been tested independently.
Currently the keys on the LCD keypad are unreadable because of hack I used to get sample rate up(necessary to filter out engine noise). It should be possible to fineness multiplexing the pins, but a small delay must be added to let the MUX flip and values go to normal.
The Goertzel algorithm is implemented sloppy with lots of floats. Needs to be converted to long/int math for faster speed.
I will work on this more as time permits, but right now I have an 8 in the driveway that's taking up a lot of my time.
#5
Current version works, but with limited effectiveness. It can sense the 2600hz frequency which corresponds to knock, and it can take a rolling average to give you some idea what's going on. It can't filter out engine noise, because it can't yet see e-shaft angle. It also takes a long time to analyze each sample. Ideally the sample should analyze under 1ms, but until I spend a night coding and reworking the math, it will remain a bit slower. Thanks for the offer of help, but most of what I need to work out is more math than code. Still any suggestions/rewrites will be gladly accepted!
All that said, our engines knock quite a bit. At least low level knock. At high RPM knock gets bad, I have some ideas as to why and what can be done to avoid it, but that's for another day.
If anyone wants to build their own prototype I'll provide any additional info as needed. Public release prototypes coming as soon as I get them done. Best thing is it should install with 2 wire splices (other than power/ground) and have both knock detection and fail-safe capabilities.
All that said, our engines knock quite a bit. At least low level knock. At high RPM knock gets bad, I have some ideas as to why and what can be done to avoid it, but that's for another day.
If anyone wants to build their own prototype I'll provide any additional info as needed. Public release prototypes coming as soon as I get them done. Best thing is it should install with 2 wire splices (other than power/ground) and have both knock detection and fail-safe capabilities.
#7
Yeah my turbo build is still in progress, but having a knock detection/engine fail-safe was the cornerstone of making my plan work safely. Now that I have this in a workable form nothing is stopping me from progressing. Lemme get a couple days off of work and I'll send you one I'll PM you for address when it's ready.
#8
Registered
iTrader: (1)
I happen to have an arduino and a sainsmart lcd keypad laying around - I may give this a shot when I have some free time. I have read though that the knock sensor has been described as "useless" by a few experts with this engine.
Have you considered trying to detect engine misfires by analyzing the crank sensor? If you combine that with maybe a thermocouple on both of the outer exhaust header legs you would have an excellant idea of the engine health.
Have you considered trying to detect engine misfires by analyzing the crank sensor? If you combine that with maybe a thermocouple on both of the outer exhaust header legs you would have an excellant idea of the engine health.
#9
The knock sensor is far from useless. The stock ecu detects and corrects knock so seamlessly that it's hard to tell anything happened. The real problem happens when you advance timing beyond what the ecu can correct. Then knock gets louder and louder until things start breaking.
Also after 7k the ecu stops looking, probably because knock is unavoidable at higher rpms. This is very dangerous when boosted, because there is nothing to prevent engine damage. I may have a workaround, but I don't want anyone trying it yet and blowing up their engines.
Our engines knock at a frequency centered around 2600hz. Knock is easily distinguishable on a spectrograph and easily detectable with software based filtering. I just slapped some code together and put it on an arduino.
EGTs will tell you a lot about mixture and timing, but that's only part of the story. Detecting misfires is pretty pointless, the stock ecu does it off the e-shaft sensor but really it's just an emissions check like everything else obd2.
Also after 7k the ecu stops looking, probably because knock is unavoidable at higher rpms. This is very dangerous when boosted, because there is nothing to prevent engine damage. I may have a workaround, but I don't want anyone trying it yet and blowing up their engines.
Our engines knock at a frequency centered around 2600hz. Knock is easily distinguishable on a spectrograph and easily detectable with software based filtering. I just slapped some code together and put it on an arduino.
EGTs will tell you a lot about mixture and timing, but that's only part of the story. Detecting misfires is pretty pointless, the stock ecu does it off the e-shaft sensor but really it's just an emissions check like everything else obd2.
#10
Registered
iTrader: (1)
My comments come from a long time ago when Racing Beat was developing their flashes. They unbolted the knock sensor because they deemed it to not pick up real knock reliably and pick up false knock repeatedly.
The mazda service tech diagnostic tool can show front and rear misfires well before the engine CEL will be displayed. My experience has been by the time the CEL displays for a misfire, its well past the point where you have melted a cat and toasted a seal. Reading the raw misfire count lets you easily identify bad coils before you cause failures. Analyzing the crank sensor and Egts from each rotor can also tells you about misfires and the performance of one rotor to the other in addition to an aid in tuning.
The mazda service tech diagnostic tool can show front and rear misfires well before the engine CEL will be displayed. My experience has been by the time the CEL displays for a misfire, its well past the point where you have melted a cat and toasted a seal. Reading the raw misfire count lets you easily identify bad coils before you cause failures. Analyzing the crank sensor and Egts from each rotor can also tells you about misfires and the performance of one rotor to the other in addition to an aid in tuning.
#13
weeeeeeeeee
iTrader: (12)
So I've spent a little bit of time recently monitoring the OE knock sensor. Unless there is an additional filtering method I've found it to be pretty much useless.
Harlan I don't mean to rain on your parade but I don't think you're hearing knock. If I was knocking like the sensor suggests I would've cratered my motor quite some time ago.
Harlan I don't mean to rain on your parade but I don't think you're hearing knock. If I was knocking like the sensor suggests I would've cratered my motor quite some time ago.
Last edited by ShellDude; 06-30-2013 at 01:38 PM.
#14
The code has a goertzel filter with a hanning window, so yes the output has some heavy digital signal processing. I set it up to respond at 2600 hz not because it's the only frequency where knock occurs, but because it's in the band where knock occurs and there isn't much engine noise at that frequency. Need to test more, but the MAZDA edit table I've seen suggests that the ECU uses a much more basic approach.
It's abnormal combustion that causes the noise we call knock. A pocket of unburnt fuel and air get compressed durring combustion until a hot spot in the chamber ignites it or until autoignition temp. This occurs at the trailing rotor face because it's the last to burn and because it has a rich mixture with little to no exhaust gas to moderate the burn. This abnormal combustion happens at 45deg ATDC and if it is violent enough we can hear it. At higher rpms knock is unavoidable (at least with our current timing strategy) because the fuel burns so slowly you can't maintain a complete burn, but the knock is still mild enough that it isn't that much of a worry with NA.
The point I'm trying to make is that knock can be detected at much lower levels that what is audible or what can cause engine damage. So yes, low levels of knock will not crater your engine, but that doesn't mean they should be ignored either.
Sorry guys I've been really busy with work recently. As soon as I get my rebuilt engine back in and start moving forward again I'll post more and move the project forward.
It's abnormal combustion that causes the noise we call knock. A pocket of unburnt fuel and air get compressed durring combustion until a hot spot in the chamber ignites it or until autoignition temp. This occurs at the trailing rotor face because it's the last to burn and because it has a rich mixture with little to no exhaust gas to moderate the burn. This abnormal combustion happens at 45deg ATDC and if it is violent enough we can hear it. At higher rpms knock is unavoidable (at least with our current timing strategy) because the fuel burns so slowly you can't maintain a complete burn, but the knock is still mild enough that it isn't that much of a worry with NA.
The point I'm trying to make is that knock can be detected at much lower levels that what is audible or what can cause engine damage. So yes, low levels of knock will not crater your engine, but that doesn't mean they should be ignored either.
Sorry guys I've been really busy with work recently. As soon as I get my rebuilt engine back in and start moving forward again I'll post more and move the project forward.
#15
Here is the current source. This is running on an arduino uno with a Sainsmart LCD. The LCD is not required, but you'll have to write your own output without it.
19khz sampling occurs in realtime. The square of the amplitude is found for the target frequency (currently set at 2550) then that value is averaged with 32 of it's buddies to get a result. That means that if you set a knock target for cutout and your engine is just barely above the limit it will take 135ms to respond, on the other hand if the knock is much louder than the limit it can respond in much less time.
The magnitude that is produced is squared, so if it goes up by a factor of 10 then the volume is really just 3.2 times louder. Getting the actual magnitude instead of the square is rather difficult to do with one chip because of the amount of math that has to be done with each sample. So just keep that in mind when you set limits. If you find the average knock value and set the limit at double then you have actualy set the limit at 1.4 times average.
For the wiring, connect a 50kohm resistor between pins A1 and A2, and A2 and A3. This provides a voltage divider for the input. A1 is set to ground in the code and A3 is set to 5v because it gave me handy voltage/ground sources. Connect the knock sensor yellow/red wire to A2 with a 10k pf capacitor for isolation.
PLEASE DO NOT USE THESE FEATURES YET they still have issues. There a input for RPM on digital pin 3. This will read and display accurate RPM until somewhere around 6k. After that it stars creating interference with the ECU and reads inaccurately.Setting pin 3 to output (defaults to ground) with the e-shaft sensor connected will cause the engine to instantly stop spark and fuel. However this may be beyond the current limitations of the arduino pin.
I'm working on some better isolation for the e-shaft signal as well as using a transistor to ground instead of the arduino directly. At this point those are the only holdups. I may dial in frequency a bit more or play with how many samples are averaged, but the code does work well as written right now. I have other versions of the code with knock limits and other features, but they are not as complete as this version.
When I actually have a release version there will be an LED dash light to give indication of knock as well as engine cuttout. Install will be two wires to the ecu plus power and ground, with an optional rear o2 sensor simulator. And as always the schematics and source will be freely available to anyone.
19khz sampling occurs in realtime. The square of the amplitude is found for the target frequency (currently set at 2550) then that value is averaged with 32 of it's buddies to get a result. That means that if you set a knock target for cutout and your engine is just barely above the limit it will take 135ms to respond, on the other hand if the knock is much louder than the limit it can respond in much less time.
The magnitude that is produced is squared, so if it goes up by a factor of 10 then the volume is really just 3.2 times louder. Getting the actual magnitude instead of the square is rather difficult to do with one chip because of the amount of math that has to be done with each sample. So just keep that in mind when you set limits. If you find the average knock value and set the limit at double then you have actualy set the limit at 1.4 times average.
For the wiring, connect a 50kohm resistor between pins A1 and A2, and A2 and A3. This provides a voltage divider for the input. A1 is set to ground in the code and A3 is set to 5v because it gave me handy voltage/ground sources. Connect the knock sensor yellow/red wire to A2 with a 10k pf capacitor for isolation.
PLEASE DO NOT USE THESE FEATURES YET they still have issues. There a input for RPM on digital pin 3. This will read and display accurate RPM until somewhere around 6k. After that it stars creating interference with the ECU and reads inaccurately.Setting pin 3 to output (defaults to ground) with the e-shaft sensor connected will cause the engine to instantly stop spark and fuel. However this may be beyond the current limitations of the arduino pin.
I'm working on some better isolation for the e-shaft signal as well as using a transistor to ground instead of the arduino directly. At this point those are the only holdups. I may dial in frequency a bit more or play with how many samples are averaged, but the code does work well as written right now. I have other versions of the code with knock limits and other features, but they are not as complete as this version.
When I actually have a release version there will be an LED dash light to give indication of knock as well as engine cuttout. Install will be two wires to the ecu plus power and ground, with an optional rear o2 sensor simulator. And as always the schematics and source will be freely available to anyone.
#17
After extensive testing with the current code, I've decided the signal to noise ratio sucks, and there is nothing the software can do to fix it. The high frequency engine noise >10kh causes the goertzel to have false positives. It can be averaged out and compared to a baseline at each rpm giving a solid indication of knock, but it can be worlds better with an analog filter. Also providing filtered input to the ECU should cut out a lot of false positives there. I've played with amps/filters, but for me to get up to speed on analog circuits and make something that will work will take more time than I'm willing to dedicate to this project right now.
So... I'm working on a mostly off the shelf solution that can send the ECU a filtered signal, as well as send the knock box a filtered signal, and allow det phones to be plugged in.
I wish I had thought of this approach earlier, you guys are gonna laugh when you see how simple this is.
So... I'm working on a mostly off the shelf solution that can send the ECU a filtered signal, as well as send the knock box a filtered signal, and allow det phones to be plugged in.
I wish I had thought of this approach earlier, you guys are gonna laugh when you see how simple this is.
#18
Ok, I've got it half working. Here is the setup:
Knock sensor -> Equalizer -> Amp -> Det phones/ECU/KNOCK Box.
Currently have a single knock sensor on the front rotor housing output to a speaker. Working through some ignition noise, need to switch to shielded cable and move the spark plug wires.
Everything is working though. The prerecorded knock I have filters nicely and makes knock obvious both by ear and by DSP, haven’t caused any knock with the new engine yet, so it’s untested in place, but the setup is the same. The ecu can be fed a knock signal, although when it's a filtered signal it has to be louder than the original (because the filter makes it quieter). I plan on tuning output volume until knock is barely audible with the ECU correcting.
The Equalizer is stereo, so running 2 knock sensors in and 1 feed out is pretty simple, also has a built in VU meter so I should be able to tell which housing is having knock. A definite upgrade for the S1 knock sensing just by having a second sensor.
Until I swap out with shielded cable this is just an elaborate set of det cans, but it is all coming together. I'll try to share what I can, but right now my time is limited and getting this project workable (ready for turbo) is more important than documenting.
Knock sensor -> Equalizer -> Amp -> Det phones/ECU/KNOCK Box.
Currently have a single knock sensor on the front rotor housing output to a speaker. Working through some ignition noise, need to switch to shielded cable and move the spark plug wires.
Everything is working though. The prerecorded knock I have filters nicely and makes knock obvious both by ear and by DSP, haven’t caused any knock with the new engine yet, so it’s untested in place, but the setup is the same. The ecu can be fed a knock signal, although when it's a filtered signal it has to be louder than the original (because the filter makes it quieter). I plan on tuning output volume until knock is barely audible with the ECU correcting.
The Equalizer is stereo, so running 2 knock sensors in and 1 feed out is pretty simple, also has a built in VU meter so I should be able to tell which housing is having knock. A definite upgrade for the S1 knock sensing just by having a second sensor.
Until I swap out with shielded cable this is just an elaborate set of det cans, but it is all coming together. I'll try to share what I can, but right now my time is limited and getting this project workable (ready for turbo) is more important than documenting.
#20
It's really simple to set up. You need an extra knock sensor, some shielded microphone wire, an equalizer with frequency band around 2600hz and an amplifier.
The frequency does not have to be exactly 2600 hz, but if you have 2k and 3k you want to turn both of them up and everything else down. The EQ I have has a 2.5khz band and that's the one I use. Basically you are using the equalizer as a bandpass filter.
For knock sensors, you should be able to use any flat response knock sensor. If you hook it up and you can hear if someone taps lightly on the engine when turned off then you'll be fine. I used a stock sensor because I had one laying around and I want a matched pair when I go stereo.
Since our engines are so quiet at this frequency range it only becomes loud at higher loads or when knock is happening. So I'm going to leave this feature in and have an audible indication of low level knock. It provides an extra level of fail-safe just being able to hear what the engine is doing.
The frequency does not have to be exactly 2600 hz, but if you have 2k and 3k you want to turn both of them up and everything else down. The EQ I have has a 2.5khz band and that's the one I use. Basically you are using the equalizer as a bandpass filter.
For knock sensors, you should be able to use any flat response knock sensor. If you hook it up and you can hear if someone taps lightly on the engine when turned off then you'll be fine. I used a stock sensor because I had one laying around and I want a matched pair when I go stereo.
Since our engines are so quiet at this frequency range it only becomes loud at higher loads or when knock is happening. So I'm going to leave this feature in and have an audible indication of low level knock. It provides an extra level of fail-safe just being able to hear what the engine is doing.
#21
OK, so with shielded cable it is perfect. Low level knock is easily distinguishable, and the filtered output is quiet enough the rest of the time to just leave the speaker going. I would have posted sooner, but I haven't had time to get much done. When I get a chance to take some recordings I'll let you guys hear what the filtered and unfiltered output sounds like. This is so easy to do, and so effective everyone running a boosted engine should have one.
Thread
Thread Starter
Forum
Replies
Last Post