02-16-2023 11:18 AM - edited 02-16-2023 11:28 AM
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.
02-16-2023 11:30 AM - edited 02-16-2023 11:30 AM
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.
02-16-2023 12:06 PM
02-16-2023 12:24 PM - edited 02-16-2023 12:50 PM
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.
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!
02-16-2023 01:02 PM - edited 02-16-2023 01:05 PM
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.
02-16-2023 01:22 PM - edited 02-16-2023 01:24 PM
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.