Infrared HPWM setup


Closed Thread
Results 1 to 20 of 20

Hybrid View

  1. #1
    Join Date
    Oct 2010
    Posts
    413


    Did you find this post helpful? Yes | No

    Default Re: Infrared HPWM setup

    I will do that thanks a lot.

    Yesterday i tried till late at night to set a code for the TX and RX, a very simple one but didnt work.

    tx:

    Code:
    '*-----------------------------------------------------------------------------|
    '*                        |  --------------------- |                           |
    '*----------------------- | EUART 1 Configuration  | --------------------------|
    '*                        |  --------------------- |                           |
    '*-----------------------------------------------------------------------------|                                                                             |
            DEFINE HSER_RCSTA 90h ' Enable serial port & continuous receive
            DEFINE HSER_TXSTA 24h ' Enable transmit, BRGH = 1
            DEFINE HSER_CLROERR 1 ' Clear overflow automatically
            DEFINE HSER_SPBRG 130 ' 9600 Baud @ 64MHz, -0.02%
            SPBRGH = 6
            BAUDCON.3 = 1         ' Enable 16 bit baudrate generator             
    '------------------------------------------------------------------------------|
    
    ID	    VAR BYTE
    button1 var porta.0  ' we configure this button 1 at porta.0
    button2 var porta.1  ' we configure this button 2 at porta.1
    RED     var latc.3   ' a RED LED indicates the PIC working condition
    Blue    var lata.2   ' a Blue LED indicates the push button everytime
    
    high red
    pause 100
    low red 
    pause 50
    high red
    '------------------------------------------------------------------------------|
    BEGIN:
    
       ID	= 10
    if button1 = 0 then 
        gosub button1_pressed
    	endif
    
    low blue
    	GOTO BEGIN
    '------------------------------------------------------------------------------|
    
    button1_pressed:
    high blue
    	    hSEROUT [ID]  ' we send at portc.6 which is connected the IR module at the 74LS00 in pin No2 
    	    PAUSE 100
        return
    
    button2_pressed:
    high blue
    	    hSEROUT [ID]  ' we send at portc.6 which is connected the IR module at the 74LS00 in pin No3 
    	    PAUSE 100
        return
    end
    RX:
    Code:
    '*-----------------------------------------------------------------------------|
    '*                        |  --------------------- |                           |
    '*----------------------- | EUART 2 Configuration  | --------------------------|
    '*                        |  --------------------- |                           |
    '*-----------------------------------------------------------------------------|                                                                             |
    
            DEFINE HSER2_RCSTA 90h ' Enable serial port & continuous receive
            DEFINE HSER2_TXSTA 24h ' Enable transmit, BRGH = 1
            DEFINE HSER2_CLROERR 1 ' Clear overflow automatically
            DEFINE HSER2_SPBRG 130 ' 9600 Baud @ 64MHz, -0.02%
            SPBRGH2 = 6
            BAUDCON2.3 = 1         ' Enable 16 bit baudrate generator
            
    '-------------------------------------------------------------------------------|
    ID	    con 10
    Green   var lata.1   ' a Green LED which indicates the 1st output of the IR input code
    Blue    var lata.0   ' a Blue LED indicates the 2nd output of the IR input code 
    Red     var lata.2   ' a Red LED indicates the PIC working condition
    '------------------------------------------------------------------------------|
    '                 RED LED indicates that PIC is up and running                 |
    '------------------------------------------------------------------------------|
    
    high red
    pause 100
    low red 
    '------------------------------------------------------------------------------|
    
    Begin:
    
    hSERin2 [wait(ID)]
    high red
    'pause 100
    
       gosub FIRST_SIGNAL
    '   endif
    
    '------------------------------------------------------------------------------|
    
    FIRST_SIGNAL:
    high green
    pause 500
    low green
    return
    
    end

  2. #2
    Join Date
    May 2013
    Location
    australia
    Posts
    2,643


    2 out of 2 members found this post helpful. Did you find this post helpful? Yes | No

    Default Re: Infrared HPWM setup

    any Alias that refers to a LATx reg cannot be safely used with HIGH,LOW,TOGGLE or any other pbp high level command
    the sort of bugs it can introduce vary from chip to chip and can be difficult to understand , don't do it

    Blue var lata.2 '; an alias to a lata

    high blue ; will not work safely
    blue = 1 ; will work
    low blue ; will not work safely
    blue = 0 ; will work
    toggle blue ; will not work safely
    blue = !blue ; will work
    etc...

    Yesterday i tried till late at night to set a code for the TX and RX, a very simple one but didnt work.
    how are the chips connected , show a schematic
    Warning I'm not a teacher

  3. #3
    Join Date
    Oct 2010
    Posts
    413


    Did you find this post helpful? Yes | No

    Default Re: Infrared HPWM setup

    I will make the schematic on paper later today and will upload it here.

    thanks

  4. #4
    Join Date
    Nov 2003
    Location
    Greece
    Posts
    4,132


    1 out of 1 members found this post helpful. Did you find this post helpful? Yes | No

    Default Re: Infrared HPWM setup

    Quote Originally Posted by richard View Post
    any Alias that refers to a LATx reg cannot be safely used with HIGH,LOW,TOGGLE or any other pbp high level command the sort of bugs it can introduce vary from chip to chip and can be difficult to understand , don't do it

    Blue var lata.2 '; an alias to a lata

    high blue ; will not work safely
    Though this is the recommended way to control output pins. I suppose this was before LAT registers showed up?

    Ioannis

  5. #5
    Join Date
    Oct 2010
    Posts
    413


    Did you find this post helpful? Yes | No

    Default Re: Infrared HPWM setup

    Please find the schematic as follows.

    I hope i didnt forget anything. In any case is very simple.

    Name:  Schematic_IR TX_2023-06-02.png
