work in progress hip9011 integration

It's all about the code!
Spilly
contributor
contributor
Posts: 64
Joined: Thu Jul 31, 2014 11:30 pm

Re: hip9011 integration

Post by Spilly »

russian wrote:
Spilly wrote:I'm used to configuring I/O in source code for the microcontroller. The requirement to set the I/O in Tuner Studio took me a while to figure out.
Technically you can define everything via the source code - see dodge_neon.cpp for example, see http://rusefi.com/wiki/index.php?title=Manual:Engine_Type
Yet again my lack of experience with projects of this scale and using eclipse was the issue. I wasn't digging deep enough into the code to figure out how to set I/O in the source code.
russian wrote:I also need to shoot a video of how I test this on a bench so that you maybe would clarify what I do wrong, because I do not understand part of what's going on.
I would be happy to take a look. You can imitate your knock sensor with a function generator. Just set the function generator to output a sine wave at the same frequency as your engine's resonant knock frequency.

If you don't have a function generator, you can use your computer as a function generator with audacity (http://web.audacityteam.org/). Audacity will let you create a tone at a specific frequency. You will need to cut up a headphone cable in order to wire your computer's audio output jack to the TPIC/HIP input.

I made a few changes so that once the knock output level is greater than a user configurable threshold level ignition advance is decreased. Also, the user can configure a maximum amount of ignition advance that can be subtracted while knocking.

My current implementation is a fairly crude way of doing this but it's a start.

advance_map.cpp


engine.h


hardware.cpp


HIP9011.cpp


HIP9011.h


I will update this thread with more information later. My eyeballs are turning to mush from staring at this screen all day.
Spilly
contributor
contributor
Posts: 64
Joined: Thu Jul 31, 2014 11:30 pm

Re: hip9011 integration

Post by Spilly »

Here is a patch for today. I will be updating this post with information on the changes later tonight.

Patch


Edit:
External knock sensor adc calculated voltage, TPIC8101 digital integrator, and HIP9011 adc calculated voltage are all referenced against the same configurable threshold.

Each consecutive engine cycle that knock occurs, one degree of ignition advance is removed. Ignition advance is decreased until the configured maximum value is reached. If knock previously occurred, and the engine goes one cycle with no knock, one degree of ignition advance is added. Ignition advance is added when not knocking until the initial (before knocking) ignition advance is reached.

If a HIP9011 is being used, the set_knock_ic dev console command must be used. By default the TPIC8101 is enabled.
set_knock_ic 0 = HIP9011 (looks at adc for knock control)
set_knock_ic 1 = TPIC8101 (looks at digital integrator value)

To set the minimum voltage threshold for a knock event, the set_knock_threshold dev console command must be used. The default value is 4.0 volts.

To set the maximum number of degrees of ignition advance that can be removed while knocking, the set_max_knock_sub_deg dev console command must be used. The default value is 20.0 degrees

In the next few days I plan to make the knock control a PI (proportional and integral) control loop. The information used in this control loop will most likely be based the amplitude of the knock signal and the number of engine cycles.

I need to learn how the offsets in the tunerstudio files work, so can make these additions accessible through TS.

If anyone has any suggestions, please let me know.
User avatar
AndreyB
Site Admin
Posts: 14727
Joined: Wed Aug 28, 2013 1:28 am
Location: Jersey City
Github Username: rusefillc
Slack: Andrey B

Re: hip9011 integration

Post by AndreyB »

That's some cool progress :)

I've moved some of the fields into the configuration & explained what I did @ http://rusefi.com/forum/viewtopic.php?f=5&t=10&p=15698#p15698 and commited the knock logic.

Did not merge the digital output yet, need some sleep and then I will read it,

Thank you a _lot_!
Very limited telepathic abilities - please post logs & tunes where appropriate - http://rusefi.com/s/questions

Always looking for C/C++/Java/PHP developers! Please help us see https://rusefi.com/s/howtocontribute
User avatar
kb1gtt
contributor
contributor
Posts: 3777
Joined: Tue Sep 10, 2013 1:42 am
Location: ME of USA

