Jump to content

Serial Communication Giving the wrong bit


bradjb911

Recommended Posts

Hello,

I'm working with the Zigbee API interface and running into some trouble with the serial communication. Before I begin to explain my problem, let me apologize if I misuse the bits/bytes terminology. I'll try my best and I'll try to give examples alongside the terms.

Here is the summation of the problem: The controller sends 20 Hex bytes (accurate sending confirmed by reading with another zigbee):

7E 00 10 10 01 00 13 A2 00 40 3C 87 B4 C8 FD 00 00 68 69 EC

Labview reads:

7E00 0E90 0013 A200 403C 87B5 0000 0168 6930

It appears that my ones and zero bits are getting jammed together in the background and turned into 16-bit numbers (FFFF) instead of 8-bit numbers (FF).

So how can I tell labview to read the 8-bit version?

My code is attached.

Thanks lots!

post-15442-126843886307_thumb.jpg

Link to comment

Hello,

I'm working with the Zigbee API interface and running into some trouble with the serial communication. Before I begin to explain my problem, let me apologize if I misuse the bits/bytes terminology. I'll try my best and I'll try to give examples alongside the terms.

Here is the summation of the problem: The controller sends 20 Hex bytes (accurate sending confirmed by reading with another zigbee):

7E 00 10 10 01 00 13 A2 00 40 3C 87 B4 C8 FD 00 00 68 69 EC

Labview reads:

7E00 0E90 0013 A200 403C 87B5 0000 0168 6930

It appears that my ones and zero bits are getting jammed together in the background and turned into 16-bit numbers (FFFF) instead of 8-bit numbers (FF).

So how can I tell labview to read the 8-bit version?

My code is attached.

Thanks lots!

What is the contents of 'Read buffer 3'? (you know you read 18 bytes instead of 20)

Are you sure you configured your RS232 settings correct (like start and stop, baud rate). I think one of those is off.

Ton

Link to comment

Hello,

I'm working with the Zigbee API interface and running into some trouble with the serial communication. Before I begin to explain my problem, let me apologize if I misuse the bits/bytes terminology. I'll try my best and I'll try to give examples alongside the terms.

Here is the summation of the problem: The controller sends 20 Hex bytes (accurate sending confirmed by reading with another zigbee):

7E 00 10 10 01 00 13 A2 00 40 3C 87 B4 C8 FD 00 00 68 69 EC

Labview reads:

7E00 0E90 0013 A200 403C 87B5 0000 0168 6930

It appears that my ones and zero bits are getting jammed together in the background and turned into 16-bit numbers (FFFF) instead of 8-bit numbers (FF).

So how can I tell labview to read the 8-bit version?

My code is attached.

Thanks lots!

The bit jamming indeed indicates a problem with the serial port settings. Parity, number of bits, and start and stop bits must match exactly.

The data formatting is just that, a formatting. If you display a byte stream with a series of two hex code numbers or four hex code number is simply a choice about presenting data. That does not mean that LabVIEW makes of the stream of bytes a stream of 16 bit integers. It simply chooses to display the binary stream as 16bit hex numbers, that is all.

Link to comment

What is the contents of 'Read buffer 3'? (you know you read 18 bytes instead of 20)

Are you sure you configured your RS232 settings correct (like start and stop, baud rate). I think one of those is off.

Ton

When the receiver is set to 20 bytes then you receive, after sending the message the second time:

7E00 0E90 0013 A200 403C 87B5 0000 0168 6930 7E00

Note the 7E00 on the end is a repeat of the beginning. In other words it looks like it takes two messages to fill up the 20 byte buffer and output a response. Whereas with an 18 byte buffer the response is output immediately with just one transmission.

As to incorrect Serial settings:

The serial settings have been confirmed by running an outside terminal program (X-CTU) to receive the information. Also, in my experience incorrect port settings cause much more havoc on the data. Though if you throw enough 1's & 0's in a pot I suppose anything is possible.

Link to comment

Note the 7E00 on the end is a repeat of the beginning. In other words it looks like it takes two messages to fill up the 20 byte buffer and output a response.

I would expect that as well. You tell LabVIEW to get 20 bytes, so it gets 20 bytes (or times out), your instrument is most likely constant transmitting data.

As to incorrect Serial settings:

The serial settings have been confirmed by running an outside terminal program (X-CTU) to receive the information. Also, in my experience incorrect port settings cause much more havoc on the data. Though if you throw enough 1's & 0's in a pot I suppose anything is possible.

I have seen allmost correct readings with wrong start and stop bits, so do you have a manual of your device?

And a screenshot of the X-CTU settings?

Ton

Link to comment
  • 2 weeks later...

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.