R3VLimited Forums

Go Back   R3VLimited Forums > E30 Technical Forums > Car Audio & Electronics

Reply
 
Thread Tools Search this Thread
Old 11-12-2018, 04:20 AM   #16
george graves
I waste 90% of my day here and all I got was this stupid title
 
george graves's Avatar
 
Join Date: Oct 2003
Location: Seattle, WA
Posts: 19,792
An inductor type sensor....sure!!!!!! Never mind me.
__________________
Quote:
Originally Posted by Matt-B View Post
hey does anyone know anyone who gets upset and makes electronics?
george graves is offline   Reply With Quote
Old 11-13-2018, 08:53 AM   #17
BeirBrennerE30
R3VLimited
 
BeirBrennerE30's Avatar
 
Join Date: Oct 2003
Location: Bridgewater MA
Posts: 2,644
Send a message via AIM to BeirBrennerE30
Quote:
Originally Posted by bmwman91 View Post
So 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?
Exactly the issue. One LSb change on the PWM is a big jump on the gauge on the high end.
__________________
'15 Porsche GT3 - 7-speed PDK - Daily Driver
'86 325es - s54tu - 6-speed - Mtech 1
WTB: numbers matching - black - '89 325is - m20 - 5-speed - will pay BaT market value
BeirBrennerE30 is offline   Reply With Quote
Old 11-17-2018, 11:44 PM   #18
bmwman91
R3VLimited
 
bmwman91's Avatar
 
Join Date: Oct 2004
Location: South Bay Area
Posts: 2,192
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.
bmwman91 is offline   Reply With Quote
Old 11-19-2018, 08:57 AM   #19
BeirBrennerE30
R3VLimited
 
BeirBrennerE30's Avatar
 
Join Date: Oct 2003
Location: Bridgewater MA
Posts: 2,644
Send a message via AIM to BeirBrennerE30
Quote:
Originally Posted by bmwman91 View Post
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.
Its case (b) The gauge is non-linear. I am not so concerned about jumps at the end of the range that oil temp shouldn't actually be hitting. I am more concerned about the set-up and chacking that this is a viable way to drive the gauge long term and if there is a better way.
__________________
'15 Porsche GT3 - 7-speed PDK - Daily Driver
'86 325es - s54tu - 6-speed - Mtech 1
WTB: numbers matching - black - '89 325is - m20 - 5-speed - will pay BaT market value

Last edited by BeirBrennerE30; 11-19-2018 at 09:21 AM.
BeirBrennerE30 is offline   Reply With Quote
Old 11-19-2018, 05:34 PM   #20
bmwman91
R3VLimited
 
bmwman91's Avatar
 
Join Date: Oct 2004
Location: South Bay Area
Posts: 2,192
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.
__________________
bmwman91 is offline   Reply With Quote
Old 11-20-2018, 09:27 AM   #21
BeirBrennerE30
R3VLimited
 
BeirBrennerE30's Avatar
 
Join Date: Oct 2003
Location: Bridgewater MA
Posts: 2,644
Send a message via AIM to BeirBrennerE30
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
__________________
'15 Porsche GT3 - 7-speed PDK - Daily Driver
'86 325es - s54tu - 6-speed - Mtech 1
WTB: numbers matching - black - '89 325is - m20 - 5-speed - will pay BaT market value
BeirBrennerE30 is offline   Reply With Quote
Old 11-21-2018, 05:24 AM   #22
george graves
I waste 90% of my day here and all I got was this stupid title
 
george graves's Avatar
 
Join Date: Oct 2003
Location: Seattle, WA
Posts: 19,792
Quote:
Originally Posted by BeirBrennerE30 View Post
The AVR micro I am using is doing a decent amount.
What are you programming it in? C/avrdude or ?
__________________
Quote:
Originally Posted by Matt-B View Post
hey does anyone know anyone who gets upset and makes electronics?
george graves is offline   Reply With Quote
Old 11-21-2018, 08:21 AM   #23
BeirBrennerE30
R3VLimited
 
BeirBrennerE30's Avatar
 
Join Date: Oct 2003
Location: Bridgewater MA
Posts: 2,644
Send a message via AIM to BeirBrennerE30
Quote:
Originally Posted by george graves View Post
What are you programming it in? C/avrdude or ?
C with avrdude. I have never used Arduino or anything like. C works just fine for me.
__________________
'15 Porsche GT3 - 7-speed PDK - Daily Driver
'86 325es - s54tu - 6-speed - Mtech 1
WTB: numbers matching - black - '89 325is - m20 - 5-speed - will pay BaT market value
BeirBrennerE30 is offline   Reply With Quote
Old 11-21-2018, 11:55 AM   #24
bmwman91
R3VLimited
 
bmwman91's Avatar
 
Join Date: Oct 2004
Location: South Bay Area
Posts: 2,192
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.
bmwman91 is offline   Reply With Quote
Old 11-26-2018, 12:36 PM   #25
BeirBrennerE30
R3VLimited
 
BeirBrennerE30's Avatar
 
Join Date: Oct 2003
Location: Bridgewater MA
Posts: 2,644
Send a message via AIM to BeirBrennerE30
Thank you for the info. I will play around with it.
__________________
'15 Porsche GT3 - 7-speed PDK - Daily Driver
'86 325es - s54tu - 6-speed - Mtech 1
WTB: numbers matching - black - '89 325is - m20 - 5-speed - will pay BaT market value
BeirBrennerE30 is offline   Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -7. The time now is 08:59 PM.


Powered by vBulletin® Version 3.8.10
Copyright ©2000 - 2018, vBulletin Solutions, Inc.
Copyright 2004 - 2020 R3VLimited LLC