Re: hip9011 integration

Post by kb1gtt »

Some suggestions,

Decrease the angle by the 1 degree rate as you are doing, but increase at .1 or some smaller amount. This helps minimize the knocking.

Also I understand the ambient noise will vary with engine RPM, which means if you tuned your knock at say 2kRPM, you may be backing off the timing erroneously at 5kRPM, as it will be noisier as the lifters and such are making more noise. I suggest creating an ambient noise floor table based on at least RPM, perhaps based on load, as well. Then decrease if you are blah above that noise floor.

I understand flat tappet cam's will look very much like a ping. Windowing can help with this, but you might also need to change the window as you increase RPM. The valves with springs can add a specific time delay from when the CAM releases the valve, which can stretch out the angle when the noise happens. Especially if they start to do that high rev vibration thing. So it would probably be cool if the window could be varied based on RPM and perhaps load.

Keep up the good work, and thanks for the contributions.
Welcome to the friendlier side of internet crazy :)
Spilly
contributor
contributor
Posts: 64
Joined: Thu Jul 31, 2014 11:30 pm

Re: hip9011 integration

Post by Spilly »

kb1gtt wrote:Some suggestions,

Decrease the angle by the 1 degree rate as you are doing, but increase at .1 or some smaller amount. This helps minimize the knocking.

Also I understand the ambient noise will vary with engine RPM, which means if you tuned your knock at say 2kRPM, you may be backing off the timing erroneously at 5kRPM, as it will be noisier as the lifters and such are making more noise. I suggest creating an ambient noise floor table based on at least RPM, perhaps based on load, as well. Then decrease if you are blah above that noise floor.

I understand flat tappet cam's will look very much like a ping. Windowing can help with this, but you might also need to change the window as you increase RPM. The valves with springs can add a specific time delay from when the CAM releases the valve, which can stretch out the angle when the noise happens. Especially if they start to do that high rev vibration thing. So it would probably be cool if the window could be varied based on RPM and perhaps load.

Keep up the good work, and thanks for the contributions.
Do you think it would be overkill to implement two configurable multipliers, one for decreasing timing while knocking and the other for increasing while not knocking.

The noise floor is something I have been pondering. I have seen the lookup table solution before and if the engine's ambient noise is consistent for a given RPM, that should work fine. Constantly normalizing the noise floor should take care of inconsistencies.

However, I'm interested to see if we even need to adjust triggering parameters with RPM. The other algorithms I have seen for the TPIC8101 and the HIP9011 use fixed time constants. To see why this is a bad idea, give TPIC/HIP a constant input from a function generator and then vary the RPM (varying the RPM changes the integration time). If the time constant from the TPIC/HIP is fixed, the output will vary dramatically with RPM. If the time constant is adjusted appropriately with RPM, the output from the TPIC/HIP will be fairly consistent. You can prevent the time constant from being changed by disconnecting the SCK, SDI, or CS lines or making changes to the source code.

Variable valve timing and and the situations you explained make a varying window a must.
Spilly
contributor
contributor
Posts: 64
Joined: Thu Jul 31, 2014 11:30 pm

Re: hip9011 integration

Post by Spilly »

russian wrote:That's some cool progress :)

I've moved some of the fields into the configuration & explained what I did @ http://rusefi.com/forum/viewtopic.php?f=5&t=10&p=15698#p15698 and commited the knock logic.

Did not merge the digital output yet, need some sleep and then I will read it,

Thank you a _lot_!
Thanks! I will try to get a better understanding of it in the morning.
User avatar
AndreyB
Site Admin
Posts: 14727
Joined: Wed Aug 28, 2013 1:28 am
Location: Jersey City
Github Username: rusefillc
Slack: Andrey B

Re: hip9011 integration

Post by AndreyB »

Spilly wrote:set_knock_ic 0 = HIP9011 (looks at adc for knock control)
set_knock_ic 1 = TPIC8101 (looks at digital integrator value)
I've changed this part a bit, the commands are
enable tpic_advanced_mode
disable tpic_advanced_mode
enable knockdebug
disable knockdebug

