Shop OBEX P1 Docs P2 Docs Learn Events
RF and TX pacakges With prop — Parallax Forums

RF and TX pacakges With prop

I have used the RF and TX pagcakge with the bs2 and was able to make a lot of cool projects. I would like to keep this going with the propeller but do not know hot to start. I like using the BS2. Commands but have no knowledge of how to get the highbyte and lowbyte needed to get the message sent and received. Any help is greatly appreciated.

-andy

Comments

  • Bill HenningBill Henning Posts: 6,445
    edited 2009-09-17 04:50
    Hi Andy,

    Let's say you have a byte variable called 'b'

    To extract the low nibble, use (b&15)

    To extract the high nibble, use (b>>4)

    That's pretty easy, isn't it?

    To set the high nibble of b to the value of 'h':

    b := (b & 15) | (h << 4)

    To set the low nibble of b to the value of 'h':

    b := (b & $f0) | h

    Hope this helps,

    Bill


    Andy said...
    Man With A Plan""]I have used the RF and TX pagcakge with the bs2 and was able to make a lot of cool projects. I would like to keep this going with the propeller but do not know hot to start. I like using the BS2. Commands but have no knowledge of how to get the highbyte and lowbyte needed to get the message sent and received. Any help is greatly appreciated.

    -andy
    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Please use mikronauts _at_ gmail _dot_ com to contact me off-forum, my PM is almost totally full
    Morpheus & Mem+dual Prop SBC w/ 512KB kit $119.95, 2MB memory IO board kit $89.95, both kits $189.95
    www.mikronauts.com - my site 6.250MHz custom Crystals for running Propellers at 100MHz
    Las - Large model assembler for the Propeller Largos - a feature full nano operating system for the Propeller
  • StefanL38StefanL38 Posts: 2,292
    edited 2009-09-17 14:03
    Hello Andy,

    as you are using the propeller, I would like to invite you learning SPIN.

    If you can post an example of the data-traffic like it is send and received
    I can post SPIN-code how to do that in SPIN.

    Once you know how do this in SPIN I promise you never want to go back to Basic
    because in SPIN you have much more possabilities to do more complex things

    Basic has a lot of limitations.

    best regards

    Stefan

    Post Edited (StefanL38) : 9/17/2009 2:17:48 PM GMT
  • edited 2009-09-17 17:01
    Dear Stefan:

    I am working on the propeller and get mixed up in all of the new commands. I have attached the TX and Rx code that I would like to use with the propeller [noparse]:)[/noparse] Thanks again for all the help!!

    Sincerely,

    Andy
    bs2
    505B
    bs2
    872B
  • StefanL38StefanL38 Posts: 2,292
    edited 2009-09-17 20:14
    Hello Andy,

    in the attachement you will find SPIN-code for send and receive bytes and sending strings

    you can test it with the PST.EXE (Parallax Serial Terminal)
    So you just need your propeller and nothing else

    The code also shows some techniques how to use serial output over the prop-plug for debugging

    Play around with this code and come back with new questions

    best regards

    Stefan
  • edited 2009-09-20 22:58
    I cant open the file [noparse]:([/noparse]
    -andy
  • Bob Lawrence (VE1RLL)Bob Lawrence (VE1RLL) Posts: 1,720
    edited 2009-09-21 02:50
    Andy,

    The files works. I copied the following, from inside it:

    Pub Receive : VerifyingIsOk
    'VerifyingIsOk is the name of the resultvariable
    'this means the command "Receive" will give back a value
    'like f.e. a BS-command like "SQR"  a = SQR 100 (a will contain value 10)
    



    Sometimes when you download the extension for the file name changes . It should have .zip on the end. If it changes to something else or it doesn't have an extension just rename or add it.

    If you can't unzip it and the extension is ok, just Google for a free unzip program.

    Post Edited (Bob Lawrence (VE1RLL)) : 9/21/2009 3:52:01 AM GMT
  • edited 2009-09-21 03:20
    Thanks [noparse]:)[/noparse]
  • TheGrueTheGrue Posts: 114
    edited 2009-09-21 05:13
    @StefanL38 - Call me a Noob to spin but I also have a couple of questions about your Spin code [noparse][[/noparse]of which I find more informative then what was sent to me on the same subject]

    First [noparse][[/noparse]and forgive if this is really a Noob question] Why is the highbyte multiplied by 256?
    x := ReceivedByte * 256   'store highbyte into x
    



    Second, To transmit the data from the tilt sensor [noparse][[/noparse]when I move to a Propeller based transmitter] do I just do the same only in reverse? What would that code look like?

    Third Parallax sent me the following code. How does this fit into the picture since I have their Wireless Remote for Boe -Bot Kit and want to control my Propeller based robot?

    Term.Start(31, 30, 0, 9_600)      ' Open serial terminal
    
       ' First method
       x.byte[noparse][[/noparse] 0] := Term.rx              ' Read in the first byte as the lowest byte                                                                                                   
       x.byte[noparse][[/noparse] 1] := Term.rx              ' Read in the second byte as the next lowest byte
       x.byte[noparse][[/noparse] 2] := Term.rx              ' Read in the third byte as the next lowest byte
       x.byte[noparse][[/noparse] 3] := Term.rx              ' Read in the fourth byte as the highest byte
       term.hex(x,8)                        ' x now contains all four bytes
       term.tx(13)
    
    

    Post Edited (TheGrue) : 9/21/2009 11:43:32 PM GMT
  • StefanL38StefanL38 Posts: 2,292
    edited 2009-09-21 06:36
    Hello Andy,

    you will be astonished to read this but YOU are GREAT !

    Because of my more or less advanced or "expert" state in programming I would have never searched for
    a syntax like you received it from parallax.

    VAR
      word x
    
    Pub Demo
      x.byte[noparse][[/noparse] 0 ]  := Term.Rx    'equivalent for BS2 "x.LOWBYTE"
      x.byte[noparse][[/noparse] 1 ]  := Term.Rx    'equivalent for BS2 "x.HIGHBYTE"
    
    
    



    So forget about my previous code ! Compared to "x.byte[noparse][[/noparse] 0 ] etc." my previous code is "from the back behind through the chest into the eye"

    You can use the syntax "x.byte[noparse][[/noparse] 0 ]" etc. for both sending and receiving


    to explain the * 256:

    One byte is 8 bit. With 8 bit you can count from 0 to 2^8 - 1 = 256 - 1 = 255. (count from 0 to 255)

    If you have a word variable which has 16 bit (= 2 bytes)
    The upper 8 bits (=HIGHBYTE) contain a part of the value and the lower 8 bites (=LOWBYTE)

    this works this way

                  9876543210
        1 binary %0000000001
        2 binary %0000000010 
        3 binary %0000000011 
        4 binary %0000000100 
        ....
      254 binary %0011111110
      255 binary %0011111111
                  9876543210
      256 binary %0100000000
    
                  hi-byte lowbyte>
                  5432109876543210
      256 binary  %000000100000000
    
      256 binary  hi-byte= %0000001
      256 binary  lo-byte= %0000000
      
      257 binary  hi-byte= %0000001
      257 binary  lo-byte= %0000001   257 = 1 * 256 + 1
    
      258 binary  %000000100000010
    
      258 binary  hi-byte= %0000010
      258 binary  lo-byte= %0000001   258 = 1 * 256 + 2   (decimal 1 is binary %1 decimal 2 is binary %10
    
     1030 binary %0000010000000110
     1030 binary hi-byte %00000100
     1030 binary lo-byte %00000110    1030 = 4 * 256 + 6  (decimal 4 is binary %100 decimal 6 is binary %110
     
    
    



    I took a quick look at wikepedia
    In this case my opinion is the explaining on wikipedia isn't very good
    Also some of the links at the end of the article are complicated to read

    this one seems to be Ok Binary Digits

    But you can play araound and learn it with the propeller !
    The FullDuplexSerialPlus-object has methods "dec", bin", "hex" which outputs values in decimal, binary, or hexadecimal digits

    best regards

    Stefan

    Post Edited (StefanL38) : 9/21/2009 6:43:55 AM GMT
Sign In or Register to comment.