Shop OBEX P1 Docs P2 Docs Learn Events
Tweaking Jon W.'s code — Parallax Forums

Tweaking Jon W.'s code

ERMERM Posts: 34
edited 2006-05-23 16:07 in BASIC Stamp
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:

'
[noparse][[/noparse] 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

Comments

  • Jon WilliamsJon Williams Posts: 6,491
    edited 2006-05-23 12:58
    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
  • GadgetmanGadgetman Posts: 2,436
    edited 2006-05-23 13:37
    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... smile.gif

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Don't visit my new website...
  • Jon WilliamsJon Williams Posts: 6,491
    edited 2006-05-23 16:07
    Exactly -- and I actually send the timing value to a routine that [noparse][[/noparse]typically] uses 0.1 second increments (we don't need one millisecond resolution fro prop control).

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Jon Williams
    Applications Engineer, Parallax
Sign In or Register to comment.