Value found and value used?
MichelB
Posts: 154
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
To what document are you referring?
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Tracy Allen
www.emesystems.com
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Tracy Allen
www.emesystems.com
·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··that you may have and all of your time finding them
·
·
·
·
Sam
Post Edited (sam_sam_sam) : 11/11/2009 10:28:00 PM GMT
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
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,
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:
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
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.