This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

Wind speed sensor question

I am using the C51 compiler and have code for the silabs C8051F120.

I have built a wind speed sensor with a rotary encoder but it seems to top out at 42mph. I know there have been gusts greater than that since I started using it.

I have considered calibrating the unit with an automobile and think i may be missing edges of the encoder signal because of processing overhead. I think the encoder counter routine should be interrupt driven.

My coworker Frisky suggested the circuitry is not able to handle fast counting signals coming from sensor and said that the 2nd problem circuitry should be analyzed.

Does anyone have an idea why that might happen?

Parents
  • Broken code!

    First off: Don't use any floating point numbers to count integers. It takes time and makes the code big.

    Second, you should be looking for a transition from one state to another, either low-to-high or high-to-low depending on polarity of the pulse. Your code do not look for such a transition. It counts time in one state. You may count the same pulse multiple times.

    When polling, you must compare the current pin state with the previous.

    However, the above can not be your code, since it does not read any wind speed, only the total number of pulses. Real code must count number of pulses for a specific time interval. Always post the real code if you want help!

    Another thing: Are the pulses really of fixed length? If using an opto-coupler or a mechanical switch, the pulse length will vary with the rotation speed. If you have electronics that shapes the pulse to a fixed length, then you automatically get a limit to the number of pulses you can process in a second. A pulse length of 22ms means that it isn't possible to receive more than 45 pulses/second. At higher pulse speed, the pulses will float together in a continuous signal.

Reply
  • Broken code!

    First off: Don't use any floating point numbers to count integers. It takes time and makes the code big.

    Second, you should be looking for a transition from one state to another, either low-to-high or high-to-low depending on polarity of the pulse. Your code do not look for such a transition. It counts time in one state. You may count the same pulse multiple times.

    When polling, you must compare the current pin state with the previous.

    However, the above can not be your code, since it does not read any wind speed, only the total number of pulses. Real code must count number of pulses for a specific time interval. Always post the real code if you want help!

    Another thing: Are the pulses really of fixed length? If using an opto-coupler or a mechanical switch, the pulse length will vary with the rotation speed. If you have electronics that shapes the pulse to a fixed length, then you automatically get a limit to the number of pulses you can process in a second. A pulse length of 22ms means that it isn't possible to receive more than 45 pulses/second. At higher pulse speed, the pulses will float together in a continuous signal.

Children