Email: Password: Remember Me | Create Account (Free)

Back to Subject List

Old thread has been locked -- no new posts accepted in this thread
???
06/13/10 14:07
Read: times


 
Msg Score: +3
 +3 Informative
#176638 - Modeling With Gray Code
I very often model embedded programming algorithms through the use of other applications such as Excel or MathCad. This can be a good way to fine tune the methods to be used and also lends to a way to document more complex parts of your project. The recent dicussion here regarding "nice color sequences" had a brush of a suggestion about Gray Code. I've always wanted to capture an algorithm that would convert a binary counting sequence to Gray code using the "reflected binary" scheme. After doing some Google searches I found some ideas about how to do this type of conversion and have implemented them into a spreadsheet as a pair of Visual Basic User Defined Functions.

Spreadsheet with GrayCode functions

This spreadsheet can be a good starting point for anyone needing to check out an algorithm that works based upon the properties of Gray encoded number patterns. It is very simple to create a column of numbers that increment from say 0 to 255 using a spreadsheet formula. Up to now, getting a column of corresponding Gray code has been a pain in the tush. Now, with the use of these VBA code functions it is very easy.

If one has to generate Gray Code in a similar manner in side an actual embedded code set the VBA script subroutines are easily to translate to C or to your favorite assembly language. Note that if these routines are made in C or Assembler they would be "cleaner" looking than these VBA routines. VBA does not have an unsigned long (32-bit) variable type and it takes some particular coding techniques to keep VB from doing automatic sign extension of negative numbers or complaining about numerical overflow when the numbers would exceed the holding capacity of the long data type.

----------------------

Do you use spreadsheet modeling for algorithms or as a means to document your embedded code? If so feel free to share some of your experiences.

What have you used Gray Code for?

Michael Karas


List of 14 messages in thread
TopicAuthorDate
Modeling With Gray Code            01/01/70 00:00      
   Good idea            01/01/70 00:00      
      I use php for a lot of modeling            01/01/70 00:00      
   most recently..            01/01/70 00:00      
      Let's discuss faster...            01/01/70 00:00      
         Its safer..            01/01/70 00:00      
            Slightly hostile enviroment            01/01/70 00:00      
               For sure...hostile            01/01/70 00:00      
                  sort of...            01/01/70 00:00      
      fifo grey-code addressing            01/01/70 00:00      
         Its all hand waving again.            01/01/70 00:00      
   Using Spreadsheets            01/01/70 00:00      
   gawk/sh/cut/sed            01/01/70 00:00      
      Cygwin environment            01/01/70 00:00      

Back to Subject List