Interfacting RF Module


Closed Thread
Results 1 to 9 of 9
  1. #1
    rastan's Avatar
    rastan Guest

    Default Interfacting RF Module

    got a bit of a problem, think it could be to do with the timing of the serin serout commands. basically, its a rf switch with seperate rf solutions (UK) transmitter/reciever pair bought from maplin. Im trying to get a light to turn on when a serial command is recieved. it looks like its coming through the reciever ok (as in serial signal looks like its ok- cant be exact though) but the pic is not reading the serial command properley. any ideas??? heres the code.

    Send:
    cmcon0 = 7
    ansel = 0
    TRISA = 0
    TRISC = 1
    PORTA = 0

    'RF test program

    Start:

    IF PORTC.2 = 1 Then
    PORTA.0 = 1
    PORTA.0 = 0
    PORTA.0 = 1
    PORTA.0 = 0
    PORTA.0 = 1
    PORTA.0 = 0
    SerOut 0,4,[%10010,%1111]
    EndIF

    GoTo Start


    Recieve:
    cmcon0 = 7
    ansel = 0
    TRISA = 1
    TRISC = 0
    PORTC = 0
    Dat VAR BYTE

    'RF test program

    Start:

    SerIn PORTA.0,4,[10010],Dat

    IF Dat = 1111 Then
    PORTC.2 = 1
    Pause 500
    PORTC.2 = 0
    EndIF


    GoTo Start




    By the way, its a PIC 16F684 and the bit in the send program at the start is apparently to tell the transmitter that there is somethgin about to be sent, ie. wake it up. (a tip from microchip forums)

    Thanks.

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


    Did you find this post helpful? Yes | No

    Default

    wich model of transmitter / receiver do you use ? Is there any datasheet.

    there's few things wierd in your code...

    Code:
    Send:
    cmcon0 = 7 
    ansel = 0    
    TRISA = 0   
    TRISC = 1   
    PORTA = 0 
    
    'RF test program
    
    Start:
    
    IF PORTC.2 = 1 Then 
    PORTA.0 = 1 ;|
    PORTA.0 = 0 ;|
    PORTA.0 = 1 ;\
    PORTA.0 = 0 ;+ what these lines are suppose to do here ???
    PORTA.0 = 1 ;/
    PORTA.0 = 0 ;|
    SerOut 0,4,[%10010,%1111] ;not familiar with pin0 as output + not sure that SEROUT handle %... may use [18,15]
    EndIF
    
    GoTo Start
    let' say you want to send these in serial to PORTA.0

    %101010
    %10010
    %1111

    first i suggest you to begin with
    Porta.0=1
    pause 10

    this will force Serial out to High level. It appear that you must do it before send any serial data to avoid errors.

    i'm not sure that SEROUT will support those % so
    %101010 = 42
    %10010 = 18
    %1111= 15

    SEROUT PORTA.0,4,[42,18,15]

    will work


    and with this other
    Code:
    Recieve:
    cmcon0 = 7
    ansel = 0
    TRISA = 1
    TRISC = 0
    PORTC = 0
    Dat VAR BYTE
    
    'RF test program
    
    Start:
    
    SerIn PORTA.0,4,[10010],Dat   ; not sure that SERIN handle % May use [18]
    
    IF Dat = 1111 Then ;must write dat=%1111 or $0F
    PORTC.2 = 1
    Pause 500
    PORTC.2 = 0
    EndIF
    
    
    GoTo Start
    hope this help!
    Last edited by mister_e; - 9th November 2004 at 04:14.
    Steve

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

  3. #3
    rastan's Avatar
    rastan Guest


    Did you find this post helpful? Yes | No

    Default

    ok thanks, ive tried that but it still doesnt work. And i dont really no what to try next. is it possible that the baud is too fast?? im running it at 2400 baud. it looks ok at the reciever end, but it doesnt seem to be reading it properly. as to the pin0 question, its just PORTA.0 is there something wrong with that????
    Some people on the microchip forum told me to put sync bits, im not sure that this will work, but ill give it a go. anybody got any ideas or had this problem before???

    thanks

  4. #4
    rastan's Avatar
    rastan Guest


    Did you find this post helpful? Yes | No

    Default

    right, i dont think it was the rf modules, ive just connected the tx to the rx (thourhg a resistor) and its still not reading it properley. Theres definatly sometihng im missing. probably something silly.
    can anyone give me a snippet of code that they know that works for just going from tx to rx. just something simple.

    thanks

    heres the latest code

    Tx:

    cmcon0 = 7
    ansel = 0
    TRISA = 0
    TRISC = 1
    PORTA = 0

    'RF test program

    Start:

    IF PORTC.2 = 1 Then
    PORTA.0 = 1
    Pause 10
    SerOut PORTA.0,4,[0,0,0,0,"A",15]
    EndIF

    GoTo Start


    Rx:

    cmcon0 = 7
    ansel = 0
    TRISA = 1
    TRISC = 0
    PORTC = 0
    Dat VAR BYTE

    'RF test program

    Start:

    SerIn PORTA.0,4,["A"],Dat

    IF (Dat = 15) Then
    PORTC.2 = 1
    Pause 500
    PORTC.2 = 0
    EndIF


    GoTo Start

  5. #5
    Join Date
    Jul 2003
    Location
    Sweden
    Posts
    237


    Did you find this post helpful? Yes | No

    Post

    Hi Rastan,

    TRISC in the Tx section should be 4, not 1 as you have now. You're setting PortC.0 as input and the rest of PortC as outputs. I usually write theese numbers in binary since that makes it easier to distinguish between inputs and outputs.

    %00000100 = 4

    The bit to the far left is bit 7, thr rightmost bit is bit0. When you look at it you should think ..... 0 looks like O as in Output, 1 looks like I as in Input.

    You could ofcourse also write "TRISC.2 = 1" or "INPUT PortC.2" if you only want to set that pin to input.

    /Ingvar

  6. #6
    rastan's Avatar
    rastan Guest


    Did you find this post helpful? Yes | No

    Default

    ok thanks, but that was corrected. just a minor cock up. whats more worrying is that when i send a serial value in, and then send that same serial value out again and put a dual scope on them then the signal coming out is delayed (which is what i expected) but the a bit of 1 is shorter than the incoming. about 3 quarters of the original size.

    Tx:
    cmcon0 = 7
    ansel = 0
    TRISA = 0
    TRISC=15

    i VAR BYTE
    loop:

    For i = 1 TO 15
    PORTA.0 = 1
    Pause 10
    SerOut PORTA.0,0,[i]
    Pause 1000 'Delay for Receive scope
    Next i
    GoTo Loop


    Rx:

    cmcon0 = 7
    ansel = 0
    TRISC = 0


    'RF test program

    DataRec VAR BYTE


    Loop:
    SerIn PORTA.0,0,DataRec
    SerOut PORTA.1,0,[DataRec]
    PORTC = DataRec
    GoTo Loop


    this is ok, when i send the Tx the lights light up in binary order which is good, but they have to be on Ports 1-4 not 0-3 like i thought. weird. any explanations??
    so anyway, whem i try and ask if this incoming number is the same as something it just doesnt read/confirm properley and doesnt light up.

    Meanwhile on the original subject, i got the Transmitter/reciever working using the Holtek HT12D and HT12E. so there good.

    Thanks

  7. #7
    Join Date
    Jul 2003
    Location
    Sweden
    Posts
    237


    Did you find this post helpful? Yes | No

    Post

    You're not saying if this last piece of code is beeing tested using RF modules or not. If yes, go back to using a resistor(1k ish) and a wire(don't forget to connect the grounds together). Don't use very long wires and too big resistor(ohms not physical size ;-) ). Then try this code ......

    Tx:
    cmcon0 = 7
    ansel = 0
    TRISA = 0
    TRISC=15

    i VAR BYTE

    PORTA.0 = 1 'True mode idles high
    Pause 150 'Make sure reciever is in sync

    loop:

    For i = 0 TO 15
    SerOut PORTA.0,0,[i]
    Pause 1000 'Delay for Receive scope
    Next i
    GoTo Loop


    Rx:

    cmcon0 = 7
    ansel = 0
    TRISC = 0
    TRISA = %00000001
    PortA.1 = 1 'True mode idles high

    'RF test program

    DataRec VAR BYTE


    Loop:
    SerIn PORTA.0,0,100,Loop,DataRec
    SerOut PORTA.1,0,[DataRec]
    PORTC = DataRec
    GoTo Loop

    ...... i've made small changes to make sure that the reciever is ready to recieve when the transmitter is sending.

    If you can't make this work you probably should connect to a PC using inverted mode or a rs232 driver.

    Ohh, almost forgot that you have a scope. Verify that you have correct timings, each bit should be 1/2400=416.6us long. Each transmission starts with a startbit(low), this pulse should be about 417us long. Some of the time this pulse will be followed by one or more low pulses, the time will ofcource be longer when this happens. It will always be a multiple of 417us(0.417ms, 0.833ms, 1.25ms and so on) but never more than (1+8)*0.416667=3.75ms. If the bit-timing is more than about 2% off you need to check your oscillators.

    /Ingvar

  8. #8
    rastan's Avatar
    rastan Guest


    Did you find this post helpful? Yes | No

    Unhappy

    ok cheers guys, but ive just had an insident involving my Flash PICKit 1, a shitty alternating power supply and something called "hiss hiss fuzz frazle ouch thats hot bugger".

    So no more experimenting till i get summit else. One good question though, what programmer does everyone use, thus which do people think is the best for build/price/comatibility assuming that i only program basic PIC's?

    Is it worth forking out for a picstart plus (rip off) or sometihng else.
    cheers

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


    Did you find this post helpful? Yes | No

    Default

    I heard good comments on Melabs EPIC. I use PICSTART PLUS since several years now... never had any problems.


    some people also like IC-Prog... see this thread on forum
    http://www.picbasic.co.uk/forum/show...=&threadid=703

    regards
    Steve

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

Similar Threads

  1. Interfacing 16F88 to RF module
    By scomi85 in forum General
    Replies: 2
    Last Post: - 19th February 2009, 12:52
  2. problem with sending data using RF module
    By rano_zen06 in forum mel PIC BASIC Pro
    Replies: 51
    Last Post: - 10th April 2008, 17:08
  3. RF Module
    By shahidali55 in forum General
    Replies: 22
    Last Post: - 9th March 2007, 09:00
  4. Rf module
    By tangray in forum Adverts
    Replies: 0
    Last Post: - 7th August 2006, 07:14
  5. LINX RF module and PIC
    By Michael in forum mel PIC BASIC Pro
    Replies: 9
    Last Post: - 18th January 2006, 22:44

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