A function for ASC11 to decimal

Discuss PIC and electronic related things

Moderators: David Barker, Jerry Messina

Post Reply
be80be
Registered User
Registered User
Posts: 90
Joined: Mon Feb 23, 2009 2:15 am
Location: tn

A function for ASC11 to decimal

Post by be80be » Fri Dec 14, 2012 7:50 pm

Does any one have a sample of ASC11 to decimal Thanks Burt

Jerry Messina
Swordfish Developer
Posts: 1473
Joined: Fri Jan 30, 2009 6:27 pm
Location: US

Post by Jerry Messina » Sat Dec 15, 2012 10:05 pm

Burt -

If you mean you want to convert a string of ASCII numeric chars (ie "1234") into a number, look at the StrToDec() function in Convert.bas

be80be
Registered User
Registered User
Posts: 90
Joined: Mon Feb 23, 2009 2:15 am
Location: tn

Post by be80be » Sat Dec 15, 2012 11:15 pm

I no about that. What the deal is I've seen a functions that changes data

back thats been sent to the pic over a com port I send 1 the pick tells me it's a 49 which is 1 in asc11 I send a 0 it's 48 I want the dam thing to send decimal not text I send 123 but I get 49 50 51

I saw a function I'm sure you even made it or helped
I no I can take and -48 from 49 get's the 1 so on

But how to turn a bigger number back don't seem to work.

Jerry Messina
Swordfish Developer
Posts: 1473
Joined: Fri Jan 30, 2009 6:27 pm
Location: US

Post by Jerry Messina » Sun Dec 16, 2012 12:47 pm

...send decimal not text I send 123 but I get 49 50 51
It sounds like you're working with a string data type, and not a byte.

If you have a byte (0-255) and you want to send it out the serial port as a single binary byte, then use Usart.WriteByte()

There seems to be a lot of confusion about ASCII text, string data, and it's binary data representation.

be80be
Registered User
Registered User
Posts: 90
Joined: Mon Feb 23, 2009 2:15 am
Location: tn

Post by be80be » Sun Dec 16, 2012 7:26 pm

Here what I was trying to do just need to add the CR as a test so it knows to wait for the next 3 byte from the usart

Code: Select all

Dim StrA, StrB, StrC As Char
Dim StrResult As String
 SetBaudrate(br9600)
While true
    StrA = (USART.ReadByte)// 1
    StrB = (USART.ReadByte)// 7
    StrC = (USART.ReadByte)// 0 
    StrResult = StrA+StrB+StrC

 SegDisplay.Update (StrToDec(StrResult))
Wend
I would like to make a function that wait's for a start byte then reads the 3 bytes and looks for CR then outputs this to my seven segment display

There is a problem with that code to I can't send numbers less then a 100 to it all i need is 0 to 255 dang this looks easy but it's not LOL

Post Reply