Shop OBEX P1 Docs P2 Docs Learn Events
Wireless Communication — Parallax Forums

Wireless Communication

SANSAN Posts: 29
edited 2009-11-04 13:15 in Propeller 1
Hi!
I am making 2 autonomous robot,using Propeller Chip which needs to communicate with each other.
Is it better to use Easy Bluetooth Module(#30085) for this purpose ?
Is it possible to transfer data all the time using a new cog in propeller, even when other cogs are doing another tasks ?

Comments

  • Mike GreenMike Green Posts: 23,101
    edited 2009-10-20 04:28
    1) Yes, the Easy Bluetooth Module would be a good way for the two robots to communicate as long as you remember the distance limitations (30m).

    2) Yes, you can use a cog (probably 2) to completely manage communications using the Easy Bluetooth. You probably will need a 2nd cog to handle the low-level serial I/O and provide a buffered input routine (FullDuplexSerial). The communications management cog would communicate with the other cogs by using shared variables in the main (hub) memory.
  • SANSAN Posts: 29
    edited 2009-10-20 11:44
    Thank you very much sir.
    One more question...
    Is it possible to declare and use 2d array variable in Spin Language for Propeller chip ? - Like other computer language.
  • StefanL38StefanL38 Posts: 2,292
    edited 2009-10-20 13:19
    You can define as many arrays as you want until the 32kB of RAM is filled up.

    Analyse how big the values are that you want to store in the array-elements.
    you can define arrays of byte (values 0-255), word(-32767 to 32678 or long (-2.147.483.648 to 2.147.483.648)

    arrays of word need two bytes per array-element
    arrays of long need four bytes per array-element

    best regards

    Stefan
  • Mike GreenMike Green Posts: 23,101
    edited 2009-10-20 13:37
    Your question was about 2D arrays.

    Spin only supports 1D arrays. You can't declare 2D or higher order arrays.

    Part of the reason for this is that there's limited memory available ... 32K bytes for the storage of a program and its data. It's expensive in terms of memory to store the amounts of data usually involved in 2D arrays. It's not hard to implement 2D arrays using 1D arrays and putting the subscript calculations explicitly like A[noparse][[/noparse] i*5+j ] = B[noparse][[/noparse] j*5+k ] + C[noparse][[/noparse] i*5+k] for A[noparse][[/noparse] i,j ] = B[noparse][[/noparse] j,k ] + C[noparse][[/noparse] i,k ] where A, B, and C are 5 x 5 arrays.

    That said, I think one of the 3rd party Spin compilers (homespun) implements multiple dimension arrays.

    There's also the Catalina C compiler and, if your programs are not that large, ImageCraft allows free use of their commercial C compiler for programs up to 16K in size.
  • SANSAN Posts: 29
    edited 2009-11-03 10:35
    Hello Sir,
    I have bought a pair of Parallax Easy Bluetooth Module (#30085).
    Now, I want to know how I can connect to bluetooth module for communication ?
    Is there any perticular object for that or the Serial obj, cna be used ?
    Plz help me.
  • Mike GreenMike Green Posts: 23,101
    edited 2009-11-03 14:25
    Any of the serial objects can be used to communicate with the Easy Bluetooth module. I would recommend using the FullDuplexSerial object that comes with the Propeller Tool, mostly because it's buffered and can operate at high speeds if you want. The Easy Bluetooth module can operate directly off the +3.3V supply used by the Propeller and can be directly connected to any two I/O pins. I suggest using a series 2.2K resistor in the Tx lead of the Easy Bluetooth module to protect the Prop and Easy Bluetooth module in case you accidentally make the Prop pin an output opposite to the Easy Bluetooth module's signal polarity (one high and the other low). It's not necessary, but it would be prudent.
  • SANSAN Posts: 29
    edited 2009-11-03 17:04
    Than u sir.
    Now I can connect the module with my PC and its working fine with FullDuplexSerial object.
    But my ques is how i can connect two Easy Bluetooth Module ? Is there any command to Specify the MAC address of the bluetooth ?
    If u can give me a sample code.
  • w8anw8an Posts: 176
    edited 2009-11-04 04:40
  • Mike GreenMike Green Posts: 23,101
    edited 2009-11-04 04:45
    You need to study the documentation, both for the Easy Bluetooth Module and the RBT-001 Bluetooth module that is part of it. All of that documentation and sample code is provided as links on the webpage that wBan mentioned.
  • Ken PetersonKen Peterson Posts: 806
    edited 2009-11-04 13:15
    I would like to point out that although SPIN doesn't support 2D arrays directly, there are several ways simulating a 2D array in code. Search the forum to find them.

    Here's one way:
    con
      MAX_X = 15
      MAX_Y = 15
    
    var
      BYTE array[noparse][[/noparse](MAX_X + 1) * (MAX_Y + 1)]
    
    pub initialize_array | x, y
      repeat x from 0 to MAX_X
        repeat y from 0 to MAX_Y
          array[noparse][[/noparse]x<<4+y] := 0
    
    
    



    It helps if your array dimensions are powers of 2 so you can use the "<<" operator.

    As for radio links, you may want to look at ZigBee as well.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    "A government big enough to give you everything you want, is big enough to take away everything you have. "
    - Thomas Jefferson

    Post Edited (Ken Peterson) : 11/4/2009 1:21:34 PM GMT
Sign In or Register to comment.