LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

String data to boolean data

Hi I am using my PIC Microcontroller for controlling 4 Motors. I have programmed my PIC. Meanwhile I have interfaced PIC with LabVIEW using VISA. Am going to read the data from PIC. I am passing 1 byte binary data from PIC to LabVIEW. The Problem is when I am getting the data in string. I want the string data to be converted into Boolean value.  For example: Am passing 0100 data, 4 individual bits correspond to the 4 motor status. So When I pass this value, in my labVIEW the boolean indicator motor 2 should be glow. Help me with this guys. Thanks in advance 

0 Kudos
Message 1 of 9
(4,604 Views)

Hi velkumar,

 

convert the string to an array of U8 values, index the first byte from the array, convert this U8 value to a boolean array.

 

3 simple functions: StringToU8Array, IndexArray, NumberToBooleanArray…

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
Message 2 of 9
(4,582 Views)

Thank you , I attached my VI. When i run this, only motor 1 boolean indicator glows. For all value.

0 Kudos
Message 3 of 9
(4,544 Views)

Hi velkumar,

 

I cannot open your LV2015 VI right now, so I attach a snippet containing just the 3 functions mentioned above:

check.png

Seems easy to implement…

Best regards,
GerdW


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

Thanks. But When I run this... String value gets accumlated ie the previous value gets accumaled with the new value. As I am continously sending the string data from my PIC to labview. Is there is any way for seperating new string from the old one.

0 Kudos
Message 5 of 9
(4,529 Views)

Hi velkumar,

 

as I said before: I cannot open your VI because of the LabVEIW version you use.

 

Is there is any way for seperating new string from the old one.

Simple solution: When you want to get the data of the new string you should work with this new string - don't attach it to the old data…

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
0 Kudos
Message 6 of 9
(4,522 Views)

Hi GerdW,

 Thanks for your reply, I have attached snippet of my program. I cant get you what you are trying to say

0 Kudos
Message 7 of 9
(4,513 Views)

Hi velkumar,

 

- you always read the latest data: I have no idea why you think you accumulate your string data

- you use DeleteFromArray to get the last byte of the string: no idea why you do this

- using BytesAtPort is most often the wrong function to use. Either you use the TermChar or, like in your case, you read a fixed amount of data…

 

What's the data rate you want to receive? What's the message size you receive? What's the message format?

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
0 Kudos
Message 8 of 9
(4,491 Views)

Duplicate thread: http://forums.ni.com/t5/Instrument-Control-GPIB-Serial/String-data-to-indicate-ON-OFF-of-motor/m-p/3...


GCentral
There are only two ways to tell somebody thanks: Kudos and Marked Solutions
Unofficial Forum Rules and Guidelines
"Not that we are sufficient in ourselves to claim anything as coming from us, but our sufficiency is from God" - 2 Corinthians 3:5
0 Kudos
Message 9 of 9
(4,469 Views)