Shop OBEX P1 Docs P2 Docs Learn Events
Question about Stampworks Experiment #27 code — Parallax Forums

Question about Stampworks Experiment #27 code

RDL2004RDL2004 Posts: 2,554
edited 2005-10-23 02:27 in BASIC Stamp
I have a question about the following code in StampWorks Experiment #27

Main:
GOSUB Read_0831
mVolts = result */ $139C ' x 19.6 (mv / unit)
DEBUG Home
DEBUG "ADC..... ", DEC result, " ", CR <<< What is the purpose of the " " in this line ?
DEBUG "volts... ", DEC mVolts DIG 3, ".", DEC3 mVolts
PAUSE 100 ' delay between readings
GOTO Main ' do it again

With the " " the ADC.... will be 0 to 255, without the " ", it doesn't go to zero anymore.
When the pot is adjust to zero volts the ADC..... will show some random number,
less than 50 usually, but it still goes to 255 every time when adjusted to 5 volts.

confused.gif

- Rick

Comments

  • Jon WilliamsJon Williams Posts: 6,491
    edited 2005-10-22 00:46
    The " " is just a method of erasing the last digit of the previous reading should the current reading be smaller (e.g., last reading was three digits wide, current reading is two digits wide).··I've attached·the update of the program in StampWorks 2.0 (book at printer now).· Notice the use of CLREOL (clear to end of line) instead of the space -- this works better.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Jon Williams
    Applications Engineer, Parallax
  • RDL2004RDL2004 Posts: 2,554
    edited 2005-10-23 02:27
    Thank you so much, I didn't realize the value in DEBUG had that kind of persistence.
    It's like the LCD display then as far as having to clear out the previous value(s)?
    You can probably understand how confused I was with the following code added for debugging purposes.



    DEBUG "Binary..... " BIN, result, " ". CR
    DEBUG "Hex........" HEX, result, " ", CR


    DEBUG "ADC..... ", DEC result, " ", CR
    DEBUG "volts... ", DEC mVolts DIG 3, ".", DEC3 mVolts

    PAUSE 100 ' delay between readings

    Funny though, I had added a ...

    DEBUG CLS

    at the beginning at one point but took it out because it caused flickering when DEBUG redrew the screen.

    The CLREOL looks like it will work better and be more understandable as far as code goes.

    I will try your new code next.

    Also, thank you so much for the code and examples in your StampWorks book, it has been the most useful of all Parallax books I have downloaded.

    I am adapting this code to be a read out for a power supply display where the voltage can range from 0 to 19.99 volts.

    I have fixed the leading zero on the display when value is under 10.00 volts (I was making it harder than it was)

    I am looking now to code a round-off function. If any can help I would appreciate it.

    I would be happy with display that showed nearest 100th volt, I can truncate using DIG but that is not as accurate as rounding.

    I am sure as above, where I removed leading zero, that I am making this harder than it is, but I am learning.

    I will also be trying to make the Stamp display amps if I can figure out how and I would also like to make it so that the code can run on a BS1 too.
    I have 1 ohm 20 watt resisitor to read volts drop, I hope this will be adequate.


    Thanks,

    - Rick


    I have BS1 with serial adapter,
    WAM (BOE 1), BoE-Bot (BOE 2),
    and Professional Developement Board with SX Key
    (very nice board, but have not even thought about programming SX),
    I have the BS1 set up on the PDB (no need serial adapter now).
Sign In or Register to comment.