Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. The Lounge
  3. Adventures in fan control

Adventures in fan control

Scheduled Pinned Locked Moved The Lounge
helpquestion
9 Posts 5 Posters 2 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • H Offline
    H Offline
    honey the codewitch
    wrote on last edited by
    #1

    The hypothetical fan has a tach pin that pulses high twice per revolution. There are two ways to get the RPM: 1. Count the actual pulses it makes in a minute and divide by two (or a fraction of a minute and factor accordingly) 2. Count the time (in microseconds probably) between pulses and use that to extrapolate the RPM. There are 6e+7 microseconds in a minute, so working with that, you divide it by twice the duration of the pulse. 2 has an obvious advantage in that it doesn't require you to sample for a significant period of time before you get a value. In fact, you can get a value each revolution since there are two pulses. The problem with 2 is it doesn't work? My RPMs come back as like 5-7 on a 1700RPM fan being run at full power. I've had other people eyeball my code and my math. There's nothing wrong with it. So I've got some sort of theory of operation problem. You'd think a fan would be relatively simple, but it stumped me.

    To err is human. Fortune favors the monsters.

    OriginalGriffO R CPalliniC P 4 Replies Last reply
    0
    • H honey the codewitch

      The hypothetical fan has a tach pin that pulses high twice per revolution. There are two ways to get the RPM: 1. Count the actual pulses it makes in a minute and divide by two (or a fraction of a minute and factor accordingly) 2. Count the time (in microseconds probably) between pulses and use that to extrapolate the RPM. There are 6e+7 microseconds in a minute, so working with that, you divide it by twice the duration of the pulse. 2 has an obvious advantage in that it doesn't require you to sample for a significant period of time before you get a value. In fact, you can get a value each revolution since there are two pulses. The problem with 2 is it doesn't work? My RPMs come back as like 5-7 on a 1700RPM fan being run at full power. I've had other people eyeball my code and my math. There's nothing wrong with it. So I've got some sort of theory of operation problem. You'd think a fan would be relatively simple, but it stumped me.

      To err is human. Fortune favors the monsters.

      OriginalGriffO Offline
      OriginalGriffO Offline
      OriginalGriff
      wrote on last edited by
      #2

      Overflow? Clock tick period? If this is shorter than you expected, you will get silly results if you try to time between two consecutive pulses. If the rising edge isn't high / sharp enough, it could be triggering early or late? But of course, sticking a scope probe on the pulse may change the results ... :-D

      "I have no idea what I did, but I'm taking full credit for it." - ThisOldTony "Common sense is so rare these days, it should be classified as a super power" - Random T-shirt AntiTwitter: @DalekDave is now a follower!

      "I have no idea what I did, but I'm taking full credit for it." - ThisOldTony
      "Common sense is so rare these days, it should be classified as a super power" - Random T-shirt

      H 1 Reply Last reply
      0
      • OriginalGriffO OriginalGriff

        Overflow? Clock tick period? If this is shorter than you expected, you will get silly results if you try to time between two consecutive pulses. If the rising edge isn't high / sharp enough, it could be triggering early or late? But of course, sticking a scope probe on the pulse may change the results ... :-D

        "I have no idea what I did, but I'm taking full credit for it." - ThisOldTony "Common sense is so rare these days, it should be classified as a super power" - Random T-shirt AntiTwitter: @DalekDave is now a follower!

        H Offline
        H Offline
        honey the codewitch
        wrote on last edited by
        #3

        I check the overflow condition by short circuiting with an early return if old_tick_us is greater than tick_us if that makes sense. In that case I just don't use that reading. I've verified I'm getting the ticks because I've tried #1. I've even tried taking a sample only every ten revolutions (20 ticks) and counting the duration between that and the initial tick and I don't get better results - can't remember what they were and I'm getting a friend's help to test since I don't currently have a power supply that can run a fan - one is on order. Edit:

        OriginalGriff wrote:

        If the rising edge isn't high / sharp enough, it could be triggering early or late?

        I missed this somehow when I first read your post. Interesting. The only thing that makes me doubt it is the RPM readings I'm getting are so bloody low - single digits when they should be four digits. It makes me think there's a deeper issue.

        To err is human. Fortune favors the monsters.

        1 Reply Last reply
        0
        • H honey the codewitch

          The hypothetical fan has a tach pin that pulses high twice per revolution. There are two ways to get the RPM: 1. Count the actual pulses it makes in a minute and divide by two (or a fraction of a minute and factor accordingly) 2. Count the time (in microseconds probably) between pulses and use that to extrapolate the RPM. There are 6e+7 microseconds in a minute, so working with that, you divide it by twice the duration of the pulse. 2 has an obvious advantage in that it doesn't require you to sample for a significant period of time before you get a value. In fact, you can get a value each revolution since there are two pulses. The problem with 2 is it doesn't work? My RPMs come back as like 5-7 on a 1700RPM fan being run at full power. I've had other people eyeball my code and my math. There's nothing wrong with it. So I've got some sort of theory of operation problem. You'd think a fan would be relatively simple, but it stumped me.

          To err is human. Fortune favors the monsters.

          R Offline
          R Offline
          Rich Leyshon
          wrote on last edited by
          #4

          Not knowing what hardware you are using, just a thought that maybe irrelevant - but have you got any components (capacitors/inductors that in conjunction with resistors or internal resistance of other components) that may have accidentally created a filter that is tuned to roughly the frequency you would be expecting and either attenuating the signal or passing it to ground? Maybe an idea to use an optical isolator to separate the output signal totally from the inductive load of the fan motor???

          H 1 Reply Last reply
          0
          • R Rich Leyshon

            Not knowing what hardware you are using, just a thought that maybe irrelevant - but have you got any components (capacitors/inductors that in conjunction with resistors or internal resistance of other components) that may have accidentally created a filter that is tuned to roughly the frequency you would be expecting and either attenuating the signal or passing it to ground? Maybe an idea to use an optical isolator to separate the output signal totally from the inductive load of the fan motor???

            H Offline
            H Offline
            honey the codewitch
            wrote on last edited by
            #5

            I do share a ground with the fan but they are on a different power supply than the MCU that is taking the reading. There aren't any components in the circuit other than a level shifter, which I know can handle these frequencies because I routinely use them with I2C devices. Edit: I should add, I am getting all the ticks because method #1 in my original post works.

            To err is human. Fortune favors the monsters.

            1 Reply Last reply
            0
            • H honey the codewitch

              The hypothetical fan has a tach pin that pulses high twice per revolution. There are two ways to get the RPM: 1. Count the actual pulses it makes in a minute and divide by two (or a fraction of a minute and factor accordingly) 2. Count the time (in microseconds probably) between pulses and use that to extrapolate the RPM. There are 6e+7 microseconds in a minute, so working with that, you divide it by twice the duration of the pulse. 2 has an obvious advantage in that it doesn't require you to sample for a significant period of time before you get a value. In fact, you can get a value each revolution since there are two pulses. The problem with 2 is it doesn't work? My RPMs come back as like 5-7 on a 1700RPM fan being run at full power. I've had other people eyeball my code and my math. There's nothing wrong with it. So I've got some sort of theory of operation problem. You'd think a fan would be relatively simple, but it stumped me.

              To err is human. Fortune favors the monsters.

              CPalliniC Offline
              CPalliniC Offline
              CPallini
              wrote on last edited by
              #6

              Can't you just output the duration between pulses, in order to discriminate between a measure error or computation error?

              "In testa che avete, Signor di Ceprano?" -- Rigoletto

              In testa che avete, signor di Ceprano?

              H 1 Reply Last reply
              0
              • CPalliniC CPallini

                Can't you just output the duration between pulses, in order to discriminate between a measure error or computation error?

                "In testa che avete, Signor di Ceprano?" -- Rigoletto

                H Offline
                H Offline
                honey the codewitch
                wrote on last edited by
                #7

                The only reason I haven't done that yet - admittedly part of it is laziness - is it complicates the code and I'm not sure what readings I should be expecting as I have no practical concept of a microsecond vs a spinning fan.

                To err is human. Fortune favors the monsters.

                CPalliniC 1 Reply Last reply
                0
                • H honey the codewitch

                  The only reason I haven't done that yet - admittedly part of it is laziness - is it complicates the code and I'm not sure what readings I should be expecting as I have no practical concept of a microsecond vs a spinning fan.

                  To err is human. Fortune favors the monsters.

                  CPalliniC Offline
                  CPalliniC Offline
                  CPallini
                  wrote on last edited by
                  #8

                  You should get about 18 msec for 1700 rpm (about 6 sec for 5 rpm).

                  "In testa che avete, Signor di Ceprano?" -- Rigoletto

                  In testa che avete, signor di Ceprano?

                  1 Reply Last reply
                  0
                  • H honey the codewitch

                    The hypothetical fan has a tach pin that pulses high twice per revolution. There are two ways to get the RPM: 1. Count the actual pulses it makes in a minute and divide by two (or a fraction of a minute and factor accordingly) 2. Count the time (in microseconds probably) between pulses and use that to extrapolate the RPM. There are 6e+7 microseconds in a minute, so working with that, you divide it by twice the duration of the pulse. 2 has an obvious advantage in that it doesn't require you to sample for a significant period of time before you get a value. In fact, you can get a value each revolution since there are two pulses. The problem with 2 is it doesn't work? My RPMs come back as like 5-7 on a 1700RPM fan being run at full power. I've had other people eyeball my code and my math. There's nothing wrong with it. So I've got some sort of theory of operation problem. You'd think a fan would be relatively simple, but it stumped me.

                    To err is human. Fortune favors the monsters.

                    P Offline
                    P Offline
                    Phil Hodgkins
                    wrote on last edited by
                    #9

                    If method 1 works and method 2 does not, then there is either an error in the time recorded or an error in the maths. You should be getting about 17000 microseconds between pulses. How many did you get? (60s/1700 rpm = 0.035 s per rotation = 17000 microseconds per 1/2 rotation)

                    1 Reply Last reply
                    0
                    Reply
                    • Reply as topic
                    Log in to reply
                    • Oldest to Newest
                    • Newest to Oldest
                    • Most Votes


                    • Login

                    • Don't have an account? Register

                    • Login or register to search.
                    • First post
                      Last post
                    0
                    • Categories
                    • Recent
                    • Tags
                    • Popular
                    • World
                    • Users
                    • Groups