[rusEfi] '03 Miata with VVT #28

Your chance to introduce yourself and your vehicle
User avatar
AndreyB
Site Admin
Posts: 14292
Joined: Wed Aug 28, 2013 1:28 am
Location: Jersey City
Github Username: rusefillc
Slack: Andrey B

Re: '03 Miata with VVT #28

Post by AndreyB »

10ms is used in case of 0 period setting

Code: Select all

int dt = maxI(10, engineConfiguration->auxPidDT[0]);
Looks like https://github.com/rusefi/rusefi/issues/341 fix was not a success?

https://github.com/rusefi/rusefi/issues/393 code is ready need to test
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
puff
contributor
contributor
Posts: 2961
Joined: Mon Nov 11, 2013 11:28 am
Location: Moskau

Re: '03 Miata with VVT #28

Post by puff »

Is there a way to extract the leftover data from the flash after it has been accidentally erased? This might provide some hints on the nature of that bug. Might be it is erased in some pattern? (E.g., just one sector?)
User avatar
AndreyB
Site Admin
Posts: 14292
Joined: Wed Aug 28, 2013 1:28 am
Location: Jersey City
Github Username: rusefillc
Slack: Andrey B

Re: '03 Miata with VVT #28

Post by AndreyB »

puff wrote:Is there a way to extract the leftover data from the flash after it has been accidentally erased?
A custom version of firmware would be needed since default firmware would reset itself if an error is detected.
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
stefanst
contributor
contributor
Posts: 703
Joined: Wed Feb 17, 2016 12:24 am
Location: USA 08530

Re: '03 Miata with VVT #28

Post by stefanst »

russian wrote:10ms is used in case of 0 period setting

Code: Select all

int dt = maxI(10, engineConfiguration->auxPidDT[0]);

Thanks- I think 10ms is definitely fast enough.
russian wrote: Looks like https://github.com/rusefi/rusefi/issues/341 fix was not a success?
Unfortunately not. But on the bright side, we're getting pretty good at reproducing it. So testing of fixes may be easier :D
russian wrote: https://github.com/rusefi/rusefi/issues/393 code is ready need to test
I'll drive home on the old code, since I would like to get there. But I should be able to test the new code after dinner.
User avatar
kb1gtt
contributor
contributor
Posts: 3758
Joined: Tue Sep 10, 2013 1:42 am
Location: ME of USA

Re: '03 Miata with VVT #28

Post by kb1gtt »

I fixed some things on my horrible wiki page. So it kind of now works. I have some equations and some talk about OVP vs Snubber diode typologies. This page is horribly written, but it does include some math and some simulations which might be of interest for educational purposes.

https://sourceforge.net/p/daecu/wiki/Injector_driver_theory/
Welcome to the friendlier side of internet crazy :)
stefanst
contributor
contributor
Posts: 703
Joined: Wed Feb 17, 2016 12:24 am
Location: USA 08530

Re: '03 Miata with VVT #28

Post by stefanst »

Thanks for the info!

On to the next subject- VVT:
I downloaded the latest and greatest. To jump right to the ending: It didn't work.
Tunerstudio now offers me Min(v) and Max(v). I entered 26 and 39 respectively, but it didn't have any impact. debugf1 still varies between 0 and 90. I verified that the values were properly uploaded to rusefi. No dice.

Next: injector deadtime:
The VE table was near impossible to tune. It went from super-lean to super-rich with no apparent reasons. It took me a hile to figure out that the dead-time was waaay off. NB stock injectors at 13.xV have around 1.3ms or so. The table was set to 0.8.
Fixed it and now we have a much easier time tuning. I'll be going for another ride to work and back tomorrow (temperatures in the eighties- perfect for Miata-driving!) and run autotune.

I'll also try and see if reduced p-factor will help with the cold-oil oscillations. Of course with the temperatures getting up there the oil won't be all that cold...

Edit: Log uploaded for your viewing pleasure.
Attachments
2017-04-10_19.52.42.msl
(5.42 MiB) Downloaded 720 times
User avatar
AndreyB
Site Admin
Posts: 14292
Joined: Wed Aug 28, 2013 1:28 am
Location: Jersey City
Github Username: rusefillc
Slack: Andrey B