Views: 1548
Size:  99.8 KB

  6. #6
    Join Date
    May 2013
    Location
    australia
    Posts
    2,643


    1 out of 1 members found this post helpful. Did you find this post helpful? Yes | No

    Default Re: Infrared HPWM setup

    if you look at the data sheet for a tsop4838 you will see that you have a numbers of issues to contend with
    Name:  ast.jpg
Views: 1906
Size:  106.1 KB

    1. @9600baud the bit time is 100uS or approx 4 cycles of 38khz , about 2 to three times faster than the tsop4838 can cope with
    2. the max burst rate is 800/sec a 9600baud stream can exceed that
    3. after a 70 cycle transmission a 12 cycle min tx gap must be made [some devices can lock up if u don't and need a pwr cycle to recover]
    4. the device will do its very best to reject a continuous transmission and go mute till a min tx gap in tx is observed, which is what you are doing.

    overall tsop4838 is not particularly suitable for serial tx from a uart, you could try a much lower baud rate and you will need to
    invert the transmission logic so that there no transmission at idle

    i would also wire tx to rx directly to verify code works before trying ir link, also have a look at Manchester encoding and check out ir tx protocols like RC5/6 NEC etc
    Warning I'm not a teacher

  7. #7
    Join Date
    Oct 2010
    Posts
    413


    Did you find this post helpful? Yes | No

    Default Re: Infrared HPWM setup

    Hi Richard,

    you are right, i have decreased the speed and manage to play a lit bit with the delay in useconds.

    I worked somehow but not always reliable.

    I think i will try the RC5 method.

  8. #8
    Join Date
    May 2013
    Location
    australia
    Posts
    2,643


    1 out of 1 members found this post helpful. Did you find this post helpful? Yes | No

    Default Re: Infrared HPWM setup

    I worked somehow but not always reliable.
    the series resistor for the led is wat too big, it will make range / reliability pretty low. it could go as low as 39 ohms safely [probably lower even] in a non continuously on configuration otherwise 100 ohm would be better
    Warning I'm not a teacher

Similar Threads

  1. Replies: 3
    Last Post: - 23rd October 2011, 12:53
  2. InfraRed Data Com
    By rayzrocket in forum Off Topic
    Replies: 5
    Last Post: - 29th March 2010, 15:42
  3. Infrared x PIC
    By ewandeur in forum mel PIC BASIC Pro
    Replies: 3
    Last Post: - 29th December 2009, 18:30
  4. infrared help
    By griffin in forum mel PIC BASIC Pro
    Replies: 4
    Last Post: - 30th December 2008, 05:34
  5. infrared
    By bmohnsen in forum General
    Replies: 1
    Last Post: - 2nd May 2007, 16:35

Members who have read this thread : 4

You do not have permission to view the list of names.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts