PeterW
Member
S7Guy said:I like to add comments liberably as well, but not within the comment header of the network
I do similar, sometimes it can be just a single line identifying what the next group of instructions are about.
S7Guy said:I like to add comments liberably as well, but not within the comment header of the network
// If the overload is OK when required to Run then start the drive //
-motorA
-motorA O/L
---| |-------|/|-------( ) -Run_Motor
// While "Call for Run Motor-A" is ON, if "Motor-A O/L is Tripped" is OFF, then...
turn ON "Run Motor-A Drive" //
Call Motor-A
for Run O/L is
Motor-A Tripped
---| |-------|/|-------( ) Run Motor-A Drive
// While "Call for Run Motor-A" is ON, if "Motor-A O/L is Tripped" is OFF, then...
turn ON "Run Motor-A Drive" //
A Call_for_Run_Motor_A
AN Motor_A_O/L_is_Tripped
= Run_Motor_Drive_A
// While the call to run the motor signal is ON... if the motor overload tripped
signal is OFF, then... turn ON the output to run the drive for that motor. //
Device E-Stop
Cause-A Faulted is OK
---| |---+---|/|------| |----( ) Turn ON Device
|
Cause-B |
---| |---+
|
Cause-C |
---| |---+
|
Cause-D |
---| |---+
If you want the book... yer gonna have to pay for it! Fair is fair... no?
Terry Woods said:...but I am not pleased, not pleased at all, with the signal names (especially the signal names), nor the comments.
Terry Woods said:A -motorA // If the overload is OK when required to Run
AN -motorA_O/L
= -Run_Motor //Then start the drive
Doesn't the above code (and comment) look like this in Ladder...
// If the overload is OK when required to Run then start the drive //
-motorA
-motorA O/L
---| |-------|/|-------( ) -Run_Motor
If there is data present on the end position the type of data is determined:
- Reservation/empty window code or (UFO)PIC
- In case of (UFO)PIC: Induct bit or not
If the data is a reservation/empty window code or a (UFO)PIC with induct bit
(NO physical product expected), the one-shot data_sync is directly SET, the
data is copied to the FIF downstream and the entry is deleted from tracking.
If the data is a (UFO)PIC without induct bit (physical product expected) the
following handling is executed:
- If the product is at the handover position and being handed over
(M_SI_Hand_Over), the one-shot data_sync is SET, the data is copied to the
FIF downstream and the entry is deleted from tracking.
- If the product is at the handover position (product offset >= handover
offset) and NOT being handed over (eg in a die-back situation) nothing
happens.
- If there is NO product at the handover position (NOT M_SI_Hand_Over and
product offset < handover offset) the entry is deleted from tracking
(invalid entry).
NOTICE: The detection of data at the end of the conveyor and the detection of a
product at the handover position comes exactly at the same moment!
OPN #i_DB_Track // Open tracking DB
L DBNO
T #t_DB_Num_Track // Determine tracking block DB number
SET // RESET one-shot handover data
R "M_FD_Data_Sync"
// Check if entries are used in the tracking DB
L DBW 0
L 0
>I
JCN HA99
// Determine pointer to last used entry
L DBW 0 // Number of entries used in tracking DB
SLW 5 // Shift bytes to make pointer to last entry
L P#2.0 // 6 (Header lenght) - 4 (record lenght) = offset
+D // Add offset to jump over tracking DB header
LAR1
// Detect data at end position
L DBW [AR1,P#0.0] // IF position of last entry >= position end
L #t_Position_End
>=I
JCN HA99
// Determine data type at end position: (UFO)PIC or Res/E
// Determine if the induct bit is set in case of (UFO)PIC
SET // Reset data type bits
R #t_Data_Is_PIC
R #t_Data_Is_Induct_Bit
L DBW [AR1,P#2.0] // Copy data at end position to temp
T #s_Data
L 0 // IF found data is a (UFO)PIC code
>I
JCN HA20
S #t_Data_Is_PIC // SET temp Data_Is_PIC
TAR1 // Copy AR1 to temp t_Memory_AR1
T #t_Memory_AR1
CALL "FC_Read_Bool_Record" // IF induct bit is set (no physical product expected)
i_Record_Number:=#s_Data
i_P_BOOL_Record:="DB_UDT_PIC_Record".Status.Induct_Bit
i_DB_Number :="DB_PIC_List"
o_BOOL :=#t_Data_Is_Induct_Bit // SET temp Data_Is_Induct_Bit
L #t_Memory_AR1 // Copy temp t_Memory_AR1 to AR1
LAR1
HA20: ON #t_Data_Is_PIC // IF data is Res/E
O #t_Data_Is_Induct_Bit // OR data is Induct (UFO)PIC
O(
A #t_Data_Is_PIC // OR data is (UFO)PIC
AN #t_Data_Is_Induct_Bit
A "M_SI_Hand_Over" // AND at handover position + being handed over
)
JC HA50 // THEN jump to set data sync
L "MW_SI_Product_Offset" // ELSE IF NO product on Handover position
L "MW_SI_Handover_Offset" // (Product offset < Handover offset)
<I
JCN HA99
TAR1 // Copy AR1 to temp t_Memory_AR1
T #t_Memory_AR1
CALL "FC_Log_Event_Track" // AND Report event PIC data lost due to wrong position
i_Event_ID :="DB_Event".Tracking.PIC_Lost_Wrong_Position
i_Event_Data:=#s_Data
i_AreaID :="MW_SI_AreaID"
i_ZoneID :="MW_SI_ZoneID"
i_SectionID :="MW_SI_SectionID"
L #t_Memory_AR1 // Copy back temp t_Memory_AR1 to AR1
LAR1
JU HA51 // AND jump to remove (UFO)PIC from tracking
// Set one-shot data sync + copy data to FIF Downstream
HA50: S "M_FD_Data_Sync" // SET one-shot handover data
L DBW [AR1,P#2.0] // AND copy data last entry to FIF Downstream
T "MW_FD_PIC"
HA51: L DBW [AR1,P#0.0] // Copy position to temp
T #t_Pos_Data_Delete
CALL "FC_Write_Track_Unc" // AND clear entry from tracking
i_DB_Num_Track :=#t_DB_Num_Track
i_Position_Write:=#t_Pos_Data_Delete
i_Data :=0
HA99: NOP 0
The sample you disected was a very simplified example, it is normal in STL to code as much code in a single network that ladder code take 10, 20 or more networks to achieve.
rsdoran said:This part has me confused, I have not heard of this, got an example of STL in one "network" that would translate to 20 rungs of ladder?
Cause Interlock1 Interlock2 Output
---| |----| |------------| |---------( )
Cause Interlock1 HelpReason1
---| |----|\|------------------------( )
Cause Interlock2 HelpReason2
---| |----|\|------------------------( )