added to http://rusefi.com/wiki/index.php?title=Manual:Software:dev_console_commands#Knock_Detection
Very limited telepathic abilities - please post logs & tunes where appropriate - http://rusefi.com/s/questions

Always looking for C/C++/Java/PHP developers! Please help us see https://rusefi.com/s/howtocontribute
DaWaN
Posts: 51
Joined: Sat Sep 20, 2014 6:54 pm
Location: Benschop, Netherlands

Re: hip9011 integration

Post by DaWaN »

Spilly wrote: However, I'm interested to see if we even need to adjust triggering parameters with RPM. The other algorithms I have seen for the TPIC8101 and the HIP9011 use fixed time constants. To see why this is a bad idea, give TPIC/HIP a constant input from a function generator and then vary the RPM (varying the RPM changes the integration time). If the time constant from the TPIC/HIP is fixed, the output will vary dramatically with RPM. If the time constant is adjusted appropriately with RPM, the output from the TPIC/HIP will be fairly consistent. You can prevent the time constant from being changed by disconnecting the SCK, SDI, or CS lines or making changes to the source code.
The sound of knock has little to do with a function generator creating a constant tone during the knock watch window.
Of course this will yield different integration results as the window for higher RPM is much smaller compared to lower RPM.

I actually wonder whether there is actually so much of a difference in acoustic energy compared to RPM. I think it is more related to the amount of torque and in general that is kind of flat over RPM.
A knock event is one uncontrolled combustion and will not generate a constant tone during the knock window. Remember the knock frequency is already fixed over RPM!
I think you should base the implementation on either recorded engine knock sounds over a wide RPM range or some sort of paper showing actually measured data and not on a function generator generating a constant tone.
User avatar
kb1gtt
contributor
contributor
Posts: 3777
Joined: Tue Sep 10, 2013 1:42 am
Location: ME of USA

Re: hip9011 integration

Post by kb1gtt »

This page includes the audio signal captured from a knock sensor. http://home.netcom.com/~bsundahl/knock/sound/KnockSounds.htm#Knock
Welcome to the friendlier side of internet crazy :)
User avatar
AndreyB
Site Admin
Posts: 14727
Joined: Wed Aug 28, 2013 1:28 am
Location: Jersey City
Github Username: rusefillc
Slack: Andrey B

Re: hip9011 integration

Post by AndreyB »

[video][/video]
Very limited telepathic abilities - please post logs & tunes where appropriate - http://rusefi.com/s/questions

Always looking for C/C++/Java/PHP developers! Please help us see https://rusefi.com/s/howtocontribute
User avatar
AndreyB
Site Admin
Posts: 14727
Joined: Wed Aug 28, 2013 1:28 am
Location: Jersey City
Github Username: rusefillc
Slack: Andrey B

Re: hip9011 integration

Post by AndreyB »

[video][/video]
Very limited telepathic abilities - please post logs & tunes where appropriate - http://rusefi.com/s/questions

Always looking for C/C++/Java/PHP developers! Please help us see https://rusefi.com/s/howtocontribute
User avatar
AndreyB
Site Admin
Posts: 14727
Joined: Wed Aug 28, 2013 1:28 am
Location: Jersey City
Github Username: rusefillc
Slack: Andrey B

Re: hip9011 integration

Post by AndreyB »

kb1gtt wrote:How do you have this wired? Is that a 2 wire sensor? I think you have a 3 wire. I wonder if we are getting buggered because we followed the TPIC datasheet. Perhaps we should remove R161 and R162.
I have KS return going to GND and KS SIG is my input
Image
Very limited telepathic abilities - please post logs & tunes where appropriate - http://rusefi.com/s/questions

Always looking for C/C++/Java/PHP developers! Please help us see https://rusefi.com/s/howtocontribute
User avatar
AndreyB
Site Admin
Posts: 14727
Joined: Wed Aug 28, 2013 1:28 am
Location: Jersey City
Github Username: rusefillc
Slack: Andrey B

