Eng-Tips is the largest engineering community on the Internet

Intelligent Work Forums for Engineering Professionals

  • Congratulations waross on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

what does this mean?

Status
Not open for further replies.

ladybird

Electrical
Jan 19, 2005
8
0
0
DE
i have this Function from SIMATIC S7 and am trying so hard to understand what its meant to do.

network 1: Int to ASCII

L #input
L B#16#FO
AW
SRW 4
L 9
<=I
TAK
SPB goo1
+ 7
goo1: + 48
SLW 8
T #output

L #input
L B#16#F
AW
L 9
<=I
TAK
SPB goo2
+ 7
goo2: + 48
L #output
+I
T #output

Cheers
 
Replies continue below

Recommended for you

Hi,

It convert a interger value between 0 to 255 dec
( or HEX 0 to FF ) to ASCII
If #input = 100 dec then #output = 3634 = '64',
that is the Hex value of dec 100 in ASCII

[TT]
network 1: Int to ASCII

[blue]sample #input is decimal 72 = hex 48 [/blue]

[blue]// left digit first [/blue]

L.#input..[blue]//.01001000 = 72 dec [/blue]
L.B#16#FO.[blue]//.11110000 = 240 (mask left nibble)[/blue]
AW........[blue]//.01000000 = 64[/blue]
SRW..4....[blue]//.00000100 = 4[/blue]
L....9....[blue]//.00001001 = 9 [/blue]
<=I.......[blue]//.is 4 <= 9 ? (yes RLO =1)[/blue]
TAK.......[blue]//.mov ACCU2->ACCU1= 4-> ACCU1[/blue]
SPB..goo1.[blue]//.RLO = 1 so jump[/blue]
+..7......[blue]//.if RLO=0 ( add offset +7;[/blue]
..........[blue]//.left digit becomes a character from A - F )[/blue]
[red]goo1:[/red]+ 48[blue]// add dec 48 = 48 + 4 = 52[/blue]
..........[blue]//.= HEX 34 (48 = Hex 30 = ASCII '0' )[/blue]
SLW.8.....[blue]//. mov it to the right place ( left digit )[/blue]
T.#output.[blue]//.0010001000000000 = HEX 3400[/blue]

..........[blue]//.right digit next[/blue]
L.#input..[blue]//.01001000 = 72 dec[/blue]
L.B#16#F..[blue]//.00001111 = 15 ( mask right nibble )[/blue]
AW........[blue]//.00001000 = 8[/blue]
L.9.......[blue]//.00001001 = 9[/blue]
<=I.......[blue]//.IS 8 <= 9 ? ( YES RLO = 1 )[/blue]
..........[blue]//.;this means a digit between 0 - 9[/blue]
TAK.......[blue]//.mov ACCU2 -> ACCU1 = 8 --> ACCU1[/blue]
SPB.goo2..[blue]//.RLO = 1 so jump ; else Accu1 is at least 10![/blue]
+.7.......[blue]//.this means a character between A - F ;[/blue]
..........[blue]//.so add offset for ASCII[/blue]
..........[blue]//.ie. 10 + 7 + 48 = 65 = ASCII 'A'[/blue]
[red]goo2:[/red]+ 48[blue]// add dec 48 = 48 + 8 = 56 = HEX 38[/blue]
L.#output.[blue]//.0010001000000000 = 13312 = HEX3400[/blue]
+I........[blue]//.0000000000100110 = 56 = HEX0038[/blue]
T.#output.[blue]//.0010001000100110 = 13368 = HEX3438[/blue]

and this is in ASCII '48'
[/TT]

HTH
Rolf
 
Status
Not open for further replies.
Back
Top