I am trying to read in wind speed from an anampmeter, into my Mega 2560. The output from the anamometer is a con stant frequency and 2.5V peak (not peak to peak). However as the anamometer rotates it passes a read switch which forces the wave low (0V). I must count how many times the anamometer passes the read switch.
How would i count this?
I was thinking about using AC-DC rectification (4 diodes and a capacitor - but this sound like allot of effort because i must have this done for tuesday and i dont have a capacitor). After the rectification i simply use a innterupt to generate whenever there is a falling edge. But the rectified signal will be bouncy giving errornous falling edges???
No, this is the output from a bought anamometer.To be honest i dont even know whgere the sine wave comes from? the anamometer takes a 2.5V DC input, and im testing in a lab where the parts arnt even moving.
You can use a differentiate circuit to detect the sharp edge from the reed switch. But that involves passing the signal through a capacitor.
Alternatively you can read the signal from the analogue pin, track the value and when you get a difference between two successive readings that is bigger than some threshold you know you have the reed switch event.
I wonder if you are looking at the output from the reed switch when open - you're picking up noise
Ill try that in a bit, but can noise produce a constant frequency, and amplitude sine wave?
Alternatively you can read the signal from the analogue pin, track the value and when you get a difference between two successive readings that is bigger than some threshold you know you have the reed switch event.
I only know how to generate interrupts from a input. I have other stuff going on in my program so i cannot be evaluating only every sweep through of the code as i might miss a count.
You can use a differentiate circuit to detect the sharp edge from the reed switch. But that involves passing the signal through a capacitor.
I think i will have to try this. Do you know of what value capacitor i should use?
try connecting an ohm-meter to it and see what it has to say
Its has a 515 ohm, but how will this make a difference?
if it's 50Hz or 60Hz (depending on your location) it could just be mains hum
It looks to be approximatly 50Hz. Im not sure what mains hum is, how can i remove it. (I assume it has something to do with the power sorce, available at my country. Im from south africa so 50Hz would be right- i think. But it has no external power input other than directly from the arduino's vcc port)
if it is mains hum, then a simple capacitor across the contacts should reduce it
mains hum is just induced current in long wires that are aywhere near the mains
I had expected you to report 0 ohms (short circuit) when the reed is closed, and very high when open
The sort of circuit I imaged for you would be:
a) connect one side to ground
b) connect the other side to +5 volts (or whatever your 'duino is using), via say 10k resistor
c) connect any pin to the resistor (obviously not the end that's connected to 5 volts
as your anemometer turns I would expect to see HIGH, changing to LOW as the reed closes
I'm assuming that there is no power to the device - purely passive?
But it has no external power input other than directly from the arduino's vcc port)
Yes it sounds like just mains pickup to me.
It is probably a very high impedance and will disappear with a small load.
I would use a 10K resistor from the input to ground and a 1K resistor from the input to +5V.
I had expected you to report 0 ohms (short circuit) when the reed is closed, and very high when open
0 ohms closed , 515 ohms open;
The sort of circuit I imaged for you would be:
The anamometer has these 4 conductors:
Supply voltage on the yellow conductor. - Arduino 5V
Analog ground is on the red conductor. - Arduino ground
Speed signal is on the black conductor. - this is the output im plugging to my Arduino input port, i have plugged it in directly but im going to add a resistor now and get back to you.
Direction signal is on the green conductor. - dont worry about direction that works
if it is mains hum, then a simple capacitor across the contacts should reduce it mains hum is just induced current in long wires that are aywhere near the mains
This sounds interesting. I really think this could be it, since the cable from the anamometer is about 15m long and its wound in a coil at the moment sitting next to my arduino. You say a capacitor across the contacts, which two contacts?
Yes it sounds like just mains pickup to me.
It is probably a very high impedance and will disappear with a small load.
I would use a 10K resistor from the input to ground and a 1K resistor from the input to +5V.
So can i just connect a 10kohm between the black connection to the input port and a 1kohm between supply 5V and the red conductor and this should remove the sine wave? ill try this thanks.
Ok i connected the resistors as instructed. When i run my interrupt code it never generates any interuupts. So i checked it using this analogue read in example:
0 is obviously closed
not sure why you don't just get high numbers when open
that's what the resistor is meant to do, pull the line high
did you try Grumpy_Mike's suggestion - two resistors?
not sure why your interrupt code doesn't work
a) how have you wired it
b) show us the code
I connected the output to a occilascope again and with the resistors added it is no longer a sine wave but now a square wave. I dont know if this means anything.
What about the capacitor? what value one should i use and how should i connect it.
I have a 10k resistor between the black conductor and the A0 port. I have a 1k resistor between the Arduino 5V and the yellow conductor. The red is connected directly to ground and the green hangs free atm.
no, if i got 1 pulse per revolution it would be easy =(
Its a continous square wave with constant frequency and amplitude untill the reed connects and it drops to a flat zero. Like my picture in the first post with a square wave instead of a sine wave. (one flat 0V per revolution)
I cant even count the rising edges of a signal with no reed switch closes and subtract it from the signal with reed switch closes because the reed switch may be closed for varying ammounts of time.
Should i not just construct a rectifier? will a single capacitor be enough? I have four diodes but im not too clued up on that kind of thing. can i use any diodes?