PDA

View Full Version : Tweaking Jon W.'s code



ERM
05-23-2006, 11:49 AM
Hi guys (and gals),

I am trying to reapply Jon Williams' sequencer.bs2 code where he has entered data into the EEPROM data section. That data looks like this:

' -----[ EEPROM Data ]-----------------------------------------------------

RecLen CON 3 ' 3 bytes per record

ZigZag DATA Word %0000000010000000, 2
DATA Word %0000000101000000, 2
DATA Word %0000001000100000, 2
DATA Word %0000010000010000, 2
DATA Word %0000100000001000, 2
DATA Word %0001000000000100, 2
DATA Word %0010000000000010, 2
DATA Word %0100000000000001, 2
DATA Word %0010000000000010, 2
DATA Word %0001000000000100, 2
DATA Word %0000100000001000, 2
DATA Word %0000010000010000, 2
DATA Word %0000001000100000, 2
DATA Word %0000000101000000, 2
DATA Word %0000000010000000, 2
DATA Word %0000000000000000, 0

Now, rearranging this data, can this format be used in single lines of code instead of writing it into the EEPROM. (i.e.

%0100000000000001, 2

Instead of writing:

high 0
pause 200
low 0

I know the above %000...1, 2 code does not work, but can it be rewritten to work to refrain from using the latter code saving space?

Thanks,
Tony

Jon Williams
05-23-2006, 08:58 PM
If there was an easier (or more code-efficient) way to implement a sequencer, Tony, I would have published it -- trust me, I've done a lot of work with this stuff. Each record in the table represents two separate items: the pins value, and the duration to hold those pins, and you cannot deal with both items in a single line of code.

The beauty of this kind of sequencer is that you can adjust the sequence without ever making adjustments to the "engine" itself.

▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Jon Williams
Applications Engineer, Parallax

Gadgetman
05-23-2006, 09:37 PM
The ONLY way to compact it would be if you separated the Pin-data and the delay into two tables, and used nibbles instead of Bytes to store the delay.

BUT... That would probably make for a more complex code which takes more EEPROM space and executes slower...
(Not to mention, is much more difficult to read... http://forums.parallax.com/images/smilies/smile.gif

▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Don't visit my new website...

Jon Williams
05-24-2006, 12:07 AM
Exactly -- and I actually send the timing value to a routine that [typically] uses 0.1 second increments (we don't need one millisecond resolution fro prop control).

▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Jon Williams
Applications Engineer, Parallax