Uncategorized

HOW-TO: USB REMOTE control RECEIVER

now that we listen to MP3s, as well as view XVIDs or x264s, a computer is the enjoyment center in at least one space of many homes. Unless you have a special HTPC, though, you’re most likely stuck using the keyboard to pause, modification the volume, as well as fast-forward through bothersome Mythbusters recaps. PC remote control receivers variety from ancient serial port designs (who has one?) to USB devices not supported by prominent software. In this how-to we style a USB infrared receiver that imitates a typical protocol supported by software for Windows, Linux, as well as Mac. We’ve got a full guide to the protocol plus schematics as well as a parts list.

Design overview

Remote controls transmit data on an modulated infrared beam. An infrared receiver IC separates the modulated beam into a clean stream of 0s as well as 1s. The data stream is decoded by a microcontroller as well as sent to a computer over a USB connection. software processes the codes as well as triggers actions on the computer.

Ιστορικό

Computer infrared receivers

The oldest PC infrared receiver style uses a receiver IC to toggle a serial port pin, typically DCD. This style most likely originated on Usenet, as well as it’s still the most prominent on the web: Engadget, Instructables, etc. These aren’t true serial devices since they don’t send data to the PC. Instead, a computer program times pulses on the serial port as well as demodulates the signal. This is a very easy design, however it depends on direct interrupt gain access to as well as timing precision that’s no longer offered in Windows. Linux or Mac users can try this receiver, if you still have a serial port. We couldn’t get this type of receiver to work with the serial port on a contemporary Windows XP PC, as well as don’t expect the accurate timing to transfer through a USB->serial converter.

Some a lot more advanced infrared receivers are true serial port devices that determine or decoding infrared signals before sending data to the computer. The UIR/IRMan as well as UIR2 integrate a traditional picture 16F84, however don’t supply firmware and/or source code. These devices ought to work on a contemporary computer, through a USB->serial converter if necessary. The USBTINY as well as USBIRBOY are native USB devices, however lack broad support.

Receiver software

Regardless of receiver type, the computer needs a program to listen for incoming remote commands as well as convert them to actions on the computer. Linux as well as Mac users have LIRC, which supports a lot of different receiver types. Windows users are a bit less fortunate. WinLIRC is an abandoned Windows port of LIRC for easy interrupt-based serial port receivers; WinLIRC was last developed in 2003. Girder was originally a freeware PC automation utility, however has ended up being costly bloatware with a 30 day trial. Fortunately, the last freeware version of Girder (3.2.9b) is still offered for download.

Working with IR remote protocols

Decoding IR signals

Remote controls encode commands in the spacing or timing of a 38KHz provider pulse, [San Bergmans] has an explanation of the principals involved. An infrared receiver IC separates the data stream from the carrier. Our task is to decode the data stream with a microcontroller. There are dozens of remote control protocols, however Phillips’ RC5 is widespread as well as typically used by hobbyists.

RC5 is stream of 14 equal length bits of precisely 1.778ms per bit time. A pulse during the very first half of the bit time represents 0, a pulse in the second half represents 1. This plan is called Manchester coding.

We used a logic analyzer to take a look at the output of a Happauge WinTV remote control, a known RC5 remote. The diagram shows two presses of the 1 button, as well as two presses of the 2 button; note that the output is inversed as well as the Manchester coding is backwards from the above description.

The very first two bit times are start bits, followed by a toggle bit. The toggle bit inverses each time a button is pressed so the receiver can tell the difference between a hold as well as a repeated press. The next 5 bits are the address (0b11110=0x1E), followed by the command (0b000001=0x01, 0b000010=0x02). A backwards compatible extension to RC5 uses the second start bit as command bit 7.

Representing remote codes to the computer

Looking at previous designs, we saw three general methods of communicating remote commands to a computer:

Protocol particular receivers decode one protocol, as well as send actual decoded commands to the PC

A a lot more general type of receiver steps the timing as well as spacing of each pulse as well as sends the full waveform to the PC for analysis.

Some receivers produce a distinct hash for a signal, however don’t really include sufficient data to completely recreate the waveform.

While our preference is towards the general hash method, our only remote uses RC5 aswell as it was a lot more fascinating to develop an RC5 particular decoder. We explain modifications for a a lot more general version in the firmware section.

Computer interface protocol

We didn’t want to write our own receiver software or driver, so we looked for an existing, well recognized communication protocol to imitate. The UIR/IRMAN/IRA/CTInfra/Hollywood+ type receiver is supported by Girder as well as LIRC, as well as uses a easy serial protocol with handshake:

The gadget is initialized by the DTS as well as DTR pins of the serial port. We don’t have these as well as don’t care.

The computer sends “IR”, with an optional delay. The gadget replies “OK”. We’ll just send “OK” on every “R”

