Weird peace of S5 code... ?

userxyz

Member
Join Date
May 2002
Location
any
Posts
2,768
Weird peace of code:

Code:
;SPER 310 VERTRAGING VULSTAND
	AWL
	A	DB 104
	SPA	FB 51
NAME:	D99/BCD 
DUAL:	T 0
OVER:	M 253.1
BCD :	DR 26

DUAL is a BYTE parameter, my S7 compiler doesn't accept T0 connected to it, this peace of code comes from a S5 CPU... So it should be working code.. ?

Anyone who understands this ?

Kind regards,
Gerry
 
What

Hello,

What can I do, I mean, in the original S5 software, Dual is also connected to T0 ... ?

Thanks,

Regards,
Gerry
 
Fc18

This is the internal code of FC18:

Code:
      L     0
      T     MB   251
      L     #DUAL
      T     MB   250
      L     99
      >I    
      =     #OVER
      BEC   
      L     9
      L     #DUAL
      >=I   
      T     #BCD
      BEC   
//;
//;
      L     MB   250
      L     80
      <I    
      JC    M001
      =     "M 251.7"
      -I    
      T     MB   250
M001: L     MB   250
      L     40
      <I    
      JC    M002
      =     "M 251.6"
      -I    
      T     MB   250
M002: L     MB   250
      L     20
      <I    
      JC    M003
      =     "M 251.5"
      -I    
      T     MB   250
M003: L     MB   250
      L     10
      <I    
      JC    M004
      =     "M 251.4"
      -I    
      T     MB   250
M004: L     MB   250
      L     8
      <I    
      JC    M005
      =     "M 251.3"
      -I    
      T     MB   250
M005: L     MB   250
      L     4
      <I    
      JC    M006
      =     "M 251.2"
      -I    
      T     MB   250
M006: L     MB   250
      L     2
      <I    
      JC    M007
      =     "M 251.1"
      -I    
      T     MB   250
M007: A     "M 250.0"
      =     "M 251.0"
      L     MB   251
      T     #BCD
 
It looks like it's converting a number to BCD?

The old S5 timers could output the current time as a binary number or 3 digit BCD code with time base. The T 0 must be the binary value.
 
Last edited:
IIRC T0 is "Timer number 0"

And I assume it gives its value (in BCD format I'm pretty sure) to variable BCD after some mathematic/binary manipulation.

..I didn't read your code really through just looked if the #DUAL is used and how (atleast once read/load from) and how #BCD is used (atleast once write/transfer to)

At FC call it do give starting values to these variables, some are memory addresses(might chance or not) and some are constant like T0.

It's 1AM here and I'm tired, so I might be totally wrong, especially because I'm not a real S5 expert.

PS. Is this PLC controlling process ie. valves 0..100% valves etc. this might be a part of the control mechanism to chance ie. ramp time or other control values. Take a look where the T0 is used and how, might be important or atleast good to know. Especially if you are converting this to S7 as your another topic suggest.
 
Last edited:
DUAL is a BYTE parameter, my S7 compiler doesn't accept T0 connected to it, this peace of code comes from a S5 CPU... So it should be working code.. ?
I think S5 accepted that Tx at a BYTE input and interpreted it as integer.

In your S7 program, that T0 is probably programmed as S5TIMER, Maybe you can use the #BI output for your #dual input

or change the program. I think all it does is an overflowcheck (>99)
and a BCD conversion at >=9 (up to 9 the byte code of BCD and INT are the same)
But you might not need that because the timer T0, if programmed as S5Timer, has a #BCD output
 
Last edited:
in S5 the instruction L T0 will give you a binary value for elapsed time and LD T0 will give you the BCD version.

Passing it to a FB and looking at how the code is converting to BCD makes me sure its the binary value being passed, especially as its doing a greater than check with the binary value of 99.

Timers values are between 0 to 999, this code only transfers values up to 99 as the output #BCD is a single byte, this gives you 2 BCD characters.

If the value is greater than 99, it block ends, I'm pretty sure the outputs of FB's in S5 maintained the last value if not written to during a scan.

So the Fb as I stated above is taking a binary value of the elaspsed time and converting it to BCD if the value is 99 or less.
 

Similar Topics

I have created a project in TIA Portal v16 Upd6 with S7-1200 (6ES7214-1AG40-0XB0) and WinCC Unified (PC station). The communication between the...
Replies
4
Views
145
I currently have a weird issue involving Ethernet IP communication between a ABB CI873 (EthernetIP Module) and a 1756-L83ES. The Layout is as...
Replies
8
Views
752
Good morning. I'm doing a rehab and I need to recycle some part of the old code that won't change and that I need. This is a calculation that...
Replies
22
Views
1,362
I'm trying to figure out a weird behavior I'm seeing in my CCW program. It's for controlling a gas polarizer (for medical imaging). I'm using an...
Replies
6
Views
462
I'm trying to figure out some weird behavior I'm seeing in one of my programs. This should be fairly straightforward - except that it's not...
Replies
11
Views
950
Back
Top Bottom