An inductor type sensor....sure!!!!!! Never mind me.
Announcement
Collapse
No announcement yet.
Controlling stock oil temp gauge
Collapse
X
-
Originally posted by bmwman91 View PostSo at the high temperature end, due to the non-linear transfer function, a one LSb change in the oil temperature value leads to a large jump in the PWM duty cycle / needle position? If so, there are a couple of fairly easy solutions since the needle is a relatively slow device (compared to the 100ms sampling period of the input).
What type of microcontroller are you using?e30sport.net
'15 Porsche GT3 - 7-speed PDK - Daily Driver
'86 325es - s54b32tu - 6-speed - Mtech 1
'89 325is - m20b25 - 5-speed - Individual
Comment
-
Just to be crystal clear, which LSb is the root cause of the sensitivity?
a) CAN temperature value changes one LSb, which maps to a jump of many counts of the PWM duty cycle for high temperatures
b) A change of one LSb of the PWM duty cycle, at high temperatures, makes the gauge jump
Case (a) seems like the more likely culprit. Also, what is the PWM frequency?
If it is case (a), then your only good option is interpolation between PWM duty cycles for the current and previous CAN values, maybe even requiring a moving-average of more than just the last 2 values. If case (b), then you would need to do something similar to the solution for (a), but implemented as a dithering function to interleave the previous and new LSb value fast enough to not show up in the needle.Last edited by bmwman91; 11-17-2018, 11:50 PM.
Comment
-
Originally posted by bmwman91 View PostJust to be crystal clear, which LSb is the root cause of the sensitivity?
a) CAN temperature value changes one LSb, which maps to a jump of many counts of the PWM duty cycle for high temperatures
b) A change of one LSb of the PWM duty cycle, at high temperatures, makes the gauge jump
Case (a) seems like the more likely culprit. Also, what is the PWM frequency?
If it is case (a), then your only good option is interpolation between PWM duty cycles for the current and previous CAN values, maybe even requiring a moving-average of more than just the last 2 values. If case (b), then you would need to do something similar to the solution for (a), but implemented as a dithering function to interleave the previous and new LSb value fast enough to not show up in the needle.Last edited by BeirBrennerE30; 11-19-2018, 09:21 AM.e30sport.net
'15 Porsche GT3 - 7-speed PDK - Daily Driver
'86 325es - s54b32tu - 6-speed - Mtech 1
'89 325is - m20b25 - 5-speed - Individual
Comment
-
You could switch to a microcontroller with higher PWM resolution. Microchip dsPIC's are cheap, easy to work with and can easily provide 16b PWM resolution. Otherwise, you can try a PWM dithering scheme if you want to avoid jumps, although it sounds like you are not expecting to ever really have the oil temperature that high. Dithering would mean alternating between the new and old duty cycles rapidly, and linearly changing from 0% new duty cycle to 100% new duty cycle. If your PWM frequency is in the kHz, it would be plenty fast to make it appear smooth on the slow gauge. It's a good amount of additional code, but if this is the only thing that your microcontroller is doing, it should be pretty easy.
Your method seems like a perfectly good way of driving the gauge; it is simple and does not seem to pose any risks to anything.
Comment
-
The AVR micro I am using is doing a decent amount. Reading from a CANbus, controlling 4 7seg LED displays over i2c and reading sensor data from a ADC over i2c, monitoring the light circuit for at night dimming, and data logging. I guess I will find out if adding this will slow everything downe30sport.net
'15 Porsche GT3 - 7-speed PDK - Daily Driver
'86 325es - s54b32tu - 6-speed - Mtech 1
'89 325is - m20b25 - 5-speed - Individual
Comment
-
Originally posted by george graves View PostWhat are you programming it in? C/avrdude or ?e30sport.net
'15 Porsche GT3 - 7-speed PDK - Daily Driver
'86 325es - s54b32tu - 6-speed - Mtech 1
'89 325is - m20b25 - 5-speed - Individual
Comment
-
I think that you should be able to do this in C. ASM is probably easier, but C should be doable since it sounds like you know what you are doing. You can either use an interrupt from the timer used for the PWM DC checks (assumed in the example below), or with a really fast main loop that checks whatever PWM/CCP status flags indicate where in the output period you are. You would want to change the register holding the DC (which some timer is compared against) close to the beginning of the output-active part of the period so that the timer will then get compared against the new value during that same cycle. So, you need to be updating the PWM DC register at the same rate as the PWM frequency.
Example using some guessed numbers:
If you wanted to get even fancier, you could spread out the new-DC transition pulses over the 31-pulse step (space them out inside the step, rather than having all of the new pulses accumulate at the end). This would eat a lot more instruction cycles, though, and probably not confer any practical benefit since the gauge needle is pretty slow by comparison.Last edited by bmwman91; 11-21-2018, 12:01 PM.
Comment
-
Thank you for the info. I will play around with it.e30sport.net
'15 Porsche GT3 - 7-speed PDK - Daily Driver
'86 325es - s54b32tu - 6-speed - Mtech 1
'89 325is - m20b25 - 5-speed - Individual
Comment
Comment