LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Bitwise operation then plotting

Solved!
Go to solution

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? 

 

Appreciate your suggestions. 

 

Bests,  

0 Kudos
Message 1 of 6
(530 Views)

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
0 Kudos
Message 2 of 6
(524 Views)

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.

hmdpostechpostechackr_0-1696495440966.png

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];

}

 

Appreciate your help. 

 

MinhDuc

 

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

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.

hmdpostechpostechackr_0-1696495440966.png

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
0 Kudos
Message 4 of 6
(460 Views)

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

0 Kudos
Message 5 of 6
(401 Views)

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

0 Kudos
Message 6 of 6
(337 Views)