ASCII to PDU (Septet Encoding) amansubanjar@gmail.com

Its not a little bit hard make an ASCII to PDU converter in Delphi or VB. They have unlimited Register, or even the AVR Series from ATMEL (31 registers). But hows the program in AT89S52 or 8051/8052 family? They just have 8 registers. If all registers free, then these registers still 8, it’ll decrease as we use it.

For this case I use RAM (AT89S52 has 30H – 79H addressable RAM). Some characters stored in RAM then we’ just write the formula.

PDU itself used as a standard message in SMS (Short Message Service) allover the mobile phone. Although most cellular phone could be controlled with text(ASCII) format, the process of sending or receiving always in PDU. Also if we want to make some stuff in 8bit microcontroller, will it be written by ASCII? Yah, the first time we also declare the text we want to convert , (8bit ASCII of course) then by some manipulation bit, it converted to 7 bit, then the result still converted again in hexadecimal (8bit) as microprocessor standard data.

Okay here the illustration:

8bit (ASCII character standard formatted in Hexa)——-> 7bit PDU Standard——->Hexadecimal, the final result.

And here the source Code:

$mod51

d1 equ 30h;kode ascii data 1 ch 1

d2 equ 31h

d3 equ 32h

d4 equ 33h

d5 equ 34h

d6 equ 35h

d7 equ 36h

d8 equ 37h

d9 equ 38h

d10 equ 39h

d11 equ 3ah

d12 equ 3bh

a1 equ 76h;kode ascii data 1 ch 1

a2 equ 77h

a3 equ 78h

a4 equ 79h

a5 equ 7ah

a6 equ 7bh

a7 equ 7ch

a8 equ 7dh

;SEPTET PROCESSING

send_pdu_start:

push psw

push acc

mov a1,d1

mov a2,d2

mov a3,d3

mov a4,#’ ‘

mov a5,d4

mov a6,d5

mov a7,d6

mov a8,#’0′

call septet_encoding1

mov a1,#’ ‘

mov a2,d7

mov a3,d8

mov a4,d9

mov a5,#’ ‘

mov a6,d10

mov a7,d11

mov a8,d12

call septet_encoding1

exit:

pop acc

pop psw

ret

septet_encoding1:

mov a,a1

mov b,#00000001b

call divab

mov a,a2

mov b,#10000000b

call mulab

mov a,a2

mov b,#00000010b

call divab

mov a,a3

mov b,#01000000b

call mulab

mov a,a3

mov b,#00000100b

call divab

mov a,a4

mov b,#00100000b

call mulab

mov a,a4

mov b,#00001000b

call divab

mov a,a5

mov b,#00010000b

call mulab

mov a,a5

mov b,#00010000b

call divab

mov a,a6

mov b,#00001000b

call mulab

mov a,a6

mov b,#00100000b

call divab

mov a,a7

mov b,#00000100b

call mulab

mov a,a7

mov b,#01000000b

call divab

mov a,a8

mov b,#00000010b

call mulab

ret

divab:

div ab

mov r5,a

ret

mulab:

mul ab

add a,r5

send:

acall hexascii2

acall send1

mov a,b

acall send1

ret

send1:

call tx;mov sbuf,a

;jnb ti,$

;clr ti

ret

hexascii2:

push acc

acall hexascii1

mov b,a

pop acc

swap a

acall hexascii1

ret

hexascii1:

anl a,#0fh;

cjne a,#10,lookcarry;acc a=10 dan carry 0 -> not number

lookcarry:

jnc not_number

add a,#30h

ret

not_number:

add a,#37h

ret

;=====

Then how will we sure that our code is true? Meanwhile the ascii code is sent by serial. Just test it use with hyperterminal, insert the code with the time delay more than 5 seconds, it used for unplug and plug the serial (com1) connector. If we still need more than 5 seconds, add it again with the time we can stand enough,….I did with the 3 seconds delay time. Its enough for me.

Happy coding…..It shoulda worked out.

One Response to “ASCII to PDU (Septet Encoding) amansubanjar@gmail.com”

  1. Hi there! I’m a VB programmer. I wrote an SMS server. I’ve been using Text (ASCII) mode and it worked fine until some of the messages that were being received were not being fully decoded — i still get the hex (?) characters. Thanks for this info.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: