ascii output problem


Closed Thread
Results 1 to 4 of 4
  1. #1
    Join Date
    Aug 2009
    Location
    Paso Robles California
    Posts
    153

    Default ascii output problem

    I have unit = v0(x) i am pulling this one byte out of eight

    LCDOUT $FE,1,DEC UNIT," ", UNIT," ",BIN UNIT," ",HEX UNIT

    here are four ways of showing the same var unit

    dec unit shows 0 correct
    unit shows || not correct
    bin unit shows 0 correct
    hex unit shows 0 correct

    I try doing a if unit = 0 then somewhere but unit has the value of || and I can't use dec like unit = dec v0(x)

    what am i doing and what do I need to do different?

  2. #2
    Join Date
    Dec 2012
    Location
    Tennessee
    Posts
    262


    Did you find this post helpful? Yes | No

    Default Re: ascii output problem

    it looks as if your trying to convert a byte to a string

    I Dont know how to store a string as a variable, but you need to set the string variable to that byte
    something like

    UNIT VAR BYTE
    mystring VAR ???
    unit = v0(x)
    mystring = unit
    LCDOUT $FE,1,DEC UNIT," ", mystring," ",BIN UNIT," ",HEX UNIT

  3. #3
    Join Date
    Aug 2009
    Location
    Paso Robles California
    Posts
    153


    Did you find this post helpful? Yes | No

    Default Re: ascii output problem

    I do have this I might be trying to convert a string to a byte, or pulling a byte out of a string

    X0 VAR BYTE(8)

  4. #4
    Join Date
    Oct 2005
    Location
    Sweden
    Posts
    3,610


    Did you find this post helpful? Yes | No

    Default Re: ascii output problem

    Hi,
    What kind of result do you expect?
    There's only one thing that can be stored in a variable and that is numeric values. Those values can represent different things but that's totally up to us humans.

    If the variable contains the value 0 the LCDOUT routine will send the character code for the letter zero - as long as you use the BIN, DEC, HEX modifiers.

    If you don't use any modifier it will send the value exactly as it's stored in the variable, ie it will send 0. Look at the character map of the LCD to see what character that represents.

    If you're grabbing ASCII data and putting that in the variable then you're not storing the number 0 in the variable, you're storing the number 48 which is the ASCII code for the letter 0. So if you want to compare your variable with that you need to do IF Unit = 48 or IF Unit = "0" - which is the exact same thing to the PIC.

    /Henrik.

Similar Threads

  1. HEX byte to ASCII output...
    By johnmaetta in forum mel PIC BASIC Pro
    Replies: 5
    Last Post: - 13th August 2011, 00:31
  2. PortC.7 general I/O output problem
    By bodgetts in forum mel PIC BASIC
    Replies: 12
    Last Post: - 2nd August 2011, 03:29
  3. PIC18F2320 RA4 output problem
    By Kristjan in forum General
    Replies: 2
    Last Post: - 30th May 2007, 23:56
  4. problem with output RA2 and RA3
    By savnik in forum mel PIC BASIC Pro
    Replies: 6
    Last Post: - 8th December 2006, 13:49
  5. HSEROUT No Output Problem
    By CocaColaKid in forum mel PIC BASIC Pro
    Replies: 10
    Last Post: - 22nd August 2005, 17:19

Members who have read this thread : 0

You do not have permission to view the list of names.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts