Notices
Series I Engine Tuning Forum EMS (Flash Tuning, Interceptor, Piggy Back, Stand Alone)

Introducing The Blue Knock Box.

Thread Tools
 
Search this Thread
 
Rate Thread
 
Old 05-14-2013, 12:29 PM
  #1  
Registered
Thread Starter
iTrader: (3)
 
Harlan's Avatar
 
Join Date: Mar 2011
Location: Bay City Tx
Posts: 1,041
Likes: 0
Received 3 Likes on 2 Posts
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.
Attached Files
File Type: zip
Bluebox2WIP.zip (2.0 KB, 330 views)
Old 05-14-2013, 05:00 PM
  #2  
Registered
iTrader: (3)
 
olddragger's Avatar
 
Join Date: Apr 2004
Location: macon, georgia
Posts: 10,828
Likes: 0
Received 38 Likes on 27 Posts
guys--this will be so sweet. And yes- i do think it can save boosted engines.
Old 05-14-2013, 05:03 PM
  #3  
Registered
iTrader: (15)
 
paimon.soror's Avatar
 
Join Date: Jun 2010
Location: Between Cones
Posts: 7,560
Received 25 Likes on 23 Posts
nice work sir! if you need any help with arduino coding, feel free to field some questions my way and I can try to help. The RxDuino is entirely coded in Arduino compliant code.
Old 05-14-2013, 05:24 PM
  #4  
SARX Legend
iTrader: (46)
 
9krpmrx8's Avatar
 
Join Date: Jan 2007
Location: San Antonio, Texas
Posts: 33,784
Received 452 Likes on 366 Posts
Good stuff, let's see how it works out.
Old 05-14-2013, 07:53 PM
  #5  
Registered
Thread Starter
iTrader: (3)
 
Harlan's Avatar
 
Join Date: Mar 2011
Location: Bay City Tx
Posts: 1,041
Likes: 0
Received 3 Likes on 2 Posts
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.
Old 05-14-2013, 09:23 PM
  #6  
SARX Legend
iTrader: (46)
 
9krpmrx8's Avatar
 
Join Date: Jan 2007
Location: San Antonio, Texas
Posts: 33,784
Received 452 Likes on 366 Posts
Well, I can test it on a boosted application if needed. Preventing knock is a good thing, Are you still turbocharging your 8?
Old 05-17-2013, 11:19 AM
  #7  
Registered
Thread Starter
iTrader: (3)
 
Harlan's Avatar
 
Join Date: Mar 2011
Location: Bay City Tx
Posts: 1,041
Likes: 0
Received 3 Likes on 2 Posts
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.
Old 05-26-2013, 10:31 AM
  #8  
Registered
iTrader: (1)
 
r0tor's Avatar
 
Join Date: May 2003
Location: PA
Posts: 3,754
Likes: 0
Received 0 Likes on 0 Posts
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.
Old 05-27-2013, 09:56 AM
  #9  
Registered
Thread Starter
iTrader: (3)
 
Harlan's Avatar
 
Join Date: Mar 2011
Location: Bay City Tx
Posts: 1,041
Likes: 0
Received 3 Likes on 2 Posts
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.
Old 05-27-2013, 11:07 AM
  #10  
Registered
iTrader: (1)
 
r0tor's Avatar
 
Join Date: May 2003
Location: PA
Posts: 3,754
Likes: 0
Received 0 Likes on 0 Posts
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.
Old 06-23-2013, 01:04 PM
  #11  
Registered
 
mperformance's Avatar
 
Join Date: Jun 2008
Posts: 87
Likes: 0
Received 0 Likes on 0 Posts
Interesting
Old 06-30-2013, 11:57 AM
  #12  
Good Morning Gremlin!
iTrader: (2)
 
Brandonien's Avatar
 
Join Date: May 2009
Location: Petawawa and Ottawa
Posts: 218
Likes: 0
Received 0 Likes on 0 Posts
If you can pull off this awesome project I would very much like one, this would be awesome!
Old 06-30-2013, 01:36 PM
  #13  
weeeeeeeeee
iTrader: (12)
 
ShellDude's Avatar
 
Join Date: Jun 2008
Location: Outside Philadelphia
Posts: 4,200
Received 229 Likes on 153 Posts
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.

Last edited by ShellDude; 06-30-2013 at 01:38 PM.
Old 07-01-2013, 04:09 PM
  #14  
Registered
Thread Starter
iTrader: (3)
 
Harlan's Avatar
 
Join Date: Mar 2011
Location: Bay City Tx
Posts: 1,041
Likes: 0
Received 3 Likes on 2 Posts
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.
Old 04-04-2014, 07:50 PM
  #15  
Registered
Thread Starter
iTrader: (3)
 
Harlan's Avatar
 
Join Date: Mar 2011
Location: Bay City Tx
Posts: 1,041
Likes: 0
Received 3 Likes on 2 Posts
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.
Attached Files
Old 04-11-2014, 01:07 PM
  #16  
The Stink w.o The Sause
iTrader: (5)
 
stinksause's Avatar
 
Join Date: Jun 2009
Location: North DE
Posts: 2,448
Likes: 0
Received 2 Likes on 2 Posts
I wish I had the skills to do this ... major props to you, sir
Old 05-14-2014, 04:34 PM
  #17  
Registered
Thread Starter
iTrader: (3)
 
Harlan's Avatar
 
Join Date: Mar 2011
Location: Bay City Tx
Posts: 1,041
Likes: 0
Received 3 Likes on 2 Posts
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.
Old 05-20-2014, 07:44 PM
  #18  
Registered
Thread Starter
iTrader: (3)
 
Harlan's Avatar
 
Join Date: Mar 2011
Location: Bay City Tx
Posts: 1,041
Likes: 0
Received 3 Likes on 2 Posts
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.
Old 05-20-2014, 10:16 PM
  #19  
Driving my unreliable rx8
 
logalinipoo's Avatar
 
Join Date: Oct 2012
Location: Alvarado, Tx
Posts: 2,051
Received 5 Likes on 5 Posts
lol, My turbo is getting very close and I'd really like to have something like this to see how it works.
Old 05-21-2014, 02:48 PM
  #20  
Registered
Thread Starter
iTrader: (3)
 
Harlan's Avatar
 
Join Date: Mar 2011
Location: Bay City Tx
Posts: 1,041
Likes: 0
Received 3 Likes on 2 Posts
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.
Old 06-04-2014, 08:57 PM
  #21  
Registered
Thread Starter
iTrader: (3)
 
Harlan's Avatar
 
Join Date: Mar 2011
Location: Bay City Tx
Posts: 1,041
Likes: 0
Received 3 Likes on 2 Posts
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.
Related Topics
Thread
Thread Starter
Forum
Replies
Last Post
BillBertelli
NE For Sale/Wanted
4
03-19-2016 03:01 PM
UnrealOne
RX-8's For Sale/Wanted
2
09-30-2015 11:04 AM
DeltaJ802
RX-8 Discussion
3
09-29-2015 01:20 PM
wayloco
RX-8's For Sale/Wanted
0
09-01-2015 09:03 PM



You have already rated this thread Rating: Thread Rating: 0 votes,  average.

Quick Reply: Introducing The Blue Knock Box.



All times are GMT -5. The time now is 10:45 PM.