Shop OBEX P1 Docs P2 Docs Learn Events
Issues with prop to prom communication with xbee — Parallax Forums

Issues with prop to prom communication with xbee

chris joneschris jones Posts: 391
edited 2011-05-08 20:30 in Accessories
Hello

i have 2 propeller boards and 2 xbees i am trying to send data from 1 xbee to the other to ensure communication but my code does not seem to be working. if someone has some code that works or can tell me what i am doing wrong in my code would be awesome.

CON

  _clkmode = xtal1 + pll16x                             ' use crystal x 16
  _xinfreq = 5_000_000                                  ' 5 MHz cyrstal (sys clock = 80 MHz)

  LCD_PIN   = 0                                         ' for Parallax 4x20 serial LCD on P0
  LCD_BAUD  = 19_200
  LCD_LINES = 4    

    ' Set pins and Baud rate for XBee comms  
  XB_Rx     = 1    ' XBee DOUT
  XB_Tx     = 2    ' XBee DIN
  XB_Baud   = 9600


  CR        = 13  ' Carriage Return value      
   
Var
  word stack[50]
  
                  
OBJ

  lcd     : "debug_lcd"
  XB      : "FullDuplexSerial"
  DXB     : "XBee_Object"      


PUB main(value) | Counter  
    XB.start(XB_Rx, XB_Tx, 0, XB_Baud) ' Initialize comms for XBee
      
    Delay (1000)                       ' one second delay

                                              
  if lcd.init(LCD_PIN, LCD_BAUD, LCD_LINES)             ' start lcd
    lcd.cursor(0)                                       ' cursor off
    lcd.backLight(true)                                 ' backlight on (if available)
    lcd.custom(0, @Bullet)                              ' create custom character 0
    lcd.cls                                             ' clear the lcd
    lcd.str(string("Sensor Node", 13))
    lcd.putc(0)                                         ' display custom bullet character
    lcd.str(string(" RX", 13))
    lcd.putc(0)
    lcd.str(string(" TX", 13)) 
   

    repeat
    
      repeat Counter from 1 to 2000        ' count up to 20   
    ' Send to Base
        xb.dec(Counter)                  ' send decimal value
        updateLcd(Counter)
       ' Delay (1000)                       ' one second delay      
      
        
        ' lets wait for some data
          Value := DXB.RxDec                ' Wait for and accept decimal value
          'DXB.Dec(Value)                    ' Send value back to base  
         updateLcd(value)
         '   Delay (1000)                       ' one second delay      



        

PRI updateLcd(value)

  lcd.gotoxy(12, 1)
  lcd.decf(value, 8)                                    ' print right-justified decimal value
  lcd.gotoxy(12, 2)
  lcd.decf(value, 8)                                    ' print indicated (with $) hex
 ' lcd.gotoxy(7, 3)
  'lcd.ibin(value, 12)                                   ' print indicated (with %) binary                
                

pub Delay(mS)       ' Delay in milliseconds  
   waitcnt(clkfreq / 1000 * mS + cnt)

  
      
DAT

  Bullet      byte      $00, $04, $0E, $1F, $0E, $04, $00, $00


Comments

Sign In or Register to comment.