LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Convert a normal number to binary?

I need to communicate numbers to a machine in binary.
 
What subVI or block do i use to transform a normal number, such as 120,000 RPM into binary?
 
The manual says:
 
All number values are transmitted as binary values. The byte order is BIG Endian, the MSB is sent first. There are 1-,2 byte data types and bits; the latter are summarized in bytes. Negative values are transmitted ina two's compliment.
 
What does that mean?????
 
Help!!!!
0 Kudos
Message 1 of 129
(8,300 Views)
Numbers are always binary they are just displayed in the specified radix.  Click on your number control and show radix then choose binary.  If your bytes are backwards (wrong endian, use swap bytes).  If you are sending strings, you can display the string as hex as well.
Paul Falkenstein
Coleman Technologies Inc.
CLA, CPI, AIA-Vision
Labview 4.0- 2013, RT, Vision, FPGA
0 Kudos
Message 2 of 129
(8,218 Views)

ok I did that, and i showed the radix (what IS a radix?)

I clicked the radix and binary is shaded out, aka I can't click it.

Why?

 

I want to have the user type in a normal number, have it converted to binary and then send the binary sequence to the device. 

0 Kudos
Message 3 of 129
(8,213 Views)
Okay, I'll take a crack at this. If you are using a LabVIEW numeric control, the number is already binary. If you have a string that says "120,000 RPM", you'll want to use a String to Decimal Number on the Sting/Number Conversion subpalette of the String palette to convert it to a decimal number.

"All number values are transmitted as binary values. The byte order is BIG Endian, the MSB is sent first. There are 1-,2 byte data types and bits; the latter are summarized in bytes. Negative values are transmitted ina two's compliment."

LabVIEW uses numbers in Big Endian format as well, so you don't have to worry about that. It looks like your device accepts I8, and I16 signed integer datatypes, as well as bits in sets of 8 (a byte). Two's compliment is standard as well. (You can look these terms up on Wikipedia for pretty comprehensive explanations). The only problem I see is that your example, "120,000" is too big to put into an I16. I think you are going to want to talk to your device in terms of Hz instead of RPM (if that's an option).

Chris
0 Kudos
Message 4 of 129
(8,207 Views)
I cant type in a number into this numeric control? It dosent do anything
0 Kudos
Message 5 of 129
(8,202 Views)
and you are right the RPM units are in x10 so 120,000 would be the number 12,000
0 Kudos
Message 6 of 129
(8,199 Views)


@Vr6Fidelity wrote:
All number values are transmitted as binary values. The byte order is BIG Endian, the MSB is sent first. There are 1-,2 byte data types and bits; the latter are summarized in bytes. Negative values are transmitted ina two's compliment.

First of all, your numbers need to be in the right representation. It must be an integer data type of one or two bytes. Most likely I8 and I16. (you cannot display a DBL as binary directly).

Everything in LabVIEW is big endian by default on any platform, so you should not need to worry about byte order in this case.

What kind of inputs does your transmission VIs accept? To transmit these numbers, most likely you need to typecast them into a string.

0 Kudos
Message 7 of 129
(8,186 Views)


@Vr6Fidelity wrote:
I cant type in a number into this numeric control? It dosent do anything

Once a control is set to binary, thye only letters you can type is "1" and "0". It should accept these just fine, but nothing else. 😄

Still, the display format is only a cosmetic property that does not change the underlying data. For convenience, I would leave the display at decimal. It won't matter.

Can you show us how you communicate with the device? Do you have some third party communication tools? Visa? GPIB? Serial?

0 Kudos
Message 8 of 129
(8,177 Views)

Hello Altenbach. Glad you came in here, as I see you wrote a pretty quick 110 MS Binary converter in the labview challenge. (see do look before I ask)

So in order to type in a value of 12,000 i need to be I16 correct? or would that need to be 32?

So i want to have a sensible user input, divide it by 10, and then convert it into binary. To me this seems pretty simple but I am struggling with this.

 

 

0 Kudos
Message 9 of 129
(8,175 Views)
I do not understand the difference between visa and Serial. Im using the block "Visa Write" but I am not sure this is appropriate. It also dosen't seem to work.
 
I have a serial cable connected to com1 on my computer and it runs to the motor drive.
0 Kudos
Message 10 of 129
(8,170 Views)