Shop OBEX P1 Docs P2 Docs Learn Events
quick ? about LOOKDOWN/UP comand... — Parallax Forums

quick ? about LOOKDOWN/UP comand...

RinksCustomsRinksCustoms Posts: 531
edited 2008-03-29 09:19 in Propeller 1
it's an easy enough comand to understand, the question is with how the tables are stored in memory. Is each element stored as a LONG, or can it be modified like a data structure with BYTE/WORD before the elements?

Specifically, I'm wondering if two tables with 225 elements each, and each element having a numeric value up to 45370 (a pseudo floating decimal) which would fit into a WORD value based table system.

As you can see, 450 LONGs would·just about tie up a cog by themselves, so the idea of modifying the elements with a WORD alignment would use memory most efficiently while cutting memory usage in half. This is the only approach I know to obtain data from a MAF sensor, (Mass Air Flow).

I have obtained 225 data points for this sensor as it's response is more of a log curve. I have the data in Exel format if any·mathematitians know of a way to convert the output frequency to a more useable grams/sec measurement in what is sure to be a complex formula. Obtaining this data alone took 2 months of scouring the internet. The data reads from 0.14 grams/sec @ 750Hz to 453.70 g/sec@ 12KHz and there are 225 data points in my information. I'm not going to post the data here due to the proprietory nature of it, but I can e-mail it to anyone willing to take a stab at the formula approach.

▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
E3 = Thought

http://folding.stanford.edu/·- Donating some CPU/GPU downtime just might lead to a cure for cancer! My team stats.

Comments

  • Mike GreenMike Green Posts: 23,101
    edited 2008-03-27 00:15
    I'm still not sure what you're asking. You have two tables of 225 elements and the table entries can range up to 45370. Is this for use with Spin or assembly? Why not just store them as words? They can be defined in a DAT section as WORDs and referenced using array subscripting from Spin.
  • hippyhippy Posts: 1,981
    edited 2008-03-27 01:44
    LookUp/LookDown are all Hub RAM based so don't use Cog memory at all. Also there are no tables to speak of, no data structure. Both are sequences of bytecode 'compares' of the index against each LookUp/LookDown entity. Each entity ( implemented as a bytecode PUSH #value, or two for a range of values ) varies in size depending on value so it wouldn't be at all easy to modify the data within the LookUp/LookDown bytecode sequence at run-time, although it could be done.
  • stevenmess2004stevenmess2004 Posts: 1,102
    edited 2008-03-27 01:50
    To add to what hippy said the values will be byte aligned as well so longs won't necessarily start at the right place making it even harder.
  • RinksCustomsRinksCustoms Posts: 531
    edited 2008-03-27 03:34
    sorry if that was cryptic, i'll try to clarify, I don't know ASM. Could you modify a lookdown/lookup like this;
    LOOKDOWN ("variable" word : word0, word1, word2, .. )

    I'm looking to make one lookdown list having 225 entries, comparing an incoming frequency from a sensor to a frequency in the LOOKDOWN list, when/if that lookdown returns a value from the list, that value would then be passed to a LOOKUP list where the desired g/sec is returned to the program.

    This is the best way I know how to deal with a logarithmic sensor with known data points across it's range of opperation. I probably have another misconception of how spin and these comands work.

    Are the elements in a lookdown/up "list" in the form of LONGs, & if the default is a LONG for an element, does a modifier exist to change the alignment from a LONG to a WORD? - since my largest value will not exeed the maximum value that a WORD can store.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    E3 = Thought

    http://folding.stanford.edu/·- Donating some CPU/GPU downtime just might lead to a cure for cancer! My team stats.

    Post Edited (RinksCustoms) : 3/27/2008 3:44:11 AM GMT
  • stevenmess2004stevenmess2004 Posts: 1,102
    edited 2008-03-27 07:00
    You could do it using a word array in the dat section and a binary search. This will probably be slower than LOOKDOWN though. The elements in the list are made whatever length they need to be. For example if the value is 12 than it will be a byte while if it is a 2^30 than it will be a long.

    Don't forget that the propeller has a log table that you may be able to use if you have the equation for the sensor. This could give you a better resolution and may be faster or slower depending on the function. Did you get my PM?
  • hippyhippy Posts: 1,981
    edited 2008-03-27 13:15
    RinksCustoms said...
    sorry if that was cryptic, i'll try to clarify, I don't know ASM. Could you modify a lookdown/lookup like this;
    LOOKDOWN ("variable" word : word0, word1, word2, .. )

    I'm looking to make one lookdown list having 225 entries, comparing an incoming frequency from a sensor to a frequency in the LOOKDOWN list, when/if that lookdown returns a value from the list, that value would then be passed to a LOOKUP list where the desired g/sec is returned to the program.

    That will work in Spin "as is", but you don't need the "word:" qualifier ...

    It doesn't matter if word0, word1 etc are byte, word or long variables, the LookDown will deal with that automatically. If you want to alter what those values are at run-time you'll have to create your own lookup table as an array and then write code which will scan through it.

    f you have a spare Cog that lookup table scanning can be done in PASM and should be very quick compared to the actual LookDown Spin command.
  • RinksCustomsRinksCustoms Posts: 531
    edited 2008-03-29 02:12
    hippy said...
    RinksCustoms said...
    sorry if that was cryptic, i'll try to clarify, I don't know ASM. Could you modify a lookdown/lookup like this;
    LOOKDOWN ("variable" word : word0, word1, word2, .. )

    I'm looking to make one lookdown list having 225 entries, comparing an incoming frequency from a sensor to a frequency in the LOOKDOWN list, when/if that lookdown returns a value from the list, that value would then be passed to a LOOKUP list where the desired g/sec is returned to the program.

    That will work in Spin "as is", but you don't need the "word:" qualifier ...

    It doesn't matter if word0, word1 etc are byte, word or long variables, the LookDown will deal with that automatically. If you want to alter what those values are at run-time you'll have to create your own lookup table as an array and then write code which will scan through it.

    f you have a spare Cog that lookup table scanning can be done in PASM and should be very quick compared to the actual LookDown Spin command.
    this first run of the programwill be done in spin only, since I don't know any PASM. Just for clarifacation there will be no variables in these lookdown/up lists. The "word1, word2.." are simply values in the list which do not exceed a WORD limitation. My question was with how each element in that list was stored when it was compiled. I was curious if·each element of the list was stored as a long by default, and if it could be modified from a long to a word sized list element.

    But if the lokdown/up does this automatically, then no worries, also i didn't know you could do this with variables/constants, cool.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    E3 = Thought

    http://folding.stanford.edu/·- Donating some CPU/GPU downtime just might lead to a cure for cancer! My team stats.
  • deSilvadeSilva Posts: 2,967
    edited 2008-03-29 09:19
    LOOKUP/LOOKDOWN can be best considered as a "condensed CASE". That's really cool.
    But it needs considerable and quite unpredictable time which is not so cool. Accessing an ordered constant list of any length to speak of (and this starts near 64) is generally done in a different way...

    Post Edited (deSilva) : 3/29/2008 11:07:02 AM GMT
Sign In or Register to comment.