Re: '03 Miata with VVT #28

Post by AndreyB »

stefanst wrote: I downloaded the latest and greatest. To jump right to the ending: It didn't work.
Maybe fixed now.

Looking for full CurrentTune.msq, will hard-code better defaults for set engine_type 47.
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
stefanst
contributor
contributor
Posts: 703
Joined: Wed Feb 17, 2016 12:24 am
Location: USA 08530

Re: '03 Miata with VVT #28

Post by stefanst »

Here's the current tune.

A few words of warning:
  • VVT PID is still oscillating somewhat, especially with cold oil.
  • VVT target table is not tuned for power at all- juts something we found on the internet
  • Alternator control is not as stable as I would like to see.
  • Ignition table is for 93 Octane or better only. And it may still cause knock- haven't verified
  • VE table needs more tuning
  • Accel enrichment is completely untuned
On the positive side: The car feels better than stock. The stock tune is just so incredibly safe that it sucks all the fun right out of the car. Stock lambda is between 9 and 10 at full throttle and timing is very conservative. But of course "feels better than stock" is mighty subjective.
Attachments

[The extension msq has been deactivated and can no longer be displayed.]

User avatar
kb1gtt
contributor
contributor
Posts: 3758
Joined: Tue Sep 10, 2013 1:42 am
Location: ME of USA

Re: '03 Miata with VVT #28

Post by kb1gtt »

Perhaps something to consider, perhaps dithering the control signal might help. With cold oil you might be faced with some hysteresis. Hysteresis could cause mean that when you command it to go to say 0% to 50%, it only gets to 40%. Or if you go from say 100% to 50% it only gets to 60%. This can cause a bunch of problems for you PID. However if you command 50%, then your output is 40% for like 5mS, and 60% for 5mS, the average is 50%. However this dithering commonly removes the hysteresis.

Is there a way to verify that your valve is reaching where you are commanding it to go? I suspect part of your tuning is that at low temp, when you command it to go to a position, that position is different when it is warm.

Also how fast does this need to react? Is 10mS perhaps to fast? Perhaps change that to 100mS, or 500mS.
Welcome to the friendlier side of internet crazy :)
DaWaN
Posts: 51
Joined: Sat Sep 20, 2014 6:54 pm
Location: Benschop, Netherlands

Re: '03 Miata with VVT #28

Post by DaWaN »

kb1gtt wrote:Perhaps something to consider, perhaps dithering the control signal might help. With cold oil you might be faced with some hysteresis. Hysteresis could cause mean that when you command it to go to say 0% to 50%, it only gets to 40%. Or if you go from say 100% to 50% it only gets to 60%. This can cause a bunch of problems for you PID. However if you command 50%, then your output is 40% for like 5mS, and 60% for 5mS, the average is 50%. However this dithering commonly removes the hysteresis.

Is there a way to verify that your valve is reaching where you are commanding it to go? I suspect part of your tuning is that at low temp, when you command it to go to a position, that position is different when it is warm.

Also how fast does this need to react? Is 10mS perhaps to fast? Perhaps change that to 100mS, or 500mS.
I would say 10mS is a bit too fast. I am not an expert on control engineering at all, but at 1000 RPM the cam only swings around 8.3 times a second. If I am not mistaken the cam has 3 tooth, so at 1000 rpm you only get an update of the cam position every 40 milliseconds. I think updating the PID loop has no real sense when no new input is available.

The valve might also have some dependency on battery voltage. And then there could be dependencies on oil viscosity and pressure. So yeah, VVT is kind of a complicated system :)
stefanst
contributor
contributor
Posts: 703
Joined: Wed Feb 17, 2016 12:24 am
Location: USA 08530

Re: '03 Miata with VVT #28

Post by stefanst »

Thanks for all the input everybody. Unfortunately I was unable to download the latest firmware version, so the permissible range for my PID loop was still 0-90.
I did however play with the parameters a bit and now we have a much more stable control loop, but also more sluggish reaction. Full log of morning commute is attached.
I changed:

P: 2 ->1
I: 0.005 ->0.02
D: 0 ->5

