Shop OBEX P1 Docs P2 Docs Learn Events
Need help with programming question. — Parallax Forums

Need help with programming question.

PTaylorPTaylor Posts: 12
edited 2011-01-07 11:10 in BASIC Stamp
I'm new to stamps, and have been playing around with a few circuits here and there. So far, so good.
The project I am playing with right now is from this page:
hxxp://www.emesystems.com/OL2therm.htm (replace xx with tt)

Basic Stamp and Thermocouples

I've got the program running, all is working correctly. It displays the correct temperature in the debug terminal.
Well, I've been playing with converting the temperature from C to F, and I've got it displaying that correctly, but one thing I cannot figure out is how to save or store the values in a variable.
The program does store the data captured from the SHIFTIN command into a variable named RESULTS, and then it uses the debug command to modify the data and display it as a number in the DEBUG window.
If I use the DEBUG command to display what value is stored in the variable RESULTS, it displays an ASCII character. not what I want, I want to store the actual number (C or F) into a variable for use later, and I'm drawing a blank. Any suggestions?

Comments

  • PJAllenPJAllen Banned Posts: 5,065
    edited 2011-01-07 10:49
    Dig deeper into DEBUG in PBASIC Help, focus on the examples there using the DEC formatter.
  • Mike GreenMike Green Posts: 23,101
    edited 2011-01-07 10:49
    Stamp Basic has what are called "formatters" which are described in the sections of the manual on the SEROUT and DEBUG statements and in one of the appendices. Your DEBUG statement and your variable are working correctly. If you just give the variable in the DEBUG list, it sends the variable value as a byte which displays its character value. If you want the value to display as a human-readable decimal number, you need to prefix the value with DEC, like "DEBUG DEC RESULTS". If you want the value displayed in hexadecimal, you'd use "DEBUG HEX RESULTS". There are other formats available including binary and fixed width values in decimal, hex, and binary.
  • PTaylorPTaylor Posts: 12
    edited 2011-01-07 11:10
    Ok, thanks everyone. I was playing around with that before and had that figured out. I think I'm just trying to wrap my brain around how the data is actually stored. I had done what you suggested MIKE GREEN, and saw that by changing from BIN, HEX, DEC, I could display the results as such. Used my calculator to verify the values displayed were indeed the same in DEC. It's been a long time since I messed with coding, hex and binary.

    I'll have hundreds of more questions in the near future for a few things I'm playing with.
    Again, thanks!
Sign In or Register to comment.