PDA

View Full Version : Need advice how to.



phoenix_1
- 18th May 2008, 21:27
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..

mackrackit
- 19th May 2008, 07:48
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

phoenix_1
- 19th May 2008, 12:00
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.

mackrackit
- 19th May 2008, 12:12
OK, misunderstanding.
I seem to remember this


X1 = (NUMS[1]-"0")

The -"0" is what you need.
I think:)

phoenix_1
- 21st May 2008, 20:23
OK, misunderstanding.
I seem to remember this


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



@ 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