LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Decimal to Gray Code

Tbob's example is correct. What you have to realize is that the display is an array so the least significant bit is element 0 so the display reads backwards. You could use the reverse 1D array function but that would make element 0 bit 4 so if you need the results elsewhere, the logic may be backwards. Another way is to use a cluster of LEDs as the display. Make a cluster with LEDs labeled bit0, bit1, etc. Use the function Array to Cluster and set if for the correct elements (number of bits in encoder). In the cluster, you can arrange the LEDs in any order that you want. Make sure though, that the order of controls in the cluster are the same as the bit number. That is, the LED labeled bit0 should be the 0th element in the cluster.
0 Kudos
Message 11 of 18
(3,245 Views)
Use the resize handle in the right direction instead of the down direction.  First grab the handle and move it up to resize back to one element.  Then move the mouse pointer to the right side and grab the resize handle there and move it to the right.  The display will show elements from left to right instead of top to bottom.
- tbob

Inventor of the WORM Global
0 Kudos
Message 12 of 18
(3,244 Views)
Hi,
 
I'd like to ask another question:
 
Now I've successfully translated a decimal number to Gray Code. But since I need to display the data on an intensity graph, I need 2 for-loops outside the Gray Code codes. My data changed from the original single value(data in decimal) to 1D array (data in Gray Code), then 2D array (1st for-loop), and finally 3D!! (2nd for-loop). I'd like to display the data on a spreadsheet, but then spreadsheet only takes 2D data. 
 
Is there any way I can group the 1D array (Gray Code) to a single number, so that I'll only have 2D array (instead of 3D) at the end?
 
Thanks,
Manson 
0 Kudos
Message 13 of 18
(3,226 Views)
Spreadsheet can take 3D array if you write the 3rd dimension to worksheets in Excel.  Lets say your 3D array is in rows, columns, and pages.  First page data (rows and columns) can be written to worksheet #1, Second page data to worksheet #2.  There are property and methods in Excel to create new worksheets and set certain worksheet as the active one so that it will receive the 2D data.  You would have to send 3D array into a for loop with indexing enabled.  That way, each loop iteration would act on 2D data array for each page.  In your loop, use Excel methods to create a worksheet and make it active, write 2D array to current worksheet, repeat the loop.
- tbob

Inventor of the WORM Global
0 Kudos
Message 14 of 18
(3,209 Views)
Oops, sorry...  Missed something that was already answered.  I wish you could delete your own posts.

Message Edited by Novatron on 08-02-2005 02:32 PM

0 Kudos
Message 15 of 18
(3,208 Views)
Hi,
 
One thing I noticed about Excel is that it can only show 6 binary bits (That's what I read from the Excel Help column). But I've 23 bits of data that I'd like to display in Gray Code (or binary in Excel, since Excel doesn't know what Gray Code is). Is there any way I can display my 23 bit data in Excel?
 
Thanks,
Manson
0 Kudos
Message 16 of 18
(3,191 Views)
Display your data in Excel as strings.  Convert your binary bits to a string of 1s and 0s.  Excel can then display the entire 23 character string.  You will have to resize the columns to show the entire string.
- tbob

Inventor of the WORM Global
0 Kudos
Message 17 of 18
(3,187 Views)

I was working in a different mathematical field. Unintentionally, I discovered two ways to convert numbers to Gray code. Example with 173 (8 digits in binary system); from right to left: I make the divisions of 173 with the numbers 2,4,8,16,32, ..., 256. I round each quotient to the nearest integer. I am writing this integer down from the corresponding fraction. If this integer is even, then I write below this digit 0, otherwise I write the digit 1. These digits form the Gray code of 173: 11111011

 

..........................173...........................

___________________________________

256 128  064 032 016 008 004 002

001  001 003 005 011 022 043 087

....1.......1.....1.....1.....1.....0.....1......1

 

Faster method. I can convert all numbers that have equal lengths of digits in the binary system to Gray codes. I do this without turning any number into binary. Here I find it difficult to present this method because it contains graphs, but you can find this here:

 

http://viXra.org/abs/2004.0456?ref=11278286

 

0 Kudos
Message 18 of 18
(1,424 Views)