The issue is now that in some cases "I" is the party most responsible for driving the loop and that slows things waaaaay down. So that's not going to work. See picture below.
This is what's happening:
  • We command a jump from 5.5deg to 30deg (green line).
  • This causes a huge difference between commanded and actual value, so P (not graphed) and I (yellow line) go up up up.
  • At the peak I is at 55 and total is at 78.
  • Now we overshoot the target and hit 47deg advance. Didn't even know that was possible!
  • Now the difference between commanded value and actual is -15.
  • With I still sitting at 46 and offset being 32, there's not much that P can do to get us back on target.
  • We have to wait until I gets back down to a reasonable range before the actuator starts moving again.
VVT_Overshoot.png
VVT_Overshoot.png (21.17 KiB) Viewed 14360 times
So I need to go back to more "P" and less "I" in order to get rid of this type behavior. I think I'll go back to the old values, but slow the loop down to only run every 100ms. This should help avoid "I" going crazy based on outdated information.

Of course trying to tune a VE table while your intake cam is at random positions is not guaranteed to yield great results. I'm quite happy with the full-throttle parts I was able to tune, but part throttle and the low MAP region are still very very wonky.
Attachments
2017-04-11_08.39.04.msl
(5.98 MiB) Downloaded 792 times
stefanst
contributor
contributor
Posts: 703
Joined: Wed Feb 17, 2016 12:24 am
Location: USA 08530

Re: '03 Miata with VVT #28

Post by stefanst »

I almost forgot: Shutting down after autotune caused another complete loss of settings. 3 strikes!
stefanst
contributor
contributor
Posts: 703
Joined: Wed Feb 17, 2016 12:24 am
Location: USA 08530

Re: '03 Miata with VVT #28

Post by stefanst »

Tried timebase 100ms and VVT went crazy. Set it back to 0. We still get oscillations with sudden commanded jumps for VVT angle. So I set the "D" to 5. Maybe that slows things down a bit.

Also: Strike 4 for losing the firmware. Again, autotuning and shutting down the engine.
User avatar
AndreyB
Site Admin
Posts: 14292
Joined: Wed Aug 28, 2013 1:28 am
Location: Jersey City
Github Username: rusefillc
Slack: Andrey B

Re: '03 Miata with VVT #28

Post by AndreyB »

stefanst wrote:Strike 4 for losing the firmware. Again, autotuning and shutting down the engine.
4 our of how many shutting down engine with autotune? What is the ratio?

I will build a custom version of firmware which does not reset to default automatically - this should help isolate the issue.
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: 14292
Joined: Wed Aug 28, 2013 1:28 am
Location: Jersey City
Github Username: rusefillc
Slack: Andrey B

Re: '03 Miata with VVT #28

Post by AndreyB »

russian wrote:I will build a custom version of firmware which does not reset to default automatically - this should help isolate the issue.
http://rusefi.com/temp/no_auto_reset.zip

No idea how exactly it would behave with a damanged config, maybe a red light and no start?

The idea is to damage config and then read flash into a file so that we can compare corrupted file with normal file, and see what exactly is not well.
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
stefanst
contributor
contributor
Posts: 703
Joined: Wed Feb 17, 2016 12:24 am
Location: USA 08530

Re: '03 Miata with VVT #28

Post by stefanst »

Good news everyone: My VE table is getting better and better. The secret is: Turn off autotune auto-updating!
I was running autotune in "update controller" mode where autotune constantly updates the ECU. I think we have some misunderstanding between Tunerstudio and rusefi. Tunerstudio (autotune) assumes that updates are being sent to the ECU instnatly and works under the assumption that the ECU is running at the same values as displayed in the updated TS table. It appears that the update from TS to rusefi does not happen all that often. The problem?
Here's the problem with that:
Assume the car is running steady-state. Let's say we're maintaining 2000rpm and 50kpa. It's running lean- AFR is 19. So, autotune decides we need to increase VE. It increases VE by a certain value. It checks again and, because the ECU has not yet been updated with the new VE value, the engine is still running lean. So autotune thinks we need to increase the VE even more. And so forth and so forth. At some point the VE is ridiculously high and NOW autotune finally updates the ECU and we're going super-rich. Fail!