Remote control codes are sent as a distinct six byte hash. We’ll decode an RC5 signal as well as send the actual values, however a generic hash might be used instead.

This protocol is for a serial port device, however our USB receiver will appear as a virtual serial port as well as the program won’t understand the difference.

Σκεύη, εξαρτήματα

Click right here for a full size schematic (png). Our receiver is based on a USB enabled picture 18F2455 microcontroller, the smaller, less expensive version of the 18F2550. The 18F household is programmable with the hobbyist preferred JDM-style programmers if a diode is used to decrease VPP to a risk-free level. The picture gets one decoupling capacitor (C1), as well as a diode (D1) as well as resistor(R1) on the ICSP programming header. We exposed the serial port on a pin header for debugging or a mixed USB/serial port version using a MAX RS232 transceiver IC.

The USB peripheral requires a 20MHz outside clock (Q1, C5,6), as well as a .220uF capacitor. We faked the capacitor using 2 x .1uF decoupling capacitors (C2,3). A 3mm LED (LED1) as well as a 330ohm present limiting resistor (R2) show USB connection status.

We used a TSOP-1738 infrared receiver IC which calls for a 4.7uF decoupling capacitor (C4). If you can’t discover this specific IC, any type of receiver noted right here ought to work. The TSOP-1738 output is the inverse of the received signal, it pulls to ground when a pulse is detected, so a pull-up resistor (R3) holds the pin high when no signal is present. check if you use a different receiver, you may requirement to use a pull-down resistor as well as reverse the Manchester decoding routine in the firmware.

The circuit draws power from the USB bus, so we don’t requirement an extra power supply.

Parts list

Click right here for a full size placement diagram (png). The PCB style is 100% through-hole as well as single sided. The schematic as well as PCB were made with Cadsoft Eagle, freeware versions are offered for many platforms. All the files are included in the job archive (zip).

Μέρος

Περιγραφή

Ic1

PIC 18F2455

28 pin .300 socket

C1,2,3

0.1uF capacitor

C4

4.7uF capacitor

C5,6

27pF capacitor (15pF may be better)

D1

1N4181 diode

Q1

20MHz crystal

R1,3

10K ohm resistor

R2

330 ohm resistor

TSOP

TSOP1738 (obsolete, try TSOP1138)

USB

USB ‘B’ plug, female

SER

.1″ pin header

Icsp

.1″ pin header

Υλικολογισμικό

The firmware is written in C using Microchip’s complimentary presentation C18 compiler. Firmware as well as source are included in the job archive (zip).

We used version 2.3 of Microchip’s USB stack to produce a USB serial port using the default chauffeurs already offered on many systems. The USB stack has easy functions to enumerate the USB gadget as well as transfer data between gadget as well as host. It only took a few pin changes to get the CDC presentation working on our custom-made hardware.

Our implementation of the UIR/IRMAN/IRA/CTInfra/Hollywood+ protocol simply responds to the letter ‘R’ with ‘OK’. This ought to satisfy the handshake requirements of any type of implementation of this protocol.

We chose to specifically decode RC5 (and RC5x) since it’s a widely used protocol, as well as the only type of remote we have to work with. many of the decoding is done in the interrupt handler:

The very first signal modification triggers an interrupt that starts a 889us (one-half bit period) timer.

On each timer interrupt, one-half of a Manchester coded bit is sampled.

Every other interrupt the measurements are compared, as well as the bit value is calculated to be 0, 1, or an error. Errors reset the decoding routing.

At the end of each transmission the address as well as command bytes are decoded, as well as sent to the host with 4 buffer bytes(0). We discard the toggle bit since it would confuse the PC software into thinking every other press was a distinct code. We append the second start bit to the command bit for RC5x compliance; this just adds 0x40 to non RC5x remote codes.

A a lot more general version can be made by removing the Manchester coding step (3), as well as sending 48 sample bits (all 6 bytes) to the computer.

Installing the USB infrared receiver

Most operating systems already have chauffeurs that support aΕικονικό gadget σειριακής θύρας όπως ο δέκτης. Ωστόσο, τα Windows XP έχουν τα απαιτούμενα προγράμματα οδήγησης, ωστόσο χρειάζεται βοήθεια από ένα .inf Δεδομένα για να τους συνδέσετε κατάλληλα με τη συσκευή μας.

Τα Windows θα εμφανίσουν το νέο παράθυρο διαλόγου υλικού την πρώτη φορά που συνδέετε τον δέκτη. Επιλέξτε για να χρησιμοποιήσετε έναν προσαρμοσμένο αυτοκινητιστή καθώς και να το τοποθετήσετε στα δεδομένα .inf που περιλαμβάνονται στο αρχείο εργασίας (zip). Αυτό συνδέει το gadget σε έναν αυτοκινητιστή που έχει ήδη συμπεριληφθεί στα Windows, καθώς και προσθέτει τον δέκτη ως θύρα COM. Μπορείτε να ελέγξετε τον αριθμό θύρας COM στον πίνακα ελέγχου.

