rpm = 30*1000/(millis() - timeold)*rpmcount;
rpm = 60*1000/(millis() - timeold)*rpmcount;
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?)
Found this:Properties of Pins Configured as INPUTArduino (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
tiny mistake on picture fixedThe 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.
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.
Please enter a valid email to subscribe
We need to confirm your email address.
To complete the subscription, please click the link in the
email we just sent you.
Thank you for subscribing!
via Egeo 16