Wireless modules - help with code not working


Closed Thread
Results 1 to 32 of 32

Hybrid View

  1. #1
    Join Date
    Dec 2011
    Location
    IO93ok
    Posts
    190


    Did you find this post helpful? Yes | No

    Default Re: Wireless modules - help with code not working

    Hi Dick, Loannis,

    I received the modules back on Friday just as I was leaving to have a few days away for the Holiday long weekend in UK.

    They have been tested as OK but that doesn't relate as I couldn't measure any RF out when I sent them back. Never the less I believe Ciseco, so I'm continuing by etching two new pcbs with link pad outputs so I can link any pin to the module.

    They should be complete today and populated. Then I will do more tests.

    The speed issue came up so I'm running at 10MHz so 9600 should work reliably. As for True, well the Picaxe code sample seems to use N9600 but I seem to remember I didn't trust this. So I wrote a loop of serout/serin with all baud rates one after another for testing. I think I mentioned this earlier in the post. Ciseco claim any serial comms sent, will be echoed out. Their data sheet isn't any clearer.

    I can use any pin/s so I will test HW serial and serout/in. Hopefully with some sort of result, as these are not my modules.

    I do have access to a full professional RF spectrum test setup, however without serout/in comms working there is no point using it.

    Rob
    Last edited by tasmod; - 7th May 2013 at 09:19.

  2. #2
    Join Date
    Dec 2011
    Location
    IO93ok
    Posts
    190


    Did you find this post helpful? Yes | No

    Default Re: Wireless modules - help with code not working

    At last. Working.

    Redesigned pcb's but not reconfigured. Just turned pic sideways for ease of removal and added pads for each pin to facilitate cross connection, although not finally needed.

    After making up the boards I wrote the most simple TX/RX routines and connected the 3 pins needed with temporary jumpers. They immediately talked to each other. Replacing the jumpers with the modules and they talked !!!!

    There was one change in code that needed to be added but later removal and they still talked although not quite 100%. That was the extra first characters "SSSSSSSSBOB" before the required string to match the serin string of "BOB"


    Send code -------------

    Code:
    Include "modedefs.bas" 
    DEFINE OSC 10
    
    
    TRISA = %00000000
    
    CMCON=7
    
    pause 2000
    
    TEST:
        serout PortA.3, T9600,["SSSSSSSBOB"] 
        PAUSE 500
        GOTO TEST  
    END

    Receive code -----------------------------

    Code:
    Include "modedefs.bas" 
    DEFINE OSC 10
    
    TRISA = %11111101       
    
    CMCON=7
    
    relay var PortA.1
    
    
    low relay
    
    pause 2000
    
    TEST:
        low relay
        pause 100
        serin PortA.2,T9600,["BOB"] 
        high relay
        PAUSE 1000
        GOTO TEST
            
    END
    Now I need to expand the code to do just what I want and to then add a decent antenna to get the range.

    I'm considering a 'Moxon' Rectangle which gives 3dbd gain with excellent f/b ratio fitted directly to modules via short solid wire. It can be made up using UK twin earth cable wire. About 1.5mm copper. It's very small indeed at 123x46mm

    Rob
    Last edited by tasmod; - 7th May 2013 at 19:40.

  3. #3
    Join Date
    Jan 2005
    Location
    Montreal, Quebec, Canada
    Posts
    3,172


    Did you find this post helpful? Yes | No

    Default Re: Wireless modules - help with code not working

    You pause 500 after transmit, but pause 1000 after reception?

    Robert

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


    Did you find this post helpful? Yes | No

    Default Re: Wireless modules - help with code not working

    Besides what Robert noted, you have to setup port A.3 as high before transmitting. RS232 needs a standard state before tx/rx.

    So, I suppose T9600 made the difference?

    Code:
    Include "modedefs.bas" 
    DEFINE OSC 10
    
    high porta.3
    TRISA = %00000000
    
    CMCON=7
    
    pause 2000
    
    TEST:
        serout PortA.3, T9600,["SSSSSSSBOB"] 
        PAUSE 500
        GOTO TEST  
    END
    Ioannis

  5. #5


    Did you find this post helpful? Yes | No

    Default Re: Wireless modules - help with code not working

    Hi all, I'm trying the true mode, but my loopback setup is still not working.

    Code:
    '**************************************************************************
    '*Program to test XRF radio communications via loopback method            *
    '*Uses a pushbutton switch on porta pin 4                                 *
    '*Target processor is PIC 12f1822                                         *
    '*207 program words, revised 05/07/2013                                   *
    '*Program by Dick Ivers                                                   *
    '*All rights reserved                                                     *
    '************************************************************************** 
    'set 12f1822 configurat1on
    #CONFIG
      __config _CONFIG1, _FOSC_INTOSC & _MCLRE_OFF & _CLKOUTEN_OFF & _WDTE_ON
      __config _CONFIG2, _PLLEN_OFF & _LVP_OFF
    #endconfig
    
    'set registers
            OSCCON = %01111000   '16 mhz osc
            OSCTUNE = 0          'factory calibration
            ANSELA = 0           'all digital inputs
            OPTION_REG.7 = 0     'global pullups enabled
            WPUA = %010000       'porta pin 4 weak pullup enabled
            CM1CON0.7 = 0        'comparator disabled
            TRISA  = %011110     'porta.0 & porta.5 are outputs, all others input
    
        while OSCSTAT.0 = 0      'wait for stable freq.
        wend
        
        define OSC 16            '16 mhz oscillator
    
    'Define debug parameters
    DEFINE DEBUG_REGG PORTA        'set debug port to porta
    DEFINE DEBUG_BIT 0             'use pin ra0 of porta for debug
    DEFINE DEBUG_BAUD 9600         'set baud rate to 9600
    DEFINE DEBUG_MODE 0            'communicate in true mode
    
    DEFINE DEBUGIN_REGG PORTA      'set debug port to porta
    DEFINE DEBUGIN_BIT 1           'use pin ra1 of porta for debugin
    DEFINE DEBUGIN_BAUD 9600       'set baud rate to 9600
    DEFINE DEBUGIN_MODE 0          'communicate in true mode
    
        i var byte
        char var byte
    
        For i = 1 to 3
        porta.5 = 0              'led on
        pause 333
        porta.5 = 1              'led off
        pause 333
        next
    
    asleep:
        nap 2   'delay 4 ms
        if porta.4 = 1 then asleep
      
    DT:
        debug 55
        debugin 100,blink,[char]
        if char = 55 then
         porta.5 = 0            'led on solid
         goto halt
        endif    
    
    blink:
        porta.5 = 0     'led
        pause 500
        porta.5 = 1     'led off
        pause 500
        if porta.4 =1 then asleep
        goto DT   
       
    halt:
        stop                   'led stays on
    The communications not working. The led blinks when the remote transceiver is not powered, as it should. When its powered the program should branch to a solid on led , but no it keeps blinking. Any ideas?

  6. #6
    Join Date
    Nov 2003
    Location
    Greece
    Posts
    4,161


    Did you find this post helpful? Yes | No

    Default Re: Wireless modules - help with code not working

    Dick, I would suggest at first to test your code with a PC and see if you have the PIC working. For this you will need a MAX232 or similar to invert and drive the serial port.

    If this test passes please post your results. But I have a feeling that it won't.

    Ioannis

    P.S. Also try with capitals in define OSC 16. As this: DEFINE OSC 16. Just in case...
    Last edited by Ioannis; - 8th May 2013 at 08:22.

  7. #7


    Did you find this post helpful? Yes | No

    Default Re: Wireless modules - help with code not working

    Ioannis,
    PIC to PC is working. Code and setup as follows:

    Code:
    '**************************************************************************
    '*Program to test PIC to PC communications via loopback method            *
    '*Target processor is PIC 12f1822                                         *
    '*142 program words, revised 05/08/2013                                   *
    '*Program by Dick Ivers                                                   *
    '*All rights reserved                                                     *
    '************************************************************************** 
    'set 12f1822 configurat1on
    #CONFIG
      __config _CONFIG1, _FOSC_INTOSC & _MCLRE_OFF & _CLKOUTEN_OFF & _WDTE_ON
      __config _CONFIG2, _PLLEN_OFF & _LVP_OFF
    #endconfig
    
    'set registers
            OSCCON = %01111000   '16 mhz osc
            OSCTUNE = 0          'factory calibration
            ANSELA = 0           'all digital inputs
            OPTION_REG.7 = 0     'global pullups enabled
            WPUA = %010010       'porta pin 1 and pin 4 weak pullups enabled
            CM1CON0.7 = 0        'comparator disabled
            TRISA  = %011110     'porta.0 & porta.5 are outputs, all others input
    
        while OSCSTAT.0 = 0      'wait for stable freq.
        wend
        
        define OSC 16            '16 mhz oscillator
    
    'Define debug parameters 
    DEFINE DEBUG_REGG PORTA        'set debug port to porta
    DEFINE DEBUG_BIT 0             'use pin ra0 of porta for debug
    DEFINE DEBUG_BAUD 9600         'set baud rate to 9600
    DEFINE DEBUG_MODE 1            'communicate in inverted mode
    
    DEFINE DEBUGIN_REGG PORTA      'set debug port to porta
    DEFINE DEBUGIN_BIT 1           'use pin ra1 of porta for debugin
    DEFINE DEBUGIN_BAUD 9600       'set baud rate to 9600
    DEFINE DEBUGIN_MODE 1          'communicate in inverted mode
    
        i var byte
        char var byte
    
        For i = 1 to 3
        porta.5 = 0              'led on
        pause 333
        porta.5 = 1              'led off
        pause 333
        next
    
    'user input with VT100 terminal
    
    re:     debugin [char]     
            debug char
            
            goto re
    The PIC echos back to the PC correctly. Double characters display as expected. Note that the transmission mode is inverted. I believe this mode is standard for RS232 communications. Also, I am using a null modem cable (Tx and Rx reversed ). I believe this is also standard. Haven't tried the radio link yet with this set up.. Any suggestions?
    Dick

    p.s. The DEFINES are capitals in the actual code. Not all show this way with the pasted code.
    Last edited by Dick Ivers; - 8th May 2013 at 18:10.

Similar Threads

  1. Wireless modules and simple setup, what is required?
    By tasmod in forum mel PIC BASIC Pro
    Replies: 17
    Last Post: - 11th April 2013, 17:57
  2. Low latency Wireless RF transceiver modules?
    By mark155 in forum General
    Replies: 0
    Last Post: - 4th March 2010, 05:20
  3. Wireless modules FCC approved
    By Michael in forum mel PIC BASIC Pro
    Replies: 10
    Last Post: - 7th September 2008, 02:23
  4. Software RS232 and wireless modules
    By Michael in forum mel PIC BASIC Pro
    Replies: 10
    Last Post: - 17th August 2008, 05:27
  5. Wireless comms with Linx LR modules
    By telemark in forum mel PIC BASIC Pro
    Replies: 1
    Last Post: - 2nd July 2006, 01:58

Members who have read this thread : 1

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