Go Down

Topic: .vb Application Serial Port thru Xbee (Read 3631 times) previous topic - next topic

sorrowSin

Hello all

It's my first time here on Arduino Forums so I'm not so sure if this is the right place to post this question, but I hope I can still get some help :D

I have a .vb application very simple one in which I use Serial Port communication at the same time I have set up my Arduino Mega 2560 with very simple application as well. When I connect the Arduino straight to the the PC using a USB port, I'm able to send the number "1" to the Arduino and have it read and turn on a LED or even move a motor. The communication port from VB to Arduino is good when using the USB port BUT ! here is the problem. I recently bought 2 Xbee modules Series 1 (i know im cheap XD) a Xbee shield for the arduino  and a USB Xbee explorer for the 2nd Xbee module.

http://www.sparkfun.com/products/9976
http://www.sparkfun.com/products/8687
http://www.sparkfun.com/products/8664     x2

doing some research on the net i was able to make communication between my 2 xbees
using X-CTU Range testing feature on the given program

my Low address, Pan ID. channel. and all that fancy stuff are set right and yet sometimes it doenst work

thats my 1st question why sometimes it doesnt want to make communication between both Xbees

my 2nd and most important question is

When i have 100% good communication based on the Xctu range test, and i try to send the number "1" to the arduino from my VB application , i wont do anything at all,  on the hardware it will show the lights of DOUT blink (when data arrives to arduino) but it wont do any action

in other words , Is there a way to send a "signal" from a VB application (serial port) ----> to Xbee (conected to the USB Xbee explorer)------> wireless ----> to XBee shield ----> to Arduino -----> to the application and make it have some action (using pin from 3-12 btw)

if so can you please help me ? Thank you in advance and sorry if my english not so good XD >.<


PaulS

First question. Why is this a poll? How exactly do you benefit from us voting on whether you have a problem? If there is some benefit in us voting, why are both choices the same?

Quote
I recently bought 2 Xbee modules Series 1 (i know im cheap smiley-lol)

No, you are smart. The series 1 radios are for point to point communication. The series 2/2.5 radios are for something else entirely.

If Digi had been smart, instead of greedy, they would have called them Series Smith and Series Wesson, or something that did not imply that series 2.5 was better somehow than series 1.

Quote
my Low address, Pan ID. channel. and all that fancy stuff are set right and yet sometimes it doenst work

Well, there is a contradiction here. If the values are all set right, they would work every time.

Quote
in other words , Is there a way to send a "signal" from a VB application (serial port) ----> to Xbee (conected to the USB Xbee explorer)------> wireless ----> to XBee shield ----> to Arduino -----> to the application and make it have some action (using pin from 3-12 btw)

Of course there is.

Quote
on the hardware it will show the lights of DOUT blink (when data arrives to arduino) but it wont do any action

On which hardware? It can't be the XBee, because the XBee doesn't have any lights. The XBee shield doesn't have a LED labeled DOUT. It does have one labeled TX that should blink when the XBee is sending. So, it must be the Arduino. Although that doesn't make sense, since none of my Arduinos has a DOUT light.

Quote
if so can you please help me ?

Sure. Show us the VB code and the Arduino code.

Quote
Thank you in advance and sorry if my english not so good

It was good enough.

sorrowSin

well its my first time here so idk how to walk myself thru the site

1. Yes it sounds contradictory about having the Pan ID , channel, ehm low address sourc, all that stuff. But believe i run range test once it works and some other times it doesnt keeps saying Data timeout.

2. yes when i said DOUT led blink i was refering to the Xbee shield on the Arduino board
whenever i had stablish good connection from PC to Arduino wireless... the usb xbee explorer's TX LED will blink AND at the same time the DOUT LED on the XBee shiled will blink  but no action.

so here is my VB code very simple

Imports System.Object
Imports System.MarshalByRefObject
Imports System.ComponentModel.Component
Imports System.IO.Ports

