Shop OBEX P1 Docs P2 Docs Learn Events
433mhz module: Convert this picbasic code to propeller? — Parallax Forums

433mhz module: Convert this picbasic code to propeller?

CrosswindsCrosswinds Posts: 182
edited 2012-03-28 14:31 in Accessories
Hello Guys!

Trying to get started with a new wireless project of mine. I have posted this question over in the propeller forum, but the thread is absolutely stone cold.


Forgive me for this double post, but here it comes:



Trying to control some wall-outlet relays, wich is cordless and works on the 433MHz band. I am completely new to the wireless stuff with propeller, and have never used it on another platform either.

I have found a protocol for the recievers, and also code that works with PIC (Basic, PBASIC?)


The protocol can be found following this link: http://svn.telldus.com/svn/rf_ctrl/nexa_2_6_driver/trunk/NexaProtocol.txt

And here is the Pbasic code:
DEFINE OSC 4

' Timing as described in NexaProtocol.txt
T CON 350      ' T = 350uS
T3 CON 1050    ' 3T
T32 CON 11200  ' 32T (Stop/Synch)

' Note we're using 1 VS X as shown in text
A1_ON  CON %111000000000 ' 12-bit code for House/Unit A1 ON
A1_OFF CON %011000000000 ' 12-bit code for House/Unit A1 OFF 

'           ||||||||||||____ 4-bit House code
'           ||||||||________ 4-bit Unit code
'           ||||____________ 3-bit Unknown code
'           |_______________ 1-bit Activation code 1=ON 0=OFF 

D_PACKET VAR WORD ' Holds 12-bit data packet to send
INDEX VAR BYTE    ' Data packet bit index pointer
LOOPS VAR BYTE    ' Loop counter

TX VAR PORTB.0    ' Connects to RF transmitter data in

LOW TX            ' TX output idles low for RF carrier OFF

Main:
    D_PACKET = A1_ON
    GOSUB Send
    PAUSE 5000
    D_PACKET = A1_OFF
    GOSUB Send
    PAUSE 5000
    GOTO Main
    
Send:
    FOR LOOPS = 1 TO 4    ' send each packet 4 times
      FOR INDEX = 0 TO 11 ' sends 12 bits per pass LSB 1st
        
        HIGH TX           ' The 1st half of a 0 or X  bit period is the
        PAUSEUS T         ' same so no need to repeat this sequence inside
        LOW TX            ' the IF block
        PAUSEUS T3 
        
        IF D_PACKET.0[INDEX]=1 THEN
           HIGH TX        ' send a 1 bit (1=X here)
           PAUSEUS T3
           LOW TX
           PAUSEUS T
        ELSE
           HIGH TX        ' send a 0 bit
           PAUSEUS T
           LOW TX
           PAUSEUS T3
        ENDIF
      NEXT INDEX          ' loop until all 12-bits sent
      
      ' Start of Stop/Synch period after each 12-bit packet
      HIGH TX
      PAUSEUS T
      LOW TX
      PAUSEUS T32
      ' End of Stop/Synch period
      
    NEXT LOOPS        ' send 4 packets per pass
    RETURN
      
    END



It would be great if someone could help me translate this to spin, so that i have a test-code as a kickstart.

The code above does also use the parallax module, but way back when they came separated as sender and reciever.



Iam very excited to get started with this project, so any help will be greatly appreciated!


Thanks guys.


Daniel

Comments

This discussion has been closed.