Controlling stock oil temp gauge

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • george graves
    I waste 90% of my day here and all I got was this stupid title
    • Oct 2003
    • 19986

    #16
    An inductor type sensor....sure!!!!!! Never mind me.
    Originally posted by Matt-B
    hey does anyone know anyone who gets upset and makes electronics?

    Comment

    • BeirBrennerE30
      R3VLimited
      • Oct 2003
      • 2740

      #17
      Originally posted by bmwman91
      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.
      e30sport.net
      '86 325es - s54b32tu - 6-speed - Mtech 1
      '89 325is - m20b25 - 5-speed - Individual​
      '06 M3 Competition - 6-speed
      '19 Porsche GT3 RS - 7-speed PDK
      '94 Lancia Delta HF Integrale EvoII - Giallo Ginestra
      '97 Range Rover Vitesse

      Comment

      • bmwman91
        No R3VLimiter
        • Oct 2004
        • 3128

        #18
        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, 10:50 PM.

        Transaction Feedback: LINK

        Comment

        • BeirBrennerE30
          R3VLimited
          • Oct 2003
          • 2740

          #19
          Originally posted by bmwman91
          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.
          Last edited by BeirBrennerE30; 11-19-2018, 08:21 AM.
          e30sport.net
          '86 325es - s54b32tu - 6-speed - Mtech 1
          '89 325is - m20b25 - 5-speed - Individual​
          '06 M3 Competition - 6-speed
          '19 Porsche GT3 RS - 7-speed PDK
          '94 Lancia Delta HF Integrale EvoII - Giallo Ginestra
          '97 Range Rover Vitesse

          Comment

          • bmwman91
            No R3VLimiter
            • Oct 2004
            • 3128

            #20
            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.

            Transaction Feedback: LINK

            Comment

            • BeirBrennerE30
              R3VLimited
              • Oct 2003
              • 2740

              #21
              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
              '86 325es - s54b32tu - 6-speed - Mtech 1
              '89 325is - m20b25 - 5-speed - Individual​
              '06 M3 Competition - 6-speed
              '19 Porsche GT3 RS - 7-speed PDK
              '94 Lancia Delta HF Integrale EvoII - Giallo Ginestra
              '97 Range Rover Vitesse

              Comment

              • george graves
                I waste 90% of my day here and all I got was this stupid title
                • Oct 2003
                • 19986

                #22
                Originally posted by BeirBrennerE30
                The AVR micro I am using is doing a decent amount.
                What are you programming it in? C/avrdude or ?
                Originally posted by Matt-B
                hey does anyone know anyone who gets upset and makes electronics?

                Comment

                • BeirBrennerE30
                  R3VLimited
                  • Oct 2003
                  • 2740

                  #23
                  Originally posted by george graves
                  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.
                  e30sport.net
                  '86 325es - s54b32tu - 6-speed - Mtech 1
                  '89 325is - m20b25 - 5-speed - Individual​
                  '06 M3 Competition - 6-speed
                  '19 Porsche GT3 RS - 7-speed PDK
                  '94 Lancia Delta HF Integrale EvoII - Giallo Ginestra
                  '97 Range Rover Vitesse

                  Comment

                  • bmwman91
                    No R3VLimiter
                    • Oct 2004
                    • 3128

                    #24
                    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, 11:01 AM.

                    Transaction Feedback: LINK

                    Comment

                    • BeirBrennerE30
                      R3VLimited
                      • Oct 2003
                      • 2740

                      #25
                      Thank you for the info. I will play around with it.
                      e30sport.net
                      '86 325es - s54b32tu - 6-speed - Mtech 1
                      '89 325is - m20b25 - 5-speed - Individual​
                      '06 M3 Competition - 6-speed
                      '19 Porsche GT3 RS - 7-speed PDK
                      '94 Lancia Delta HF Integrale EvoII - Giallo Ginestra
                      '97 Range Rover Vitesse

                      Comment

                      Working...