Shop OBEX P1 Docs P2 Docs Learn Events
help HEXA => dec & ping — Parallax Forums

help HEXA => dec & ping

fred1456fred1456 Posts: 13
edited 2007-07-17 16:32 in BASIC Stamp
hello everybody.

could you tell my how transfom a hexadecimal signal from a ping))) sonar to a decimal value? i don't find it ...

thx

Comments

  • Mike GreenMike Green Posts: 23,101
    edited 2007-07-16 21:37
    The PING doesn't produce a hexadecimal value. It produces a variable length pulse that you can measure. Perhaps you're referring to the value produced by the PULSIN statement which is a number. Any number in PBasic can be displayed easily in binary (like %010011) using the BIN formatter in a SEROUT or DEBUG statement or in hexadecimal (like $5D32) using the HEX formatter in a SEROUT or DEBUG, or in decimal (like 5673) using the DEC formatter in a SEROUT or DEBUG statement. Have a look at the discussion of formatters in the chapter on the SEROUT statement.
  • fred1456fred1456 Posts: 13
    edited 2007-07-17 16:24
    ok, it isn't a hexadecimal value, but how can i turn the valur from the signal form the ping and the PULSIN statment to a decimal value???????
  • Mike GreenMike Green Posts: 23,101
    edited 2007-07-17 16:32
    What do you mean by "decimal value"? All numeric values in a Stamp are 16-bit numbers (from 0 to 65535 or from -32768 to 32767 depending on how you use them). Hexadecimal or decimal are simply ways to represent these numbers on a keyboard or display or in a text file.

    What are you actually trying to do? Do you want to convert the PULSIN value to some kind of distance measurement or do you want to see the value on the DEBUG window?

    If you just want to see the value in the DEBUG window, use the DEC formatter and read the section of the PBasic manual on the DEBUG and SEROUT commands for examples and a description.
Sign In or Register to comment.