-
Notifications
You must be signed in to change notification settings - Fork 7
/
Copy pathfan_tuning.ino
80 lines (56 loc) · 1.96 KB
/
fan_tuning.ino
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
// Basic demo for readings from Adafruit EMC2101
#include <Wire.h>
#include <Adafruit_EMC2101.h>
Adafruit_EMC2101 emc2101;
void setup(void) {
Serial.begin(115200);
while (!Serial) delay(10); // will pause Zero, Leonardo, etc until serial console opens
Serial.println("Adafruit EMC2101 test!");
// Try to initialize!
if (!emc2101.begin()) {
Serial.println("Failed to find EMC2101 chip");
while (1) { delay(10); }
}
Serial.println("EMC2101 Found!");
emc2101.setDutyCycle(40);
emc2101.setFanMinRPM(150);
Serial.print("FAN minimum RPM:"); Serial.println(emc2101.getFanMinRPM());
}
void loop() {
Serial.print("External Temperature: ");
Serial.print(emc2101.getExternalTemperature());Serial.println(" degrees C");
Serial.print("Internal Temperature: ");
Serial.print(emc2101.getInternalTemperature());Serial.println(" degrees C");
Serial.print("Fan RPM:: ");Serial.print(emc2101.getFanRPM());Serial.println(" RPM");
Serial.print("LUT Enabled: "); Serial.println(emc2101.LUTEnabled());
Serial.println("");
delay(100);
Serial.println("Comparing default behavior of fan speed to RPM");
emc2101.invertFanSpeed(false);
delay(100);
for(int i = 0; i<10; i++){
Serial.print("Setting pwm to "); Serial.println(i+5);
emc2101.setDutyCycle(i+5);
delay(3000);
Serial.print("Fan RPM:: ");
Serial.print(emc2101.getFanRPM());
Serial.println(" RPM");
Serial.print("Fan PWM: ");Serial.print(emc2101.getDutyCycle());
Serial.println(" %");
delay(2000);
}
Serial.println("\nInverting fan speed polarity...");
emc2101.invertFanSpeed(true);
for(int i = 0; i<10; i++){
Serial.print("Setting pwm to "); Serial.println(i+5);
emc2101.setDutyCycle(i+5);
delay(4000);
Serial.print("Fan RPM:: ");
Serial.print(emc2101.getFanRPM());
Serial.println(" RPM");
Serial.print("Fan RPM:: ");Serial.print(emc2101.getDutyCycle());
Serial.println(" %");
delay(2000);
}
delay(100);
}