Shop OBEX P1 Docs P2 Docs Learn Events
Scale Factor wrong? — Parallax Forums

Scale Factor wrong?

jeffrey morrisjeffrey morris Posts: 52
edited 2005-08-10 14:38 in BASIC Stamp
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?

Comments

  • Jon WilliamsJon Williams Posts: 6,491
    edited 2005-08-10 02:15
    You may be using slightly different values. What are your raw (unscaled) readings?

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Jon Williams
    Applications Engineer, Parallax
  • jeffrey morrisjeffrey morris Posts: 52
    edited 2005-08-10 10:34
    Raw readings using circuit on page 151: 1 to 608
  • Jon WilliamsJon Williams Posts: 6,491
    edited 2005-08-10 10:59
    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 morrisjeffrey morris Posts: 52
    edited 2005-08-10 11:27
    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 SavageChris Savage Parallax Engineering Posts: 14,406
    edited 2005-08-10 14:38
    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
Sign In or Register to comment.