Click here to Skip to main content
15,888,351 members
Articles / Programming Languages / Visual Basic

USB IR with c8051

Rate me:
Please Sign up or sign in to vote.
4.50/5 (3 votes)
18 Jul 2014CPOL2 min read 39.9K   2.4K   36   1
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.

VB.NET
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, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


Written By
Estonia Estonia
This member has not yet provided a Biography. Assume it's interesting and varied, and probably something to do with programming.

Comments and Discussions

 
QuestionLong in the tooth. Pin
SteveHolle18-Jul-14 9:56
SteveHolle18-Jul-14 9:56 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.