can someone help


Closed Thread
Results 1 to 5 of 5
  1. #1
    Join Date
    Aug 2008
    Posts
    81

    Default can someone help

    hello
    can someone help me as I use these modules rf
    http://www.ebay.com/itm/Perfect-2Mbp...item35bee9e1e1
    to communicate between 2 PIC16F628A
    thank

  2. #2
    Join Date
    Mar 2011
    Location
    Los Angeles, California
    Posts
    322


    Did you find this post helpful? Yes | No

    Default Re: can someone help

    What is the question / problem?

  3. #3
    Join Date
    Feb 2012
    Location
    PERTH AUSTRALIA
    Posts
    838


    Did you find this post helpful? Yes | No

    Cool Re: can someone help

    please give more info on what your are seeking to do , want from the pic and RF module ,

    But i would start out by saying the following
    1. pic chips you are looking to use don't support an inbuilt spi bus , so shiftin / shiftout command structure is to be used to get the command to the RF module

    2. depending what your final use is for the pics, consideration of what other functions it may have to do ,You may look at 16F1825 for a good price, given it better mem/ cpu flexibility

    3. do a search on my other posts relating to the rf module , you will find some good details and structure refs

    4. i found connecting the IRQ pin on the module to be handy , but not a requirement

    5. cos the module works at 3.3V not 5v, you may wish to look at using the pic at 3.3v , with a regulator , consider the osc speed , standby voltage , wakeup requirements of the module - depending on the app / pic requirements/ PIC programming at 3.3v

    6. depending on your requirements , consider a another RF modual that would require a serial stream of data only to be sent / recieved as an alternative to this module, this options depends on how critical the data sent / received is / retry requirements/ voltage etc , note that there are also alot of devices that use 2.4ghz

    7. only look at the NRF24L01+ versions, these are often with a zig zag pattern on the aerial not the one you have linked to
    have a look at http://www.ebay.com.au/itm/2-PCS-NRF...item35bc3877e9
    I have found that the range on the plus version to be better.


    I hope that some of the questions raised help you to define what your seeking from what the rf module is to do


    Regards

    Sheldon

  4. #4
    Join Date
    Aug 2008
    Posts
    81


    Did you find this post helpful? Yes | No

    Default Re: can someone help

    hello Sheldon
    thank you
    esperencia not have much in this type of modules
    I'll buy other modules
    thank you very much
    a hug

  5. #5
    scumari's Avatar
    scumari Guest


    Did you find this post helpful? Yes | No

    Default Re: can someone help

    After receiving those two from Ebay, I started programming a routine.
    This is a working two way communication routine:

    '************************************************* ***************************
    '* Name : nRFLarge.BAS *
    '* Author : SCUMARI Tec *
    '* Notice : Copyright (c) 2013 SCUMARI Group *
    '* : All Rights Reserved *
    '* Date : 1-6-2013 *
    '* Version : 1.0 *
    '* Notes : PIC18LF13K50 controller for the NRF24L01+ RF module *
    '* : This is standard software for both sender and receiver. *
    '* : Both module start in receive mode. When the button is pressed,*
    '* : a byte is randomized ans send over by two bytes. Both recei- *
    '* : ver and sender displays the value on a LED bar. *
    '************************************************* ***************************
    ' PIC18LF13K50
    ' ___ ___
    ' VDD O|1 - 20|O VSS
    ' RA5 OSC1 OSCIN O|2 19|O RA0 + PGD
    ' RA4 AN3 OSC2 CLKOUT O|3 18|O RA1 D- PGC
    ' RA3 MCLR VPP O|4 17|O VUSB
    ' RC5 CCP P1A T0CKI O|5 16|O RC0 AN4 C12IN+ INT0 VREF+
    ' RC4 P1B C12OUT SRQ O|6 15|O RC1 AN5 C12IN1- INT1 VREF-
    ' RC3 AN7 P1C C12IN3- PGM O|7 14|O RC2 AN6 P1D C12IN2- CVREF INT2
    ' RC6 AN8 SS T13CKI T1OSCI O|8 13|O RB4 AN10 SDI SDA
    ' RC7 AN9 SDO T1OSCO O|9 12|O RB5 AN11 RX DT
    ' RB7 TX CK O|10 11|O RB6 SCK SCL
    ' -------
    '18F14K50
    @ __CONFIG _CONFIG1L, 000h
    @ __CONFIG _CONFIG1H, 018h
    @ __CONFIG _CONFIG2L, 000h
    @ __CONFIG _CONFIG2H, 000h
    @ __CONFIG _CONFIG3H, 080h ;080h is MCLRE
    @ __CONFIG _CONFIG4L, 000h
    @ __CONFIG _CONFIG5L, 003h
    @ __CONFIG _CONFIG5H, 0C0h
    @ __CONFIG _CONFIG6L, 003h
    @ __CONFIG _CONFIG6H, 0E0h
    @ __CONFIG _CONFIG7L, 003h
    @ __CONFIG _CONFIG7H, 040h

    INCLUDE "modedefs.bas"

    DEFINE OSC 16
    DEFINE SHIFT_PAUSEUS 100


    OSCCON = 118 '4550 op $FE / K50 op 118 / 689 op 112
    OSCTUNE = 31 '4550 op $0F / K50 op 31 / 689 op 15

    ADCON0 = 0
    ANSEL = 0
    ANSELH = 0
    UCON = 0
    IOCA = 3
    IOCB = 0
    INTCON = 0


    PORTA = 0
    TRISA = %00111111
    PORTB = 0
    TRISB = 0
    PORTC = 0
    TRISC = 0

    sck VAR PORTB.4
    miso VAR PORTA.4
    irq VAR PORTA.1
    mosi VAR PORTB.5
    scn VAR PORTB.6
    ce vAR PORTB.7

    butt var PORTA.0

    addr var byte
    addr1 var byte
    addr2 var byte
    addr3 var byte
    addr4 var byte
    addr5 var byte
    addrm var word
    temp VAR word
    tmp VAR BYTE
    indatl VAR BYTE
    indath VAR BYTE
    outdatl VAR BYTE
    outdath VAR BYTE
    i VAR BYTE
    pype var byte
    cnt var byte

    'Times
    tlong con 100
    tmid con 50
    tshort con 25

    scn = 1
    sck = 0
    ce = 0

    pause 100
    PORTC = 129
    pause 50
    PORTC = 66
    pause 50
    PORTC = 36
    pause 50
    PORTC = 24
    pause 50
    PORTC = 24
    pause 50
    PORTC = 36
    pause 50
    PORTC = 66
    pause 50
    PORTC = 129
    pause 50
    PORTC = 0
    pause 100

    indatl = 0

    init:


    addr = %11100010 : gosub ComWrite 'Flush RX
    addr = %11100001 : gosub ComWrite 'Flush TX
    addr = 32 + 7 : outdatl = %01000000: gosub ConfWrite 'Clear RX_DR, TX_DS and MAX_RT
    'Set PWR_UP to 1 (00.1)
    'MASK_RX_DR = 0 (00.6)
    'MASK_TX_DS = 1 (00.5)
    'MASK_MAX_RT = 1 (00.4)
    'Set PRIM_RX to 1 for receive (00.0)
    addr = 32 + 1 : outdatl = %00000001 : gosub ConfWrite 'ENAA_Px
    addr = 32 + 2 : outdatl = %00000001 : gosub ConfWrite 'ERX_Px
    addr = 32 + 5 : outdatl = 40 : gosub ConfWrite 'RF_CH
    addr = 32 + 6 : outdatl = $0F : gosub ConfWrite 'RF_SETUP
    addr = 32 + 17 : outdatl = 2 : gosub ConfWrite 'RX_PW_P0
    addr1 = $E1: addr2 = $E2: addr3 = $E3: addr4 = $E4: addr5 = $E5
    addr = 32 + 10 : gosub ADDRWrite 'RX_ADDR_P0
    'addr1 = $E1: addr2 = $E2: addr3 = $E3: addr4 = $E4: addr5 = $E5
    'addr = 32 + 11 : gosub ADDRWrite
    'outdatl = $E1
    'addr = 32 + 15 : gosub ConfWrite
    addr1 = $E1: addr2 = $E2: addr3 = $E3: addr4 = $E4: addr5 = $E5
    addr = 32 + 16 : gosub ADDRWrite 'TX_ADDR

    ' 'Read back config
    ' for i = 0 to 9
    ' PORTC = i
    ' pause 500
    ' addr = i : gosub statRead
    ' PORTC = indatl
    ' pause 1000
    ''init2:
    '' if butt = 1 then init2
    ' next i
    ' addr = 10 : gosub AddrRead
    ' PORTC = addr1
    ' pause 500
    ' PORTC = addr2
    ' pause 500
    ' PORTC = addr3
    ' pause 500
    ' PORTC = addr4
    ' pause 500
    ' PORTC = addr5
    ' pause 500
    ' addr = 16 : gosub AddrRead
    ' PORTC = addr1
    ' pause 500
    ' PORTC = addr2
    ' pause 500
    ' PORTC = addr3
    ' pause 500
    ' PORTC = addr4
    ' pause 500
    ' PORTC = addr5
    ' pause 500
    ' 'goto init


    addr = 32 : outdatl = %00111111 : gosub ConfWrite 'Start receiving
    'Set CE to 1
    pause 100
    ce = 1
    pauseus 200

    main:

    if butt = 0 then gosub Transmit
    if irq = 0 then gosub Receive

    goto main


    Transmit:
    ce = 0
    addr = %11100001 : gosub ComWrite 'Flush TX
    addr = 32 : outdatl = %00111110 : gosub ConfWrite 'PRIM_RX = 0
    random temp
    PORTC = temp : outdatl = temp : outdath = temp
    addr = %10100000 : gosub DataWrite 'send TX_PLD
    pauseus 100
    Trans0:
    ce = 1
    PAUSEUS 200
    ce = 0
    pause 100
    Trans1:
    addr = 7 : gosub statRead
    if indatl.4 = 0 then Trans2 'Read MAX_RT
    addr = 32 + 7: outdatl = %00100000: gosub ConfWrite 'Clear MAX_RT
    goto trans0
    Trans2:
    if indatl.5 = 0 then Trans1 'Read TX_DS
    addr = 32 + 7: outdatl = %00100000: gosub ConfWrite 'Clear TX_DS
    addr = 32 : outdatl = %00111111: gosub ConfWrite 'Set PRIM_RX to 1
    ce = 1
    pause 500
    return

    Receive:
    ce = 0
    pause 100
    addr = %01100001 : gosub DataRead
    PORTC = indath
    pause 200
    PORTC = indatl
    addr = 32 + 7: outdatl = %01000000: gosub ConfWrite 'Clear RX_DR
    addr = %11100010 : gosub ComWrite 'Flush RX
    pause 100
    ce = 1
    return

    '################################################# ##########################
    ComWrite:
    scn = 0
    pauseus tshort
    for tmp = 0 to 7
    mosi = addr.7
    pauseus tshort
    sck = 1
    pauseus tmid
    sck = 0
    pauseus tmid
    addr = addr << 1
    next tmp
    scn = 1
    return

    ConfWrite:
    scn = 0
    pauseus tshort
    for tmp = 0 to 7
    mosi = addr.7
    pauseus tshort
    sck = 1
    pauseus tmid
    sck = 0
    pauseus tmid
    addr = addr << 1
    next tmp

    for tmp = 0 to 7
    mosi = outdatl.7
    pauseus tshort
    sck = 1
    pauseus tmid
    sck = 0
    outdatl = outdatl << 1
    pauseus tmid
    next tmp
    ' SHIFTOUT mosi, sck, 1,[addr]
    ' SHIFTOUT mosi, sck, 1,[outdatl]
    ' pauseus tshort
    scn = 1
    return

    StatRead:
    scn = 0
    pauseus tshort
    for tmp = 0 to 7
    mosi = addr.7
    pauseus tshort
    sck = 1
    pauseus tmid
    sck = 0
    pauseus tmid
    addr = addr << 1
    next tmp

    pauseus tshort
    indatl = 0
    for tmp = 0 to 7
    indatl = indatl << 1
    sck = 1
    pauseus tmid
    indatl = indatl + miso
    sck = 0
    pauseus tmid
    next tmp
    pauseus tshort
    ' SHIFTOUT mosi, sck, 1,[addr]
    ' SHIFTOUT miso, sck, 1,[indatl]
    ' pauseus tshort
    scn = 1
    return

    AddrWrite:
    scn = 0
    pauseus tshort
    for tmp = 0 to 7
    mosi = addr.7
    pauseus tshort
    sck = 1
    pauseus tmid
    sck = 0
    pauseus tmid
    addr = addr << 1
    next tmp

    for tmp = 0 to 7
    mosi = addr1.7
    pauseus tshort
    sck = 1
    pauseus tmid
    sck = 0
    addr1 = addr1 << 1
    pauseus tmid
    next tmp
    for tmp = 0 to 7
    mosi = addr2.7
    pauseus tshort
    sck = 1
    pauseus tmid
    sck = 0
    addr2 = addr2 << 1
    pauseus tmid
    next tmp
    for tmp = 0 to 7
    mosi = addr3.7
    pauseus tshort
    sck = 1
    pauseus tmid
    sck = 0
    addr3 = addr3 << 1
    pauseus tmid
    next tmp
    for tmp = 0 to 7
    mosi = addr4.7
    pauseus tshort
    sck = 1
    pauseus tmid
    sck = 0
    addr4 = addr4 << 1
    pauseus tmid
    next tmp
    for tmp = 0 to 7
    mosi = addr5.7
    pauseus tshort
    sck = 1
    pauseus tmid
    sck = 0
    addr5 = addr5 << 1
    pauseus tmid
    next tmp
    ' SHIFTOUT mosi, sck, 1,[addr]
    ' SHIFTOUT mosi, sck, 1,[outdatl]
    ' pauseus tshort
    scn = 1
    return

    AddrRead:
    scn = 0
    pauseus tshort
    for tmp = 0 to 7
    mosi = addr.7
    pauseus tshort
    sck = 1
    pauseus tmid
    sck = 0
    pauseus tmid
    addr = addr << 1
    next tmp

    pauseus tshort
    addr1 = 0
    for tmp = 0 to 7
    addr1 = addr1 << 1
    sck = 1
    pauseus tmid
    addr1 = addr1 + miso
    sck = 0
    pauseus tmid
    next tmp
    pauseus tshort
    addr2 = 0
    for tmp = 0 to 7
    addr2 = addr2 << 1
    sck = 1
    pauseus tmid
    addr2 = addr2 + miso
    sck = 0
    pauseus tmid
    next tmp
    pauseus tshort
    addr3 = 0
    for tmp = 0 to 7
    addr3 = addr3 << 1
    sck = 1
    pauseus tmid
    addr3 = addr3 + miso
    sck = 0
    pauseus tmid
    next tmp
    pauseus tshort
    addr4 = 0
    for tmp = 0 to 7
    addr4 = addr4 << 1
    sck = 1
    pauseus tmid
    addr4 = addr4 + miso
    sck = 0
    pauseus tmid
    next tmp
    pauseus tshort
    addr5 = 0
    for tmp = 0 to 7
    addr5 = addr5 << 1
    sck = 1
    pauseus tmid
    addr5 = addr5 + miso
    sck = 0
    pauseus tmid
    next tmp
    pauseus tshort
    scn = 1
    return

    DataWrite:
    scn = 0
    pauseus tshort
    for tmp = 0 to 7
    mosi = addr.7
    pauseus tshort
    sck = 1
    pauseus tmid
    sck = 0
    pauseus tmid
    addr = addr << 1
    next tmp

    for tmp = 0 to 7
    mosi = outdatl.7
    pauseus tshort
    sck = 1
    pauseus tmid
    sck = 0
    outdatl = outdatl << 1
    pauseus tmid
    next tmp
    for tmp = 0 to 7
    mosi = outdath.7
    pauseus tshort
    sck = 1
    pauseus tmid
    sck = 0
    outdath = outdath << 1
    pauseus tmid
    next tmp
    ' 'FILL with zeroos
    ' for tmp = 0 to 15
    ' mosi = 0
    ' pauseus tshort
    ' sck = 1
    ' pauseus tmid
    ' sck = 0
    ' pauseus tmid
    ' next tmp
    ' SHIFTOUT mosi, sck, 1,[addr]
    ' SHIFTOUT mosi, sck, 1,[outdatl]
    ' SHIFTOUT mosi, sck, 1,[outdath]
    pauseus tshort
    scn = 1
    return


    DataRead:
    scn = 0
    for tmp = 0 to 7
    mosi = addr.7
    pauseus tshort
    sck = 1
    pauseus tmid
    sck = 0
    pauseus tmid
    addr = addr << 1
    next tmp

    pauseus tshort
    indatl = 0
    for tmp = 0 to 7
    indatl = indatl << 1
    sck = 1
    pauseus tmid
    indatl = indatl + miso
    sck = 0
    pauseus tmid
    next tmp
    pauseus tshort
    indath = 0
    for tmp = 0 to 7
    indath = indath << 1
    sck = 1
    pauseus tmid
    indath = indath + miso
    sck = 0
    pauseus tmid
    next tmp
    scn = 1
    return

    Have fun.
    Last edited by scumari; - 7th June 2013 at 07:12.

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