problem with sending data using RF module


Results 1 to 40 of 52

Threaded View

  1. #23
    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.

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