Click here to Skip to main content
65,938 articles
CodeProject is changing. Read more.
Articles
(untagged)

USB IR with c8051

0.00/5 (No votes)
18 Jul 2014 2  
USB IR with c8051

USB_IR_with_c8051/previews2.JPG

View large

Introduction

This is a WinLirc like application that uses USB toolstick instead of RS232 and suits all TV remotes.
It can remotely control your computer with IR remote control of all manufacturers and needs only a toolstick from silabs.
This toolstick can be either Toolstick Base adapter (F326) or toolstick debug adapter (F321).
The same applies for IR sensor - suits all of them that operate on 5V and receives 38KHz signal(TSOP -1708, IRM8752, practically any IR receive module) or any 3,3V if you supply 3.3V and make changes to schematics.

Of course IR-sensor does not bring TX-pin up enough, you need to supply 4,7K resistor between 5V and RX-pin for debug adapter input (something like this).

Background

Look also at Counter_based_c8051.aspx and Toolstick_LCD_with_c8051.aspx from my previous work and projects that using the same 'debug adapter'.

Using the Code

You can put the named IR codes to 'Settings.ini' file located in app.path folder and teach the program to understand the remote by setting ShowTheMatch=true.
Then you can copy-paste code between '' symbols from main window to 'Settings.ini'.
Repeated codes are marked with ':Nr'. Really it's the ir-repeat code '01' that remote sends when you hold down the button for a long time.
It's not important- but when you want to increase 'volume' by remote - it's convenient to hold the button instead of repeatedly pushing it again and again. 
To not confuse the sent signals with others that are repeating - the program periodically resets the actual signal to zero (that means when remote does not send code for 100ms, it resets the sent signal to zero - and the program waits for the actual code again).
This is needed to eliminate the IR-detector faulty noise signals (due to interference from luminofor lamps or other).

USB_IR_with_c8051/NotMatch.JPG

By default, the signal length is put to catch 22-bit length signals- you can change that accordingly to match your remote in code.

If CurIndex > 22 Then
    '---------------
    For i = 0 To MaxCodesCount
        If Codes(i).CodeBinary = Code Then
            Code = Codes(i).CodeName
            match = True
            Exit For
        End If
    Next i
        If match Then
            Interval = 0
            RepeatCount = 0
            RaiseEvent ReadMess(Code & ":" & RepeatCount & vbCrLf, 1)
            PrevCode = Code
            bRepeat = True
        Else 'not match found
            If ShowNotMatching Then RaiseEvent ReadMess_
        	      ("not match '" & Code & "'" & vbCrLf, 1)
                bRepeat = False
        End If
    '-------------------
    'Code = ""
End If

Notify.dll acts like intermediate notification events messenger for the main app.
WindowTitle.dll periodically checks for a window.hWnd number and notifies the main app through notify.dll the changes.

Sample Settings.ini:

[Codes]
ShowNotMatching=0
Max=6
0=000101111101011001101111;Up
1=00010111110101100100111;Down  
2=00010111110111000011101;Right
3=0001011111001000011101;Left
4=0001011111011010000101;OK
5=0001011111001000100111;Top
6=0001011111000100010111;Off		

In my app, I send messages to a window named 'VLC DirectX video' and 'TV'.
In addition, I can remotely 'shut down' the computer.

License

This article has no explicit license attached to it but may contain usage terms in the article text or the download files themselves. If in doubt please contact the author via the discussion board below.

A list of licenses authors might use can be found here