Shop OBEX P1 Docs P2 Docs Learn Events
rf communication between computer and boe-bot — Parallax Forums

rf communication between computer and boe-bot

tom2tom2 Posts: 10
edited 2008-10-31 07:30 in Learn with BlocklyProp
My project is to have a bs2 and with a rx 433mhz connected to a pc by usb cable. On the tx 433 mhz side I have a bs2 on a boe-bot
that will run autonomously. I have the hatachi HM55B compass module programmed to give the coordinates. My problem is I want the boe-bot to transmitt the coordinates to the rx pc side and display them on the debug screen. Unfortunately there is not too much source code from parallax on the rx, tx. I have tried and tried and I am getting nowhere. I don't no where the problem is and I need help. I've attached the hatachi source code from parallax and it comments where the data is displayed but I still can't get it to display on the rx side.

Comments

  • SRLMSRLM Posts: 5,045
    edited 2008-10-22 23:55
    Did you try the wireless link with a simple string, like "Hello World!" ? The way to solve this problem is with step by step breakdown: does the RF link work? Does your compass work? When both of those are true, then you can go on to "does can I get the correct compass data over the RF?"
  • tom2tom2 Posts: 10
    edited 2008-10-23 00:41
    yes the tx and rx work and so does the compass. I tried the tilt controled boe-bot and it works fine but a little sluggish. I've wrote a program in which I can control the boe-bot through the computer by tx to the rx on the boe-bot. I don't know if it could the data type I'm sending or not. here is what I'm trying to send from compass program. I'm going to try to send a quote like you suggested.


    DEBUG HOME, "x-axis N(-S) = ",SDEC x, ' Display axes and degrees
    CLREOL, CR, "y-axis W(-E) = ",
    SDEC y, CLREOL, CR, CR, "angle = ",
    DEC angle, " degrees", CLREOL

    PAUSE 150 ' Debug delay for slower PCs

    LOOP ' Repeat main loop
  • SRLMSRLM Posts: 5,045
    edited 2008-10-23 01:16
    Okay. From the code above, here's why it doesn't work: you can't use the debug command. That command is only good for when you have the USB/Serial cable hooked up to your stamp. Instead, you have to use the SEROUT command on the module that you are sending the data from (the "remote" BS2) and a Serin command on the recieving BS2. Then that BS2 will be able to send out a DEBUG (since it will be connected to the computer).


    Take a look at the RF module documention. Near the end they have some sample source code (available for download from the product page). Make sure that you're looking at the BS2 code.

    Finally, you don't need the

    PAUSE 150 ' Debug delay for slower PCs

    Unless you're running a computer from the 60s, the BS2 will be much slower than the computer. [noparse]:)[/noparse]
  • tom2tom2 Posts: 10
    edited 2008-10-23 01:39
    Thanks I'll give that a try and get back with you tomorrow.
  • tom2tom2 Posts: 10
    edited 2008-10-30 02:23
    I got to the point where I can send the data to the rx. However here is where I got of track. I want to send to rx something like this
    from the tx to the rx, "x coordinates = and then the value for x" and then for y so on,
  • SRLMSRLM Posts: 5,045
    edited 2008-10-30 02:37
    And your question is... What? How to do that?

    Take a look in the BS2 reference and syntax manual under SEROUT and SERIN.

    A primer:

    Serout Pin, Baud, [noparse][[/noparse]"!", "x coordinates = ", DEC x]


    I'll add that it's not very useful to send the words "x coordinates" since what exactly will the reciever do? Most likely throw them away. It's much easier just to use some formatter like "," to seperate your data to make the DEC command work.
  • tom2tom2 Posts: 10
    edited 2008-10-30 02:44
    here is what I'm send from the tx
    x VAR Word
    y VAR Word
    DO
    PULSOUT 8, 1200 'Sync pulse for the receiver
    SEROUT 8, 16468, [noparse][[/noparse] "!", x.HIGHBYTE, x.LOWBYTE, y.HIGHBYTE, y.LOWBYTE ]
    x = x + 1
    y = y + 1
    PAUSE 10
    LOOP

    here is what I have on the rx side

    ©Parallax, Inc. • 433.92 MHz RF Transmitter and Receiver (#27980, #27981) • v1.0 1/06 Page 6 of 8
    x VAR Word
    y VAR Word
    DO
    LOW 0
    SERIN 7, 16468, [noparse][[/noparse]WAIT("!"), x.HIGHBYTE, x.LOWBYTE, y.HIGHBYTE, y.LOWBYTE]
    HIGH 0
    DEBUG " coordinates are x= , y= , " cr,
    DEBUG ? y
    LOOP
  • SRLMSRLM Posts: 5,045
    edited 2008-10-30 02:58
    And...? Your problem? I have many, varied skills, but I can't mind read.
  • tom2tom2 Posts: 10
    edited 2008-10-30 03:13
    It does not send any values all the debug screen shows is

    coordinates are x= , y= , over and over, I'm not getting the x or y numeric values
  • tom2tom2 Posts: 10
    edited 2008-10-30 03:35
    I think I sinking deeper I don't know how to use decx and I can't find it in the help menu.
  • Bruce BatesBruce Bates Posts: 3,045
    edited 2008-10-30 04:04
    Tom -

    DEC n is a formatter, and it's a sub-parameter of SERIN and SEROUT. Look ath the appropriate command for information about it.

    Regards,

    Bruce Bates

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    When all else fails, try inserting a new battery.
  • SRLMSRLM Posts: 5,045
    edited 2008-10-30 05:15
    Well, you certainly won't get anything for x. You don't have a debug for that. And are you sure you are not getting something on the debug that looks like:

    coordinates are x= , y= ,
    y = 0 coordinates are x= , y= ,
    y = 0 coordinates are x= , y= ,
    y = 0 coordinates are x= , y= ,
    y = 0 coordinates are x= , y= ,
    y = 0 coordinates are x= , y= ,

    It should output this all the time, no matter what the RF modules are doing. The important part to look at is y = 0. Is it really 0 all the time, or does it change? Also, try

    Debug DEC5 ? Y
  • sylvie369sylvie369 Posts: 1,622
    edited 2008-10-30 11:19
    Try changing both of the "16468"s to "16780". That is, lower your baud rate to 2400, and see if that helps.

    Also double-check that you really do have the transmitter module wired to pin 8 of that BS2, and the receiver module wired to pin 7 of that BS2, and that you have the +5v and Gnd pins of the transmitter and receiver wired to the Vdd and Gnd of their respective BS2 modules.

    Post Edited (sylvie369) : 10/30/2008 3:16:22 PM GMT
  • tom2tom2 Posts: 10
    edited 2008-10-31 01:42
    I think I got it, below is the rx and tx code it seems to work. I added the longer pause to slow it down and played with the values of x and y also I changed the var from word to byte. When I used dec x on the rx side I got a error that said urinary operator, declare variable. I looked at the example on dec which lead me to debug it showed no declaration. Take a look and see what you think as always your input is greatly appreciated. However I had no luck with sending the message hello.

    ' {$STAMP BS2}
    ' {$PBASIC 2.5}
    x VAR Byte
    y VAR Byte
    DO
    PULSOUT 8, 1200 'Sync pulse for the receiver
    SEROUT 8, 16780, [noparse][[/noparse] "!", "x coordinates = ",DEC x, " y coordinates = ", DEC y ]
    x = x+1
    y = y+2
    PAUSE 8000
    LOOP


    on the rx side I had



    do
    serin 7, [noparse][[/noparse] wait (!), dec x, dec y]

    debug ? x
    debug ? y

    pause 2000

    loop
  • sylvie369sylvie369 Posts: 1,622
    edited 2008-10-31 03:12
    tom2 said...
    I think I got it, below is the rx and tx code it seems to work. I added the longer pause to slow it down and played with the values of x and y also I changed the var from word to byte. When I used dec x on the rx side I got a error that said urinary operator,

    That'd be a problem all right. smhair.gif
  • tom2tom2 Posts: 10
    edited 2008-10-31 03:20
    Yea your right. I have to learn to be more like a computer when it comes to programming. A computer is like a stupid obedient child. Which means it cannot think, it only does what you tell it!
  • SRLMSRLM Posts: 5,045
    edited 2008-10-31 07:30
    When I was first learning to program, my teacher had the class write down the steps in order to shut down a computer (psuedo code using clicks, etc) He demonstatrated that what we wrote (close windows, click start, etc) wouldn't work. Why? Because how do you close a window? Well, you find the x, then move the mouse there, then click. Anyway, it's a little lesson that yes, a computer really is rather unintelligent.
Sign In or Register to comment.