preso.cratico
Hello! I just started exploring OpenPLC. I think it's a brilliant project! Previously, I used TIA Portal while studying my degree. There, we were taught sequential programming. I remember we programmed small step-by-step sequences. I would like to know if OpenPLC has something similar to what is known in TIA Portal as "First Scan." Thanks to this marker, when the program starts, the other steps are read, and the step labeled as zero is initiated. Until an event occurs, such as a sensor detection, it is not possible to proceed to the next step. This marker, called "First Scan," would only be activated when the PLC or Arduino (in my case) is powered on for the first time, that is, when it is supplied with current for the first time.
 
Attached is a picture showing how the "First Scan" marker, only when the PLC is powered with electricity, sets step 0 (E0) to SET. For subsequent situations, when the AND condition (Step 4 and TON3) is met, step 0 (E0) will be set to SET, and the others will be reset.
example.jpg
Reply 0 0
thiagoralves
Just create a BOOL variable (name it anything you’d like) and set its initial value to 1 in the table. Then at the end of your program (last rung) set this variable to 0. This will give you the exact same effect.
Reply 1 0
preso.cratico
Thank you, I will try it. I will let you know if it works for me!
Reply 0 0
preso.cratico
Hi again.
I'm experiencing the following issue. I get this message when transferring to the Arduino UNO: "Could not process location '__MX0_4' from line: BOOL,__MX0_4,M,X,0,4." I've attached some photos with the language I've structured and the variables.
 
variables.jpg
 
ladder.jpg
Reply 0 0
thiagoralves
%MX locations do not exist. Check this link for the location mapping: https://autonomylogic.com/docs/2-5-modbus-addressing/
 
If you don't want this variable to be mapped to any Modbus register or physical IO, just leave the location blank.
Reply 0 0
prof.giovanni
perhaps you should try converting the TIA Portal ladder into Openplc Editor with this method you see in the figure. the inputs and outputs mapped according to the addresses indicated in "documentation - openplc runtime - physical addressing
ladder siemens.jpgtecnica batch con predisposizioni.jpg
Reply 0 0
preso.cratico
 
perhaps you should try converting the TIA Portal ladder into Openplc Editor with this method you see in the figure. the inputs and outputs mapped according to the addresses indicated in "documentation - openplc runtime - physical addressing
ladder siemens.jpgtecnica batch con predisposizioni.jpg
From what I understand from your message and the photos you've shown, it is about replacing the reset bf method (which allows any phase in our sequence to be reset to 0 when the controller starts up) and directly applying sequential programming. I was told that this system marker helps ensure that, for example, if the controller starts up and a sensor is sending an erroneous reading, or the system is stuck in an incorrect stage, the reset bf resets everything.
Does the fact that "phase_0" starts as TRUE (1) mean that if there’s a false reading as I mentioned earlier, the programming forces the system to go to phase 0? I’m not sure if I explained this last part clearly—thanks for your help!
 
Reply 0 0
fg71
VAR
  FirstScan : BOOL := TRUE;
END_VAR

IF FirstScan THEN
  (* Do something on the first scan *)

  (* set FirstScan to FALSE *)
  FirstScan := FALSE;
END_IF;

(* When the second scan is executed, variable FirstScan is FALSE, meaning Do something on the first scan will not be executed *)
 
Reply 1 0
prof.giovanni
I hope I understood your words well.
the phase variables are not retentive so if it gets stuck in a phase, it does not restart from that phase. in automation systems it is necessary to foresee emergency situations from which to escape according to a well-defined procedure.

the proposed example is for educational purposes. furthermore, an automation system will not start if a sensor gives a false reading. the system is stopped in the first phase (initial phase) and only after pressing START does it start. Furthermore, firstscan does not guarantee against this error. programming with set/reset can be replaced by that with MOVE where the phase variable is not boolean but integer.
Reply 0 0
prof.giovanni
..... I forgot in TIA Portal if it uses OB100. firstscan is a bit old for current programming
Reply 0 0
preso.cratico
..... I forgot in TIA Portal if it uses OB100. firstscan is a bit old for current programming
You are right about the OB100 block. My knowledge of more complex programming with TIA Portal is limited, as what I learned was all very basic. I’m studying to become an electromechanical maintenance technician, and programming is not something they’ve taught us in depth. They just wanted us to have some basic knowledge of programming in LD language. What I’m doing now is self-taught, on my own. Thank you very much for the help you’ve given me!
Reply 0 0
fg71
Electromechanical maintenance technician greatest knowledge is to know how things are working and from that knowledge they use logic to find the issue.
In other words if PLC program have passed Factory Acceptance Testing" (FAT) in most cases its not the issue later with PLC program but more likely a mechanical failure that could produce delay or other symptoms. It could be a bad approach to think the solution is to change the PLC program in that regard.
 
Only my though 😉
Reply 0 0
prof.giovanni
"It could be a bad approach to think the solution is to change the PLC program in that regard., you write.
I think that everyone can write the PLC program as they want, the important thing is that it has a repeatable logic and that it is not a sequence of instructions incomprehensible to those who modify it later.
Reply 0 0
Reply