Home/Support/Support Forum/Monitor digital IO on XBee radio.

Monitor digital IO on XBee radio.

0 votes
Hi.

Is there a way to monitor the status of digital IO on an xbee radio?

My problem is that I have an xbee where I have a switch connected to a diode. This is connected between a digital IO and ground.

I would like to be able to monitor the "connection" between this digital IO and ground so that I'm able to see, in my application, whether the diode is on or not.

Is there a way to check if the digital IO and ground has a connection, or are there any other ways to solve this?

I'm using C# and Windows Forms Application for this, if that helps.
asked Mar 7, 2016 in XBee Programmable Development by Lars New to the Community (5 points)

Please log in or register to answer this question.

1 Answer

+1 vote
 
Best answer
Sure, use the Change Detect function on the radio with the DIO line enabled. Then on the receiving radio at the PC, use API mode. Then when the line changes state, it will send a packet to the base radio and the base will send out a UART API frame indicating the state change.
answered Mar 7, 2016 by mvut Veteran of the Digi Community (12,834 points)
edited Apr 4, 2016 by mvut
Ok, I understand.

I have enabled change detect (IC) and set it to 2 in XCTU. How will the api frame change from this? How can I interpret the api frame to recognize the change detect?
You also need to set the IU command on the 802.15.4 modules to see that output data.  You can then look at page 22 in the manual to see how it is determined.
I have IU command enabled. I have set D0 to DI. I have IC set to 1 (to enable change detect on D0).

It doesn't generate a frame when it changes state (I turn the switch on/off to turn the diode on/off).

Do you have any idea of where I am going wrong?
Yes I have.

I have gone through the settings several time, and I am convinced that everything is set up correctly, but when I try to test the connection in XCTU, it doesn't send any frame when I turn the switch on/off. It sends and receive  frames every so often without me doing anything, but the only difference is the frame ID, checksum and one other value I am yet to determine.

Do you have any idea of what I can do from here?
I have now figured out how to use Change Detect, but it sends about 300 samples in a matter of seconds when a change is detected.

Any idea what's wrong?

Edit: It works now. Thank you for your help!

So far the only thing that is different between the packets is 80 or 81 at the end of the API frame. If I were to add more end points and wanted to use change detect on these as well - it wouldn't be enough to look for 80/81. Are there other ways to identify this?

And is there a way to read these frames using C# or any other language? I can send frames through C# but I am confused as to how I can read frames that are received through this.
No, the frame type byte is what determines the type of frame it is.

Yes, you should be able to write a C or C# program to read the DIO status API frame and determine what the status is. You should also be able to determine which node it is coming from based off of either the 16 bit (type 81) or 64 bit (type 80) frame you receive.
I will ask another question on this site to be able to specify it a bit more. I realize that this forum is more related to the XBee itself and not any programming languages making use of this, but hopefully you (or someone else) are able to assist with finding/identify the API frame received.
You really need to post a new message for that listing it as a Software Coding question and you also need to mention which lib you are using and where it is from.
When I read the serial port for the received frame, I get the frame as expected if a change is detected prior to reading the port.

However, if the port is read, and no change is detected, it waits until a change is detected, and the frame received is incomplete.

Any idea how to fix this?

For C#, my code is as follows:

private void test_read_Click(object sender, EventArgs e)
        {

                byte[] buffer = new byte[14];

                
                serialPort1.Read(buffer, 1, buffer.Length);

                string buffer_string = BitConverter.ToString(buffer);
                read_textbox.Text = buffer_string;


                if (buffer[12] == 129)
                {
                    textBox1.BackColor = System.Drawing.Color.Green;
                }

                if (buffer[12] == 128)
                {
                    textBox1.BackColor = System.Drawing.Color.Red;
                }
            


        }

When I turn on the led, then click the button, it reads the full frame. If I click the button and no change is detected, it waits until a change is detected, then reads the frame - but it's incomplete. It's as if it doesn't wait for the full frame - but there is no way to implement a delay.
...