Need advice how to.


Closed Thread
Results 1 to 5 of 5

Hybrid View

  1. #1
    Join Date
    May 2007
    Location
    Republic Serbia
    Posts
    105

    Red face Need advice how to.

    If I receive from PC to PicMicro next:

    receive var byte[8]
    hserin [STR receive\8]

    then I will receive "128ABCDE"
    And I will have next:

    receive[0] = "1"
    receive[1] = "2"
    receive[2] = "8"
    receive[3] = "A"
    receive[4] = "B"
    receive[5] = "C"
    receive[6] = "D"
    receive[7] = "E"


    How to I get from that as decimal 128 separated from ABCDE ?
    I was probe and get result from receive[0] is dec 49 and that is ASCII chr.....

    Core of my try is to thel PicMicro what to show on LCD at position what I want.

    Org of my LCD is 4x20 chr with No:. of position from 128 to 231..

  2. #2
    Join Date
    Nov 2003
    Location
    Wellton, U.S.A.
    Posts
    5,924


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by phoenix_1 View Post
    How to I get from that as decimal 128 separated from ABCDE ?
    This thread might be useful, you will need to read it all to get to the point.
    http://www.picbasic.co.uk/forum/showthread.php?t=6128
    I was probe and get result from receive[0] is dec 49 and that is ASCII chr.....
    Are you putting a "#" in front of the variable some place? If I am not mistaken,
    #1 would be 49
    Dave
    Always wear safety glasses while programming.

  3. #3
    Join Date
    May 2007
    Location
    Republic Serbia
    Posts
    105


    Did you find this post helpful? Yes | No

    Question

    Quote Originally Posted by mackrackit View Post
    This thread might be useful, you will need to read it all to get to the point.
    http://www.picbasic.co.uk/forum/showthread.php?t=6128


    Are you putting a "#" in front of the variable some place? If I am not mistaken,
    #1 would be 49
    No but if I simple want to do next:
    lcdout $fe,128+X,"ABCDE"
    where X= 1 from string (bit0 ) I was see that cant be becouse Pic see that as 128+ASCII value and that cant we do!
    After that I was probe to get DEC value from ASCII (1) waht was come from PC in message "128ABCDE" and see that byte[0] = "1" and really value for that is DEC 49 .
    Or HEX $31 .
    I need formula hove I translate $31 to dec 1 or any HEX to dec value...
    HEX or ASCII to real integer.

  4. #4
    Join Date
    Nov 2003
    Location
    Wellton, U.S.A.
    Posts
    5,924


    Did you find this post helpful? Yes | No

    Default

    OK, misunderstanding.
    I seem to remember this
    Code:
    X1 = (NUMS[1]-"0")
    The -"0" is what you need.
    I think
    Dave
    Always wear safety glasses while programming.

  5. #5
    Join Date
    May 2007
    Location
    Republic Serbia
    Posts
    105


    Did you find this post helpful? Yes | No

    Smile

    Quote Originally Posted by mackrackit View Post
    OK, misunderstanding.
    I seem to remember this
    Code:
    X1 = (NUMS[1]-"0")
    The -"0" is what you need.
    I think
    Here is my success test of geting index from array.
    After geting and ading decimal integer from example "10ABCDEF"
    x3 will be decimal 10 and i can add it with 128(first place on first line on 4x20 LCD...
    And there I can display rest of sting from array "ABCDEF"...
    Thank's to all who make me to little more think with my head...
    Robert

    Code:
    @ Device pic16F877, HS_OSC, BOD_ON, PWRT_OFF, WDT_ON, PROTECT_OFF
        define OSC 20
        ADCON0.0 = 0
        ADCON1 = 7
        DEFINE HSER_RCSTA 90h            ' enable receiver,
        DEFINE HSER_TXSTA 24h            ' enable transmit, BRGH=1
        DEFINE HSER_SPBRG 129            ' baud rate RS232 9600 Bauds
        DEFINE HSER_CLROERR 1            'Clear overflow automatically
        x1 var byte
        x2 var byte
        x3 var byte
        y var byte[8]
        
    start:
        hserin [str y\8]
        x1 = y[1]
        x2 = y[0]
        x1 = x1-48
        x2 = x2-48
        x3 = (10*x2)+(1*x1)
        hserout [dec x3,13,10]
        RCSTA.4 = 0
        RCSTA.4 = 1 
        goto start
        end
    Last edited by phoenix_1; - 21st May 2008 at 20:54.

Similar Threads

  1. Advice on Wiegand Buffer
    By brutc001 in forum Schematics
    Replies: 0
    Last Post: - 19th December 2009, 00:31
  2. Need "PIC16F84A" Controler schematic Advice...
    By Kyo_89 in forum Schematics
    Replies: 1
    Last Post: - 27th May 2009, 23:03
  3. Your OTP advice?
    By truvahorse in forum mel PIC BASIC Pro
    Replies: 1
    Last Post: - 28th June 2008, 16:37
  4. Decoding an incoming infrared signal: need advice
    By xnihilo in forum mel PIC BASIC Pro
    Replies: 10
    Last Post: - 9th May 2008, 16:28
  5. Advice needed on 'neat' Project!
    By vacpress in forum mel PIC BASIC Pro
    Replies: 5
    Last Post: - 11th February 2007, 06:21

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