This is not so bad if we're in a dynamic situation where we never stay in one cell for long. But since Accel-enrichment wasn't tuned yet, I tried to operate steady-state as much as I could, not realizing that this is a bad thing. And that really messed up my tune!

On the modified FW: I'll see if I can try tomorrow. Time is getting kind of short before my vacation.

VVT: I was running FW 20170410_2241 and we still have no enforced min/max for the Aux_PID values.
User avatar
AndreyB
Site Admin
Posts: 14292
Joined: Wed Aug 28, 2013 1:28 am
Location: Jersey City
Github Username: rusefillc
Slack: Andrey B

Re: '03 Miata with VVT #28

Post by AndreyB »

Just please post your final tune before the vacation! :)
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
stefanst
contributor
contributor
Posts: 703
Joined: Wed Feb 17, 2016 12:24 am
Location: USA 08530

Re: '03 Miata with VVT #28

Post by stefanst »

Took the '03 for another drive to work this morning with corrected fuel tables. It's starting to look better and better. I'm still not certain why I get lower AFRs in the morning with cold air than driving at noon with warmer air. Cold air should make it leaner. The only reasonable explanation to me are injector dead-time and fuel density.

Loss of firmware:
This morning I decided not to run autotune and just take a log to run through my own autotuning software (I import the log into a database and do some math and export a new VE table). And even without running autotune I just had another loss of firmware. I did, however, change some values at the beginning of my ride while the engine was running, so we still had some buffered writes that may have screwed things up.

VVT:
Started up with the old values: P-I-D: 2 - 0.005 - 0 and immediately had wildly oscillating VVT-angles, as expected. Did a little fiddling with "D" and with a "D" of "1" we seem to get reasonably stable reactions and do achieve the targeted cam-angle in a reasonable amount of time. We still get a little oscillation after any quick change in commanded value- basically we get some over- and undershoots, but then we settle in to a degree. There's still more jitter than I would like though. This is at least somewhat acceptable. I'd call it "good enough for now- re-visit later".

There was one interesting behavior on the commanded VVT-angle that appears to be an undocumented software feature:
The top-row in my target-angle table was at 85kpa. When driving 'within' the table, the commanded VVT-angle 3D-interpolated smoothly between the actual base-points. When driving off the table, meaning a MAP of >85kpa, the commanded VVT-angle suddenly made jumps. Let's say we have a value of 28* at 2500rpm and 33* at 3000rpm, the commanded value (red line in the lower graph) would jump from 28* to 33* exactly when accelerating past 3000rpm.

This is what a jumping commanded VVT-angle looks like:
VVT_Jumping.png
VVT_Jumping.png (19.65 KiB) Viewed 14327 times
In order to put a bandaid on that, I decided to just raise the MAP on the upper row of the commanded VVT-angle to 120kpa, a value we won't reach without forced induction, and voila- now we're interpolating. This log was taken on the same stretch of road, today:
VVT_Interpolating.png
VVT_Interpolating.png (20.18 KiB) Viewed 14327 times
stefanst
contributor
contributor
Posts: 703
Joined: Wed Feb 17, 2016 12:24 am
Location: USA 08530

Re: '03 Miata with VVT #28

Post by stefanst »

Looks like I just slaughtered my 3rd brainboard!
I wanted to take the car for spin at lunch to test if the latest version of the FW has limits on the Aux_PID algorithm, test my latest VE table and play with the Aux_PID values.
Uplaoding hte latest FW worked without a hitch. Power-down the ECU. Then I hooked up Tunerstudio and uplaoded the latest changes to the tune. Turned off the ignition and unplugged the laptop. Turned the ignition back on and no blinky blue light. No communication with TS either. Start up console- no comm. So I thought maybe FW got corrupted. Uploaded the previous version FW- no problem. Still no blinky blue light and no communication. Reboot laptop just to make sure- nothing.

Luckily the stock ECU is still installed and working. I'll probably have to start driving around with pre-flashed spare brainboards.