Re: hip9011 integration

Post by AndreyB »

Attached I believe a http://rusefi.com/wiki/index.php?title=Vehicle:Kia_Spectra_2005 OEM ECU picture, note that it uses TPIC8101

I believe ECU#54 is GND, same as TPIC#2 and TPIC#16. Resistors on top-left of TPIC are 100K, then 121K, then another 100K.
You do not have the required permissions to view the files attached to this post.
Very limited telepathic abilities - please post logs & tunes where appropriate - http://rusefi.com/s/questions

Always looking for C/C++/Java/PHP developers! Please help us see https://rusefi.com/s/howtocontribute
User avatar
AndreyB
Site Admin
Posts: 14727
Joined: Wed Aug 28, 2013 1:28 am
Location: Jersey City
Github Username: rusefillc
Slack: Andrey B

Re: hip9011 integration

Post by AndreyB »

now I need some knock, any ideas?
[video][/video]
Very limited telepathic abilities - please post logs & tunes where appropriate - http://rusefi.com/s/questions

Always looking for C/C++/Java/PHP developers! Please help us see https://rusefi.com/s/howtocontribute
User avatar
AndreyB
Site Admin
Posts: 14727
Joined: Wed Aug 28, 2013 1:28 am
Location: Jersey City
Github Username: rusefillc
Slack: Andrey B

Re: hip9011 integration

Post by AndreyB »

1.5 years in the making... we have knock detection on a real car! I need to thank everyone involved, guys, this would not happen without you :)

[video][/video]
Very limited telepathic abilities - please post logs & tunes where appropriate - http://rusefi.com/s/questions

Always looking for C/C++/Java/PHP developers! Please help us see https://rusefi.com/s/howtocontribute
Spilly
contributor
contributor
Posts: 64
Joined: Thu Jul 31, 2014 11:30 pm

Re: hip9011 integration

Post by Spilly »

russian wrote:1.5 years in the making... we have knock detection on a real car! I need to thank everyone involved, guys, this would not happen without you :)
You do not have the required permissions to view the files attached to this post.
User avatar
kb1gtt
contributor
contributor
Posts: 3777
Joined: Tue Sep 10, 2013 1:42 am
Location: ME of USA

Re: hip9011 integration

Post by kb1gtt »

Now that it's working, It's probably a good time to remind people about the stuff found here http://www.ti.com/product/TPIC8101/toolssoftware

It has some things we may have started to forget over the last long battle.
Welcome to the friendlier side of internet crazy :)
User avatar
AndreyB
Site Admin
Posts: 14727
Joined: Wed Aug 28, 2013 1:28 am
Location: Jersey City
Github Username: rusefillc
Slack: Andrey B

Re: hip9011 integration

Post by AndreyB »

kb1gtt wrote:Now that it's working, It's probably a good time to remind people about the stuff found here http://www.ti.com/product/TPIC8101/toolssoftware
What exact stuff? too much stuff there!
Very limited telepathic abilities - please post logs & tunes where appropriate - http://rusefi.com/s/questions

Always looking for C/C++/Java/PHP developers! Please help us see https://rusefi.com/s/howtocontribute
User avatar
kb1gtt
contributor
contributor
Posts: 3777
Joined: Tue Sep 10, 2013 1:42 am
Location: ME of USA

Re: hip9011 integration

Post by kb1gtt »

I would say mostly these two PDF's

http://www.ti.com/lit/ug/tidu285/tidu285.pdf
http://www.ti.com/lit/ug/tidu286/tidu286.pdf

Seems there is some math, and process flow notes that might be handy to remember now that things are working reliably.
Welcome to the friendlier side of internet crazy :)
Spilly
contributor
contributor
Posts: 64
Joined: Thu Jul 31, 2014 11:30 pm

Re: hip9011 integration

Post by Spilly »

kb1gtt wrote:I would say mostly these two PDF's

http://www.ti.com/lit/ug/tidu285/tidu285.pdf
http://www.ti.com/lit/ug/tidu286/tidu286.pdf

