PDA

View Full Version : Scale Factor wrong?



jeffrey morris
08-10-2005, 08:07 AM
I was following the project on page 162 of "What's A Micro Controller" book. The time values in the debug window are 331 and 937 instead of 500 and 1000. What's the correct scale factor?

Jon Williams
08-10-2005, 09:15 AM
You may be using slightly different values. What are your raw (unscaled) readings?

▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Jon Williams
Applications Engineer, Parallax

jeffrey morris
08-10-2005, 05:34 PM
Raw readings using circuit on page 151: 1 to 608

Jon Williams
08-10-2005, 05:59 PM
Here's how you can convert a reading of 1-to-608 to 500-to-1000.

A. The original span is 607 (608 - 1) and the new span is 500 (1000 - 500). The scale factor is:

new_span / old_span = 0.823

B. Convert 0.823 for use with */ by multiplying by 256; the result is 210

C. The conversion code, then, is:

newValue = rctVal */ 210 + 500

▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Jon Williams
Applications Engineer, Parallax

jeffrey morris
08-10-2005, 06:27 PM
Thanks, Jon. I think that the code on page 162 is wrong - it's missing the "time = time */ 185" line. This line is in the code on page 156. The CD-ROM doesn't have source code for the "What's A Micro Controller?" book that came with starter kit with the Home Work Board. The Home Work Board should have an on/off switch for the 9-volt battery.

Chris Savage
08-10-2005, 09:38 PM
Jeffrey,

The code examples are not included at the request of educators who use these boards. It forces the student to type in the code, improving learning from having to go through it. As for a switch, the HomeWork Board goes to sleep when not in use, as long as you end programs with an END statement. You only need to remove the battery when you're done with the board for the day.

▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Chris Savage
Parallax Tech Support
csavage@parallax.com (mailto:csavage@parallax.com)