취소
다음에 대한 결과 표시 
다음에 대한 검색 
다음을 의미합니까? 

How to convert decimal number to binary number

Hi everyone, I'll start by saying that I'm still new to Labview. I'm communicating with a lock in 5210 and I need to display a certain error in Labview. Let me explain better, I send the N command from Labview to the lock in which will return an integer between 0 and 255. This number is the decimal equivalent of a binary number. However, I don't know how to convert this integer and especially how to convert this "error" to display it on the panel. Because, for example, if bit 3 goes to 1 then I should turn on a LED to specify that channel Y is overloaded. I'm attaching the part of the lock in manual and the first part of the (incomplete) Labview code (there is also management of the ?, because if it were to return this character then the command must be resent, and * establishes the end of the number). I hope you can help me.

 

 

모두 다운로드
0 포인트
1/21 메시지
832 조회수

Hi giuli,

 


@giuli_ wrote:

which will return an integer between 0 and 255. This number is the decimal equivalent of a binary number. However, I don't know how to convert this integer and especially how to convert this "error" to display it on the panel. Because, for example, if bit 3 goes to 1 then I should turn on a LED to specify that channel Y is overloaded.

Simplest approach (for people not used to boolean logic):

  • Use NumToBooleanArray to convert your U8 value into an array of 8 boolean elements.
  • Use IndexArray to index the required bits.

When you can apply boolean math rules to your data then you should use the AND function directly on your U8 integer value to mask bit3 (0d08 = 0x08 = 0o010 = 0b00001000)…

 

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
0 포인트
2/21 메시지
826 조회수

Ok thank you. So after accumulating the characters (in the while) and after getting the string containing the decimal number, I convert it to a number and then to a boolean array? Right?

0 포인트
3/21 메시지
812 조회수

Hi giuli,

 


@giuli_ wrote:

Ok thank you. So after accumulating the characters (in the while) and after getting the string containing the decimal number, I convert it to a number and then to a boolean array? Right?


Yes.

 

Do you really need to send and receive messages with your device on a "one byte after the other" scheme?

Have you watched this video yet?

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
0 포인트
4/21 메시지
796 조회수

Thank you so much!!

0 포인트
5/21 메시지
784 조회수

Maybe this is what you are looking for.

0 포인트
6/21 메시지
719 조회수

You are getting a single byte, that has the equivalent decimal value in the range of 0..255. You don't get 1-3 decimal characters (bytes)!

 

altenbach_0-1750092468876.png

 

For that reason, you should typecast the single character to U8 and extract the bits

 

altenbach_1-1750092878584.png

 

0 포인트
7/21 메시지
710 조회수

Here's a simple way to e.g. extract the active messages.

 

altenbach_0-1750093349043.png

 

8/21 메시지
704 조회수

Thank you!

0 포인트
9/21 메시지
684 조회수

You can simplify the code using a cluster:

paul_a_cardinale_0-1750159279799.png

 

10/21 메시지
667 조회수