0
\$\begingroup\$

I'm trying to read the wind speed with my Raspberry Pi.

I have an anemometer that produces between 80mV and 12V AC at 0 to 125Hz (it's basically a wind turbine). I have it hooked up to an Analog-to-Digital Converter, which inputs to the RPi fine. But, when the wind gets sufficiently high, the anemometer's AC output will fry that ADC, which can only handle 3.3v (just like the RPi). Note the anemometer's voltage is not linearly proportional to wind speed, but generally increases with wind speed.

The AC frequency, however, is proportional to wind speed—that's what I'd like to measure. I'm thinking the best way to convert the frequency to a digital input my RPi can read (0/3.3v) is to use a zero-crossing circuit. An optocoupler would seem great, especially for isolating the RPi from voltages that would kill it, but they don't seem to trigger as low as 0.1v, usually more like 1.5v for the infrared LED. It might also be possible to connect the AC signal to a MOSFET, and use that to gate/un-gate a 3.3v signal that the RPi passes back to itself. A zener diode might work, but might produce significant heat to drop 12v to 3.3v, potentially 24hrs/day?

What is the right design for this zero-crossing circuit to produce a 3.3v digital output, but not ignore the (occasionally) low voltage AC input?

Thanks for the advice.

\$\endgroup\$
3
  • 1
    \$\begingroup\$ mgrocketman - Hi, (a) As you're new here, please see the tour & help center as the site rules differ from typical forums. (b) This document from the anemometer manufacturer is their (very common type of) recommendation for feeding its output to an ADC. That seems to address your initial issue of ADC interfacing, which (IIUC) caused you to look for the alternative of a low-voltage ZCD. Did you see that document? If so, please clarify why it isn't a solution, to avoid others suggesting something similar as an answer. Thanks. \$\endgroup\$ Commented Oct 15, 2023 at 2:33
  • \$\begingroup\$ Why do you think the zener clamp will fry something? It is going about low power signals only. If you are reading with adc a clamp with common diode like 1n4148 is sufficient. \$\endgroup\$ Commented Oct 15, 2023 at 3:32
  • \$\begingroup\$ @SamGibson I missed that document, thanks for citing it. It would have solved my problem, but the op amp comparator circuit below is a better solution altogether. \$\endgroup\$ Commented Oct 16, 2023 at 23:07

2 Answers 2

0
\$\begingroup\$

That's the job for the comparator or Opamp (connected as comparator). Take some low power rail-to-rail variant (for example cheap opamp MCP6002). Supply it by unipolar 3.3V from your RPi.

schematic

Image source: BrainKart.com - Linear Integrated Circuits : Application of Op-Amp, Zero Crossing Detector: {Sine wave to Square wave converter}

Add about "2V" zener diode to opamp noninverting input (-), righ from R resistor (Anode to GND, Cathode to opamp input) to protect opamps inputs. Select R to few tens KOhm to limit current. Resistors R2 and R1 create hysteresis shifting threshold level from 0V to some small positive voltage to fight with input noise. For 40mV hysteresis you can choose R2=33k and R1=390R. Omit RL. Output will be regular 3.3V signal. About 0V when input is above "zero" and 3.3V when input is below "zero".

\$\endgroup\$
2
  • \$\begingroup\$ Thanks for the explanation. Two questions. #1: Did you select 2v zener diode just because it's arbitrarily between 40mV and 3.3V? Could it also be a 3.3V zener diode? and #2: AnalogKid pointed out that their circuit's impedance would decrease the frequency of the anemometer signal, injecting error into the system. I believe this is also true for the zener/opamp circuit you've suggested? \$\endgroup\$ Commented Oct 16, 2023 at 22:30
  • \$\begingroup\$ #1 Choice was arbitrary. 3V3 zener will have knee higher then 3.3V. You should to pick Zener diode which has voltage <=3.3V at current I=(Vinmax-Vzener)/R. Simply - zener is "soft" at its zener votlage is current dependent. #2 There should be none or minimal frequency dependency in range of hundered Hz. \$\endgroup\$ Commented Oct 18, 2023 at 12:24
0
\$\begingroup\$

Since you are interested only in frequency, and your system already handles the signal when it is at its lowest values, then the only problem is sawing off (clipping) the tops of the signal when it is above 3 V. This can be done with 1 resistor and 1 zener diode.

The resistor is in series between the sensor output and the uC input. The zener diode is in shunt across the uC input to GND. Connect the cathode to GND and the anode to the A/D input, where the series resistor is.

Heat is not a problem. You don't say if the "12 Vac" is RMS, peak, peak-to-peak, centered about GND (both positive- and negative-going), 0 to 12 V, etc. Let's assume one of the worst cases, that the signal is 12 Vac RMS, centered about GND.

With a fixed zener diode value, the power dissipated in the resistor and zener is set by the resistor value. Start with a zener value of 3.0 V. The input impedance of the uC A/D input is very high, and the zener diode does not conduct until the input is above 3 V above GND, or 0.7 V below GND. For a first-order approximation, we will average the two resistor voltages (9 V and 11.3 V) for a resistor voltage of approx. 10.15 V RMS-ish; call it 10.2 V

With a 1 K resistor the worst case power dissipation is just 104 mW in the resistor, and much less in the zener. A 1/4 W axial resistor will be barely warm.

Because the input impedance of the A/D is much higher than the resistor value, the resistor has very little effect on the signal amplitude seen by the A/D input when the zener is not conducting. For example, if the input impedance is 100 K, then the 1K resistor in series with it decreases the signal amplitude by approx. 1%.

Note - if the anemometer is a simple AC generator, then the impedance its output sees will affect how hard it is to turn, injecting an error term into the system. For this reason, the added series resistor should be as high as possible because all of the current going through the resistor when the zener is conducting comes from the generator. The sensor might come with a spec for a recommend loading value, or minimum load value, or something like that.

O O O O O K K K K K

After writing all of that, I read the Interfacing app note. On page 1 is the recommended interface circuit that has a resistor in series with two clipping diodes. A single zener diode will do the same thing as the two diodes they show. Because you already have a uC, A/D, and software that works at the lowest signal voltage, you do not need an external comparator circuit. You would need one if the sensor signal were going to anything that requires "a logic-compatible digital signal" such as a frequency counter or a digital GPIO pin, or but you are not doing that.

https://www.nrgsystems.com/assets/resources/an40C-IF3-interface.pdf

I'm not impressed with the tech data. I couldn't find a wiring diagram that shows how many wires go to the sensor and what they do. For example, if the sensor is powered and has an output signal driver rather than the bare generator outputs, that makes things much easier.

\$\endgroup\$
3
  • \$\begingroup\$ Thanks for the detailed response. I'm going to use the opamp comparator circuit instead to get digital output and remove the need for an ADC altogether, but your circuit would still work, and your explanation was helpful. \$\endgroup\$ Commented Oct 16, 2023 at 22:59
  • \$\begingroup\$ It still is unclear to me - when the sensor out 1s 80 mVac, is that swinging from 0 V to +80 mV, or +/-40 mV centered about GND? \$\endgroup\$ Commented Oct 16, 2023 at 23:43
  • \$\begingroup\$ I'm honestly not sure what the spec sheet means by 80mV AC and 12V AC. I assumed the worst case, that it meant the anemometer output swinging from -12v to +12v in high wind speeds. The spec sheet does say "12 V (peak-to-peak) typical", so I guess +6v is the max you'd see? \$\endgroup\$ Commented Oct 16, 2023 at 23:58

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.