![]() |
![]() |
#16 |
I waste 90% of my day here and all I got was this stupid title
Join Date: Oct 2003
Location: Seattle, WA
Posts: 19,803
|
An inductor type sensor....sure!!!!!! Never mind me.
|
![]() |
![]() |
![]() |
#17 | |
R3VLimited
|
Quote:
__________________
e30sport.net '15 Porsche GT3 - 7-speed PDK - Daily Driver '86 325es - s54b32tu - 6-speed - Mtech 1 '89 325is - m20b25 - 5-speed - Individual |
|
![]() |
![]() |
![]() |
#18 |
R3VLimited
Join Date: Oct 2004
Location: South Bay Area
Posts: 2,244
|
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 at 11:50 PM. |
![]() |
![]() |
![]() |
#19 | |
R3VLimited
|
Quote:
__________________
e30sport.net '15 Porsche GT3 - 7-speed PDK - Daily Driver '86 325es - s54b32tu - 6-speed - Mtech 1 '89 325is - m20b25 - 5-speed - Individual Last edited by BeirBrennerE30; 11-19-2018 at 09:21 AM. |
|
![]() |
![]() |
![]() |
#20 |
R3VLimited
Join Date: Oct 2004
Location: South Bay Area
Posts: 2,244
|
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. |
![]() |
![]() |
![]() |
#21 |
R3VLimited
|
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 down
__________________
e30sport.net '15 Porsche GT3 - 7-speed PDK - Daily Driver '86 325es - s54b32tu - 6-speed - Mtech 1 '89 325is - m20b25 - 5-speed - Individual |
![]() |
![]() |
![]() |
#22 |
I waste 90% of my day here and all I got was this stupid title
Join Date: Oct 2003
Location: Seattle, WA
Posts: 19,803
|
What are you programming it in? C/avrdude or ?
|
![]() |
![]() |
![]() |
#23 |
R3VLimited
|
C with avrdude. I have never used Arduino or anything like. C works just fine for me.
__________________
e30sport.net '15 Porsche GT3 - 7-speed PDK - Daily Driver '86 325es - s54b32tu - 6-speed - Mtech 1 '89 325is - m20b25 - 5-speed - Individual |
![]() |
![]() |
![]() |
#24 |
R3VLimited
Join Date: Oct 2004
Location: South Bay Area
Posts: 2,244
|
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 at 12:01 PM. |
![]() |
![]() |
![]() |
#25 |
R3VLimited
|
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 |
![]() |
![]() |
![]() |
Thread Tools | Search this Thread |
|
|