draft0 - a shared blog by just some people

Go To Navigation
Show/Hide Navigation

Entries tagged 'cat:Electronics' (Page 1)

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)

Comment via email
Zeo Mobile Teardown

2015 habe ich mir mal ein Zeo Mobile genauer angeschaut und im Schlafhacking-Blog darüber geschrieben.

Hintergrund: Das Zeo war ein Gerät ("war, weil es schon lange nicht mehr hergestellt und vertrieben wird), das anhand von Bewegungsdaten, EOG und EEG ein Schlafprofil des Trägers eines Stirnbandes erstellte. Es war wahrscheinlich das erste Gerät seiner Art, das diesen Einsatzzweck einfach benutzbar, mit cloudbasierter Software für Normalconsumer und - dafür, dass es quasi kein richtiges Konkurrenzprodukt gab - ziemlich günstig, bedient hat. Ich weiß gar nicht, woran der Hersteller, Zeo, Inc., ehem. Axon Labs) gescheitert ist. Er war dem heutigen Trend so weit voraus und hat alles geboten, was den Benutzern von heutigen, ähnlichen Geräten für den Zweck der Verbesserung der Schlafqualität wichtig ist, dass man ihn eher als Innovator als als seiner Zeit voraus bezeichnen kann. Anyways, es gab/gibt hauptsächlich zwei Geräte: Das Zeo Bedside, bestehend aus Nachttisch-Empfangsgerät, Kopfband, USB-/serieller Schnittstelle und Windows-Software, und das Zeo Mobile, ein Bluetooth-fähiges Kopfband mit Smartphone-App. Für ersteres wurde von einem (Ex-)Entwickler des Gerätes eine modifizierte Firmware (Version 2.6.3R) in Umlauf gebracht, die es ermöglicht, über USB die Rohdaten der Sensoren zu empfangen und so eigene Software zu benutzen. Damit hat während des kommerziellen Untergangs Zeos nicht nur er meinen Respekt gewonnen, sondern auch das Zeo Bedside neue Einsatzmöglichkeiten und eine Fan-Community von technik-interessierten Klarträumern. Für das neuere Zeo Mobile gibt es zwar auch eine Android-App, mit der man das Gerät ohne Konto auf dem nicht mehr existeierenden Zeo-Server weiterbenutzen kann, aber aus dem einfachen Grund, dass es nicht einfach möglich ist, Rohdaten aus dem Gerät zu bekommen, haben die Zeo Mobiles bei weitem nicht die Beliebtheit unter Hobbyisten, die die wenigen noch in Umlauf befindlichen Zeo Bedsides genießen.

Also, 2015 habe ich mir mal ein Zeo Mobile genauer angeschaut und im Schlafhacking-Blog darüber geschrieben: Zeo Mobile Teardown

Eigentlich wollte ich noch einige weitere Links hier einbauen, wie zum Beispiel zu der Entwickler-Webseite und zu ein paar interessanten Software-Projekten, die die Daten der Rohdaten-Firmware des Zeo Bedside nutzen. Leider kann ich die Firmware selbst nicht mehr finden und auch die relevanten Informationen sind nur noch im Internet Archive zu finden. Dort sind die Software-Downloads aber nicht archiviert, weshalb sich der Rest erübrigt. Sehr schade. Ich hoffe jemand wird die Sachen noch mal öffentlich zur Verfügung stellen. Ich habe sie leider nicht bei mir, weil ich nie ein Zeo selbst bespielt habe.

Vielleicht nehme ich den letzten Absatz wieder zurück. Hier ein paar URLs, die oben vielleicht fehlen (habe gerade keine Lust, sie in line zu bringen):

  • https://www.gwern.net/docs/zeo/index
  • https://www.gwern.net/docs/zeo/firmware-v2.6.3R-zeo.img
  • https://www.openyou.org/2013/06/11/zeo-firmware-and-raw-data-api-on-openyou-github/
  • http://eric-blue.com/2013/06/09/life-beyond-zeo/
  • https://github.com/evsc/zeoLibrary
  • https://github.com/openyou/zeo-firmware
  • https://github.com/openyou/zeo-raw-data-api
  • https://github.com/openyou/zeo-android-api
  • https://www.klartraumforum.de/forum/showthread.php?tid=9523
  • http://www.sleepstreamonline.com/rdl/
  • https://web.archive.org/web/20120422001938/http://sourceforge.net/projects/zeorawdata
  • https://web.archive.org/web/20110307193953/http://sourceforge.net/projects/zeodecoderview
  • https://sourceforge.net/projects/rxtxlibrary/files/rxtxlibrary/
  • https://sourceforge.net/projects/zeolab/
  • https://sourceforge.net/projects/zeolib/
  • https://web.archive.org/web/20120924070141/http://developers.myzeo.com/raw-data-library/
  • https://www.klartraumforum.de/forum/forumdisplay.php?fid=29 (Inhalt nur eingeloggt sichtbar)
Comment via email
No smart home for me, thanks.

I don't think I'm going to set up anything that could be considered smart home tech for me. There are such fun projects in it and it would be very satisfying to be able to control some things remotely (that is, I'd decide on and be able to change the interface) but it would also be yet another never-ending project for me. I have never planned to install anything of that kind but I already have so many ideas about what I would do if I would go smart home and how I'd set things up. Let's leave it at that. I have enough too many unfinished project already.

For example I have those universal keypads that were made for numeric keypads (+ a fey extra keys) of industrial machines. I have at least a dozon of them, maybe two. They are great: Good quality in every aspect, nice hard click, sturdy, customisable (buttons can be switched out or replaced by blank covers) and a simple matrix connector. It would ne great to have one of these next to every door, in or on every table, at the bedside, and maybe one or two non-stationary ones that would control everything that could be relevant from the location of each terminal.

Every terminal would have a micro controller connected to a network. I could update those controllers all at once with new firmware. The keypads would have several modes from where I could control devices and the lights (including color, at least in one room). Also for my blinking light projects and mood light that would be a nice way of turning on and off exactly those lamps, effects and glowing pictures that I want at taht moment.

But I won't do it. That's a decision.

PS: Does anybody want some great small keypads for DIY use?

Edit: I remember that I, when I previously talked about this topic, said that I don't start with this because the value I see it bringing to my life isn't large enough. I said that the one thing that could convince me that it's worth investing money and time into smart home tech would be a really very reliable way of sensing presence in a room as well as somebody approaching the entrance to a room. Basically, if the music or podcast that I was currently playing on my PC or phone would automatically be played in the room I'm currently in but not in any room I'm not in, except when I was about to walk into another room, then I'd maybe get in. If this would be really really reliable and affortable, then I'd reconsider my decision. Thermal based motion sensors aren't good enough for this. I'd probably need a dozen of them in each room. (Looks like I saved a dozen of the wrong things from being scrapped.) And to customise the software for my home would probably a small project on its own. I don't know of another sensor that could do this that wouldn't require me having at least some sort of device on me all the time.

Comment via email
Another never finished electronics project: my electronic typewriter that would make a very nice retro style terminal but isn't one

Background story: I wanted to park my car at a certain small parking lot that's usually pretty full. I was lucky: There was a free spot. Or so it seemed. As I drove up to it I saw there was something lying in the middle of the free spot. Looked like somebody got rid of some scrap there. I got out and honestly I wanted to put the stuff to the back of the parking spot under the tree that was there. If somebody decided not to bring their scrap to the right facility for free for some reason that doesn't make me responsible to pick it up and bring it there, I thought. But when I saw that it was an almost new looking electronic typewriter, I quickly decided to take it with me instead. It was a Triumph Adler Gabriele PFS. As I read somewhere it came out in the late 2000s or early 2010s. So not as vintage as the name typewriter may sound. But definitely some old piece of tech that is obsolete now but has a nice character and conveys a feeling from a certain time. That and the fact that I've never had or even used one made me add it to my collection of retro tech (that I've never before called collection because it doesn't really deserve that name).

Back at home I examined and tested it and I would have cleaned it, but there was nothing to clean. The case of the internal transformer was cracked and the outer case had a deep scratch at the corner where the transformer is. Everything was working fine except for the 2.8" diskette drive. The rubber band had long been degraded. But the bigger problem was that the main motor didn't do anything else than heating up very quickly. I couldn't find a replacement easily and still couldn't find a good replacement when I searched more thoroughly later. So I've replaced the drive with an emulator so I could use SD cards instead of diskettes. That not only has the advantage of working right now but also of using a medium that is more reliable being handled by my clumsy self and available easily. New 2.8 " diskettes would cost more than SD cards and couldn't hold nearly as many and long documents.

Before the drive emulator worked I had to work a bit with the developer of its firmware. I was lucky that I had a logic analyser and that the project was actively maintained by a developer who cared for adding support for my typewriter. The interface for that model of Mitsumi QuickDisk drive was already supported before. But the reverse engineered parameters, especially the timing was just not exact enough for my Gabriele.

Well, that's the state the machine is in right now. I can use it, I can save documents to SD card, I can't read the original diskettes and I can't read the documents on a PC or create documents for the typewriter on a PC without writing software for it first. I'm not using it for anything. The best thing I could come up with on what I could/would want to do with it is to add an interface that allows me to use it as a text printer. It has a printball with all important characters (no ASCII line art though, sadly) and maybe completely switch out its software to give the machine a new purpose. The easiest way for me would probably be to ignore all the electronics that are already inside and add a microcontroller that handles the LCD, print head and communication with the outside. I still wouldn't have any use for that though. So additionally I would turn it into a serial or telnet or SSH terminal, maybe all three. That would be more fun. Vintage look, vintage keyboard, vintage feel overall, a display that is subpar because it's old technology but still good enough to do its job, and the ability to print text on paper. Yeah, that would be fun. But I still wouldn't really have a use for it. I have a laptop that can do that job better and the keyboard of the typewriter doesn't have as many keys as I'd want it to have.

So, I'm not going to do it, or anything else with it. Maybe some day. Or none. Got any better/additional idea what I could do with it?

Comment via email
USB Volume Control Knob

Volume control used to be a lot more responsive, quick and simple when the used potentiometers (analogue knobs or wheels). Just reach to the knob and the volume is at 0 or 100% almost instantly. No key combinations, no deactivated function keys, no switching tabs, no delay (!), no pressing the same botton multiple times or holding it down. I miss that.

(tba:content)

Comment via email
"RGB LEDed" Shop Sign

Found this old shop sign on ebay Kleinanzeigen. Idk, I just wanted to have it. Picket it up for 10 € since it wasn't far from me. Put some RGB LEDs and an Arduino inside, used some sample RGB LED sketch, Robert is your uncle. (tbc)

File Attachments (5 files)
Comment via email
Mastodon