LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Convert a normal number to binary?

It's much simpler if the data types are correct and consistent. Have a look at the attached example. I have not read enough of the pdf file to understand what the block counter is supposed to be. The example calculates the byte count and the checksum and just uses the Build Array to append everything together before finally using the Byte Array to String function. Some of this can be simplified even more but you should be able to get started with this.
0 Kudos
Message 21 of 129
(2,201 Views)

1. Thank you

2. You mentioned earlier that i should be using I16, and im curious why you decided to use U8.

3. Can 8 bits handle the number 12,000?

The Block count is simply an advancing interger, like a message "title" if you will. The first message sent to the controller is 0 and it will respond with the same block count of zero to that message. Then the next message sent will be 1 and so on.

 

The checksum really was the complicated aspect, Im going to look at it now and figure out how it COUNTS.

 

Im always startled at how small your VI soulutions are.

 

 

0 Kudos
Message 22 of 129
(2,199 Views)
Ok dennis further questions about your response:
 
1. In the PDF page 6 under [BCnt] which is the byte counter, It says the number of all bytes from [BlkCnt] to and including [Chks]
       A. I think this wants me to calculte how many bytes the message LENGTH is or the sum of all the numbers in the message?
       B. Does your array size count the number of elements in the array or something else?
 
2. When using build array, the bottom terminal gets added last? I have never really worked with arrays before.
0 Kudos
Message 23 of 129
(2,192 Views)
Any discussion of I16 or any other data types was before you mentioned that you were sending a string to VISA Write and before you posted the pdf file. Everything appears to be single bytes except for the byte count and data. The byte count part of my example would need to be modified for that. The data can be multiple bytes. I left that as a string because I did not go through all of the pdf to determine how the speeds are encoded. That is something you will still have to do. In the 5.2 example, the data sent is 07D0. this corresponds to a reference speed of 20.000 1/min. The 07D0 is not a simple conversion of 20 to hex.
0 Kudos
Message 24 of 129
(2,191 Views)
07D0 = 2000
 
The manual states that the speed value should be divided by 10 when transmitted. So this would be 20,000RPM.
 
The germans use periods for commas.
 
So i guess the question is: is each character a bit? so 07D0 would be 4 bits?
0 Kudos
Message 25 of 129
(2,179 Views)

I know that when the command 07D0 is sent, it is supposed to represent 2000 but 07D0 does not translate directly to 20000.

07D0 is two bytes. Each hex number is 4 bits. 1111=xF.

0 Kudos
Message 26 of 129
(2,173 Views)

So should I be typecasting these written values into strings? I cant seem to get that to work.

I need to make my string of varibaes into a long string

 

0 Kudos
Message 27 of 129
(2,151 Views)

Well, my statement about 07D) was pretty stupid. That is equal to 2000.

Anyway, I don't understand your latest VI. It does not have the byte count calculation, the check sum creation, or the Byte Array to String. When you do the read, you'll have to use the String to Byte Array if you want to decode complex messages but in some cases, all you will get is the ACK message back. Here's another mod. This one has the subkey and data to set the reference speed.

0 Kudos
Message 28 of 129
(2,139 Views)

Error, LV9 is newer than LV8

😞

 

0 Kudos
Message 29 of 129
(2,136 Views)
Sorry, forgot you were using an older version.
0 Kudos
Message 30 of 129
(2,129 Views)