Seems there is some math, and process flow notes that might be handy to remember now that things are working reliably.
I believe we have the math part dialed in. Sadly I have the equations burned into the back of my skull from staring at the datasheet for this IC for almost two years.

I'm not sure if this document and research was done before or after TI started producing the TPIC. It is still an interesting read with lots of good info on knock, digital signal processing, and harmonics. http://www.ti.com/lit/an/spra039/spra039.pdf
User avatar
AndreyB
Site Admin
Posts: 14727
Joined: Wed Aug 28, 2013 1:28 am
Location: Jersey City
Github Username: rusefillc
Slack: Andrey B

Re: hip9011 integration

Post by AndreyB »

crystal hardware issue sub-thread is now http://rusefi.com/forum/viewtopic.php?f=4&t=903
logic levels hardware issue sub-thread is now http://rusefi.com/forum/viewtopic.php?f=4&t=904
Very limited telepathic abilities - please post logs & tunes where appropriate - http://rusefi.com/s/questions

Always looking for C/C++/Java/PHP developers! Please help us see https://rusefi.com/s/howtocontribute
User avatar
RasPL
Posts: 24
Joined: Thu Oct 15, 2015 6:44 pm
Location: Poland

Re: hip9011 integration

Post by RasPL »

The middle frequency of bandpass filter depends from engine geometry and is constant for all the time. You can calculate it Knock frequency (kHz) = 1800/(PI * D) where D is cylinder bore diamater in mm.
Then you need to setup up Gain parameter that You have 2.5-3V knock voltage whitout knock and Integrator value set at about 100-200uSec.
Now next parameters like knock window and knock window start - advance angle ATDC from which You start searching knock for current ignition event and the lenght of this window in Degrees or just end angle
Next thing is to build engine noise table which is just knock voltage(rpm) function
And now You are ready to calculate knock level=knock voltage(rpm) - engine noise(rpm)
From knock level depends all corrections for next ignition event at this cylinder like ignition retard,fuel addition,boost reduction.

Good to start is read MS Mega Manual or just some standalone ECU manual. Here is manual for our polish ecumaster emu standalone ECU, knock sensing pages 80-82
http://ecumasterusa.com/downloads/emu-manual.pdf

With this manual You can very easy add other functions to rusefi ECU ;)
User avatar
AndreyB
Site Admin
Posts: 14727
Joined: Wed Aug 28, 2013 1:28 am
Location: Jersey City
Github Username: rusefillc
Slack: Andrey B

Re: hip9011 integration

Post by AndreyB »

RasPL wrote:Next thing is to build engine noise table which is just knock voltage(rpm) function
This. This looks to be the part rusEfi is currently missing and this matches my experience while playing with rusEfi - I was getting higher output the higher RPMs were.

Once I add the noiseTable the last remaining part is for rusEfi to end up in hands of somebody who can definitively induce knock and test all this. It looks like rusEfi would happen once I move to nowhere and get a dyno in my 12 car garage...
Very limited telepathic abilities - please post logs & tunes where appropriate - http://rusefi.com/s/questions

Always looking for C/C++/Java/PHP developers! Please help us see https://rusefi.com/s/howtocontribute
User avatar
RasPL
Posts: 24
Joined: Thu Oct 15, 2015 6:44 pm
Location: Poland

Re: hip9011 integration

Post by RasPL »

Maybe just connect secound knock sensor to Mic input of PC/Laptop and use headphones or build/use some audio amplifier?
http://home.netcom.com/~bsundahl/knock/listen/listen.htm

here is some sound record of knocking engine
User avatar
AndreyB
Site Admin
Posts: 14727
Joined: Wed Aug 28, 2013 1:28 am
Location: Jersey City
Github Username: rusefillc
Slack: Andrey B

Re: hip9011 integration

Post by AndreyB »