Public Class Test

    Dim serialport1 As SerialPort
    Dim clicked As Boolean

    Private Sub Test_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        Try
            serialport1 = New SerialPort()
            serialport1.PortName() = "COM9"
            serialport1.Parity() = Parity.None
            serialport1.BaudRate() = "9600"
            serialport1.DataBits() = 8
            serialport1.Open()
        Catch ex As Exception
            MsgBox(ex.Message)
            serialport1.Close()
        End Try
        Left.Enabled() = False
        Right.Enabled() = False
    End Sub

    Private Sub LightLED_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles LightLED.Click
        Try
            serialport1.DiscardInBuffer()
            serialport1.Write("1") ''Send Value of 49
        Catch ex As Exception
            MsgBox(ex.Message)
        End Try
    End Sub
----------------------------------------------------------------------------------------------------------------------------------
and my "Arduino code"

int data = 0;
void setup()
{
  Serial.begin(9600);

}
void loop()
{
  if(Serial.available())
  {
    data = Serial.read();
  }
  if (data == 49)
     digitalWrite(8,HIGH);
}

its just a simple test program to see if i have "com" assuming that works i can proceed to something more complex
oh and can you explain me wassup with the S1 and S2 that i didnt get quiet well

thank you for your time

PaulS

Are you configuring the XBees using X-CTU? The only values that need to be set are PAN ID, MY and DL. MY on XBee 1 should be the same as DL on XBee 2, and vice versa.

You are setting pin 8 as though it is an output pin, but you haven't declared pin 8 as an OUTPUT pin, so all that the Arduino is doing is enabling or disabling the pull-up resistor on the input pin 8. You will not see anything happen as a result of doing that.

Add:
Code: [Select]
pinMode(8, OUTPUT);
to setup.

Add another button to your VB application, to turn the LED off. Add the callback function. In the callback, it should look just like the LightLED_Click function, except that it should send "0", instead of "1".

Add some code to the Arduino:
Code: [Select]
  if (data == '1')
     digitalWrite(8,HIGH);
  else if (data == '0')
     digitalWrite(8, LOW);


You should then be able to click one button to turn the LED on and the other button to turn it off.

Observe the behavior of the TX and RX LEDs on the XBee shield. The TX should flash every time you click a button.

Observe the behavior of the TX and RX LEDs on the Arduino. The RX light should flash every time you click a button (and the LED should go on or off).

sorrowSin

omg im sorry yea ehmm the pinMode(8,OUTPUT) i have that right im sorry apologize i copy the wrong sketch so yea
it would have pinMode set up as you mention

now i did some other configuratoins to my Xbee tho here are the 2 configurations i have for my xbee modules
and yes im using XCTU

i have my DL MY PAN ID and so As CH well set up i think...
but with extra configurations at the line IO pass
---Base---
(3) DO -DIO0 Configuration is set to 3 DI  (base XBee connected to pc thru usb explorer)
(1) IC - DIO change detect set to 1
(FFFF) IA -I/O Input Address

--Reciever---
(5)D0 - DIO0 Configuration 5 (do High)
(1) IC - DIO change detect set to 1
(FFFF) IA -I/O Input Address

i guess if you have or may b download X-CTU you can load those files i upload on this reply message
Modem XBEE : XB24  Xbee 802.15.4  Version 10E8

even its its on XBP24 modem or Xb24 with the same desctiptions i just mention above it wont make com all the time

so now i know is my Xbee set up based on what you said, could you please help me with the right configuration
thank you again so so much for your time :D




sorrowSin

i tired what you said change the DL MY and Pan ID for both Xbee modules

---BASE---                 ---Reciever---
PAN ID = 27                PAN ID = 27
DL 4444                      DL 3333
MY 3333                     MY 4444

modem XB24 Function Set XBEE 802.15.4 Version 10E8

