PIC to control NEXA remoteswitch


Closed Thread
Results 1 to 22 of 22

Hybrid View

  1. #1
    Join Date
    Jan 2008
    Location
    Sweden
    Posts
    187

    Default PIC to control NEXA remoteswitch

    I have this RF transmitter http://www.parallax.com/Store/Access...%2cProductName
    And want to wite a program in PBP that controls NEXA remote switches http://www.elbutik.se/product.html?product_id=219031
    i have found the protocol that NEXA use but i canīt understand how to write a program that sendīs the RF code.

    I have tryed to play whit SEROUT, SERUOT2, and PULSOUT for some hours now but nothing works.

    Can anyone here give me some tips on how to write the program?

    NEXA protocol
    http://svn.telldus.com/svn/rf_ctrl/n...xaProtocol.txt


    I use PicBasicPro 2.50b.

  2. #2
    Join Date
    Jan 2008
    Location
    Sweden
    Posts
    187


    Did you find this post helpful? Yes | No

    Default

    Maybe itīs not posible whit PBP to write that code?

  3. #3
    Join Date
    Aug 2006
    Location
    Look, behind you.
    Posts
    2,818


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by Fredrick View Post
    I have this RF transmitter http://www.parallax.com/Store/Access...%2cProductName
    And want to wite a program in PBP that controls NEXA remote switches http://www.elbutik.se/product.html?product_id=219031
    i have found the protocol that NEXA use but i canīt understand how to write a program that sendīs the RF code.

    I have tryed to play whit SEROUT, SERUOT2, and PULSOUT for some hours now but nothing works.

    Can anyone here give me some tips on how to write the program?

    NEXA protocol
    http://svn.telldus.com/svn/rf_ctrl/n...xaProtocol.txt


    I use PicBasicPro 2.50b.
    Hello Fredrick,
    Your posts have made 1 thing very clear to me, and that is: You have not even bothered to look at the data sheet you linked to. Why did I say that ? No not to be mean spirited, but because THEY GIVE YOU the source code you are requesting here. Yes it is in pdf format which means you have to retype it. ( 9 lines of code each for xmit and receive ) to paraphrase sunday school; "The forum helps those, who help themselves".
    So, get the transmitter and receiver talking to one another , sending data, and then worry about how to format it, you can manipulate the data on the receiver end if it turns out you cannot send it just the way you want it sent, the main thing is get the data there.
    Last edited by Archangel; - 28th December 2008 at 22:26.
    If you do not believe in MAGIC, Consider how currency has value simply by printing it, and is then traded for real assets.
    .
    Gold is the money of kings, silver is the money of gentlemen, barter is the money of peasants - but debt is the money of slaves
    .
    There simply is no "Happy Spam" If you do it you will disappear from this forum.

  4. #4
    Join Date
    Jan 2008
    Location
    Sweden
    Posts
    187


    Did you find this post helpful? Yes | No

    Default

    And were do you find the source code in PBP for control a NEXA swich from a Parallax transmitter?

    I canīt find it.

    EDIT
    The code you are talking about is for transmitt to the Parallax RF reciver not the NEXA 230Volt remoteswitch.....!!!
    Last edited by Fredrick; - 28th December 2008 at 21:14.

  5. #5
    Join Date
    Aug 2006
    Location
    Look, behind you.
    Posts
    2,818


    Did you find this post helpful? Yes | No

    Default

    Do you have the transmit / receive link up and working? Can you control the nexa without the wireless? Seems like 3 separate problems, control nexa, control wireless, control both together.
    Last edited by Archangel; - 28th December 2008 at 22:32.
    If you do not believe in MAGIC, Consider how currency has value simply by printing it, and is then traded for real assets.
    .
    Gold is the money of kings, silver is the money of gentlemen, barter is the money of peasants - but debt is the money of slaves
    .
    There simply is no "Happy Spam" If you do it you will disappear from this forum.

  6. #6
    Join Date
    Jan 2008
    Location
    Sweden
    Posts
    187


    Did you find this post helpful? Yes | No

    Default

    Yes, the Parallax transmitter and reciver works fine, no problem...
    I can read data sheets!!!

    But how do i send the same RF code that the NEXA remote controls sends to the NEXA remote swich.

    I have seen other projects that sends NEXA RF code whit a PIC and a RF transmitter but thats in ASM code.

    Code:
            extern  IntRet
    ;        extern  ReceiveB,RT1Ini,IntRet,TxCharB
            extern  STRTUP
    ;        extern  STRTUP,TBuffCB
    
            global  RFNIni,RFNTrns
    ;        global  RTTrnsB
            global  CCP1Int,CCP2Int
    
            include SYSTEM.INC      ;System definitions
            include P16C74A.INC     ;Definitions for PIC16C74A
    
    ;************************************************************************
    ;*                                                                      *
    ;* CONSTANTS                                                            *
    ;*                                                                      *
    ;* Constant definitions for this program module.                        *
    ;*                                                                      *
    ;************************************************************************
    
    ;
    ; Bittime definitions for NEXA RF transmitter
    ;
    BITTIM1 equ     295             ;1/4 bittime
    BITTIM2 equ     590             ;2/4 bittime
    BITTIM3 equ     885             ;3/4 bittime
    BITTIM4 equ     1180            ;4/4 bittime
    BITTIMP equ     10240           ;Bittime for preamble
    ;BITTIME equ     590             ;Bittime for NEXA RF transmitter
    BITTIME equ     295             ;Bittime for NEXA RF transmitter
    
    ;************************************************************************
    ;*                                                                      *
    ;* VARIABLES                                                            *
    ;*                                                                      *
    ;* Variable definitions for this program module.                        *
    ;*                                                                      *
    ;************************************************************************
    
    RAM0    UDATA
    
    TXCount res     1               ;Transmission counts
    BCount  res     1               ;Transmit bit counter
    XmtHldH res     1               ;Transmit/receive holding register high
    XmtHldL res     1               ;Transmit/receive holding register low
    XmtRegH res     1               ;Transmit/receive shift register high
    XmtRegL res     1               ;Transmit/receive shift register low
    BCountR res     1               ;Receive bit counter
    
    XFlag   res     1
    
    ;************************************************************************
    ;*                                                                      *
    ;* FUNCTIONS                                                            *
    ;*                                                                      *
    ;* Functions for this program module.                                   *
    ;*                                                                      *
    ;************************************************************************
    
    PROM    CODE
    
    ;
    ; Initalize device driver.
    ;
    RFNIni  movlw   B'00000001'     ;Enable timer 1
            movwf   T1CON
    
            movlw   B'00001000'     ;CCP2 as output compare (pin RC1)
            movwf   CCP2CON
    
    ;        movlw   B'00000100'     ;CCP1 as input capture (pin RC2)
    ;        movwf   CCP1CON
    
            errorlevel  -302
            bsf     STATUS,RP0      ;Bank 1
    ;        bsf     PIE1,CCP1IE     ;Enable capture/compare 1 interrupt
            bsf     PIE2,CCP2IE     ;Enable capture/compare 2 interrupt
            bcf     STATUS,RP0      ;Bank 0
            errorlevel  +302
            return
    
    ;
    ; Transmitt data.
    ;
    ;  IN:  W = Data
    ;       FSR = Address
    ;  OUT: W,FSR destroyed
    ;
    RFNTrns movwf   XmtHldH         ;Data
            movfw   FSR
            movwf   XmtHldL         ;Address
            swapf   XmtHldL,f
            movlw   4
            movwf   TXCount         ;Number of transmissions
            bsf     XFlag,0
            return
    
    ;
    ; Capture/compare 1 interrupt service routine.
    ;
    CCP1Int bcf     STATUS,RP0      ;Bank 0
            bcf     PIR1,CCP1IF     ;Clear interrupt flag
            tstf    BCountR
            bnz     BitRead
    ;        movlw   low ( BITT15  ) ;Low byte of timer value (1.5 bittime)
            addwf   CCPR1L,w        ;Update low byte of compare register
            movwf   FSR             ;Use FSR for temp storage
    ;        movlw   high ( BITT15 ) ;High byte of timer value (1.5 bittime)
            btfsc   STATUS,C        ;Update high byte of compare register
            addlw   1               ;Add one for carry
            addwf   CCPR1H,f
            movfw   FSR
            movwf   CCPR1L
            btfbs   PORTC,2,IntRet  ;Verify startbit twice
            btfbs   PORTC,2,IntRet
            movlw   9
            movwf   BCountR
            movlw   B'00001010'     ;CCP1 as interrupt only
            movwf   CCP1CON
            goto    IntRet        
    
    BitRead movlw   low ( BITTIME ) ;Low byte of timer value
            addwf   CCPR1L,w        ;Update low byte of compare register
            movwf   FSR             ;Use FSR for temp storage
            movlw   high ( BITTIME );High byte of timer value
            btfsc   STATUS,C        ;Update high byte of compare register
            addlw   1               ;Add one for carry
            addwf   CCPR1H,f
            movfw   FSR
            movwf   CCPR1L
    
            clrc
            btfsc   PORTC,2         ;Test receive bit (RC2)
            setc
    ;        rrf     XmtReg,f        ;Shift bit into receive register
            decfsz  BCountR,f       ;Increment bitcount
            goto    IntRet
            movlw   B'00000100'     ;CCP1 as input capture (pin RC2)
            movwf   CCP1CON
    ;        rlf     XmtReg,f        ;Stopbit -> carry
            bnc     FErr            ;Framing error if no stopbit
    
    ;        movfw   XmtReg          ;Read received character
            clrc
    ;        call    ReceiveB        ;Decode message. Complete ?
            goto    IntRet
    
    FErr    setc
    ;        call    ReceiveB        ;Decode message. Complete ?
            goto    IntRet
    
    ;
    ; Capture/compare 2 interrupt service routine.
    ;
    CCP2Int bcf     PIR2,CCP2IF     ;Clear interrupt flag
            bcf     STATUS,RP0      ;Bank 0
    
            btfbc   XFlag,0,C2Norm0 ;Exit if transmission disabled
            movfw   BCount
            bz      C2z1
            decfsz  BCount,f
            goto    C2z2
            decfsz  TXCount,f
            goto    C2z1
            bcf     XFlag,0
            goto    C2Norm0
    
    C2z1    movfw   XmtHldH
            movwf   XmtRegH
            movfw   XmtHldL
            movwf   XmtRegL
    
            rlf     XmtRegL,f
            rlf     XmtRegH,f
            movlw   50
            movwf   BCount
            bsf     CCP2CON,CCP2M0  ;Send bit = 1
    
            movlw   low (BITTIMP)   ;Low byte of timer value (1/4 duty cycle)
            addwf   CCPR2L,w        ;Update low byte of compare register
            movwf   FSR             ;Use FSR for temp storage
            movlw   high (BITTIMP)  ;High byte of timer value
            goto    C2SetL
    
    ;        goto    C2Norm
    
    C2z2    btfsc   BCount,0
            bcf     CCP2CON,CCP2M0  ;Send bit = 0
            btfss   BCount,0
            bsf     CCP2CON,CCP2M0  ;Send bit = 1
    
            bcf     STATUS,C        ;Bit = 0
            btfbc   BCount,1,???1
            btfbc   BCount,0,???3
            rrf     XmtRegH,f
            rrf     XmtRegL,f
            bcf     STATUS,C        ;Bit = 0
    ???3    btfsc   XmtRegL,0
            bsf     STATUS,C        ;Bit = 1
    ???1    btfbc   BCount,0,???2
            btfbs   STATUS,C,???4
    ???5    movlw   low (BITTIM1)   ;Low byte of timer value (1/4 duty cycle)
            addwf   CCPR2L,w        ;Update low byte of compare register
            movwf   FSR             ;Use FSR for temp storage
            movlw   high (BITTIM1)  ;High byte of timer value
            goto    C2SetL
    
    ???2    btfbs   STATUS,C,???5
    ???4    movlw   low (BITTIM3)   ;Low byte of timer value (1/4 duty cycle)
            addwf   CCPR2L,w        ;Update low byte of compare register
            movwf   FSR             ;Use FSR for temp storage
            movlw   high (BITTIM3)  ;High byte of timer value
            goto    C2SetL
    
    C2Norm0 bcf     CCP2CON,CCP2M0  ;Send bit = 0
    C2Norm  movlw   low (BITTIM2)   ;Low byte of timer value (1/4 duty cycle)
            addwf   CCPR2L,w        ;Update low byte of compare register
            movwf   FSR             ;Use FSR for temp storage
            movlw   high (BITTIM2)  ;High byte of timer value
    C2SetL  btfsc   STATUS,C        ;Update high byte of compare register
            addlw   1               ;Add one for carry
            addwf   CCPR2H,f
            movfw   FSR
            movwf   CCPR2L
            goto    IntRet

  7. #7
    Join Date
    Aug 2006
    Location
    Look, behind you.
    Posts
    2,818


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by Fredrick View Post
    Yes, the Parallax transmitter and reciver works fine, no problem...
    I can read data sheets!!!
    OK, sorry, I thought that was what you were having trouble with. From fishing the internet this thing looks a lot like X10 controls, and I am guessing you want to control it without interfacing to a nexa transmitter, yes?
    If you do not believe in MAGIC, Consider how currency has value simply by printing it, and is then traded for real assets.
    .
    Gold is the money of kings, silver is the money of gentlemen, barter is the money of peasants - but debt is the money of slaves
    .
    There simply is no "Happy Spam" If you do it you will disappear from this forum.

Similar Threads

  1. Control NEXA 230V RF Switch
    By Fredrick in forum Code Examples
    Replies: 3
    Last Post: - 6th December 2009, 23:19
  2. Replies: 5
    Last Post: - 12th September 2007, 15:59
  3. Motor Control PLC with a PIC
    By sougata in forum mel PIC BASIC Pro
    Replies: 11
    Last Post: - 2nd November 2006, 07:59
  4. Pic Control With Software
    By Agent36 in forum General
    Replies: 5
    Last Post: - 18th October 2006, 18:18
  5. Need help on pic to pic flow control (simple problem I think)
    By khufumen in forum mel PIC BASIC Pro
    Replies: 1
    Last Post: - 11th January 2006, 00:34

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