Shop OBEX P1 Docs P2 Docs Learn Events
WaM CH6 #4? — Parallax Forums

WaM CH6 #4?

JimFolsJimFols Posts: 11
edited 2007-01-13 06:30 in Learn with BlocklyProp
Hi,

I really do not understand the relevance of the numbers in Lookdown Command 'values' in Activity #4. Therefore I am having problems adding segment d in the 'Your Turn' exercise.

I have WaM and the Basic Stamp Manual, but I'm just not getting it. Is there another approach I could use so it might sink in?

I'm having fun, but I do not want to move on until I get this.

Thank you,

Jim

Comments

  • AImanAIman Posts: 531
    edited 2007-01-12 14:50
    This is not intended to sound like no answer, but is actually a way of trying to help you·utulize the forum to its fullest extent.

    If you don't understand something then post the definitions word for word from the books or material,· state what you think and then ask· 'Is this correct?'. This helps us know what you think, what information your using and allows us to give a much better answer.

    Example:

    Definition of a hamburger is meat between a bun.

    I assume this means beef.

    Is this correct?

    Post Edited (AIman) : 1/12/2007 2:55:33 PM GMT
  • Chris SavageChris Savage Parallax Engineering Posts: 14,406
    edited 2007-01-12 16:04
    Jim,

    The values in the first section are there to demonstrate how the LOOKDOWN command finds a given value in a list and returns its index or position in the list. Used in conjunction with the LOOKUP command this can provide a way to translate a series of values from one value or format to another. The values themselves are not related to the segments at that point. I hope this helps. Take care.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Chris Savage
    Parallax Tech Support
  • PARPAR Posts: 285
    edited 2007-01-13 05:21
    JimFols said...
    Hi,

    I really do not understand the relevance of the numbers in Lookdown Command 'values' in Activity #4. Therefore I am having problems adding segment d in the 'Your Turn' exercise.

    ...
    The specific numbers used in the example Lookdown command in the first program listed under Example #4 (SimpleLookdown.bs2), are totally arbitrary, but the list of numbers does include the number "167", which is what the variable, "value", is set to earlier in the program.

    The result of the Lookdown command, "index", will contain the value of the position, 0 through 4; there are five numbers in that list) of "value". Index will be "3" in this example because the value "167" is item #3 (the fourth item) in the Lookdown list.

    In the second example program, DialDisplay.bs2, the list of values in the Lookdown command include "40, 50, 275, etc".

    Those values were determined by prior experimentation, using the particular potentiometer, resistances, capacitance, connected to pin P5 (as shown in Figure 6-14).

    The values were chosen (through experimentation as I indicated) so that the slot of the dial of the potentiometer would more or less line up (point to) one of the LED segments circling the LED device (i.e., segments E, F, A, B, or C) going from the lower left corner of the LED device clockwise (refer back to Figure 6-2 for how the LED segments are labelled).

    When you turn the potentiometer's dial to point to a particular LED segment, your BS2 can calculate from the resistance of that dial position a value ("time"). You can then use "time" to Lookdown a list of known "times" (the ones you found by experimentation) to see where in the Lookdown list your pot's current "time" falls (it's "index" position in the list). In the example program, you want to find the "index" of the list value which is "less than or equal to" your pot's "time".

    E.g., if the current pot's "time" is "60", then it would be found less than or equal to the second item in the list, "150" ("150"'s index in the list is "1" because you start counting from zero).

    Now with that index in hand, you can use it to Lookup which LED segments you need to light up (starting with segment E and circling on around until you light up all the segments clockwise to the one to which your pot dial slot is pointing.

    How do you know which segments to light up, and in particular how to light up through segment D? The bit strings you insert into the Lookup command tell which segments are to be lit up.

    Your problem is to figure out the bit string which will light up segments E, F, A, B, C, D simultaneously, as well as finding out by experimentation what the maximum value of "time" is (which will provide the "index" for when the dial is turn far clockwise).

    The Lookdown and ·Lookup commands in the example have six values listed. You need to add a seventh value to each command, the 7th "time" (max clockwise pot dial position) value, and the 7th "index" value (with the EFABCD LED segment pattern), respectively.

    Figures 6-10 and 6-11 provide insight into how to find which segments are turned on by which BS2 pins. You should be able to create that 7th "index" value with the information from those figures.

    If this explanation is still too obscure and/or incomplete, feel free to ask specific questions about particular points.

    (Also notice that the Lookdown command can take two forms, with or without a "comparison operator";·the comparisonop, <=, ·is used in the DialDisplay.bs2 program.)

    PAR
    ·
  • JimFolsJimFols Posts: 11
    edited 2007-01-13 06:30
    Thank you for the replies.

    Thank you PAR for giving me the boost I needed.

    I've got it now.

    DO
    HIGH 5
    PAUSE 100
    RCTIME 5, 1, time
    LOOKDOWN time, <= [noparse][[/noparse]20, 40, 100, 200, 300, 400, 500 ], index

    LOOKUP index, [noparse][[/noparse]%11100111, %11100101, %11100001, %01100001,
    %00100001, %00000001, %00000000 ],OUTH

    LOOP

    I was looking for things other than what I should have been. I just got in a mental block that I could not get free of.
    Your explaination caused me to look back and start over.

    I feel like a new man.

    Thanks again,

    Jim
Sign In or Register to comment.