then i uploaded this simple applicaiton to the Arduino to test connectivity using X-CTU range test
void setup()
{
  pinMonde(11,OUTPUT);
  Serial.begin(9600);
}
void loop()
{
  if(Serial.available())
  {
    Serial.print((char)Serial.read());
    digitalWrite(11,HIGH);
  }
}

it worked the pin 11 LED turned on and on the range test graph it show 100% connection
i was so happy and decided to now send the any value with my .vb code

BUT once again nothing happend :(:(  T_T .... on the shields it shows the TX and DOUT blink (usb explorer / xbee shield)

so i went back to do the test range and again 0% nothing happend lost connection with XBee was lost :( thte XCTU failed

this is rele anoying me im reading every single tutorial online going back to my networking books programing techniques to go around
this problem but so far no results and i am very ashamed to not get it working and keep asking for help

can somebody please help me thank you

PaulS

I wonder if there is some issue with the 10E8 firmware version. I use 10E6, and have had none of the issues you are having. It might be worth a try loading an older version of the firmware.

sorrowSin

ok now prob I'm going to confuse you XD

I placed an LED on pin 8 and 11
if pin 8 is on means no data is available
if pin 11 is on means data is available

void setup()
{
  Serial.begin(9600);
      pinMode(8,OUTPUT);
    pinMode(11,OUTPUT);
}
void loop()
{
  if(Serial.available())
  {
    digitalWrite(11,HIGH);
    Serial.print((char)Serial.read());
  }
  else if (!Serial.available())
  {
    digitalWrite(8,HIGH);
    digitalWrite(11,LOW);
  }
}

so then i use AGAIN ! -.-' X-CTU range test
and nothing no conection Data timeout !
AND on the arduino Pin 8 lights up !

Now when i do the test on X-CTU from arduino to usb explorer (arduino now sends data for test to usb explorer) the conection is 99% with one packet lost

this is confusing at this point im starting to think is the Xbee shield on arduino ! the one not working the UART is on when i do the test
and i even also tried setting it up ONLINE and nothing

why is it so complicated with the S1 the fucntion sets are as helpful as the XB pro or S2

Do you know anyway to fix it? or go around this problem either software/hardware - wise ?

and agian thank you so much for your help :D

PaulS

Do you have one or two explorers? If I were you, I'd have two of them, so that I could be certain that the shield/arduino was not interfering in the configuration/setup of the XBees. Only when they are both talking to each other, using the X-CTU range test would I install the XBee in the shield.

If the XBee then gets re-configured, the shield or your code on the Arduino is the culprit.

I have two of them. Setting up a pair of XBees that talk to each other as soon as they are turned on takes less than 5 minutes, and never needs to be done again.

sorrowSin

yea ... well i prob gonna take me a week to get another USB explorer for the Xbee
but i shall buy another one they not that expensive either ...
then i was think you think i fried the Xbee xD cuz even if it was the shield
then i read somethings on the net like solding some pins in orther to make reset or
talk to each other did you sold anything  on your shields? o.0

PaulS

Quote
did you sold anything  on your shields?

No. I didn't solder anything, either.

sorrowSin

you know 1st i was pissed at myself for being so stupid and not noticing that the wire that was connecting both the Xbee shiled and the Arduino was not thick enough to make connect both of them the actual socket that i was using the pins coming out of it was thin enough to b lose
therefore causing the connection weaker or "timeout packet" -.- ' '  so thats one

AND NOW !  GRRR :0 :0 :0 i think i broke my arduino mega 2560 

when i connected to the pc via usb not xbee
vista doesn't detect the driver at all
doesnt show in device manager , it doesnt make the sound when you connect a new driver to the pc

but wat makes it even more strange is that the power led on arduino still On (green)
when i reset it still on and the L (led flashes or sometimes stays on )
and the TX and RX LEDS stay off all the time no matter I reset
and i still gettin 5V and 3 V from the respective pins

I had it with this micro-controller going back to PIC -.- -.-

Go Up