PIC to PIC TX RX and PIC to PC COM RX ..a little help please


Closed Thread
Results 1 to 40 of 68

Hybrid View

  1. #1


    Did you find this post helpful? Yes | No

    Default it works ...kinda

    Hi Dave :-)
    How are you ?

    Well the lines you gave me work on the wire ..just like before...so I decided to try the TX/RX RF pair TLP-434 and RLP-434 from Bruce at Rentron.
    And .... it works ...kinda :-)
    Instead of seeing the number 3 (DEC 3) it shows me the number 2 (DEC 2) in MCS serial terminal window.
    oh and it also seems to bypass the if NET=3 statement/test for some reason ..I don't think it ever 'sees' a 3 coming in.
    So now I'm wondering where I have gone wrong :-(

    Here's my receiver code :

    Code:
    '*************************************
    'Keypress display on LCD and TX to wherever
    '*************************************
    
    'Ocsillator selections here
    'DEFINE OSC 8
    'OSCCON=%01110000
    'or
    'DEFINE OSC 4
    'OSCCON=%01100000
    'OSCTUNE.6 = 0 'PLL Multiplier disabled
    'OSCTUNE.6 = 1 'PLL 4x
    'Ocsillator selections here
            OSCCON = $70            'Int CLK 8MHz
            OSCTUNE.6 = 1           'PLL 4x
            ADCON1= %00001111       '$0F = disable A/D converter
            cmcon   =   7 
            INTCON2.7 = 0     'switch pull-ups ON
    'END of oscillator selections
      'timer/oscillator defines 
            DEFINE OSC 32            '4x 8MHz
    'END of timer/oscillator defines
    
    'Port IO directions and presets for port pins begin here
    'TRISX = %76543210   << tris bit order numbering
    'TRISA = %11111111       'All pins are inputs
    '// Define port pins as inputs and outputs ...
            TRISA  = %00000000 'example only - TRISB = %00001111 ;Make B4-B7 outputs, B0-B3 inputs, 
            TRISB = %11111111  'for 4x4 keypad all input
            TRISC = %10010000
            TRISD = %00000000
            TRISE.0 = 0
            TRISE.1 = 0
            TRISE.2 = 0
    'End of Port IO directions and presets for port pins begin here
    
    'variables begin here
           
            net var byte
            
            led var PORTD.0
    'end of variables
    
    'includes begin here
            INCLUDE "modedefs.bas"
            include "c:\pbp\samples\keypad.bas"
    'end of includes
    
    main:
    high LED 
    'RF SERIN line here
    
         SERIN PORTC.4,T2400,[9],net
         serout PORTC.3,T2400,["the key pressed or received value is ",net,10,13]
          low led
          IF net = 3 then 
           low LED
        serout PORTC.3,T2400,["the key pressed or received value is ", net,10,13]
        pause 100
    endif  
    'LOOKUP  net,[0,"123A456B789C*0#D"],net 'use lookup table to diplay proper display in hyperterminal
    '************************SEROUT TO HYPERTERMINAL
    goto main 
    end
    and the transmitter code
    Code:
    
    '*************************************
    '16F887 Transmit to PIC 18f4520 serout loop
    '*************************************
     '@__config _INTRC_OSC_NOCLKOUT & _WDT_OFF & _MCLRE_ON & _LVP_OFF & _CP_OFF
     
    'Ocsillator selections here
      'OSCCON = %01100001 for 4mhz, or OSCCON = %01110001for 8mhz
    '        OSCCON = %01110001           'Int CLK 8MHz
    '        ANSEL= %11111111       '$0F = disable A/D converter
    '        option_reg = 7     'switch pull-ups ON
    'END of oscillator selections
      'timer/oscillator defines 
     '       define osc 8        '8MHz
    'END of timer/oscillator defines
    'clear the ports
    
    
    
    OSCCON = %01110001          'Int CLK 8MHz
    ANSEL = %00000000           'All digital
    OPTION_REG.7 = 0            'Weak pull-ups enabled
    
    DEFINE OSC 8                '8MHz
    PORTA=0
    PORTB=0
    PORTC=0
    PORTD=0
    PORTE=0
    'end of port clear
    
    'Port IO directions and presets for port pins begin here
    'TRISX = %76543210   << tris bit order numbering
    'TRISA = %11111111    <<   'All pins are outputs
    '// Define port pins as inputs and outputs ...
            TRISA  = %00000000 'example only - TRISB = %00001111 ;Make B4-B7 outputs, B0-B3 inputs, 
            TRISB = %11111111  'for 4x4 keypad all input
            TRISC = %10100000
            TRISD = %00000000
            TRISE.0 = 0
            TRISE.1 = 0
            TRISE.2 = 0
    'End of Port IO directions and presets for port pins begin here
    
    'includes begin here
            INCLUDE "modedefs.bas"
            include "c:\pbp\samples\keypad.bas"
    'end of includes
                       
    'variables begin here
            
            
            LED var PORTd.0   ' Alias PORTD.0 to LED
     'RF variables
            TRAIN	VAR BYTE
            TRAIN=$55
            net var byte
     'Variables end here
    
        
    loopy:
            high LED '  LED on
            'for RF use the line below
            SEROUT PORTC.4,T2400,[TRAIN,TRAIN,TRAIN,TRAIN,TRAIN,9,3]
            low led
    goto loopy
    end
    Any help would be greatly appreciated

    Kind regards
    Dennis

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


    Did you find this post helpful? Yes | No

    Default

    Getting a 2 ?? Maybe you just need to add 1

    Try sending something other than a 9 or waiting for something other than a 9.
    It must be seeing the 9 or it would not go on to the next command.

    This is the very most basic code, but it does work. I pulled it from my "laser fence". If the beam is broken the TX kicks in and an alarm goes off at the house.
    Dave
    Always wear safety glasses while programming.

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


    Did you find this post helpful? Yes | No

    Default

    Code:
    DEC net
    Might be the missing link...on the display

    If the LED goes low then I would say it is working, but try sending something else and see what happenes.
    Dave
    Always wear safety glasses while programming.

  4. #4


    Did you find this post helpful? Yes | No

    Default and now for the next step

    Hi Dave

    I still haven't solved the number 3 problem
    Where should I place the DEC keyword in ? As I try to compile with DEC keyword in, MCS spits out compile errors.

    I am using TLP-434 and RLP-434 modules.
    With this in mind would you suggext I now start adding in manchester encoding ?
    Should I be trying SERIN/OUT2, DEBUG and HSER first ? (these all worked well when the PIC's were wired together)

    I see your lines of serin code pre-condition the receiver first, should i be sending more $55's ?

    As always any help or suggestions,tips,tricks etc would be greatly appreciated.

    Kind regards

    Dennis

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


    Did you find this post helpful? Yes | No

    Default

    Well crap. The DEC modifier does not work with straight SERIN. Sorry about that.

    Yes, setup for SERIN2/SEROUT2
    get that working with wires and we will go from there.

    The Manchester stuff is not needed at this time.
    Dave
    Always wear safety glasses while programming.

  6. #6


    Did you find this post helpful? Yes | No

    Default it's working

    Hi Dave

    Great news ;-)

    It's working :-) and I'm thrilled --thank you!

    Using HSERIN both wired and wireless
    WOOOOOHOOOOO!

    Now I have a question...
    I would say the receiver get's maybe one in every 50 sent packets, if I'm lucky ;-(
    What do I need to change or try to make this better ?
    The reason I am asking is because I would like to press button 3 on the keypad and that is transmitted and receiver number 3 switches on.
    Does that make sense ?

    Kind regards

    Dennis

  7. #7
    Join Date
    Dec 2005
    Posts
    1,073


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by Dennis View Post
    I would say the receiver get's maybe one in every 50 sent packets, if I'm lucky ;-(
    You need 2-3m physical separation between TX & RX. Otherwise, the superregenerative receiver and the transmitter will interfere with each other.

Similar Threads

  1. Direct PIC to PC without MAX232
    By acjacques in forum Serial
    Replies: 14
    Last Post: - 23rd October 2014, 22:32
  2. Serial VB 2005 pic 16f877a problems
    By Snap in forum mel PIC BASIC Pro
    Replies: 28
    Last Post: - 8th July 2013, 01:52
  3. PIC or xbee times out after Tx 504 bytes
    By archendekta in forum mel PIC BASIC Pro
    Replies: 6
    Last Post: - 23rd November 2009, 09:45
  4. HSERIN & Interupts (aka controlling PIC programs from a remote PC)
    By HankMcSpank in forum mel PIC BASIC Pro
    Replies: 16
    Last Post: - 17th June 2009, 15:46
  5. RX TX modules - intermitent communication
    By ruijc in forum mel PIC BASIC Pro
    Replies: 13
    Last Post: - 11th June 2009, 01:13

Members who have read this thread : 2

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