LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

how to convert string of 0's and 1's to cluster of Boolean true/ false, <0,0,0,0,....> string to cluster {F,F,F,F...}

ok, so I have a program where 32-bit serial data is read from a register in the string format <0,0,0,0,.....>, you get the idea, and is sent back in the format <command,action,32-bit uint data>.

"<" indicates start, ">" indicates end, and "," is the delimiter (separator).

 

I need to read in the values, and set them to a cluster of 32 LEDs. Thus far i have been unsuccessful (data reads in fine from micro). I'd show what I tried, but as all my attempts didn't work, I don't think there is any point. Tried using "scan string from token" and "scan from string", but couldn't get them to work in this case. I could "bang it out" (do it the hard, unprofessional way) using "scan from string" and 32 outputs, but there has to be a better way than making some crazy "Rube Goldberg" code, right? (or maybe not?)

 

goal: <0,0,0,0,....> string converted to {F,F,F,F...} cluster, if that makes sense

 

in addition, at some point i need to take a cluster of 32 Boolean {F,F,F,F....} and convert that to binary 0b0000 then to a 32-bit uint to be sent back over serial. I haven't started working on that yet though, so the main issue is the aforementioned string to cluster.

 

not looking for someone to do all the work, but any suggestions are greatly appreciated. I just started using labview a week ago, and thus far this is the only thing i cant figure out. Thanks.

0 Kudos
Message 1 of 6
(1,877 Views)

Why a cluster? why not an array?

I would extract the contents of  <0,0,0..> and parse it into an array of int using Spreadsheet string to array function and comma as a delimiter. Now you have a 32-element array of 1s and 0s. Convert this to a boolean using the Number to Bool function, now I get a 32-element array of booleans. When required, feed this array of boolean to boolean array to number function to get the equivalent U32 data.

Santhosh
Soliton Technologies

New to the forum? Please read community guidelines and how to ask smart questions

Only two ways to appreciate someone who spent their free time to reply/answer your question - give them Kudos or mark their reply as the answer/solution.

Finding it hard to source NI hardware? Try NI Trading Post
Message 2 of 6
(1,866 Views)

stb.png

"If you weren't supposed to push it, it wouldn't be a button."
0 Kudos
Message 3 of 6
(1,842 Views)

thanks santo, heres what i came up with. I feel that it can be simplified further? but thank you very much 😉 the plan was to convert from cluster to array later on anyways, but doing array to cluster seems better. The cluster is for 32 led indicators.

 

Capture2.PNG

 

yeah paul, thats actually similar to what i began with (i never got mine fully working), but i knew there had to be a better way (i have to do this around 20 times), and i always looking to learn new features. Thanks for showing the "hard way"!

 

now all i have to do is convert the cluster into a 32-bit uint number to write to the micro.

 

edit: did that too. Thanks guys!

Capture3.PNG

0 Kudos
Message 4 of 6
(1,826 Views)

string to cluster.png

Oops I see you did something similar.


Really I would leave it as an array because you should be able to convert it directly into a 32-bit number using Boolean Array to Number.

Bill
CLD
(Mid-Level minion.)
My support system ensures that I don't look totally incompetent.
Proud to say that I've progressed beyond knowing just enough to be dangerous. I now know enough to know that I have no clue about anything at all.
Humble author of the CLAD Nugget.
0 Kudos
Message 5 of 6
(1,805 Views)

I would lean more to using the Spreadsheet String To Array for the heart of the conversion.

 

EDIT: It looks like a few of us had similar ideas.

 


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 6 of 6
(1,788 Views)