Page 3 of 3
Re: Speedo out erratic
Posted: Sat Feb 01, 2014 10:59 am
by tobmag
Lance.
Done some testing now on the bench disabeling the input masking and only using odd values.
I also tested using the VSS out from the trans stim.
Unfortunatly there are no changes, my speedo still stops at 140kph...
Did also run some sweeps with the signal generator rather then sitting on a fixed hz but no luck with that either.
Tried using sine, square and triangle wave, no change.
Did play around with the pp Voltage while using sine wave and also different duty cycles in square wave....no change.
BR//Tobmag
Re: Speedo out erratic
Posted: Sat Feb 01, 2014 1:05 pm
by Bernard Fife
Tobmag,
Okay, it sounds like your issue isn't caused by the colliding interrupts as I proposed.
I haven't been able to duplicate your issue on my bench yet, but I will try to do that as soon as I have a test setup running again.
It does strike me as possible that the kph/mph calculations may be mixed up, and when you set 250 kph you may actually get 155 limit (which is close enough to 140 to warrant a little suspicion) so I will check that out as well (even though it is unlikely).
Lance.
Re: Speedo out erratic
Posted: Sat Feb 01, 2014 1:24 pm
by Bernard Fife
Tobmag,
When you say the speed stops at 140 kph, do you mean the MShift speedo in TS, or the vehicle speedo you are driving with the speedo output? I suspect it is the second.
However, I am now seeing missing pulses as you indicated on my bench with your MSQ (but not with the default settings) so that is encouraging as it gives me something to test with. I will dig into this and let you know when I have found the problem.
Lance.
Re: Speedo out erratic
Posted: Sat Feb 01, 2014 2:29 pm
by Bernard Fife
Tobmag,
I see what is going on. I have a fix to implement, and I will explain more when I have working code for you to try (hopefully shortly, as soon as I stop kicking myself in the head for missing something so obvious!

).
Lance.
Re: Speedo out erratic
Posted: Sat Feb 01, 2014 3:01 pm
by Bernard Fife
Tobmag,
Here is 4.137 code/ini for you to try:
S19 posted at:
http://www.msgpio.com/manuals/mshift/fi ... 37.abs.s19 (right click and 'Save As')
INI posted at:
http://www.msgpio.com/manuals/mshift/fi ... t_4137.ini (right click and 'Save As')
The problem was a simple one: the code uses the pin for PWM in various modes. The speedo output was done simply by toggling the PWM duty cycle between zero and the full period (100%). That meant the pin timer mode didn't have to be changed when switching from PWM function to the speedo function. However (and this is what I neglected)
the 'problem' is that the PWM timer ports are controlled by hardware and they can ONLY be switched on or off on the half-cycles. The default frequency for PWM pin 4 is about 98 hertz, and that limited the max frequency for the speedo toggling to ~196 Hertz (which is just over 140 kph with your parameters). Higher frequencies miss the ideal switching time by more and more, so the output gets slower rather than faster (i.e. there is an interference effect between the PWM frequency and the speedo output frequency).
This is fixed in the attached code. The speedo output is set-up as a digital switch when the speedo mode is selected, and the pin is immediately switched directly in the VSS timer. I have tested this with your MSQ, and it appears to work well on my scope (up to 400+ Hz).
The only downside is that the controller must be re-booted when switching to or from speedo mode (this could have been avoided by increasing the pin frequency, but that really only shifts the problem to a higher speed, etc., and it likely would have come up again for another user).
Give this code a whirl and let me know if it still doesn't seem right to you. If it does seem to work, I will release it after some more testing.
And thanks for keeping me 'honest' on this, sometimes I wander too far down the wrong path!
Lance.
Re: Speedo out erratic
Posted: Sun Feb 02, 2014 12:12 pm
by tobmag
Lance.
Once again we have a winner.
Been doing some testing and its workig just fine now.
Im very pleased that we or actually you could solve this one as well.
I was a bit confused as well when I was testing the output signal with the scope, it wouldnt read the speedo frequency and the more I cranked up the VSS speed it seemed that nothing happend with the speedo output. I should need to adjust the time devider as the hz goes up but it seemed stuck.
I thought this was related to my USD150 USB oscillioscope not beeing fast enough...
Thanks Lance.
Re: Speedo out erratic
Posted: Sun Feb 02, 2014 12:28 pm
by Bernard Fife
Tobmag,
Yeah, this was a tough one to find (but easy to fix).
For a long time I thought it must be a timer interrupt interference issue (which looks just like the problem we were having, except that it should happen worst at one speed, and be better on either side of that, not increasingly worse at higher speeds).
I couldn't really see what was going on until I used quite extreme input frequencies, then I could see bursts of output signals at regular intervals, then nothing for a bit of time, then another burst, etc. That got me thinking more about interference, and since you had shown it couldn't be the longer timer interrupts (by testing at odd frequencies that weren't multiples of 10,100,etc. msecs), it had to be something else.
I finally recalled about the PWM limiting the switching frequency when I read a note I had made in comments in the code way back when the code was written. All the other output ports can be switched as often as the code allows (24 million times a second, in theory) and I wrote the speedo output code so long ago (several years) that I forgot about that limitation until I finally read the comments (which weren't in the speedo output code, but rather in the PWM configuration code).
And with the default parameters (or any values close), it takes about 320 mph to reach the critical frequency, which is likely why no-one was seeing or reporting this before now.
I really appreciate you taking the time to dig into this and getting it sorted with me - the code is better in a some important ways, and it wouldn't have happened without you!
Lance.
Re: Speedo out erratic
Posted: Sat Feb 08, 2014 12:10 am
by tobmag
I really appreciate you taking the time to dig into this and getting it sorted with me - the code is better in a some important ways, and it wouldn't have happened without you!
I've learned a lot during this time as well and at the sime time I find this very satisfying that we can get things to work in a smooth way.
BR//Tobmag