LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

How to convert potency values to binary data

Solved!
Go to solution

Hey. 

I need to build a VI on which I input a potency value (from 0 to 300 W), and then convert this value to a 12-bit binary value, to be sent to my electronics's DAC and control the potency.

I was reading stuff about fixed point numbers, but didn't reach any solid conclusions.

Since i have 4095 numbers in a 12-bit value, I can have a precision of 0,07326 in my controls. 

To sum up, when I throw my minimal value (0 W) I want a 0000-0000-0000 byte;

When I throw my maximal value (300 W) I want a 1111-1111-1111 byte.

 

Can you guys please help me on what tools shall I use to build this? 

Thanks!

0 Kudos
Message 1 of 9
(3,226 Views)

What datatype does the instrument accept? Should it be just a string of three bytes?

 

SImply scale a U32 integer to the range of x000000 to xFFFFFF (0..300), and typecast it to a string. Take the string subset of the 3 useful bytes and send it to the instrument. (you might have to worry about byte order, too).

Message 2 of 9
(3,220 Views)

The instrument is a 12-byte DAC.

Shouldn't i scale a U16 integer to the range?

I am pretty new to labview, so i'm sorry for the basic answer, but this range scale you're talking about: how is it done? Properties -> Data entry?

0 Kudos
Message 3 of 9
(3,207 Views)

Ah, sorry, I thought you saind 24bit. Yes, scale to 12 bits.

 

However, it is now not clear what the instrument wants, because it is typically quantized to bytes (multiples of 8 bits). You seem to have 1.5bytes here.

Does the instrument want a hexadecimal or binary formatted string? Does it want a typecast U16, ignoring one nibble?

 

 

Message 4 of 9
(3,206 Views)
Solution
Accepted by topic author pedroseger

pedroseger wrote:

I am pretty new to labview, so i'm sorry for the basic answer, but this range scale you're talking about: how is it done? Properties -> Data entry?


You still don't say what datatype the instrument wants. Here are some possibilities showing the scaling.

Message 5 of 9
(3,195 Views)

altenbach, i'm not sure of what DAC we are using, but i believe it's something like that:

http://www.maximintegrated.com/en/products/analog/data-converters/digital-to-analog-converters/MAX57...

Anyways, I'm working with the labview part only. I just want to build a numeric entry in my front panel which produces a 12-bit value, with the precision of this value being limited by the 4095 possible values in a 12-bit. Point is: I'm pretty new to labview, so i don't even know exactly what tools shall I use to do it 😞

0 Kudos
Message 6 of 9
(3,192 Views)

Yes, my example above does the scaling. You can set the display format of the numeric back to decimal to see [0 ..4095]. It is currently set to binary display.

Message 7 of 9
(3,186 Views)

Well, I believe that your example cleared the path for me. I think i can do it now!

I have no words to describe my gratefulness for your help.

Thank you very much!

0 Kudos
Message 8 of 9
(3,178 Views)

Of course ideally you would change the order of operations slightly and do the division by 300 on the upper wire brach.

This way the compiler can fold everything into a constant to be multiplied with the numeric value.

 

 

 

(No big deal here, though. It is even possible that compiler optimiziations will do the same on the original code)

0 Kudos
Message 9 of 9
(3,137 Views)