There are just 2 points of connection between the original board and the new bubble display board. A twin connector to the ground and 5V on the bottom right, and a triple for the data, clock and latch. Fortunately there were three unused outputs from the Nano with unused rails. That’s the 2nd red box at the top.
…on enclosures
How do you find the right container for a project. How do you make the cuts and holes for the bits you want on the outside? I hate this bit… It turns a beautiful bit of neat electronics into a messy clump of duck taped rubbish…
Project : Cool 2 – Here we go!
Here is the first step for part two of my cooling project. It uses just 3 outputs to drive a pair of shift registers, and ultimately a 4-digit bubble display!
Currently the display toggles between displaying 24.5C and 1496 (the RPM)… Why? Because those are the two hard coded values I’ve picked in my function calls!
Given its only 3 pins, my plan is to put it all on a different bit of Veroboard, and connect it to the original board with a plug! Exciting stuff 🙂
Project : Cool – The Code
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 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 |
#define aref_voltage 3.3 int min_temp = 30; int max_temp = 50; int led = 13; //Optional output LED int temp = A0; //Middle pin of tmp36 thermistor int blinkDuration = 0; unsigned long lastBlinkTime; boolean blinkOn = false; boolean testMode = false; volatile int rpmTicks = 0; int rpmInterval = 1000; long rpmLastTime = 0; /* Coolermaster Fan Min Duty Cycle = 90 Max Duty Cycle = 255 */ int fanPWM = 10; int fanDutyCycle = 0; int fanTransistor = 7; void rpm() { rpmTicks ++; } // the setup routine runs once when you press reset: void setup() { analogReference(EXTERNAL); //Sets the AREF pin to 3.3V // initialize serial communication at 9600 bits per second: Serial.begin(9600); pinMode(fanPWM, OUTPUT); pinMode(fanTransistor, OUTPUT); pinMode(led, OUTPUT); //Make A0 the analogue thermistor input pinMode(temp, INPUT); // function 'rpm' will be called when the rpm_sense pin goes high attachInterrupt(0, rpm, RISING); //set the timer variables rpmLastTime = millis(); lastBlinkTime = millis(); } // the loop routine runs over and over again forever: void loop() { //depending on the speed of the fan, the blink rate is 'mapped' to a different scale //so when the rate goes from 95-255, the blink millisecond time goes from 500-25 //The faster the fan, the shorter the duration, so the faster the blink effect blinkDuration = map(fanDutyCycle, 95, 255, 500, 25); //Do the LED flashing if (blinkOn) { if (millis() - lastBlinkTime >= blinkDuration) { digitalWrite(led, !digitalRead(led)); lastBlinkTime = millis(); } } else { if (digitalRead(led) == HIGH) { digitalWrite(led, LOW); } } //PWM Sensing int timeElapsed = (millis() - rpmLastTime); if (timeElapsed > rpmInterval) { long actualTicks = rpmTicks; Serial.println((millis() - rpmLastTime)); //Do temperature work int tempreading = analogRead(temp); float temp_v = tempreading * aref_voltage; //3.3V temp_v /= 1024.0; Serial.write("TEMP_V: "); Serial.print(temp_v); Serial.write("V\n"); float tempC = (temp_v - 0.5) * 100; Serial.write("TEMP: "); Serial.print(tempC); Serial.write(" degrees C\n"); fanDutyCycle = map(constrain(tempC, min_temp, max_temp), min_temp, max_temp, 90, 255); //Fan Speed analogWrite(fanPWM, fanDutyCycle); Serial.write("RPM: "); Serial.write("(tps:"); float ticksPerSecond = (actualTicks / 2.0) / (timeElapsed / rpmInterval); Serial.print(ticksPerSecond); Serial.write(") "); Serial.print(ticksPerSecond * 60); Serial.write(" @ FDC: "); Serial.println(fanDutyCycle); rpmLastTime = millis(); rpmTicks = 0; if (fanDutyCycle >= 95) { blinkOn = true; digitalWrite(fanTransistor, HIGH); Serial.println("Transistor High"); } else { blinkOn = false; digitalWrite(fanTransistor, LOW); Serial.println("Transistor Low"); } } delay(5); // delay in between reads for stability } |
Project : Cool – Veroboard Layout
Well, rather than struggle with a tool not designed for the job, I threw away any thoughts of doing the stripboard in MS Word. Instead I downloaded the demo of a bit of prototyping software called LochMaster 4.0. It natively does stripboard, and you can even flip the board to see the solder points and cut strips underneath! I’ve now purchased the software, as I think it’s going to be pretty handy.
Anyway, this is the top of the board, the Vin of the Nano is bottom right. The power connection to the red and black rails on the right is 12V. The 5V green rail is taken FROM the Nano, you don’t supply it.
Additional parts :
- C1 – 0.1 uF cap to make the 3.3V reference voltage smooth.
- D1 – Small diode to prevent back EMF from the fan. A 4001.
- D2 – Small 5V LED (this and the resistor are actually entirely unnecessary, as the on-board LED would probably be enough)
- T1 – The transistor at the top is for switching the fan on and off. I think its a BC337
Regarding the pin strip headers, the top (4-way) is for the PWM fan. The S pin is the RPM pin, and the P pin is the PWM signal pin to the fan.
The bottom 3-way header is for the TMP36 thermistor. Since I wanted to have this at the end of a cable, so I could position it where I wanted, I made it a header.
This is the back of the board, showing the places where the strips need to be cut.
Code is to follow, when I’ve commented it and tidied it up. I’ll mark the Nano pins on my next project. You should be able to work it out from the circuit and the code though.
Project : Cool – Complete! Project : Cool 2 begins
It’s done… The mighty Nano has been deployed in my TV cabinet, behind the Xbox One. The TMP36 thermistor is resting at the end of a cable on top of it. When the XB1 is turned on and the temp rises to 30 degrees, the fan kicks in, and will give a smooth stepping of speed up until 50 degrees, where the fan is maxed out. (I’m hoping I never get to this stage!!).
But, in the true spirit of tinkering, I’ve already got at least 3 improvements/changes that I want to put in to the next version!!
Firstly, the RPM calculation isn’t working properly, but that’s moot anyway, because I’ve got no way of showing what it is!
Secondly, the flashing LED is a bit pointless, because the on board one is bright enough, but in any case, it wouldn’t be needed if #1 is done.
Thirdly, I need to mount it properly, in a box.
..etc
…and another step back
Wow – of all the mistakes to make, I finished making the stripboard layout (again), cut all the holes, and went to put the Nano into the 2 female pin strips, and…
I’d cut the strips 1 hole too many !!! I think that I might be able to get away with it though, I might just be able to remount the 5V, GND and Vin lines which are the only ones used from the right hand side of the Nano…
Moral : measure 38 times, cut once…
…and one step back
I’ve done this before and obviously didnt learn my lesson. I copied the circuit onto the coppered side of the stripboard so I can mark the points to cut the tracks, and then did the cuts before I put the components on! But of course, when I turned the board over, its reversed everything!
Deep breath, and repeat: I’m a noob, I’m a noob…
Complete circuit and program!
I had to wait for the thermistor and other bits to arrive through the front door, so took some time to try and find some software to help mock up the stripboard layout. I found one for Windows 8.1, but its not perfect. I might just try to do it in Word or something. Anyway, the final bits arrived, and got installed into the breadboard, and amazingly, it WORKS!
Functionally, I measure the temp every few seconds, and map anything between 30 and 50 degrees to a duty cycle of 90 to 255 PWM output. (90 is about the slowest this fan will go). I’ll document the code in another post, when I’ve got a circuit to show. I do a bit of a trick with the constrain statement to get the transistor to kick in.
Project : Cool
Ok, my first project is a replacement for a previous gadget I’d knocked up to cool my devices under my TV, as they are in a new cabinet with very little vertical headroom.
The current one just adjusts the voltage to the 12v PC fan with the aid of a variable resistor, and a thermistor. Set to the right value, the voltage to the fan increases to its startup level when the temp goes a few degrees above ambient.
My brief for my Arduino powered one is to use a PWM fan, and adjusting the ‘duty cycle’ based on the analogue input from the thermistor. Also, I wanted to add an LED for feedback, and a transistor to turn off the fan completely when the temperature is around room temp.
As you can see, I’m not there yet. Stay tuned.