Knock windowing code discussion
Posted: Thu Apr 24, 2008 5:49 pm
I've just been chattering about knock with a few people off line and whilst thinking about windowing came up with a neat algorithm to do it cleanly.
Given the assumption that you are after knock and not pre-ignition which is a fair one IMO you can unmask an interrupt pin on each ignition event such that a signal can be received, and then if you get that interrupt, check you are within the prescribed window, and if you don't, it doesn't matter. in either case, you turn the interrupt off again until the next ignition event if you are hit. if you aren't hit it doesn't matter, if you are, you get at max one interrupt per spark which is acceptable and possible. in the case where you are inside the window, you set variables such that the next ignition calc pulls timing, and even remove some timing from the existing calcs such that if the calcs are a bit behind timing is pulled sooner.
These are just random thoughts that I just had this instant, so there could be flaws, point them out and discuss!
Admin.
Given the assumption that you are after knock and not pre-ignition which is a fair one IMO you can unmask an interrupt pin on each ignition event such that a signal can be received, and then if you get that interrupt, check you are within the prescribed window, and if you don't, it doesn't matter. in either case, you turn the interrupt off again until the next ignition event if you are hit. if you aren't hit it doesn't matter, if you are, you get at max one interrupt per spark which is acceptable and possible. in the case where you are inside the window, you set variables such that the next ignition calc pulls timing, and even remove some timing from the existing calcs such that if the calcs are a bit behind timing is pulled sooner.
These are just random thoughts that I just had this instant, so there could be flaws, point them out and discuss!
Admin.