# LabVIEW

cancel
Showing results for
Did you mean:

Solved!
Go to solution

## Bitwise operation then plotting

Hello,

I am a newbie in LabVIEW. I am trying to plotting the serial data.

My data packet is 252 bytes. ADC bit: 12 -0.75 bytes. It means I have 336 data/packet.

How can I work with bitwise in LabVIEW?

Bests,

Message 1 of 6
(530 Views)

## Re: Bitwise operation then plotting

Hi hmd,

hmdpostech@postech.ac.kr wrote:

How can I work with bitwise in LabVIEW?

Yes, you can handle bits.

There are a lot of bit-related functions, like NumToBoolArray, all the boolean functions, Rotate/Shift numerics, …

Suggestion: most often you don't need to convert to boolean data (green wires), you can do all your data handling using numeric (blue integers) datatypes!

hmdpostech@postech.ac.kr wrote:

My data packet is 252 bytes. ADC bit: 12 -0.75 bytes. It means I have 336 data/packet.

How did you calculate those numbers???

252 bytes are 2016 bits. When your ADC gives 12bits/sample then you will have 168 samples in the packet…

Best regards,
GerdW

using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
Message 2 of 6
(524 Views)

## Re: Bitwise operation then plotting

Dear,

Thank you for your suggestions.

I have played around it.

I convert 252 bytes into 168 12-bit data like this and it works.

My problem is I always loss the 1 serial byte.

Besides, let's assume that I already have 168 data.

How can I do some thing like this in labview?

for (int i = 0; i < 168; i+=6)

{

plot (graph1; data_buffer[i];

plot (graph2; data_buffer[i+1];

plot (graph3; data_buffer[i+2];

plot (graph4; data_buffer[i+3];

plot (graph5; data_buffer[i+4];

plot (graph6; data_buffer[i+5];

}

MinhDuc

Message 3 of 6
(469 Views)
Solution
Accepted by topic author hmdpostech@postech.ac.kr

## Re: Bitwise operation then plotting

Hi Minh,

hmdpostech@postech.ac.kr wrote:

How can I do some thing like this in labview?

for (int i = 0; i < 168; i+=6)

{

plot (graph1; data_buffer[i];

plot (graph2; data_buffer[i+1];

plot (graph3; data_buffer[i+2];

plot (graph4; data_buffer[i+3];

plot (graph5; data_buffer[i+4];

plot (graph6; data_buffer[i+5];

}

Use the Decimate1DArray function to decimate your sample array into 6 plots…

hmdpostech@postech.ac.kr wrote:

I convert 252 bytes into 168 12-bit data like this and it works.

My problem is I always loss the 1 serial byte.

As long as you only show images of your VI we cannot edit/debug/run them in LabVIEW…

(I prefer VIs downconverted to LV2019 in case you use a more recent LabVIEW version. There's a "Save for previous" item in the File menu.)

• Can you provide a description how those 12bit samples are packed into the byte stream? (As said before: most often you don't need any green wires when handling bits…)
• How do you configure your serial (?) port?
Best regards,
GerdW

using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
Message 4 of 6
(460 Views)

## Re: Bitwise operation then plotting

What we know:

• You are (very) new to LabVIEW, and to the LabVIEW Forum.
• You do not understand that a "picture" of LabVIEW code (which cannot be fully examined, let alone edited or tested) is almost as useless as a picture of a partial listing of a 20-page C++ program.  We need to see complete VIs, possibly a complete LabVIEW Project, and saved in something other than the "latest version" (as you'll likely get only the "latest students" able to open it.  Try Save for Previous Version, and go back 2-4 years (i.e. LabVIEW 2019-2021).
• Your "Data packet" is 252 bytes.  I don't know what "ADC bit: 12 -0.75 bytes" means, but you say this represents 336 data points.

252 bytes (as @GerdW mentioned) is 2016 bits.  You say this represents 336 data points, which means you are getting 6-bit A/D data.  Really?  I've heard of 12-bit A/D chips, but 6-bit?

As we used to say (in my Undergraduate Days), "Answer Analysis reveals that the Question is Wrong" (or, perhaps more charitably, "mis-explained", and without proper LabVIEW documentation (this means attach your VI, saved as LabVIEW 2019, PLEASE.

Bob Schor

Message 5 of 6
(401 Views)

## RE: Bitwise operation then plotting

Thank you for all your suggestions.

I am quite busy recently.

I found that I should disable the termination char in VISA Configure serial port.

Bests,

MinhDuc

Message 6 of 6
(337 Views)