Jump to content

Jointing 2 Bytes Received from Serial Port


RodolfoAcialdi

Recommended Posts

Hi.

I'm a beginner of LabVIEW and i'm using the ADuC841 (with a 12-bit A/D converter) microcontroller to acquire a RMS voltage signal and send it through serial port at 9600 baud 8N1. But, the A/D have a 12 bit register (4 bits for the higher part and 8 bits for the lower part).

So, to get the correct reading from the A/D i must joint these two parts of the A/D register into a 12 bit word. Does anybody have an idea for this?

I thought about waiting for 2 terminations characters ("\n" = 0x0A) and then joint them. The program to joint then and show it is almost done but, i have no idea to make a condition to change into MSB and LSB part after a termination character and them joint these two parts.

If anybody else have another idea, please tell me.

Thanks a lot.

Link to comment

QUOTE(RodolfoAcialdi @ Oct 31 2007, 01:32 PM)

So, to get the correct reading from the A/D i must joint these two parts of the A/D register into a 12 bit word. Does anybody have an idea for this?

From serial communication, you will get bytes. LabVIEW doesn't have 12-bit data types, so you will have to store the results in at least a 16-bit integer. Look under the Data Manipulation sub-pallette, under the Numeric Pallette for the VIs you'll need, most specifically Join Numbers. Depending on how your data is transmitted, you may also need Logical Shift or Swap Bytes.

If your data is unsigned, you don't care about the highest 4 bits of the result. Be careful if your result is supposed to be signed, that can be trickier.

Link to comment

QUOTE(eaolson @ Oct 31 2007, 08:18 PM)

From serial communication, you will get bytes.

If your data is unsigned, you don't care about the highest 4 bits of the result. Be careful if your result is supposed to be signed, that can be trickier.

Ok eaolson, thanks. (my data isn't signed) Things are getting 'more clear' for me.

I have another question now. If i send firstly 1 byte (MSB) and then the other byte (LSB), wich VI may i use to join them, i mean, should i store the first one and wait for the second and then join (Join Numbers) or there's a way to join them as they are coming serially?

I'm afraid that i'm not being very clear and especific, ok.

Thanks.

Link to comment

QUOTE(RodolfoAcialdi @ Oct 31 2007, 04:00 PM)

If i send firstly 1 byte (MSB) and then the other byte (LSB), wich VI may i use to join them, i mean, should i store the first one and wait for the second and then join (Join Numbers) or there's a way to join them as they are coming serially?

You cannot join them while they are being transmitted, since you can only transmit bytes. So read both bytes off your serial port then combine them.

Link to comment

Join the conversation

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

Guest
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.