Shop OBEX P1 Docs P2 Docs Learn Events
Value found and value used? — Parallax Forums

Value found and value used?

MichelBMichelB Posts: 154
edited 2009-11-12 15:56 in BASIC Stamp
Is somebody can explain why in SW21-EX05-LED_Graph.BS2 (see page 43) raw high reading 695 is used in code instead of 746 found?

Comments

  • Tracy AllenTracy Allen Posts: 6,662
    edited 2009-11-11 16:34
    Bonjour Michel,
    To what document are you referring?

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Tracy Allen
    www.emesystems.com
  • MichelBMichelB Posts: 154
    edited 2009-11-11 16:56
    Hi dear Tracy, StampWorks page 43: ...RCTIME returned a low value of 10 and a high value of 746. Two lines after we can see ... (695 / 255), and it is the value - 695 - used·for the constant HiScale instead of 746. From where does come this value? Best regards. MichelB
  • Tracy AllenTracy Allen Posts: 6,662
    edited 2009-11-11 17:10
    I don't have quick access to Stampworks where I am now. f someone else doesn't jump in with the answer, I'll take a look at it this evening.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Tracy Allen
    www.emesystems.com
  • MichelBMichelB Posts: 154
    edited 2009-11-11 17:55
    Take all the time you need.
  • sam_sam_samsam_sam_sam Posts: 2,286
    edited 2009-11-11 22:03

    ·The hook for this is on page 40 add a Resister of 500 ohms· to 1 k ohms where the lead to ground·is to set this up ···························································
    This is how this works when you use the RCTime··

    LoScale CON 10 ' raw low reading······ ··········· This is the pot adj to the lowest value· 10
    HiScale CON 695 ' raw high reading··············· ·This is the pot adj to the highest value·746
    Span CON HiScale - LoScale ' between lo-to-hi····· This is value between lowest value to the highest value·736

    Scale CON $FFFF / Span ' scale factor 0..255

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    ··Thanks for any·idea.gif·that you may have and all of your time finding them smile.gif

    ·
    ·
    ·
    ·
    Sam

    Post Edited (sam_sam_sam) : 11/11/2009 10:28:00 PM GMT
  • JDJD Posts: 570
    edited 2009-11-12 00:17
    MichelB,

    Just to clarify; do you mean that you are getting 695 as your higher pot value instead of 746? And why that may be?

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Respectfully,


    Joshua Donelson
    www.parallax.com
  • Tracy AllenTracy Allen Posts: 6,662
    edited 2009-11-12 07:52
    Michel,

    The 746 looks to me like a typo. Everything else in the program and text is based on 695 as the hiScale value. Of course, the actual values will vary and have to be checked for every different setup.

    I would look at the fraction 255/685 = 0.372, which is slightly different the text, which for some reason is based on 695 in the denomnator. On a calculator it would be done like this:
    (rawVal - loScale) * 255 / (hiScale - loScale) = (rawVal - 10) * 255 / 685.
    And the fraction (rawVal - loScale) / (hiScale - loScale) is always less than or equal to one, that is, a proportion.
    The program itself uses the span factor of 685 in the deminator, not 695.

    The program has what seems to be a convoluted way to fill in the solid bar. It could be done with one formula, I think, like this,
    newBar = DCD (grafval / 32)
    IF (GraphMode=BarGraph) THEN newbar=newBar<<1-1
    LEDs= newBar
    


    For example, if newBar = %100000, then subtracting one gives %11111, and the shift preserves the length. Another way is
    newBar=newBar-1 | newBar
    that is subtract one and then OR back in the original one.

    A function more like a VU meter would use the ncd function:
    newBar = DCD (NCD grafval - 1)    '<--- this function uses NCD
    IF (GraphMode=BarGraph) THEN newbar=newBar<<1-1
    LEDs= newBar
    



    NCD is an integer logarithm with much greater sensitivity at low levels (short RCtimes). The original function divides the signal domain into 8 equal regions of 32 steps each.

    (An extended open ended answer to a simple question, sorry)

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Tracy Allen
    www.emesystems.com
  • MichelBMichelB Posts: 154
    edited 2009-11-12 15:56
    Joshua Donelson (Parallax) said...

    MichelB,

    Just to clarify; do you mean that you are getting 695 as your higher pot value instead of 746? And why that may be?

    Hi Joshua, the higher pot value got was 748·with the X5 Pot and just before writing this reply I tried with the X6 Pot and I found 664.

    Tracy Allen said that the 746 looks to him like a typo. Everything else in the program and text is based on 695 as the hiScale value.
    I think that Jon Williams made like me which explains the 2 values 746 and 695 in the text, 748 and 664 in my case.

    @Tracy: Thank you for the newBar explanation.

    Best regards.
Sign In or Register to comment.