Wireless Comunication Dilemma


Closed Thread
Results 1 to 10 of 10

Hybrid View

  1. #1
    Join Date
    Dec 2007
    Posts
    34

    Default Wireless Comunication Dilemma

    Hello Again,
    I have another problem with wireless communication, this time with IR.
    I am trying to setup stable IR communication between to PIC's but I cannot get it to work.
    For the transmitter i am using the 16F628 because of its Hardware PWM and for the receiver i am using the 12F629 because i have a heap of them.

    Below is the code for the PIC's, can anyone see anything wrong?

    Reciever Code<code>
    INCLUDE "modedefs.bas"

    @ DEVICE PIC12f629, XT_OSC
    @ DEVICE PIC12f629, WDT_OFF
    @ DEVICE PIC12f629, PWRT_ON
    @ DEVICE PIC12f629, MCLR_OFF
    @ DEVICE PIC12f629, BOD_ON
    @ DEVICE PIC12f629, CPD_OFF

    Define OSC 4
    CMCON = 7

    RXPIN Var GPIO.1 'Input PIN
    TXPIN VAR GPIO.2 'Output PIN
    VALID VAR byte 'Valid Code
    UTYPE VAR BYTE 'Unit Type
    UID VAR BYTE 'Unit Identefier
    VALID = 0
    utype = 0
    uid = 0

    LOW 0

    rx:
    serin rxpin,n1200,[$66],VALID,UTYPE,UID
    if VALID = 22 then hit
    goto rx

    hit:
    high 0
    pause 250
    low 0
    VALID = 0
    goto rx

    end
    </code>

    Transmitter Code<code>
    INCLUDE "modedefs.bas"

    @ DEVICE PIC16f628, XT_OSC
    @ DEVICE PIC16f628, LVP_OFF
    @ DEVICE PIC16f628, WDT_OFF
    @ DEVICE PIC16f628, MCLR_OFF

    DEFINE OSC 4 ' We're using a 4MHz oscillator
    TXPIN Var PortB.1 ' Output PIN
    VALID CON 22 ' Valid Code
    UTYPE CON 27 ' Unit Type
    UID con 2550 ' Unit Identefier

    ' Initialize hardware PWM - IRLED 38KHz drive

    PORTB = %00000000 ' PortB = 0 : IRLED On PortB.1 Off
    TRISB = %00000000 ' PortB = all outputs
    PR2 = 25 ' Set PWM for approximately 38KHz
    CCPR1L = 13 ' Set PWM Duty-Cycle to 50%
    CCP1CON = %00001100 ' Mode select = PWM
    T2CON = %00000100 ' Timer2 ON + 1:1 prescale


    IR_TX:
    serout txpin,n1200,[$66,VALID,UTYPE,UID]
    PAUSE 1000 ' 1sec delay
    GOTO IR_TX

    End
    </code>

    Thank Again,
    Jeremy

  2. #2
    Join Date
    Nov 2005
    Location
    Bombay, India
    Posts
    966


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by jhorsburgh View Post
    Hello Again,
    rx:
    serin rxpin,n1200,[$66],VALID,UTYPE,UID
    if VALID = 22 then hit
    goto rx

    hit:
    </code>

    Jeremy
    After a cursory glance at your code, I think the statement in RX should change to
    Code:
    rx:
            serin rxpin,n1200,[WAIT($66),VALID,UTYPE,UID]
    Wait for $66 and then read the rest.

  3. #3
    Join Date
    Dec 2007
    Posts
    34


    Did you find this post helpful? Yes | No

    Default

    Hey Jerson,
    I tried changing the the code but for some reason when i try to compile the code, the following error occurrs. <code>ERROR Line 25: Bad expression. (RX.pbp)</code>

    <code>rx:
    serin rxpin,n1200,[WAIT($66),VALID,UTYPE,UID] 'Line 25
    if VALID = 22 then hit
    goto rx</code>

    Is it the software i am using?
    MicroCode Studio - PBP Compiler

    The previous code works using RF modules but not for IR.

    Regards,
    Jeremy

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


    Did you find this post helpful? Yes | No

    Default

    Double check the syntax for SERIN and the wait modifier.

    Other than that, are you sure the hardware is working correctly, everything is matched?

    If you have not seen this it may help. The receiver code is for a BS2 though.
    http://www.rentron.com/Infrared_Communication.htm
    Dave
    Always wear safety glasses while programming.

  5. #5
    Join Date
    Jul 2003
    Posts
    2,405


    Did you find this post helpful? Yes | No

    Default

    See this example http://www.rentron.com/Micro-Bot/IR_Serial.htm

    SERIN does not require the WAIT modifier. Just enclose the qualifier in square
    brackets. SERIN2 can be used with the WAIT modifier followed by the qualifier
    in square brackets.
    Last edited by Bruce; - 27th August 2008 at 23:58.
    Regards,

    -Bruce
    tech at rentron.com
    http://www.rentron.com

  6. #6
    Join Date
    Dec 2007
    Posts
    34


    Did you find this post helpful? Yes | No

    Default

    Thanks Guys,
    I have been looking around at different posts and the internet and i can't find a solution, they all say what i am doing is correct but it does not work. I have attached a copy of the wiring for you guys to look at. The only other thing i can think of in the Baud Rate and the way its driven. Should N1200 work? or should i drive it TRUE?

    Thanks Again,
    Jeremy
    Attached Images Attached Images  

Similar Threads

  1. Low latency Wireless RF transceiver modules?
    By mark155 in forum General
    Replies: 0
    Last Post: - 4th March 2010, 05:20
  2. Wireless Tachometer - Design Help
    By DanPBP in forum Off Topic
    Replies: 2
    Last Post: - 3rd May 2009, 09:06
  3. RS485 Vs Wireless (TWS-434A)
    By koossa in forum Off Topic
    Replies: 3
    Last Post: - 11th April 2009, 12:40
  4. PICBASIC PRO-coding for wireless sensor node
    By syazila in forum mel PIC BASIC Pro
    Replies: 2
    Last Post: - 10th February 2009, 00:05
  5. Wireless communication gear.
    By toalan in forum Off Topic
    Replies: 5
    Last Post: - 17th March 2005, 16:33

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