LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Binary string to binary number conversion

Solved!
Go to solution

Per default leading 0's are scrapped, if you want to 0-pad to a specific width you can use the format %8b in the indicator, or just check the indicator properties where there's an option to 'pad with 0s'.

/Y

G# - Award winning reference based OOP for LV, for free! - Qestit VIPM GitHub

Qestit Systems
Certified-LabVIEW-Developer
Message 11 of 18
(938 Views)

Your data is arrays so i do not understand what you mean by "default type is not array". And in any case, if the standard array indicator is not suitable there is other ways to present array data, but that depends on your application. Or you can select one element in array with the "Index array"-function which you earlier used to split the two-dimensional array from the file into two one-dimensional arrays. But you could also autoindex over the array with a for loop which is shown in my first post. The best solution will depend on how you want to use your data and what you want to accomplish.

0 Kudos
Message 12 of 18
(925 Views)

Thanks for your patience!Heart

What I mean is that if I stay in my for loop, the default type of the function is the unsigned word, it will be the array if I move that out of the for loop. But in this application, the lookup table has to be inside the inner For loop.

I try my best to do this alone, eventually I couldn't able to do this by myself, sorry for taking your time...

thanks.PNG

0 Kudos
Message 13 of 18
(916 Views)

@AlEXINUK wrote:

the default type of the function is the unsigned word,


No, the default is what you wire into it. If you wired a %b, the default data type might be an U32. You can change that (right click the constant, change Representation).

 


@AlEXINUK wrote:

it will be the array if I move that out of the for loop. But in this application, the lookup table has to be inside the inner For loop.

..

The Interpolate 1D Array needs an 1D array, and you read a scalar value. 

 

You can build an array, in a shift register with an array, then concatenate each value to the previous array. I'm not sure if that's what you want. It definitely rubs me the wrong way. That array will grow bigger and bigger, so you'll end up with an exponential execution time (t=x^samples). In other words, it doesn't scale up well... 

 

You'd have to explain what it is you want...

Message 14 of 18
(887 Views)
Solution
Accepted by topic author AlEXINUK

I have not analyzed all of your logic, but i have some comments which may help with your initial problems.


1.

Functions "Threshold 1D array" and "Interpolate 1D array" need their inputs sorted in increasing order. The sample of your inputfile is not correctly sorted. You will therefore have to do some sorting in you program. That will be a small challenge because you need to sort both arrays synchronously if you want to use one of them as lookup to get the correct corresponding value from the other array.
You may use the attached VI to get the values sorted on first column. To get them sorted on second column the inputs of bundle and outputs of unbundle has to be switched.

2.
I do not think you are using "Threshold 1D array" and "Interpolate 1D array" in the correct way, but since i do not know what you want to accomplish i can not say for certain. 

3.
About your inner for-loop: Do not use N-terminal at the same time as indexing on input terminal.
Also, do not use several index terminals at the same time. This is a general rule.
In some situations it is valid to use both N-terminal and indexing, but make sure that you use it correctly.

4.
When i on the diagram in my earlier post stated "Replace this" and "With this" i meant to indicate that you replace the one function with the for loop and its contents.

5.
Move both conversions, Duty Ratio and PWM Regrister, outside your outer for loop. These values are constant for all of your runs and only need to be calculated one time. You may use the attached vi to do the conversion and sorting. Do not use indexing on those arrays when sending them into your for-loops. 


6.
After reading your file you may want to remove the the first row from the array since it is an header

Message 15 of 18
(870 Views)

@RolfO wrote:

1.

Functions "Threshold 1D array" and "Interpolate 1D array" need their inputs sorted in increasing order.


For the Threshold 1D array an ordered input makes most sense. But if you just want to find the first sample higher that y (that is what a threshold is) than any data will do.

 

The Interpolate 1D Array really doesn't need ordered data. If you want to get the y value between x[6] and x[7] it really doesn't matter at all what values x[0-5] and x[8..] are.

Message 16 of 18
(858 Views)

It's very detailed! 

I appreciate your help and patience! I got what I'd like to accomplish now! Smiley Very Happy

Hope you have a good day!

Message 17 of 18
(850 Views)

Kudo for accepting solutions, and of course for all the kudo's you'd given!

0 Kudos
Message 18 of 18
(843 Views)