Steeph's Web Site

Go To Navigation
Show/Hide Navigation

Entries tagged 'cat:Hardware' (Page 2)

USB/Serial PWM Fan Controller Using an Arduino

I wanted to be able to control the speed of the fans in my big NAS, Fred, individually. Even though the mainboard in use has five PWM fan connectors, the chipset can only control the speed of all fans together. There are probably good fan controllers commercially available that solve this problem better than I did. But they seemed overpriced and it seemed like a fun learning project for me.

The fan controller that I made uses an Arduino Nano clone that listens to it's serial port, waiting for a command to change the speed of a fan. When a command is recognised the continuous PWM signal for that fan is changed accordingly. It's possible to control up to six fans this way with an Arduino Nano. I'm only using three though since I only have three fan groups that need to be controlled separately.

The Arduino sketch/C code for the Arduino Nano that I used is as follows.




//fan speed sensor wire attached to digital pin 2 with a 10kohm pullup resistor
//fan PWM control wire attached directly to digital pin 9

#include <PWM.h> //include PWM library http://forum.arduino.cc/index.php?topic=117425.0

volatile int half_revolutions1; //allow half_revolutioins to be accesed in intterupt
volatile int half_revolutions2; //allow half_revolutioins to be accesed in intterupt
int rpm1; //set rpm as an integer
int rpm2; //set rpm as an integer
int pwm=255;
const byte numChars = 5;
char receivedChars[numChars];

boolean newData = false;

void setup()
{
  InitTimersSafe(); //not sure what this is for, but I think i need it for PWM control?
  bool success = SetPinFrequencySafe(9, 25000); //set frequency to 25kHz
  pwmWrite(9, 51); // 51=20% duty cycle, 255=100% duty cycle

  pinMode(5, OUTPUT);
  pinMode(6, OUTPUT);
  analogWrite(5, 170);
  analogWrite(6, 255);
  pinMode(2,INPUT_PULLUP); //set RPM pin to digital input
  pinMode(3,INPUT_PULLUP); //set RPM pin to digital input
  half_revolutions1 = 0;
  rpm1 = 0;
  half_revolutions2 = 0;
  rpm2 = 0;

  Serial.begin(9600);
}



void loop()
{
  sei(); //enable intterupts
  attachInterrupt(0, fan_rpm1, RISING); //record pulses as they rise
  delay(1000);
  detachInterrupt(0);
  attachInterrupt(1, fan_rpm2, RISING); //record pulses as they rise
  delay(1000);
  detachInterrupt(1);
  cli(); //disable intterupts

  rpm1 = (half_revolutions1/2)*60;

  Serial.print("1");
  Serial.println(rpm1);

  rpm2 = (half_revolutions2/2)*60;

  Serial.print("2");
  Serial.println(rpm2);

  rpm1 = 0;
  half_revolutions1 = 0;

  rpm2 = 0;
  half_revolutions2 = 0;

  pwm = 255;
  recvWithStartEndMarkers();
  processCommand();
}

void fan_rpm1()
{
  ++half_revolutions1; //increment before returning value
}


void fan_rpm2()
{
  ++half_revolutions2; //increment before returning value
}


void recvWithStartEndMarkers() {
    static boolean recvInProgress = false;
    static byte ndx = 0;
    char startMarker = 's';
    char endMarker = '\n';
    char rc;
 
    while (Serial.available() > 0 && newData == false) {
        rc = Serial.read();

        if (recvInProgress == true) {
            if (rc != endMarker) {
                receivedChars[ndx] = rc;
                ndx++;
                if (ndx >= numChars) {
                    ndx = numChars - 1;
                }
            }
            else {
                receivedChars[ndx] = '\0'; // terminate the string
                recvInProgress = false;
                ndx = 0;
                newData = true;
            }
        }

        else if (rc == startMarker) {
            recvInProgress = true;
        }
    }
}

void processCommand() {
    if (newData == true) {
        Serial.print("s");
        Serial.println(receivedChars);
        switch (receivedChars[0])
        {
            case '1':
                receivedChars[0] = '0';
                sscanf(receivedChars, "%d", &pwm);
                analogWrite(5, pwm);
                break;
            case '2':
                receivedChars[0] = '0';
                sscanf(receivedChars, "%d", &pwm);
                analogWrite(6, pwm);
                break;
            case '3':
                receivedChars[0] = '0';
                sscanf(receivedChars, "%d", &pwm);
                
                break;
//            default:
//                Serial.println("I don't know what that means.");
        }
        newData = false;
    }
}

Well, how should I put it? It works, usually.

(tbc?)

(tba:photos)

My Atrocities to Vintage Hardware and Software

I've thrown away a lot of stuff over the time that I mourn now. This is just to say: I'm sorry!

I feel bad when I think back and remember some things that I had collected, didn't value back then, but miss now. I had a lot of computer hardware that wasn't worth anything at the time. (Like 386 and 486 stuff in the 2000s.) I'd love to play with some of the stuff today sometimes. I think it was a waste to throw them out knowing that nobody will ever use them again. There was also an IBM PS/1 in good condition. That would be a very nice thing to own for a retro computer fan today. (It already was back then.) I also had years worth of c't magazines that I had a subscription for for a while. I had my reasons. I didn't have room to store so much stuff. But still. Maybe I could have kept just a few more things.

Even worse is that I've thrown away quite a few floppy disks with very rare software. The things I wrote back then are one thing. Nobody has a copy of these programmes I'm sure. The collection of Prologue OS software is another. Prologue was a French UNIX-like (yes, I said UNIX-like) OS for industrial applications. As far as I know there is no successor in development or still supported. It's a piece of computer history that, due to the relatively small regional spread, is not at the forefront of vintage software archives. In fact I've never seen any software for Prologue nor a version of the OS itself anywhere on the internet. The collection contained multiple versions of the OS from I don't know how long of a time span and a range of applications. The source code for many applications was also there (because of a familial connection to the author). At least some of the floppies likely contained the last copy in existence of software that was once very important in the daily work of some people.

I'm sorry!

Fujitsu Cordant Pentium II Aluminium Case Mod

I always wanted an aluminium case. A friend gave me this Pentium II he finally decided to get rid of last year. Nice PC, but even nicer in black and with newer hardware in it.

I suck at spray painting and I need to get better paint next time. But if the light comes from the right angle it looks like I imagined it.

I replaced the key lock with a large screw, got rid of the drive cages, replaced the PSU and mainboard, added a graphics card with internally pluggable VGA, replaced the external VGA port with a serial port and added a small LCD panel where the drives used to be, connected internally to the unplugged VGA port. Oh, and green LED strips. I also added two 60 mm fans in the back. I didn't want to cut a whole in any of the other sides, so 60 mm was the largest possible size. Still better than none.

And yes, I actually have a use for a RS232 port.

The main reason I put in the LCD is because I can. I liked the idea ever since I saw a build with a two-line character LCD for status messages around 2004. But nowadays there is a lot more space on the front since optical drives and diskette drives have become rare. So why not make it a regular screen that can be addressed by the OS without much custom code? The idea is to have it display CPU load, temps, notifications and stuff. But I may end up using it mainly for art, animations. I'm not sure, yet.

File Attachments (34 files)