Ο Mac καθώς και οι χρήστες του Linux μπορούν να χρησιμοποιήσουν τον δέκτη με το LIRC, ωστόσο οι χρήστες των Windows θα αντιμετωπίσουν την επιλογή του παλιού, χωρίς λογισμικό, ή της νέας έκδοσης Shareware Trawware 30 ημερών. Χρησιμοποιήσαμε την ελεύθερη έκδοση του δοκού, ωστόσο, ελπίζουμε ότι οι άνδρες μπορούν να προτείνουν ένα μεγάλο, ανοιχτό πηγές εναλλακτικό που παραβλέψαμε.

Ανεξάρτητα από το λογισμικό ελέγχου του υπολογιστή που χρησιμοποιείτε, το διαμορφώνετε για ένα δέκτη UIR / IRMAN / IRA / IRA / CTINFRA / Hollywood +, καθώς και μεταβείτε στη θύρα COM ή η σειριακή διεύθυνση που αντιστοιχεί σε αυτό. Ο δέκτης μας είναι επίσης συμβατός με οποιεσδήποτε επιλογές πρωτοκόλλου όπως το “γρήγορο Uir init” καθώς και το skip uir init check ‘, το οποίο συντομεύει ή απαλλαγεί από τη χειραψία “IR” -> “OK”. Τώρα ελέγξτε τον δέκτη καθώς και προσθέστε ένα τηλεχειριστήριο σύμφωνα με την τεκμηρίωση για το λογισμικό σας.

Χειροκίνητη διασύνδεση τερματικού καθώς και σφαλμάτων

Εάν έχετε ένα ζήτημα με τον δέκτη ή είστε απλά περίεργοι, προσπαθήστε να το διασυνδέσετε από ένα σειριακό τερματικό. Αληθινά όπως ο σειριακός τερματικός σταθμός του Ηρακλή. Ορίστε τη σωστή θύρα COM, ωστόσο η ταχύτητα καθώς και οι ρυθμίσεις διαμόρφωσης αγνοούνται από τον οδηγό σειριακού θύρα USB.

Μια χρηματοδότηση ‘R’ θα είναι έγκαιρα ο δέκτης για να απαντήσει ‘ok’. Οι κωδικοί RC5 επιστρέφονται ως ακατέργαστα bytes, οπότε φροντίστε να ρυθμίσετε το τερματικό σας για να εμφανίσετε τις εξαγωνικές τιμές αντί να το μεταφράσετε ως κείμενο ASCII. Το πολύ πρώτο byte είναι το byte διευθύνσεων RC5 (0x1e), ακολουθούμενο από το Byte εντολών (0x41), καθώς και στη συνέχεια τέσσερα buffer 0s για να τηρήσετε το πρωτόκολλο Uir / Irman. Η εικόνα δείχνει τη χειραψία, καθώς και την έξοδο ενός σύντομου τύπου στο 1,2, καθώς και 3 κουμπιά.

Ένα δωρεάν βοηθητικό πρόγραμμα που ονομάζεται Portmon Logs Com Port δραστηριότητα για έλεγχο. Αυτό είναι χρήσιμο για την κατασκοπεία σε υπάρχοντα πρωτόκολλα δέκτη, καθώς και την αποσφάλιση της αλληλεπίδρασης του προσαρμοσμένου υλικού μας καθώς και του κλειστού / ιδιόκτητου λογισμικού. Η εικόνα δείχνει δοκός που αποστέλλει τη συμβολοσειρά αρχικοποίησης «IR» (0x49,0x52), καθώς και η απάντηση του δέκτη «OK» (0x4f, 0x4b).

Το παίρνω περαιτέρω

Ο δέκτης συμμόρφωσης RC5X ακολουθεί ένα ευρέως χρησιμοποιούμενο πρωτόκολλο διασύνδεσης. Υπάρχει ένας τόνος δυνατότητας για επιπλέον χαρακτηριστικά σε έναν υπερύθρων του ανοικτού κώδικα:

Υποστηρίξτε όλα τα τηλεχειριστήρια μέσω μιας γενικής γεννήτριας hash, όπως το αρχικό υλικό Uir / Irman.

Προσθέστε επιπλέον αποκωδικοποιητές απομακρυσμένων πρωτοκόλλων, όπως το RC6.

Υποστήριξη πολλαπλών, ρυθμιζόμενων πρωτοκόλλων διεπαφής.

Εφαρμογή της σειριακής θύρας I / O.

Αποθηκεύστε τις επιλογές διαμόρφωσης στο EEPROM, συμπεριλαμβανομένου του πρωτοκόλλου, της λειτουργίας διεπαφής, τις επιλογές χρονισμού, της σειριακής θύρας κλπ.