07-22-2014 01:31 PM
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!
Solved! Go to Solution.
07-22-2014 01:37 PM
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).
07-22-2014 01:47 PM
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?
07-22-2014 01:47 PM - edited 07-22-2014 01:58 PM
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?
07-22-2014 01:56 PM
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.
07-22-2014 01:58 PM
altenbach, i'm not sure of what DAC we are using, but i believe it's something like that:
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 😞
07-22-2014 02:00 PM - edited 07-22-2014 02:01 PM
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.
07-22-2014 02:02 PM
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!
07-23-2014 03:35 PM - edited 07-23-2014 03:38 PM
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)