problem with sending data using RF module


Closed Thread
Results 1 to 40 of 52

Hybrid View

  1. #1
    Join Date
    Mar 2008
    Posts
    19


    Did you find this post helpful? Yes | No

    Default

    Hello Guys..Thanks for all the advice
    Now my Rx module works fine in a short distance around 5-6 feet.I just add 10k pull up resistor at Rx data pin and 10uF at Vcc.But If I move more than 6 feets, my Rx module start receiving noise and my LCD will display wrong counting numbers.But It's fine to me.At least it's work.I think maybe the problem is from the antenna.I just use a small wire with length 10cm each for my Tx an Rx.So anyone here have any ideas about the antenna??
    Now I'm moving foward to send a data from my keypad. IF I pressed pad1,pad2 and so on..my LCD at transmitter board will display BUS01,BUS02....What I want to do is send the word "BUSxx" each time I pressed the keypad and display it on my LCD at receiver board. So with help and some advice from mister_e..I wrote the code below.But It's not work even I Connect the transmitter and receiver pin directly.
    The FAct Is..I'm very poor with the coding..please help me guys..

    Tx part

    @ device HS_OSC, LVP_OFF
    define OSC 20

    DEFINE LCD_DREG PORTC 'LCD data port
    DEFINE LCD_DBIT 0 'LCD data starting bit 0 or 4
    DEFINE LCD_RSREG PORTB 'LCD register select port
    DEFINE LCD_RSBIT 7 'LCD register select bit
    DEFINE LCD_EREG PORTB 'LCD enable port
    DEFINE LCD_EBIT 5 'LCD enable bit
    DEFINE LCD_RWREG PORTB 'LCD read/write port
    DEFINE LCD_RWBIT 6 'LCD read/write bit
    DEFINE LCD_BITS 8 'LCD bus size 4 or 8
    DEFINE LCD_LINES 2 'Number lines on LCD
    DEFINE LCD_COMMANDUS 2000 'Command delay time in us
    DEFINE LCD_DATAUS 50 'Data delay time in us

    TRISC = %00000000 'Set port B as output
    TRISB = %00000000 'Set port D as output
    low PORTB.6 'Set the R/W bit to low

    pause 1000 'wait until the LCD initializes

    ' Define program variables
    col var byte ' Keypad column
    row var byte ' Keypad row
    key var byte ' Key value
    TransmitterPIN VAR PORTA.0
    YourByteVar var byte
    INCLUDE "modedefs.bas"
    Synk VAR BYTE
    Synk = $55
    DEFINE CHAR_PACING 500

    ADCON1 = 7 ' Make PORTA and PORTE digital


    Pause 100 ' Wait for LCD to start

    Lcdout $fe, 1, "Key In Bus ID" ' Display sign on message

    loop:
    Gosub getkey ' Get a key from the keypad
    Lcdout $FE, $C0, "BUS",DEC2 key ' Display ASCII key number
    PAUSE 200
    Goto loop ' Do it forever

    ' Subroutine to get a key from keypad
    getkey:
    Pause 50 ' Debounce

    getkeyu:
    ' Wait for all keys up
    PORTD = 0 ' All output pins low
    TRISD = $f0 ' Bottom 4 pins out, top 4 pins in
    If ((PORTD >> 4) != $f) Then getkeyu ' If any keys down, loop
    Pause 50 ' Debounce
    getkeyp:
    ' Wait for keypress
    For col = 0 to 3 ' 4 columns in keypad
    PORTD = 0 ' All output pins low
    TRISD = (dcd col) ^ $ff ' Set one column pin to output
    row = PORTD >> 4 ' Read row
    If row != $f Then gotkey ' If any keydown, exit
    Next col

    Goto getkeyp ' No keys down, go look again

    gotkey: ' Change row and column to key number 1 - 16
    key = (col * 4) + (ncd (row ^ $f))
    Return ' Subroutine over

    Main:
    High TransmitterPin
    pause 200
    SEROUT TransmitterPIN,T2400,[Synk,Synk,"~",YourByteVar]
    pause 500
    GOTO Main
    END


    Rx part

    @ device HS_OSC, LVP_OFF
    define OSC 20

    DEFINE LCD_DREG PORTC 'LCD data port
    DEFINE LCD_DBIT 0 'LCD data starting bit 0 or 4
    DEFINE LCD_RSREG PORTB 'LCD register select port
    DEFINE LCD_RSBIT 7 'LCD register select bit
    DEFINE LCD_EREG PORTB 'LCD enable port
    DEFINE LCD_EBIT 5 'LCD enable bit
    DEFINE LCD_RWREG PORTB 'LCD read/write port
    DEFINE LCD_RWBIT 6 'LCD read/write bit
    DEFINE LCD_BITS 8 'LCD bus size 4 or 8
    DEFINE LCD_LINES 2 'Number lines on LCD
    DEFINE LCD_COMMANDUS 2000 'Command delay time in us
    DEFINE LCD_DATAUS 50 'Data delay time in us

    TRISC = %00000000 'Set port B as output
    TRISB = %00000000 'Set port D as output
    low PORTB.6 'Set the R/W bit to low

    pause 1000 'wait until the LCD initializes

    INCLUDE "modedefs.bas"
    ReciverPIN VAR PORTA.0
    ADCON1 = 7 ' Alla digitala
    YourByteVar var byte


    pause 100
    LCDOUT $FE,1, " Receiving Bus ID"

    Main:
    SERIN ReciverPIN,T2400,["~"],YourByteVar
    GOSUB LCD
    GOTO Main

    LCD:
    LCDOUT $FE,1
    Lcdout $FE,$C0,"BUS",DEC2 YourByteVar
    PAUSE 500
    RETURN

    END

  2. #2
    Join Date
    Sep 2004
    Location
    montreal, canada
    Posts
    6,898


    Did you find this post helpful? Yes | No

    Default

    Try those with direct connection.
    Code:
            '
            '       TX code
            '       =======
            '
            @ device HS_OSC, LVP_OFF
            define OSC 20
            
            DEFINE LCD_DREG PORTC 'LCD data port
            DEFINE LCD_DBIT 0 'LCD data starting bit 0 or 4
            DEFINE LCD_RSREG PORTB 'LCD register select port
            DEFINE LCD_RSBIT 7 'LCD register select bit
            DEFINE LCD_EREG PORTB 'LCD enable port
            DEFINE LCD_EBIT 5 'LCD enable bit
            DEFINE LCD_RWREG PORTB 'LCD read/write port
            DEFINE LCD_RWBIT 6 'LCD read/write bit
            DEFINE LCD_BITS 8 'LCD bus size 4 or 8
            DEFINE LCD_LINES 2 'Number lines on LCD
            DEFINE LCD_COMMANDUS 2000 'Command delay time in us
            DEFINE LCD_DATAUS 50 'Data delay time in us
            
            TransmitterPIN VAR PORTA.0
            
            DEFINE CHAR_PACING 500
            
            TRISA = 0 'Set port A as output         
            TRISB = 0 'Set port B as output
            TRISC = 0 'Set port C as output
            TRISD = 0 'Set port D as output
            
            ' Define program variables
            INCLUDE "modedefs.bas"
            col     var byte ' Keypad column
            row     var byte ' Keypad row
            key     var byte ' Key value
            Synk    VAR BYTE
                    Synk = $55
            
            ADCON1 = 7 ' Make PORTA and PORTE digital
            
            low PORTB.6 'Set the R/W bit to low        
            High TransmitterPin
            Pause 500 ' Wait for LCD to start
            Lcdout $fe, 1, "Key In Bus ID" ' Display sign on message
    
    loop:
            Gosub getkey ' Get a key from the keypad
            Lcdout $FE, $C0, "BUS",DEC2 key ' Display ASCII key number
            SEROUT TransmitterPIN,T2400,[Synk,Synk,"~",KEY]
            Goto loop ' Do it forever
    
            ' Subroutine to get a key from keypad
    getkey:
            PORTD = 0                   ' All output pins low
            TRISD = $f0                 ' Bottom 4 pins out, top 4 pins in
            WHILE PORTD != $F0 : wEND   ' Wait 'till all key=up
            PAUSE 50                    ' Debounce
    
    ScanKeypad:
            For col = 0 to 3                '
                TRISD=~(DCD COL)            ' Set one I/O to output
                PAUSEUS 5                   ' wait a little bit to avoid
                                            '   erratic results
                                            '
                ROW=ncd((~(PORTD>>4)) & $f) ' read row
                                            '
                IF ROW THEN                 ' Any key pressed?
                    key = ((row-1)*4)+ col+1' --- YES convert key value
                    return                  '     and getout of here
                    ENDIF                   '
                NEXT                        '
            Goto ScanKeypad                 ' No keys down, go look again
    Notice the change in the Keypad scanning routine... this one seems to never have any erratic results now.

    Code:
            '
            '       RX code
            '       =======
            '
            @ device HS_OSC, LVP_OFF
            define OSC 20
            
            DEFINE LCD_DREG PORTC 'LCD data port
            DEFINE LCD_DBIT 0 'LCD data starting bit 0 or 4
            DEFINE LCD_RSREG PORTB 'LCD register select port
            DEFINE LCD_RSBIT 7 'LCD register select bit
            DEFINE LCD_EREG PORTB 'LCD enable port
            DEFINE LCD_EBIT 5 'LCD enable bit
            DEFINE LCD_RWREG PORTB 'LCD read/write port
            DEFINE LCD_RWBIT 6 'LCD read/write bit
            DEFINE LCD_BITS 8 'LCD bus size 4 or 8
            DEFINE LCD_LINES 2 'Number lines on LCD
            DEFINE LCD_COMMANDUS 2000 'Command delay time in us
            DEFINE LCD_DATAUS 50 'Data delay time in us
                   
            TRISA = 1 ' PORTA.0 input, other as output
            TRISB = 0 ' Set port B as output
            TRISC = 0 ' Set port C as output
            TRISD = 0 ' Set port D as output
    
            ReciverPIN VAR PORTA.0
           
            ADCON1 = 7 ' Alla digitala
    
            INCLUDE "modedefs.bas"
            YourByteVar var byte 
    
            low PORTB.6 'Set the R/W bit to low
            pause 500 'wait until the LCD initializes
            LCDOUT $FE,1, " Receiving Bus ID"
    
    Main:
            SERIN ReciverPIN,T2400,["~"],YourByteVar
            Lcdout $FE,$C0,"BUS", DEC2 YourByteVar
            GOTO Main
    Side note...There's no major advantage to use LCD in 8 bit mode.. R/W pin could also be tied directly to ground. This done you save 5 I/Os.
    Last edited by mister_e; - 5th April 2008 at 23:25.
    Steve

    It's not a bug, it's a random feature.
    There's no problem, only learning opportunities.

  3. #3
    Join Date
    Nov 2003
    Location
    Wellton, U.S.A.
    Posts
    5,924


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by rano_zen06 View Post
    So anyone here have any ideas about the antenna??
    To start learning about antennas, go here
    http://www.linxtechnologies.com/Supp...ication-Notes/
    and read app notes AN-00500 and AN-00501.

    Let us know if you need anything clarified.
    Dave
    Always wear safety glasses while programming.

  4. #4
    Join Date
    Nov 2003
    Location
    Wellton, U.S.A.
    Posts
    5,924


    Did you find this post helpful? Yes | No

    Default

    Forgot to answer you question.

    It looks like you could have the 315 or 434 MHz
    The antenna length for

    315 MHz = 22.63 cm
    434 MHz = 16.43 cm

    The above figures are just "ball park" starting lengths. Use the one for your frequency and even with out a good ground plane you should see improvement.
    Dave
    Always wear safety glasses while programming.

  5. #5
    Join Date
    Mar 2008
    Posts
    19


    Did you find this post helpful? Yes | No

    Default

    Hello Steve,
    Since I still receive noise..I decide to use Holtek encoder/decoder which is HT12E/HT12D. I construct the circuit following your advice and connect all data pins at HT12E/HT12D to port A0-PortA3.The decoder works fine but the encoder have a little bit problem.That's why I'm not receiving any signal because When I check OSC pin at encoder using logic probe,it show logic low at OSC 1 and show nothing at OSC 2.For your Information, I put 1M resistor between these 2 pins. Don't know what's really happen with my encoder. If you have any idea about the problem..can you please share it with me??

  6. #6
    Join Date
    Sep 2004
    Location
    montreal, canada
    Posts
    6,898


    Did you find this post helpful? Yes | No

    Default

    I never used those ICs... maybe you could some something in this document
    http://rentron.com/remote_control/remotes.pdf

    It show different value for the resistor. I didn't read the according datasheet to see if it affect anything though.

    Maybe you screw the OSC signal with your probe.. use a scope instead, set your probe to 10X (or 100X if you have any) and see what happen.

    TE pin should be tied low too unless the oscillator won't run.. as per Their Block Diagram (page 2) in their datasheet.
    http://www.holtek.com/pdf/consumer/2_12ev110.pdf

    As usual, Before you attach your RF modules, try direct connection, Dout to Din of your Holtek ICs.

    HTH
    Last edited by mister_e; - 8th April 2008 at 17:02.
    Steve

    It's not a bug, it's a random feature.
    There's no problem, only learning opportunities.

  7. #7
    Join Date
    Mar 2008
    Posts
    19


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by mister_e View Post
    I never used those ICs... maybe you could some something in this document
    http://rentron.com/remote_control/remotes.pdf

    It show different value for the resistor. I didn't read the according datasheet to see if it affect anything though.

    Maybe you screw the OSC signal with your probe.. use a scope instead, set your probe to 10X (or 100X if you have any) and see what happen.

    TE pin should be tied low too unless the oscillator won't run.. as per Their Block Diagram (page 2) in their datasheet.
    http://www.holtek.com/pdf/consumer/2_12ev110.pdf

    As usual, Before you attach your RF modules, try direct connection, Dout to Din of your Holtek ICs.

    HTH
    Thanks for the reply.
    I already test the holtek IC using direct connection but the result is still the same.No noise but The Rx cannot receive the data and my LCD just show static word "BUS15". Maybe there is something wrong with the code.I post the code below.Can you check it for me??

    Tx part

    '
    ' TX code
    ' =======
    '
    @ device HS_OSC, LVP_OFF
    define OSC 20

    DEFINE LCD_DREG PORTC 'LCD data port
    DEFINE LCD_DBIT 0 'LCD data starting bit 0 or 4
    DEFINE LCD_RSREG PORTB 'LCD register select port
    DEFINE LCD_RSBIT 7 'LCD register select bit
    DEFINE LCD_EREG PORTB 'LCD enable port
    DEFINE LCD_EBIT 5 'LCD enable bit
    DEFINE LCD_RWREG PORTB 'LCD read/write port
    DEFINE LCD_RWBIT 6 'LCD read/write bit
    DEFINE LCD_BITS 8;4 'LCD bus size 4 or 8
    DEFINE LCD_LINES 2 'Number lines on LCD
    DEFINE LCD_COMMANDUS 2000 'Command delay time in us
    DEFINE LCD_DATAUS 50 'Data delay time in us

    TransmitterPIN VAR PORTA.0

    DEFINE CHAR_PACING 500

    TRISA = 0 'Set port A as output
    TRISB = 0 'Set port B as output
    TRISC = 0 'Set port C as output
    TRISD = 0 'Set port D as output

    ' Define program variables
    INCLUDE "modedefs.bas"
    col var byte ' Keypad column
    row var byte ' Keypad row
    key var byte ' Key value
    Synk VAR BYTE
    Synk = $55

    ADCON1 = 7 ' Make PORTA and PORTE digital

    low PORTB.6 'Set the R/W bit to low
    High TransmitterPin
    Pause 500 ' Wait for LCD to start
    Lcdout $fe, 1, "Key In Bus ID" ' Display sign on message

    loop:
    Gosub getkey ' Get a key from the keypad
    Lcdout $FE, $C0, "BUS",DEC2 key ' Display ASCII key number
    PORTA=KEY
    Goto loop ' Do it forever

    ' Subroutine to get a key from keypad
    getkey:
    PORTD = 0 ' All output pins low
    TRISD = $f0 ' Bottom 4 pins out, top 4 pins in
    WHILE PORTD != $F0 : wEND ' Wait 'till all key=up
    PAUSE 50 ' Debounce

    ScanKeypad:
    For col = 0 to 3 '
    TRISD=~(DCD COL) ' Set one I/O to output
    PAUSEUS 5 ' wait a little bit to avoid
    ' erratic results
    '
    ROW=ncd((~(PORTD>>4)) & $f) ' read row
    '
    IF ROW THEN ' Any key pressed?
    key = ((row-1)*4)+ col+1' --- YES convert key value
    return ' and getout of here
    ENDIF '
    NEXT '
    Goto ScanKeypad ' No keys down, go look again


    Rx Part

    '
    ' RX code
    ' =======
    '
    @ device HS_OSC, LVP_OFF
    define OSC 20

    DEFINE LCD_DREG PORTC 'LCD data port
    DEFINE LCD_DBIT 0 'LCD data starting bit 0 or 4
    DEFINE LCD_RSREG PORTB 'LCD register select port
    DEFINE LCD_RSBIT 7 'LCD register select bit
    DEFINE LCD_EREG PORTB 'LCD enable port
    DEFINE LCD_EBIT 5 'LCD enable bit
    DEFINE LCD_RWREG PORTB 'LCD read/write port
    DEFINE LCD_RWBIT 6 'LCD read/write bit
    DEFINE LCD_BITS 8 'LCD bus size 4 or 8
    DEFINE LCD_LINES 2 'Number lines on LCD
    DEFINE LCD_COMMANDUS 2000 'Command delay time in us
    DEFINE LCD_DATAUS 50 'Data delay time in us

    TRISA = 255 ' PORTA as input
    TRISB = 0 ' Set port B as output
    TRISC = 0 ' Set port C as output
    TRISD = 0 ' Set port D as output

    ReciverPIN VAR PORTA.0

    ADCON1 = 7 ' Alla digitala

    INCLUDE "modedefs.bas"
    YourByteVar var byte

    low PORTB.6 'Set the R/W bit to low
    pause 500 'wait until the LCD initializes
    LCDOUT $FE,1, "Receiving Bus ID"

    Main:
    YourByteVar=PORTA & $0F
    Lcdout $FE,$C0,"BUS", DEC2 YourByteVar
    GOTO Main

  8. #8
    Join Date
    Sep 2004
    Location
    montreal, canada
    Posts
    6,898


    Did you find this post helpful? Yes | No

    Default

    There's nothing wrong in your code, has to be a hardware problem.

    Scope the DO of your Encoder.. anything going out of it?

    IF so, erm... why the decoder don't work... mmm let me guess, this Resistor for the OSC? Could be, did you tried with both value in the first PDF i sent you?
    Last edited by mister_e; - 8th April 2008 at 19:04.
    Steve

    It's not a bug, it's a random feature.
    There's no problem, only learning opportunities.

Similar Threads

  1. Using Nokia LCD
    By BobP in forum mel PIC BASIC Pro
    Replies: 300
    Last Post: - 3rd May 2018, 04:47
  2. Read/Write Problem
    By Tobias in forum mel PIC BASIC Pro
    Replies: 1
    Last Post: - 10th February 2010, 01:51
  3. Big characters on HD44780 4x20
    By erpalma in forum mel PIC BASIC Pro
    Replies: 23
    Last Post: - 7th January 2007, 02:21
  4. LCD + bar graph
    By DynamoBen in forum mel PIC BASIC Pro
    Replies: 13
    Last Post: - 5th October 2005, 14:50
  5. Sinus calculating !
    By Don Mario in forum mel PIC BASIC Pro
    Replies: 29
    Last Post: - 28th November 2004, 23:56

Members who have read this thread : 0

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