russian wrote:
RasPL wrote:Next thing is to build engine noise table which is just knock voltage(rpm) function
This. This looks to be the part rusEfi is currently missing and this matches my experience while playing with rusEfi - I was getting higher output the higher RPMs were.
https://sourceforge.net/p/rusefi/tickets/228/
Very limited telepathic abilities - please post logs & tunes where appropriate - http://rusefi.com/s/questions

Always looking for C/C++/Java/PHP developers! Please help us see https://rusefi.com/s/howtocontribute
User avatar
KaxLon
Posts: 5
Joined: Fri Oct 30, 2015 2:54 pm
Location: Alingsås, Sweden

Re: hip9011 integration

Post by KaxLon »

Ok time for my first post on this forum. :)

I have been coding for the stock Mitsubishi ECU that is used in the 1G DSM and GVR4 cars. We have a knock sensor that is connected to a interface board that generates a signal for the processor to use.
The way a "standard" knock scheme works is by detecting abnormal, filtered sound levels at ignition events. The so-called event window.
For a long time there has been dispute over if we have a windowed mode ECU or not. I set out to find out lately and sure enough the knock is windowed.
I used a Arduino to generate the 6-7 kHz noise synced to the ignition event. The signal was set to the weakest possible knock detectable by the ECU.
Here's a video of the results:
Please watch in HD.

So to answer Andrey's question about how to generate knock. You can do this in many ways. Advance timing until the engine knocks, use a signal generator that has a sync trigger or by simply hooking up a Arduino to generate the noise.
.. Kim aka KaxLon ..
User avatar
AndreyB
Site Admin
Posts: 14727
Joined: Wed Aug 28, 2013 1:28 am
Location: Jersey City
Github Username: rusefillc
Slack: Andrey B

Re: hip9011 integration

Post by AndreyB »

KaxLon wrote:You can do this in many ways. Advance timing until the engine knocks
Would it knock @ idle? If not, would it knock while revving with no load? If not, would it knock at 20 mph?

At this point I am satisfied with bench testing but still do not trust my results on the vehicle.
Very limited telepathic abilities - please post logs & tunes where appropriate - http://rusefi.com/s/questions

Always looking for C/C++/Java/PHP developers! Please help us see https://rusefi.com/s/howtocontribute
User avatar
KaxLon
Posts: 5
Joined: Fri Oct 30, 2015 2:54 pm
Location: Alingsås, Sweden

Re: hip9011 integration

Post by KaxLon »

Yes you can get it to knock at idle and very light loads. The degree of timing is different depending on engine. I know there's a MIT paper on this with calculations.
When I wish to provoke knock I play with the timing and fuel settings until I see knock. Give it a shot.
Just keep in mind that if you get knock at idle you can NOT drive the car as load will make the knock even worse with risk for disaster. ;)
.. Kim aka KaxLon ..
User avatar
AndreyB
Site Admin
Posts: 14727
Joined: Wed Aug 28, 2013 1:28 am
Location: Jersey City
Github Username: rusefillc
Slack: Andrey B

Re: hip9011 integration

Post by AndreyB »

KaxLon wrote:When I wish to provoke knock I play with the timing and fuel settings until I see knock.
Can you give me at least some examples for some engine, just to know the ballpark. 40 advance & 17 AFR?

MIT paper... Any chance you point me at it? :)
Very limited telepathic abilities - please post logs & tunes where appropriate - http://rusefi.com/s/questions

Always looking for C/C++/Java/PHP developers! Please help us see https://rusefi.com/s/howtocontribute
User avatar
KaxLon
Posts: 5
Joined: Fri Oct 30, 2015 2:54 pm
Location: Alingsås, Sweden

Re: hip9011 integration

Post by KaxLon »

Hmmm I have to look for that document on my harddrives.
In the meanwhile you might enjoy this on knock and ethanol: http://www.kaxlon.com/dsmecu/2015/PDF%20Books/2008-32-0020%20Effect%20of%20Ethanol%20on%20Knock%20in%20Spark%20Ignition%20Gasoline%20Engines.pdf

LoL 40* @ AFR 17 would certainly knock. :)
.. Kim aka KaxLon ..
Post Reply