Shop OBEX P1 Docs P2 Docs Learn Events
need object for parallax 433 MHz RF Receiver — Parallax Forums

need object for parallax 433 MHz RF Receiver

chris joneschris jones Posts: 391
edited 2010-04-07 20:38 in Propeller 1
Hello

is there a small exmpale of a object for a parallax 433 MHz RF Receiver and Transmiter
«13456

Comments

  • SRLMSRLM Posts: 5,045
    edited 2009-10-30 02:16
    Assuming you mean these modules, then it should just take some serial objects. Full Duplex Serial should work just fine.
  • chris joneschris jones Posts: 391
    edited 2009-10-30 03:05
    is there an exmaple of how i can use Full Duplex Serial object or the name of the object
  • Mike GreenMike Green Posts: 23,101
    edited 2009-10-30 03:17
    Look at the source code for either Full Duplex Serial or SerialMirror. The comments for each method describe what the call does and the parameters. For other ideas, also look at Simple_Serial and BS2 Functions.
  • chris joneschris jones Posts: 391
    edited 2009-10-30 03:25
    ok i am using siple_serial for my LCD do i access the RF units the same way ?
  • Chris SavageChris Savage Parallax Engineering Posts: 14,406
    edited 2009-10-30 03:36
    I might see what time I can invest in one. And object that handles CRC checksum would be a good choice for these radios.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Chris Savage

    Parallax Engineering
    50 72 6F 6A 65 63 74 20 53 69 74 65
    ·
  • Mike GreenMike Green Posts: 23,101
    edited 2009-10-30 03:39
    Sure. Remember that the RF units need to use inverted mode. Also remember that you need a sync pulse before each transmission. Something like this will do:
       outa[noparse][[/noparse]txPin]~~   ' set output register bit high
       dira[noparse][[/noparse]txPin]~~   ' enable output mode
       waitcnt(clkfreq/400 + cnt)   ' wait for about 2.5ms
       dira[noparse][[/noparse]txPin]~   ' disable output mode
    
  • chris joneschris jones Posts: 391
    edited 2009-10-30 04:26
    yes a CRC checksum will work in this case. but there is no object for 1 i might create one and use it as soon as i get the hang on this propeller chip

    Also

    Mike will this work i still need to disable the output mode i see

    BS2.Pulsout(E, 1200)
    BS2.Serout_Str(5,string("Spin-Up World!",13),9600,1,8) ' send string to rf device
  • chris joneschris jones Posts: 391
    edited 2009-10-30 04:28
    also i am tryomg to recive and transmit at the same time how can i run both under diffrent cogs
  • chris joneschris jones Posts: 391
    edited 2009-10-30 04:37
    this is what i have so far i can not get it to work its not all the code just the part that transmits and recives

    PUB Transmit(value)
    Repeat
    BS2.Pulsout(E, 1200)
    BS2.Serout_Str(5,string("Spin-Up World!",13),9600,1,8) ' send string to rf device
    BS2.Pause(1000) ' 1 second pause

    PUB Recive(value)
    Repeat
    BS2.Serin_Str(5,@myString,9600,1,8) ' Accept string passing pointer for variable
    BS2.Debug_Str(@myString) ' display string at pointer
    BS2.Debug_Char(13) ' CR
    BS2.Debug_Char(myString) ' show 6th character
    return mystring
  • chris joneschris jones Posts: 391
    edited 2009-10-30 13:56
    another uypdate this is how i am calling this to print to the lcd when it recives from the transmiter

    lcd.gotoxy(12, 1)
    lcd.decf(value, 8) ' print right-justified decimal value
    lcd.gotoxy(11, 2)
    lcd.Recive(myString, 8)



    BUT I GET THIS ERROR
    Expected subroutine name on /// Recive
  • chris joneschris jones Posts: 391
    edited 2009-10-30 14:08
    i have found out how i can run the transmitters under cogs i have the TX under gog1 and the RX under cog to is this correct

    VAR
    
      long  idx                        '  Counter
      byte  nstr[noparse][[/noparse]MAX_LEN]              ' for Transmit
      byte  myString[noparse][[/noparse]MAX_LEN]          ' for Recive
      byte  temp
    PUB Start
      cognew(Transmit, @nstr)   'Starts a Cog, calls BlinkingLED_A16, the Cog uses @stack0
      cognew(Recive, @myString)   'Starts a Cog, calls BlinkingLED_A17, the Cog uses @stack1
    '
    PUB Transmit
         Repeat
         ' RF is on pin 2 on propeller board    
            BS2.Pulsout(E, 1200)
            BS2.Serout_Str(2,string("Spin-Up World!",13),9600,1,8)    ' send string to rf device
            BS2.Pause(1000)   ' 1 second pause     
    
    PUB Recive
        Repeat temp from 0 to 9 'Repeat 10 times
        ' RF is on PIN 1 on Propeller board
            BS2.Serin_Str(1,@myString,9600,1,8)   ' Accept string passing pointer for variable
            BS2.Debug_Str(@myString)              ' display string at pointer
            BS2.Debug_Char(13)                    ' CR
            BS2.Debug_Char(myString)           ' show 6th character
        byte[noparse][[/noparse]$7000][noparse][[/noparse]temp]++ 'Increment RAM locations $7000 to $7009
    
    


    NOTE: i have 2 boards and i want to transmit between both i think i am close but i hit a snag

    Post Edited (chris jones) : 10/30/2009 2:50:12 PM GMT
  • chris joneschris jones Posts: 391
    edited 2009-10-30 15:09
    Any updates or advice from the community?
  • chris joneschris jones Posts: 391
    edited 2009-10-30 15:38
    i started to read the book some more for the propeller and looked at forums, maybe the propeller RF units will not work with the propeller. sorry if my questions are stupid just throwing some ideals out here
  • StefanL38StefanL38 Posts: 2,292
    edited 2009-10-30 15:42
    Yes,
    Using simple_serial means to start the receiving always in time before the other end starts sending.

    If you switch over to FullDuplexSerial you only need ONE cog for send and receive.

    That's exact what fullduplex means: Send AND receive at the same time.

    Second advantage as FullDuplexSerial (short-name FDX) does the send and recive in the backround
    you NEVER drop data as long as you check the receivebuffer before it is filled up completely.

    If you need a bigger buffer than 16 bytes you can increase
    the buffersize. With serial-mirror you can pump up the buffersize to kilobytes

    For sending call on of the send methods and the data is transferred to the send buffer very quickly and FDX does the rest in the backround
    So you are quicker back from sending as the sending needs time to be done.

    Most of the methods of simple_serial have the same name as in simple_serial. maybe not all
    But FDX provides the same functionality.

    If you need more functionality like receiving strins and store them right away use
    FullDuplexSerialPlus wich ist located at C:\Program Files\Parallax Inc\Propeller Tool v1.2.6\Examples\PE Kit\6 - Objects Lab\FullDuplexSerialPlus.spin

    To post my very personal opinion about simple_serial: simple_serial is so simple that more complexe tasks get complicated
    (as send and receive at the same time. simple_serial needs two cogs for this)

    best regards

    Stefan

    Post Edited (StefanL38) : 10/30/2009 4:35:14 PM GMT
  • BradCBradC Posts: 2,601
    edited 2009-10-30 15:49
    Your code is broken and incomplete. What is MAX_LEN?

    You are defining stack variables as BYTE when they should be LONG.
    You are referencing the stack variables from within the routines. Don't do that, you will overwrite the stack and things will go pear shaped.

    If you posted your complete code, either in-line or as an attachment you may get more suggestions.

    Personally, I'd suggest you start with the Propeller Tutorials that accompany the Propeller Tool software and dispense with the BS2 compatibility library. Learn how the chip actually works and build it up slowly.

    Stefan is right also, you can use FullDuplexSerial and do the whole lot in one cog.

    Are you using 2 pairs of identical TX/RX units, and trying to transmit full Duplex? That won't work.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    If you always do what you always did, you always get what you always got.lt's not particularly silly, is it?
  • chris joneschris jones Posts: 391
    edited 2009-10-30 16:06
    ok a few questions

    1. so i should not use the BS2 library?
    2. and i am allowed to post my full code ?
    3. i have been through the tutorials and there is nothing showing how to use a serial lcd exept the bs2 library whats your suggestion?
    4. why will 2 pairs of identical TX/RX units not work( i have 2 boards and i want each board to have an id to send first to make sure its not the same unit onboard.
    5. can you help me use the fullduplex library ?
    6. do you know of any exmpales i can follow that use the RF units in question ?
  • chris joneschris jones Posts: 391
    edited 2009-10-30 16:09
    Full code file as requested byBradC
    CON
    
      MAX_LEN = 64                                          ' 63 chars + zero terminator
      E               =     9                     ' Enable Bit
      RW              =     10                    ' Read Write Bit
      RS              =     11                    ' Register Select Bit
    
      
    OBJ
    
      bs2 : "BS2_Functions"
    
    VAR
    
      long  idx                        '  Counter
      byte  nstr[noparse][[/noparse]MAX_LEN]              ' for Transmit
      byte  myString[noparse][[/noparse]MAX_LEN]          ' for Recive
      byte  temp
    PUB Start
      cognew(Transmit, @nstr)   'Starts a Cog, 
      cognew(Recive, @myString)   'Starts a Cog,
    '
    PUB Transmit
         Repeat
         ' RF is on pin 2 on propeller board    
            BS2.Pulsout(E, 1200)
            BS2.Serout_Str(2,string("Spin-Up World!",13),9600,1,8)    ' send string to rf device
            BS2.Pause(1000)   ' 1 second pause     
    
    PUB Recive
        Repeat temp from 0 to 9 'Repeat 10 times
        ' RF is on PIN 1 on Propeller board
            BS2.Serin_Str(1,@myString,9600,1,8)   ' Accept string passing pointer for variable
            BS2.Debug_Str(@myString)              ' display string at pointer
            BS2.Debug_Char(13)                    ' CR
            BS2.Debug_Char(myString)           ' show 6th character
        byte[noparse][[/noparse]$7000][noparse][[/noparse]temp]++ 'Increment RAM locations $7000 to $7009
    
    
  • hover1hover1 Posts: 1,929
    edited 2009-10-30 16:31
    Step #1

    Declare clock settings in Constant Settings

    CON
    _clkmode = xtal1 + pll16x
    _xinfreq = 5_000_000

    if you are using a 5Mhz XTAL
  • StefanL38StefanL38 Posts: 2,292
    edited 2009-10-30 17:04
    Hello Chris,

    ok a few questions

    1. so i should not use the BS2 library?
    you can use it but it keeps you away from learning spin REALLY

    2. and i am allowed to post my full code ?
    You can do so best thing to do is to use the post reply button instead of the QUICK-reply form
    for providing your COMPLETE code use the archive-function of the propeller-tool see attached picture

    3. i have been through the tutorials and there is nothing showing how to use a serial lcd exept the bs2 library whats your suggestion?
    look into C:\Program Files\Parallax Inc\Propeller Tool v1.2.6\Examples\Library\Parallax Serial Terminal Demo.spin

    4. why will 2 pairs of identical TX/RX units not work( i have 2 boards and i want each board to have an id to send first to make sure its not the same unit onboard.
    two pairs of HARDWARE will work. MagIO meant if you try to to two simple_serial-objects to use on the same two pins (meaning SOFTWARE) wil not work

    5. can you help me use the fullduplex library ?
    see C:\Program Files\Parallax Inc\Propeller Tool v1.2.6\Examples\PE Kit\6 - Objects Lab\HelloFullDuplexSerial.spin as a start

    Parallax Serial Terminal Demo.spin has the same methods with same method names as FullDuplexSerial.spin


    6. do you know of any exmpales i can follow that use the RF units in question ?
    no

    @Parallax: Parallax Serial Terminal Demo.spin shows how to use the PST.EXE but is its own object instead of using FullDuplexSerialPlus
    The only difference is that the IO-pins are hardcoded. In my opinion this difference is so small it does not need another object.

    Please add a demo or a Lab-chapter that shows ALL details about the FullDuplexSerialPLUS-object emphasizing --PLUS-object
    as if you use FDX instead of FDX+ the newbees will come up with questions like how do I receive a string etc. etc. etc.

    This demo should show ALL of the thumble-stones laying around as it starts with

    CON
      'serial communication requires a precise clockmode
      'internal oscillator-mode RCSLOW or RCFAST is much too much unprecise
      'so ALWAYS use a xtal1-mode
      'if you don't set these constants explicitly RCFAST is used  
      _clkmode = xtal1 + pll16x
      'when using another chrystal than 5 MHz adjust constant _xinfreq
      'to the right value
      _xinfreq = 5_000_000 
    
      'result of pll16x * _xinfreq should NOT exceed 80MHz  
      'example if _xinfreq = 10_000_000 then use pll8x instead of pll16x
      'as 10_000_000 * 16 = 160MHz   and 10_000_000 * 8 = 80MHz   
    
    



    best regards

    Stefan
    420 x 298 - 15K
  • hover1hover1 Posts: 1,929
    edited 2009-10-30 17:08
    Step #2

    Start the BS2 Object

    " To use include in code:

    CON
    _clkmode = xtal1 + pll16x
    _xinfreq = 5_000_000

    OBJ
    BS2 : "BS2_Functions" ' Create BS2 Object

    PUB Start
    BS2.start (31,30) ' Initialize BS2 Object timing, Rx and Tx pins for DEBUG
    ' **************************************************************************************
    ' * NOTE: YOU MUST START THE OBJECT as it sets up the timing for many functions *
    ' **************************************************************************************"

    (As found in the BS2 Functions Library Object)
  • awesomeduckawesomeduck Posts: 87
    edited 2009-10-30 17:13
    Is the new transceiver module compatible with the old separate transmit and receive modules? e.g. do they use the same modulation technique such that I can buy the new module and use it to transmit to the old Parallax 433MHz Receiver that I have?
    Also the new transceiver web page states a range of 250 feet, but the PDF file says 2500 feet...which is it?
  • chris joneschris jones Posts: 391
    edited 2009-10-30 20:39
    hover1
    is this how i start the two objects?

    BS2.start (2,1) ' Initialize BS2 Object timing, Rx and Tx pins for DEBUG
    cognew(Transmit, @nstr) 'Starts a Cog,
    cognew(Recive, @myString) 'Starts a Cog,
  • Mike GreenMike Green Posts: 23,101
    edited 2009-10-30 20:54
    As described in the Propeller Manual, the 2nd parameter to COGNEW is the address of a stack area to be used by the new cog. This needs to be probably 20 longs in size. You're obviously trying to pass some kind of string value. That won't work. Read the Propeller Manual chapter on COGNEW. Take a look at the Propeller Education Kit tutorials. One of them is on using multiple cogs.
  • chris joneschris jones Posts: 391
    edited 2009-10-31 04:45
    since i am using the fulldeplex serial object now i will no longer need to run this under 2 cogs correct ?

    but i will have to use cogs sooner or later so i will read up on the chapter before i test agian.
  • Beau SchwabeBeau Schwabe Posts: 6,568
    edited 2009-11-04 06:42
    This link could be of some interest...

    http://forums.parallax.com/showthread.php?p=853681

    ...It's in the early stages of having the RF modules wrapped around this object, but I thought I'd throw it out there so people might report back any findings or further ideas.· Please respond to the link posted above for any detailed information.









    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Beau Schwabe

    IC Layout Engineer
    Parallax, Inc.
  • chris joneschris jones Posts: 391
    edited 2009-11-05 13:06
    thanks Beau Schwabe i will give this a shot and see how it works and report back to you.
  • chris joneschris jones Posts: 391
    edited 2009-11-05 13:15
    ok can both files be added into 1 file to do RX and TX?

    CRC_polynomial DEMO TX.spin
    CRC_polynomial DEMO RX.spin
  • Beau SchwabeBeau Schwabe Posts: 6,568
    edited 2009-11-05 15:29
    chris jones,

    These files are just to get you started. The main file to focus on is the CRC_polynomial.Spin. I am working on an RF transceiver object that will wrap both the TX and RX demo abilities together and use the CRC_polynomial.Spin object as one of it's main objects.

    The syntax might be something like this...

    rfRTX.Start(TXpin,RXpin,Baud)                            'Setup RF Transceiver
    
    rfRTX.Send({DataAddress},PacketLength,Polynomial)        'Send Data string from address starting at
                                                             '{DataAddress} for 'PacketLength' BYTES 
    
    rfRTX.Receive({DataAddress},PacketLength,Polynomial)     'Receive Data string into address starting
                                                             'at {DataAddress} for 'PacketLength' BYTES
    
    

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Beau Schwabe

    IC Layout Engineer
    Parallax, Inc.

    Post Edited (Beau Schwabe (Parallax)) : 11/5/2009 3:34:22 PM GMT
  • chris joneschris jones Posts: 391
    edited 2009-11-05 19:28
    thanks i will start working to make this work.

    Post Edited (chris jones) : 11/7/2009 3:55:16 PM GMT
  • chris joneschris jones Posts: 391
    edited 2009-11-08 07:36
    hello

    can you tell me if i am headed in the right dirtection i am trying to create an object for my RF units.

    this is the RF_Units file i am includeing in my main program
    CON
            _CLKMODE = XTAL1 + PLL16X
            _XINFREQ = 5_000_000
             
            FIFOBufferSize = 16
             
            PacketLength  = 4             'Total Number BYTES in polynomial CRC packet
        
    OBJ
      SER       : "FullDuplexSerial.Spin"
      CRC       : "CRC_polynomial"
    
    VAR
      byte  StringBuffer[noparse][[/noparse]FIFOBufferSize],Null
      long  ErrorCounter,ValidCounter
      word  PolynomialRF
      byte  LengthRF, CRCvalueRF 'Data to Send
      byte  X,T ' both X and T are counters
    
    PUB start(rxpin, txpin, mode, baudrate) : okay
    '' Initializes serial LCD object
    '' -- returns true if all parameters okay
      okay := SER.start(rxpin, txpin, mode, baudrate)                '' Initialize serial
      LengthRF                      := PacketLength
      PolynomialRF                  := CRC#CRC_8            'CRC polynomial value
      CRC.Start(@PolynomialRF)                              'Start the CRC polynomial engine in background
    '--------------------------------------------------------------------------------------------------------
        Seed := $11_22_33_44    
    PUB Send(ArrayList,PL,PO) 'ArrayList= Array to read in PL = Packet Length   'PO = Polynomial
        repeat
          X := PL ' paclet length   
          while X < 0
          ArrayList[noparse][[/noparse]X++] := X
          ser.str(string("!S"))  ''<-- Send SYNC characters 
          ser.tx(X)              ''<-- Apply CRC 
          ser.tx(CRCvalue)       ''<---Automatically generated on the fly when 'Dividend' variables are set
    PUB Recive(ArrayList,PL,PO) 'ArrayList= Array to read in PL = Packet Length   'PO = Polynomial     
           If Command(string("!S"))
           repeat
            T := PL ' paclet length    
            while T < 0
               ArrayList[noparse][[/noparse]T++] := ser.rx    
               ser.rx(CRCvalue)       ''<---Automatically generated on the fly when 'Dividend' variables are set
              If ser.rx == CRCvalueRF                            'Compare received CRC to calculated CRC
                 ValidCounter++
              else
                 ErrorCounter++
              ser.tx(1)                                        ' Position cursor at the Home position
              ser.str(string(" Err: "))
              ser.dec(ErrorCounter)
              ser.tx(9)                                        ' Send the TAB key code to the DEBUG serinal
              ser.str(string(" Val: "))
              ser.dec(ValidCounter)
              ser.tx(13)                                       ' Send the RETURN key code to the DEBUG serinal
              
              ser.dec(Dividend[noparse][[/noparse]3])
              ser.str(string("  "))
              ser.tx(9)                                        ' Send the TAB key code to the DEBUG serinal
              ser.dec(Dividend[noparse][[/noparse]2])
              ser.str(string("  "))
              ser.tx(9)                                        ' Send the TAB key code to the DEBUG serinal
              ser.dec(Dividend[noparse][[/noparse]1])
              ser.str(string("  "))
              ser.tx(9)                                        ' Send the TAB key code to the DEBUG serinal
              ser.dec(Dividend[noparse][[/noparse]0])
              ser.str(string("  "))
              ser.tx(9)                                        ' Send the TAB key code to the DEBUG serinal
              ser.dec(CRCvalue)
              ser.str(string("  "))
              ser.tx(13)                                       ' Send the RETURN key code to the DEBUG serinal
             
    
    PUB Serial_FIFO
        bytemove(@StringBuffer[noparse][[/noparse]0],@StringBuffer[noparse][[/noparse]1],FIFOBufferSize-1)
        StringBuffer[noparse][[/noparse]15] := SER.rx
    PUB Command(Compare)|_LengthRF
        _LengthRF := StrSize(Compare)
        if StrComp(Compare,@StringBuffer[noparse][[/noparse]FIFOBufferSize-_LengthRF])
           result := 1
        else
           result := 0
    DAT
    
            Polynomial    word      0           
            Length        byte      0
            CRCvalue      byte      0   
            Seed          long            '<-- purposefully left blank so that Seed is aliased as a LONG, and Dividend is Aliased as a BYTE
            Dividend      byte      0     '    with the SAME address.  This allows easy access to the BYTES within the Seed LONG variable.
                          byte      0
                          byte      0
            D3            byte      0
            D2            byte      0
            D1            byte      0
            D0            byte      0 
     
           
    
    

    Post Edited (chris jones) : 11/8/2009 8:47:30 AM GMT
Sign In or Register to comment.