This is a post from my original site, which was hosted by the former blog service of the University of Osnabrück. I have moved it to the new site for archiving. Pages linked in this article may no longer work today, and the blog comments under the article no longer exist. Opinions expressed in this article reflect the point of view of the time of publication and do not necessarily reflect my opinion today.
Wer im Internet nach einer USB- Relais karte sucht (damit kann man Schalter per USB auslösen, beispielsweise um einen Drucker vom Computer aus vom Netz zu trennen, irgendwelche Lichter zu schalten oder vielleicht auch Kaffee zu kochen), der wird früher oder später auf das entsprechende Selbstbau-Projekt von Ulrich Radig stoßen. Sie bietet sechs einzelnd schaltbare Relais (bis 8A/250 VAC) und vier per Optokoppler getrennte Eingänge bis max. 48V an. Die Platine kann man in seinem Shop bestellen, den Rest gibt's bei Reichelt oder Conrad. Alles in allem muss man mit etwa 50 EUR rechnen, wobei die teuersten Teile die Platine, die Relais, das Netzteil und der Versand sind. Und so sieht's dann aus:
USB-Relaiskarte von Ulrich Radig
Im Gegensatz zum Original habe ich ein paar kleine Änderungen vorgenommen. Die Relais stecken auf Sockeln von Typ "FIN 95.15.2", damit man sie zum Experimentieren am Treiber abnehmen kann und beim Löten nicht beschädigt. Da der eigentlich vorgesehene Relaistyp bei Reichelt nicht verfügbar war, habe ich den Typ "FIN 41.61.9 12V" verwendet. Der unterschied ist im wesentlichen nur, dass das Original zwei parallele Schalter besitzt und dieser hier nur einen. Das ist aber nicht schlimm, da der zweite Schalter vom Platinenlayout nicht verwendet wird. Des Weiteren habe ich gelbe statt rote LEDs für die Eingänge verwendet und dem Darlington-Array (ULN 2003A) einen Sockel spendiert, da es beim ersten mal ein wenig empfindlich auf die Hitze des Lötkolben reagierte ;-). Potentiellen Nachbauern würde ich nahelegen, die Power-LED ebenfalls durch eine andersfarbige zu ersetzen, um sie deutlicher von der Relais-Kontroll-LED unterscheiden zu können. Dazu muss der entsprechende Widerstand angepasst werden.
Update:
Neben dem ULN 2003A hat sich auch die Feinsicherung als problematisch herausgestellt. Jeder noch so kleine Kurzschluss beim Basteln zerstört diese. Ist ja auch ihre Aufgabe, aber sie jedesmal auszulöten ist ganz schön nervig. Als Lösung bietet es sich entweder an während der Entwicklung die Sicherung zu überbrücken (dann aber bitte nur mit einer 9V-Batterie und nicht mit einem Netzteil als Stromquelle arbeiten), oder die Anschlüsse durch Steckkontakte zu ersetzen und darüber mit einer herkömmlichen gefassten Feinsicherung zu verbinden. Letzteres funktioniert hier ziemlich gut :-)
Die rudimentäre Firmware habe ich ein wenig modifiziert, die Details sind in Ulrich's Forum beschrieben. Mit dieser modifizierten Firmware erfolgt die Verwendung wie folgt:
Die Relaiskarte identifiziert sich bei Linux als serielle USB-Schnittstelle /dev/ttyACM0. Unter Windows wird es wohl COM0 oder etwas in der Art sein. Die Steuerung erfolgt über einzelne Bytes, die an diese Schnittstelle gesendet bzw. gelesen werden. Ich habe dazu die pySerial-Bibliothek verwendet.
Zunächst muss das Gerät initialisiert werden, in dem 16 mal hintereinander das Byte 0xC0 (Binär: 11000000) gesendet wird. Bis dahin akzeptiert es keine Eingaben, um Problemen mit der automatischen Hardwareerkennung vorzubeugen. Anschließend ist die Bedeutung der einzelnen gesendeten Bits die folgende:
1 1 1 1 1 1 1 1
8 7 6 5 4 3 2 1
Die Bits 1 bis 6 steuern die einzelnen Relais. Eine 1 an der entsprechenden Position aktiviert das Relais, eine 0 deaktiviert es. Das 7. Bit ändert dies in einen "Toggle"-Befehl um, wenn es aktiviert ist. Der Befehl 01000000 macht also gar nichts, der Befehl 01111111 ändert den Zustand aller Relais. Das 8. Bit fordert von der Karte eine Statusmeldung an.
An den PC gesendet werden einzelne Bytes, deren Bits entwedern den Status der Eingänge (8. Bit = 0) oder der Relais (8. Bit = 1) angeben. Diese Ausgabe erfolgt entweder automatisch, wenn sich der Zustand eines Eingangs ändert, oder explizit wenn eine Statusanfrage angefordert wurde (8. Bit = 1 im gesendeten Byte).
This is a post from my original site, which was hosted by the former blog service of the University of Osnabrück. I have moved it to the new site for archiving. Pages linked in this article may no longer work today, and the blog comments under the article no longer exist. Opinions expressed in this article reflect the point of view of the time of publication and do not necessarily reflect my opinion today.
Zutaten:
20 Vishay TSAL6400 Infrarot-LEDs (940nm)
4 Widerstände 10 Ohm
Steifenrasterplatine, in zwei Stücke mit je 1cm Breite geschnitten (quer zum Raster)
2m Kabelkanal
Netzteil 7,5V bis 9V, ca. 500mA
Ein paar Kabel und Drahtbrücken
Alles in einen Topf geben, gut mit heißem Lötzinn verrühren, und voilà:
Details: Es werden jeweils 5 IR-LEDs in Serie an einen 10-Ohm-Widerstand geschaltet, also zwei dieser Arrays auf jeder Seite. Eine Betriebsspannung von 7,5V bedeutet dann pro LED ca. 1,3V und damit die normale Forward Voltage der TSAL6400. Legt man statt dessen 9V an, so kommt man auf ca. 1,6V, was der "Maximum Forward Voltage" dieser LED entspricht. So kann man bei Bedarf noch etwas mehr "Helligkeit" herausholen. Falls dies immer noch nicht reicht kann man weitere Arrays hinzufügen. Aber bitte auf den Strombedarf achten, im Zweifel das Netzteil lieber etwas höher dimensionieren.
Nachtrag: Die Reichweite beträgt schon bei 7,5V locker 25 Meter... :-)
This is a post from my original site, which was hosted by the former blog service of the University of Osnabrück. I have moved it to the new site for archiving. Pages linked in this article may no longer work today, and the blog comments under the article no longer exist. Opinions expressed in this article reflect the point of view of the time of publication and do not necessarily reflect my opinion today.
My Wii Sensor Bar is built of two arrays of IR-LED that get its power from a proprietary port on the Wii / WiiU. Since I have a beamer as second screen with its own Sensor Bar, a Wii-to-HDMI-Adapter and a 4x2 HDMI switch I don't want to unplug and reconnect the sensor bar cable anymore when I switch from one screen to the other.
My idea: connect one sensor bar to the USB port of the TV, and the other one to the USB port of the beamer, so both will only be enabled when the specific screen is in use. Another reason to get power from an external power supply could be that you have both, a Wii and a WiiU.
So, I've tried to find out what current and amperage the sensor bar requires, and since I did not find any reliable information I've took a screwdriver, my multimeter and had a look at it.
Important: These pictures where taken on a cloned sensor bar from ebay since I don't have a screwdriver for the Tri-Wings Nintendo used on the original one. The original sensor bar has five LEDs on each side which means that you would have to short-circuit two of them when following this guide. Otherwise you would need a power source with a minimum current of 7.5V.
When measured at the connector on the Wii's backside the multimeter shows a current of 12V. But measured under load directly at the sensor bar the current goes down to 5.5V. I think this is due to the relative long cable combined with extremly thin wires, resulting in a relative high resistivity R0. However, the exact value doesn't matter since I will replace the cable anyway.
My sensor bar consists of two arrays of three LED, both having their own R1=24Ω resistors. I'm not sure what kind of infrared LED is used but some googling reveals that 940nm seems to be reasonable. Typical values for these LEDs are a Vf=1.5V and If=50mA, so we have 150mA on each side and a total of 300mA a total of 100mA (thanks @ Daniel for correcting this error). The minimal required current is 3*1.5V=4.5V, which is lower than the 5V specified for USB[1] (if your sensor bar has more LEDs on each side you should bridge or remove all but three on each side). Combined with a 10Ω resistor R1 on each side this should be fine.
The first step is to unsolder the existing cable. Use a desoldering pump to clean the holes on the board from the old solder. Now take an existing USB cable (for example an old MicroUSB cable), remove the Type B plug and strip the isolation. You only need the wires for +5V and Ground, which are typically colored in red and black, so you should remove the other ones. Strip the inner isolation, put some solder on the conductors and connect them with the ports on the board where the original cable was connected. The holes are labed on the back side of the board with + (red) and - (black). The + conductor is connected with the first LED on both sides, the - conductor with the resistors. If you inadvertently switched the poles, this is not fatal, since diodes only allow the current to pass in one direction - but the sensor bar will not work, of course.
Next, remove the original resistors and replace each of them with a 10Ω resistor.
Now you should take your multimeter and a camera (most digital cameras are able to see infrared light) and check if the sensor bar works. For personal security I suggest to use an external power bank for this test.
If you see the IR-LEDs on the camera screen you can connect the sensor bar to your TV and test them. Maybe you have to calibrate the sensivity of your Wiimotes since the brightness might have changed, especially when you were forced to bridge some LEDs.
[1]: Please note that USB uses a low-power mode per default that does not allow a device to pull more that 100mA from the port. If a device requires more power (up to 500mA) it has to ask the USB controller for permission. Since this requires active components we do not have please ensure that no other USB devices are connected to the same port, or usea dedicated USB power supply.