Continue to Site

# help needed in transmitting numbers

Status
Not open for further replies.

#### asham

##### Junior Member level 1
hi...i urgently need help in c programming..i need to transmit numbers from the PIC18 to the PC Hyperterminal...I'm using USART for this...My programming is done with C18 COMPILER and MPLAB IDE...Any help will be very much appreciated..Thanks in advance

#### IanP

To transmit numbers to Hyperterminal, regardless of microcontroller type, you will need to convert them to ASCII code, for example, ASCII representation for 0 is 30H, 1 --> 31H, 2 --> 32H and so on ..
Just add 30H to any digit before transmission .. and "." --> 2EH
( https://www.lookuptables.com/ )

Regards,
IanP

#### asham

##### Junior Member level 1
Thanks very much IanP...I will do as you as suggested.But can you tell how to define it first.(int/char/unsigned int..etc)...Thanks

#### IanP

I don't know what numbers will you be working with, but after digit-by-digit conversion to ASCII they can be declared as "unsigned char" (0-255) ..

Regards,
IanP

#### terka

Code:
#device <16F628>
#use rs232(baud=9600,parity=n,xmit=pin_b2,rcv=pin_b1,bits=8)

main() {

while(1) {
int i;           //I from 48d= 0 in aschii, up to 57d= 9 in aschii.
for(i=48;i<58;i++) {
putc(i);      //Print from 0 up to 9
delay_ms(200);
}
}

Bye

[/code]

#### asham

##### Junior Member level 1
Thanks IanP...can i use unsigned int, coz i need to transmit quite some numbers.
Terka, i tried ur program but i'm unable to build the program....I'm using MPLAB IDE w/C18 COMPILER...when i try to compile the program or any of the working programs i have, it displays a msg "can't locate build tool,find tool location"...What does this mean...? Thank you.... :|

Status
Not open for further replies.