Pages: 1 [2]   Go Down
Author Topic: Current monitor for fan running with PWM through FET  (Read 1185 times)
0 Members and 1 Guest are viewing this topic.
Left Coast, CA (USA)
Offline Offline
Brattain Member
*****
Karma: 361
Posts: 17294
Measurement changes behavior
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Quote
Btw, i still don't really understand, how to synchronize the analogRead with the PWM (to measure without low pass filter). Can you give me a code example? This is my part for measuring current:

I don't think such a method exists, In the external (to the AVR chip) electronics world the PWM lives in the digital domain and the analogReads lives in the pure analog world, they are only equally digital inside the code, So external low pass filtering to eliminate the PWM switching frequency will always be required, unless someone can prove differently?

On second thought, I guess it would be possible to implement a low pass filtering function in code to take many analogRead samples and effectively filter out the PWM switching frequency, might be an interesting project for someone better at software then me.  smiley-wink

Lefty
 
« Last Edit: November 15, 2012, 02:55:06 pm by retrolefty » Logged

United Kingdom
Offline Offline
Tesla Member
***
Karma: 224
Posts: 6619
Hofstadter's Law: It always takes longer than you expect, even when you take into account Hofstadter's Law.
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Btw, i still don't really understand, how to synchronize the analogRead with the PWM (to measure without low pass filter). Can you give me a code example?

Something like: (warning - untested code!)

Code:
 int sensorValue;
  do
  {
     while (digitalRead(fan) == LOW) { }    // wait for PWM pin to go high
     sensorValue = analogRead(A0);
  }
  while (digitalRead(fan) == LOW);   // repeat if PWM pin has gone low already
 
  float voltage = sensorValue * 5.0 / 1024.0;  
  float current = voltage / 0.22;
  Serial.println(current);
Logged

Formal verification of safety-critical software, software development, and electronic design and prototyping. See http://www.eschertech.com. Please do not ask for unpaid help via PM, use the forum.

Anaheim CA.
Offline Offline
Faraday Member
**
Karma: 47
Posts: 2892
...
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

The simplest method is to buy a fan with a speed feedback output, most computers use one... on the Processor and there are Many different types available. Go For Google...

Bob
Logged

--> WA7EMS <--
“The solution of every problem is another problem.” -Johann Wolfgang von Goethe
I do answer technical questions PM'd to me with whatever is in my clipboard

Slovenia, EU
Offline Offline
Full Member
***
Karma: 0
Posts: 153
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

I bought TC670 predictive fan failure detector.. If i power my fan directly with 12V it works great with any kind of fan (because of this i am using this IC).

Now i've got a problem because i want to run my fan through FET with PWM. If i use 100% pwm (255 in arduino) this detector works but not if i use any other PWM value. I tried to add low pass filter between source of FET and SENSE of IC but without luck.

Does anyone have any idea how to fix this? This are pictures of TC670 scheme and FET with fan. I connected fet above the sense input, so the SOURCE of the FET and sense resistor and capacitor are connected.

https://www.dropbox.com/s/542v2siyxk2tvw3/TC670.png

https://www.dropbox.com/s/2dok2nf06sakwn9/fet_ventilator.png
Logged

Slovenia, EU
Offline Offline
Full Member
***
Karma: 0
Posts: 153
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

I think I found a solution.. I didn't try yet but it seems like that's it.

https://www.dropbox.com/s/q8baz3tjlz8iu5d/670_PWM.png
Logged

Slovenia, EU
Offline Offline
Full Member
***
Karma: 0
Posts: 153
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

I tried this technique but without luck. The same problem like before. If i am running FET with 255 (100% PWM) from arduino signal led is always on but if i use any other PWM value (191 for example), led is always off (also if i am holding fan).

Any idea?

I am using TC670 with IRF530 FET.

TC670 scheme
https://www.dropbox.com/s/542v2siyxk2tvw3/TC670.png

FET wiring
https://www.dropbox.com/s/q8baz3tjlz8iu5d/670_PWM.png
Logged

Pages: 1 [2]   Go Up
Jump to: