PDA

View Full Version : Value found and value used?



MichelB
11-11-2009, 05:18 PM
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?

Tracy Allen
11-11-2009, 11:34 PM
Bonjour Michel,
To what document are you referring?

▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Tracy Allen
www.emesystems.com (http://www.emesystems.com)

MichelB
11-11-2009, 11:56 PM
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 Allen
11-12-2009, 12:10 AM
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 (http://www.emesystems.com)

MichelB
11-12-2009, 12:55 AM
Take all the time you need.

sam_sam_sam
11-12-2009, 05:03 AM
·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·http://forums.parallax.com/images/smilies/idea.gif·that you may have and all of your time finding them http://forums.parallax.com/images/smilies/smile.gif

·
·
·
·
Sam

Post Edited (sam_sam_sam) : 11/11/2009 10:28:00 PM GMT

JD
11-12-2009, 07:17 AM
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 (http://www.parallax.com)

Tracy Allen
11-12-2009, 02:52 PM
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 (http://www.emesystems.com)

MichelB
11-12-2009, 10:56 PM
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.