There is one weird issue going on with my install that has been happening from day1, which may or may not have to do with this:
When I plug the serial comm cable (micro USB) into my laptop, the frankenso is not powered, which is the correct behavior. Then I turn on the ignition, frankenso gets powered via 12V and comes online. When I turn off the ignition on the car with the micro-USB connected to the laptop, my main relay, which is controlled by frankenso, stays on and my frankenso stays powered. I can pull the ignition key and my ECU still gets power and my WBO2, which gets power from the main relay, also stays on. If I pull the micro-USB cable from the frankenso everything turns off. The engine shuts off of course, since the ignition coils are powered from the ignition switch.
So how does my USB cable function to keep the ECU powered and with that the main relay engaged? FYI: frankenso gets 12V directly from the ignition switch and not the main relay (it does control the main relay). But there are some sensors and actuators that get powered by the main relay and are controlled by frankenso, like the VVT and IAC valves/solenoids. Maybe we're feeding power back to the board from them? But then how does my USB cable, which AFAIK only carries GND, 5V and signal (5V is not connected I believe) , keep the power to the board on?
Am I feeding power trough USB signal wires and that messes up my electronics on the brainboard? @: does your '03 have the same "feature"?
User avatar
AndreyB
Site Admin
Posts: 14292
Joined: Wed Aug 28, 2013 1:28 am
Location: Jersey City
Github Username: rusefillc
Slack: Andrey B

Re: '03 Miata with VVT #28

Post by AndreyB »

stefanst wrote:@: does your '03 have the same "feature"?
No.

Just verified with my red 2003.

Ignition key on, Frankenso not connected to laptop in any way: fast blue blinking. dash shows a couple of lights.
Connecting to laptop via microUSB to get virtual USB serial port - laptop makes the "device connected" noise
turn ignition key off - dash goes down, laptop makes "device disconnected" noise, Frankenso is completely dark

I used to have a back-feeding problem via IAC but that was while I was connecting IAC to ignition +12v instead of main relay +12 - that's because my diodes are on Frankenso and there was no "main relay +12" on Frankenso. I've since added a "main relay +12" wire and this is resolved.

I know your diodes are on the connector and I believe you had this issue even before adding the diodes. Does your IAC go to the right power source? Does your VVT go to the right power source?

I am going to document +12 wires better on http://rusefi.com/wiki/index.php?title=Vehicle:Mazda_Miata_2002 and http://rusefi.com/wiki/index.php?title=Vehicle:Mazda_Miata_2003 since I am finishing my new Frankenso harness which needs to work on both my 2002 and 2003 cars.
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
stefanst
contributor
contributor
Posts: 703
Joined: Wed Feb 17, 2016 12:24 am
Location: USA 08530

Re: '03 Miata with VVT #28

Post by stefanst »

russian wrote:
stefanst wrote:@: does your '03 have the same "feature"?
I know your diodes are on the connector and I believe you had this issue even before adding the diodes. Does your IAC go to the right power source? Does your VVT go to the right power source?
I think you hit it on the nose! I'm pretty sure I have them wired to the main relay (white/red wire). So this could be the way the power comes back to the board. Once the main relay is engaged it powers the board through some backdoor and that keeps the main relay engaged.
Not sure what the contribution of my USB cable to all this is though.
stefanst
contributor
contributor
Posts: 703
Joined: Wed Feb 17, 2016 12:24 am
Location: USA 08530

Re: '03 Miata with VVT #28

Post by stefanst »

Here's my latest tune. Quite happy with how the VE table is performing at this point. This latest VE table was not confirmed yet, but only represents small, AFR-based changes from the last known good version, so I'm fairly confident it's going to be OK. Ignition table is reasonable, but I wouldn't run it on anything less than 93 octane.
Still not 100% happy about VVT control-ability.
Attachments

[The extension msq has been deactivated and can no longer be displayed.]

User avatar
AndreyB
Site Admin
Posts: 14292
Joined: Wed Aug 28, 2013 1:28 am
Location: Jersey City
Github Username: rusefillc
Slack: Andrey B

Re: '03 Miata with VVT #28

Post by AndreyB »

set engine_type 47 should now match your config with exception if weird VVT position mismatch and a few micro-differences where I believe set engine_type 47 is more correct than your current config. Can you try & migrate if looks right? Or tell me what have I missed :)
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
Post Reply