Convert Hex to Decimal???

# Thread: Convert Hex to Decimal???

1. ## Convert Hex to Decimal???

Hello, i have a problem

sorry for my english, i dont speak, ok

i'm using 16F876 and serial comunication, I wait for a string of bytes, my command is:

I=0
Y=1
IF DATAS[I]=COMMAND THEN
While I<= DATAS[Y]
.
.
.
I=I+1
WEND
ENDIF

where:
COMMAND=\$BB

if datas[y]=1,2,3,4,5,6,7,8 or 9 it works perfectly, but datas[y]=10 or more dont's function correctly, why???

i need convert Hex to decimal??? How?

Thanks.
Dave
Mexico City.  Reply With Quote

2. ## From what i understand, when you send an string of decimal character, you send each and every ASCII character of them, one after the other.

When you receive them, and use STR modifier as...
HSERIN [STR ArrayVar\4]

The results will be stor in the array variable like
ArrayVar=1
ArrayVar=2
ArrayVar=3
ArrayVar=4

So maybe...
Var1=(ArrayVar*10)+ArrayVar
Var2=(ArrayVar*10)+ArrayVar

At the end... Var1=12, Var2=34.

There's many way to do that, but it always depend how the data i sent too...
if you send 1234 and use something like

HSERIN [DEC2 Var1, DEC2 Var2]

Var1=12
Var2=34
Last edited by mister_e; - 9th May 2006 at 01:51.  Reply With Quote

3. ## mmmm, the problem is...

the problem is that the values come in hex and i need used SERIN2 in order to compare start and end of string, i belive that problem is the compara in the WHILE

While I<=DATAS[y]

"I" never take the value of DATAS[y] because value is A hex.

there is no a way to turn hex to decimal without using DEC

i see in a forum that convert hex to decimal something thus.

X=X-\$20 or X=X-\$30

i dont remember but is something thus

other idea????

i need, i'm crazy.

Thanks
Dave
Mexico City.  Reply With Quote

#### Posting Permissions

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