hex dec ascii
+ Reply to Thread
Results 1 to 7 of 7

Thread: hex dec ascii

  1. #1
    Join Date
    Aug 2009
    Location
    Cameron Park California
    Posts
    160

    Default hex dec ascii

    Below is code to make porta.5 led come on, the "If V1>100 then high porta.5" does not work. I have basically the same code where I send out 28 receive data in hex shift it and then display it on an lcd screen which works fine.
    The lcd allows me to use dec modifier to display to the lcd but the code below v1 without the dec modifier gives me d (tested on lcd screen) which is ascii for 100 but the light will not turn on what would be my best approach here.




    TH:
    SEROUT2 PORTB.2,16468,40,["28"]
    GOSUB SOUT
    GOSUB SINV1
    GOSUB SHIFTV1
    V1 = V1 */$0065
    DISPLAY_TH:
    If V1>100 then high porta.5

  2. #2
    Join Date
    Oct 2005
    Location
    Sweden
    Posts
    3,231

    Default Re: hex dec ascii

    The value is 100 but your IF statements says IF Value is more than 100....

    /Henrik.

  3. #3
    Join Date
    Aug 2009
    Location
    Cameron Park California
    Posts
    160

    Default Re: hex dec ascii

    I was just using that as an example to show I was getting ascii rather than dec, I have tried 50 and many other numbers along with = and => but without the dec modifier it just does not work guess I will input in dec and shift and try that

  4. #4
    Join Date
    Jan 2013
    Location
    Texas USA
    Posts
    229

    Default Re: hex dec ascii

    Can you provide us the values as you step through the routine?
    1. Initial value of V1 from the "GOSUB SINV1"
    2. What the details of SHIFTV1 does
    3. What the value of V1 is before you perform this "V1 = V1 */$0065"

    A little more clarity might help us help you get pointed to the issue.
    Regards,
    TABSoft

  5. #5
    Join Date
    Aug 2009
    Location
    Cameron Park California
    Posts
    160

    Default Re: hex dec ascii

    its an old program and not sure of the values, the value is correct from them but its in ascii rather than dec when outputed to lcd if I output to lcd dec3 v1 its fine I can put them on the screen side by side one reads d the other 100

    100 dec is d ascii

  6. #6
    Join Date
    Oct 2005
    Location
    Sweden
    Posts
    3,231

    Default Re: hex dec ascii

    Look, a byte variable can hold values from 0 to 255, that's it.
    All this DEC, HEX, BIN and ASCII stuff is just us humans expressing the same thing in different ways, 100=64=d=01100100.

    A character LCD is used to display stuff for humans to read so it "understands" ASCII. If a variable contains the value 100 and you send that to the LCD you'll get 'd' since 100 is the ASCII code for 'd' (exactly as you say). If you want to display the numeric value of the variable AS ASCII then you use the DEC modifier. The DEC modifier does in no way change the value.

    If you do LCDOUT $FE, 1, DEC V1 and the display shows a value of more than 100 then If V1>100 then High PortA.5 statement WILL evalute true and the problem is with controling PortA.5.

  7. #7
    Join Date
    Aug 2009
    Location
    Cameron Park California
    Posts
    160

    Default Re: hex dec ascii

    OK after HenrikOlsson spanking I started checking from his line of thinking putting in a fast blink between steps and it was hanging at a serin command and not getting value into V! also found I was missing an ADCON1 = %1111
    statement so it is working, guess I needed a slap

Similar Threads

  1. HSERIN/OUT Dec to HEX convertion problem..
    By N6VMO_ in forum mel PIC BASIC Pro
    Replies: 3
    Last Post: - 26th July 2010, 21:48
  2. DEC to ASCII not working in HSEROUT
    By SunDanzer in forum mel PIC BASIC Pro
    Replies: 3
    Last Post: - 22nd July 2009, 06:11
  3. Converting Dec word to Hex string
    By tcbcats in forum mel PIC BASIC Pro
    Replies: 1
    Last Post: - 28th August 2007, 05:44
  4. Convert dec/binary to Hex
    By SagemFree in forum mel PIC BASIC Pro
    Replies: 2
    Last Post: - 11th May 2005, 18:00
  5. Converting Bytes from hex to Dec
    By Rob Martin in forum mel PIC BASIC Pro
    Replies: 7
    Last Post: - 8th April 2005, 19:44

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