Sending API frame form MATLAB to remote XBee to get PWMoutpu

Hi,

I need to send an API frame from MATLAB through my base XBee connected via USB to my PC, to a remote Xbee and get a PWM ouput on my remote xbee with the value sent form MATLAB, so far I tried this radio configuration with no luck:

BASE

ATID 3456

ATMY 1

ATDL 2

ATAP 1

ATIT 5

ATWR

REMOTE

ATID 3456

ATMY 2

ATDL 1

ATP0 2

ATAP 1

ATIA 1

ATWR

Any inputs, ideas, codes for MATLAB, etc, :smiley: on how to solve this problem I would apreciate it greatly.

PS: English is my second language so please excuse any typing mistakes.

XBee API frames are a bit tricky to get correct. If one bit is wrong and the Checksum doesn’t match then the frame is silently ignored.

Study the XBee Document on the XBee module you are using (downloaded from Digi Int’s web site). Then do some googling on XBee API frames for additional information.

As for MATLAB, you just need to put all of the bytes that make up an API frame into a buffer then send the buffer contents to the COMM Port (USB virtual COMM).

Thanks Waltr,

I’ll try what you suggested and then come back if I have any more questions or my problem isn’t resolved yet

Hi,

I studied the xbee document and sent a frame form X-CTU form my base xbee to my remote xbee but I still can’t get a PWM ouput, I know the frame I sent is built ok because each time I send it I get a frame back that tells me the transmission was succesful, but aparently the value sent is going out the UART, and I want it to go out as a PWM output.

I configured pin 6 on my remote xbee to be a PWM output, can you help me on this matter, I just can’t get it to work, I really need some hints.

Does de PWM output only works when an analog signal is sent from the other xbee?

Ok, good start.

For additional help we need to know exactly which XBee modules you have and their Firmware version.

Also, the full Frame, in hex, that you sent, with a ‘de-code’ of what the frame components are.

I’ve never tried using the PWM out so would need to study the correct document.

OK,

I’m using Xbee Series 1 with firmware version 10EC.

First I tried sending this frame to check if the remote module was recieving correctly, and it was since I recieved the frame confirming so:

7E Start Delimeter

00 06 Length Bytes

01 API Identifier (wich means I’m requesting to transmit)

01 API Frame ID (to get an ACK saying if the trasmition was a success or not)

00 02 Destination Address Low (since I’m only using the lowest 16 bits)

00 option Byte (not used)

32 Data packet (here I only sent the value 50)

C9 Checksum

After words I tried sending this packet with the same configuration as above but a longer data packet

7E

00 15

01

01

00 02

00

00 00 33 FF 00 00 33 FF 00 00 33 FF 00 00 33 FF

33

What I sent on the data packet was a low value and then a high value to see if the PWM output could register those values.

Thanks for your help, and hope to hear from you soon :smiley:

Until I have some time to study the XBee document on output to PWM try just setting output (digital) pins high/low on the remote XBee.

waltr,

I tired what you suggested about the digital outputs but nothing, I don’t know what I’m doing wrong, and I’m starting to believe that the PWM output can only be acquired if I’m sending an Analog input from the other side, since everywhere I read that’s the only use it is given. :frowning: , I really need that Output, what else should I try?

By the way, thanks so much for your replies until now.

I haven’t had a chance to study the XBee doc yet.

But I did have the felling that the PWM out is only from an Analog input on the other XBee.

I suggested trying to set digital outputs since this should be a simple use of API commands.

With the correct API Frame a digital output on the remote XBee should be setable. Did you setup the remote XBee pins in X-CTU to be digital outputs?

Have you read through this web site to see if what you want to do is covered or questioned?

http://www.faludi.com/examples/xbee-api … rocessing/

Ok, I’m looking at the XBee doc and it should be possible to send data to an PWM pin output.

Your Frame above looks ok up to the ‘Data payload’.

7E Start Delimeter

00 06 Length Bytes

01 API Identifier (wich means I’m requesting to transmit)

01 API Frame ID (to get an ACK saying if the trasmition was a success or not)

00 02 Destination Address Low (since I’m only using the lowest 16 bits)

00 option Byte (not used)

32 Data packet (here I only sent the value 50)

C9 Checksum

Now to figure out what the 'data payload should look like.

Ahh…I think I found out how to do this. You need to send the data in an AT command. Read about M0, M1 AT commands.

I’m surprised that setting a remote Digital IO line didn’t work. You should get this working before try the PWM remote output.

Actually, to set a register on the remote xbee you need to use API identifier 0x17 (Remote AT command request). I have it on page 59 of the manual. API identifier 0x01 sends the payload data out to the remote XBee into it’s UART(buffer) to output on the Dout pin.

I think this packet should do for setting the PWM0 to 50:

7E Start Delimeter

00 09 Length Bytes

17 API Identifier (Remote AT command request)

01 API Frame ID (to get an ACK saying if the trasmition was a success or not)

00 02 Destination Address Low (since I’m only using the lowest 16 bits)

02 option Byte: Apply changes on remote

4D 30 Command name: M0

00 32 Set PWM0 duty-cycle 50-973

34 Checksum

Thanks Valen for working out the details.

I just hope the OP is still around to check on this.

Hi,

Sorry I havn’t been checking the blog lately, thanks for your replies Valen and waltr.

I’m going to try the API frame you suggested and see if I get the results I need.

Also I’ve been looking for other solutions to my problem just in case.

I’ll definetly post after I’ve tried it, thanks a lot