LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

convert an integer to 12 bit integer

 

Good Morning,

 

I know that is easy to convert an integer to 8 or 16 bit integer using the "number to boolean array" function.However, I would like to convert an integer to a 12 bit integer. Could you please advise.

 

Thank you in advance

0 Kudos
Message 1 of 14
(11,481 Views)

Hello... 🙂

 

Can you please explain why you want 12 bit integer instead of 8 or 16...? Because according to me if you use 12 bit integer you will be able to use upto 4095 no. only....

0 Kudos
Message 2 of 14
(11,475 Views)

Hi!

   I'm sorry for answering a question with another question, but... why do you want to do this? Are you addressing a microcontroller? an ADC or DAC? Are you working with a DAQ board with 12 bits precision? Are you going to emulate fixed precision math calculation? If you let us know this,it'll be easyer to help you!

 

   LabView for PC works on bytes, and I think you have to consider 12 bit integers as a mask of 16 bit integers.

 

graziano

0 Kudos
Message 3 of 14
(11,474 Views)

thorfano wrote:

I know that is easy to convert an integer to 8 or 16 bit integer using the "number to boolean array" function.However, I would like to convert an integer to a 12 bit integer. Could you please advise.


Sorry, but "number to boolean array" does not convert an integer to an integer, but to an array of booleans. That is something completely different!.

 

If you only want an array of 12 elements, start with a 16bit (or larger) integer and then user "array subset" to trim to 12 elements.

 

If you need something else, please be a bit more specific. 😉

Message 4 of 14
(11,462 Views)

Thank you all. Sorry for my poor explaination. I am using an NI USB-6212 OEM which will cooperate with another electronic circuit-card. What I really want to do is reading a digital word composed of 12 digits. Unfortunately, the available lines in the NI card is only 12, all other lines are occupied from something else. Thus, I can't start with a 16bit (or larger) integer and then use the"array subset" to trim to 12 elements, as altenbach proposed.

 

I am waiting for your support

0 Kudos
Message 5 of 14
(11,443 Views)

If I'm not wrong you want to convert a no. into 12 bit.. Like 234 is the no. Then it should be converted like 000011101010....

 

Is it like so...? Please make correct if I'm wrong...

0 Kudos
Message 6 of 14
(11,438 Views)

Yes. That's exactly what I am trying to do.

0 Kudos
Message 7 of 14
(11,429 Views)

thorfano wrote:

Yes. That's exactly what I am trying to do.


 

Since this was a long thread, could you tell us what exactly you refer to by "That's"? 😉

 

It is really not clear at all. LabVIEW does not have a native 12 bit datatype.

 

We still don't know what you actually want:

 

  • An array of 12 booleans?
  • A binary formatted string of lenght 12 consisting of the letters 0 and 1?
  • An integer indicator set to such a binary display? (Do a bitwise AND with 4095 to ensure unwanted higher bits are blanked)
  • ...

 

What kind of data do you get from the USB device? Can you make a small sample VI that contains your raw data as a diagram constant?

0 Kudos
Message 8 of 14
(11,391 Views)

altenbach wrote:

It is really not clear at all. LabVIEW does not have a native 12 bit datatype.


 

Actually, let me take this statement back. 🙂 In newer versions of  LabVIEW you can configure FXP data to be exactly 12 bit itegers.

 

Message Edited by altenbach on 10-07-2008 11:30 AM
0 Kudos
Message 9 of 14
(11,373 Views)

Hello... 🙂

 

I have done a VI it's a bit lengthy.. But hope it helps you... 🙂

 

Atleast you will get an idea... 🙂

 

The VI is in LabVIEW 7.1...

0 Kudos
Message 10 of 14
(11,344 Views)