How much current does the fan take? The ADC has a resolution of just under 5mV using the default analog reference; so if you choose the value of resistor in series with the mosfet source so that it drops 50mV or 100mV when the fan is operating normally, you will easily be able to detect it - but only if you read it while the mosfet is turned on.
Fan needs 630 mA (12V).. I connected fan to FET like this:DRAIN - Fan GND (12V is connected directly to fan+)GATE - To ArduinoSOURCE - GNDSo, if i am using connection of FET and fan like this.. Where should i put resistor and where should i measure (analog input of arduino)?
I would put a small resistor (ideally 10mohm but higher is ok given that the current isn't too big) from the source to ground.You should see voltage pulses on this resistor (6mv or so) when the motor is running, and nothing when the motor is disconnected.As the count resolution for a arduino analog input pin is 5 millivolts or so and who knows what the noise floor will be, this seems like a most undesirable unreliable measurement to use to determine if the motor is operating at normal current draw or not.LeftyWhether you use a low-pass filter after that will depend on your particular solution.You can also detect a stuck motor (connected but not running): you will see higher magnitude of the pulses.
Also connect the junction of the two to an analog input, either directly (if you synchronize the analogRead with the PWM) or via a low-pass filter. You will get nearly 140mV across the resistor at full speed, which you can easily detect via analogRead.
which you can easily detect via analogRead
either directly (if you synchronize the analogRead with the PWM)
Quote from: dc42 on Nov 13, 2012, 04:43 pmAlso connect the junction of the two to an analog input, either directly (if you synchronize the analogRead with the PWM) or via a low-pass filter. You will get nearly 140mV across the resistor at full speed, which you can easily detect via analogRead.You mean that i connect one wire after resistor to analog input, right (what did you mean with junction of two)? [FET SOURCE]-----[RESISTOR]-----(to analogInput)-----[FET GND] <-- like this, right?
Quotewhich you can easily detect via analogReadHow to do that? I tried with this but if i am correct it can be used only if power supply is 5V?1. SensorValue * 12/1023 to get voltage value
2. Than use I=U/R with values of 12V and 0,22 ohm to get current
3. If i hold the fan current should increaseIs that right?
Quoteeither directly (if you synchronize the analogRead with the PWM)And how to do that?
QuoteNo, sense_voltage = analog_reading * 5.0 / 1024.Ok,it is intresting to me that i should use 5V although i am powering my fan with 5V.. I will try and report.. Thank you for now!
No, sense_voltage = analog_reading * 5.0 / 1024.
The 5V in that calculation is the voltage on the Aref pin of the microcontroller. You can use a different voltage reference, see http://arduino.cc/en/Reference/AnalogReference.
analogWrite(fan, 255); int sensorValue = analogRead(A0); float voltage = sensorValue * 5.0 / 1023.0; float current = voltage / 0.22; Serial.println(current);