Instead of using an hall effect sensor, I have in place a photo-interrupter that gives a high logic when blocked.
Since I am only gettings 1 pulse per revolution I have changed the line: rpm = 30*1000/(millis() - timeold)*rpmcount; to rpm = 60*1000/(millis() - timeold)*rpmcount;
The arduino uno I'm using is R3 and have the output from the photo-interrupter connected to pin2.
photo-interrupter name: KTIR0611S
The reason I did not get the output from the photo-transistor directly is because the output voltage and current are too low to register as high logic and could not even light a red led. If the current coming into the base of the 2n2222a is that low I hardly doubt it would wreck the transistor.
Sounds like the opto coupler is either broken or wired the wrong way round - you're giving it a good 30mA or so of drive - have you checked that each side of the opto coupler is connected the right way round?
And those values aren't very meaningful without all the code - or some idea of what you are expecting (whats generating the pulses? how many per revolution?)
MarkT:
Sounds like the opto coupler is either broken or wired the wrong way round - you're giving it a good 30mA or so of drive - have you checked that each side of the opto coupler is connected the right way round?
And those values aren't very meaningful without all the code - or some idea of what you are expecting (whats generating the pulses? how many per revolution?)
it says it all in the post, 12V dc motor from pc fan running at 9V set up to block the photo-interrupter every revolution. Not sure how fast it is suppose to spin but the values am getting are way too random. I am sure the photo-interrupter works because the arduino detects when it is blocked. The code am using is from the readingRPM page from arduino playground.
Why is a transistor needed? Couldn't the 10K resistor be in series with the photo-interrupter collector to 5V line and the emitter of the photo-interrupter tied to ground; the signal being read at the resistor-collector junction? - Scotty
Found this:
Properties of Pins Configured as INPUT
Arduino (Atmega) pins default to inputs, so they don't need to be explicitly declared as inputs with pinMode(). Pins configured as inputs are said to be in a high-impedance state. One way of explaining this is that input pins make extremely small demands on the circuit that they are sampling, say equivalent to a series resistor of 100 megohm in front of the pin. This means that it takes very little current to move the input pin from one state to another, and can make the pins useful for such tasks as implementing a capacitive touch sensor, reading an LED as a photodiode, or reading an analog sensor with a scheme such as RCTime.
on the Arduino site under Learning/Foundations/Microcontrollers/Digital Pins.
I could be wrong but I remember hearing or reading somewhere that it will sense as little as 1ua or .0001 amps. Is your RPM input pin a Digitalread or Analogread?
scottyjr:
Found this:
Properties of Pins Configured as INPUT
Arduino (Atmega) pins default to inputs, so they don't need to be explicitly declared as inputs with pinMode(). Pins configured as inputs are said to be in a high-impedance state. One way of explaining this is that input pins make extremely small demands on the circuit that they are sampling, say equivalent to a series resistor of 100 megohm in front of the pin. This means that it takes very little current to move the input pin from one state to another, and can make the pins useful for such tasks as implementing a capacitive touch sensor, reading an LED as a photodiode, or reading an analog sensor with a scheme such as RCTime.
on the Arduino site under Learning/Foundations/Microcontrollers/Digital Pins.
Scotty
Yes I read this but what value is very little current?
Ok I figured that my photo-interrupter might be faulty. So I build my own IR transmitter receiver circuit. I am getting the same problem, the output is too high. I tested to see the rpm with the hall effect output from the fan and it gave me about 2400 rpm.
What is the problem with using IR sensor and source for speed monitoring?
The reason I did not get the output from the photo-transistor directly is because the output voltage and current are too low to register as high logic and could not even light a red led. If the current coming into the base of the 2n2222a is that low I hardly doubt it would wreck the transistor.
It's still wrong! The opto (if it saturates) will send all the current it can into the base-emitter junction of your 2N2222. As to which one will fry first... your guess is as good as mine.
Put about a 470 ohm resistor between the emitter of the opto and the base of the 2N2222. That will limit the base current to about 10 milliamps max (probably a bit less due to the base-emitter drops of both devices).
Krupski:
Let me ask you this: Does your fan have 3 wires? A lot of computer muffin fans have 3 wires... power, ground and a TACH OUTPUT! (open collector).
Check it out.
Yes I did get one of the 3 wire fans yesterday to test the code and it worked fine, got about 2400rpm. I also built a new IR rpm sensor instead of using the photo-interrupter, It still gave me wrong numbers.
Here is the circuit I used:
I have seen other people make these circuits so why is not working for me. What is wrong?
Caadi:
Yes I did get one of the 3 wire fans yesterday to test the code and it worked fine, got about 2400rpm. I also built a new IR rpm sensor instead of using the photo-interrupter, It still gave me wrong numbers.
Here is the circuit I used:
I have seen other people make these circuits so why is not working for me. What is wrong?
THAT diagram is correct (finally!)
Have you looked at the signal with an oscilloscope? Maybe you are getting 120 hz "interference" from fluorescent lighting.