kingcorn
Hi,
I've started PLC programming. I've created my first project, it works as I wanted, but I need some assistance for further improvements.
Here is the program:
Program.jpg  I have some questions.
1. When the PLC is started, the sequence is started from the LOOP2 as well. How I can prevent this?
2. When the reset button is pressed, the  "true" LOOP stops, but after the button is released, it is "true" again due to TOF output still "true". How can I reset the TOF?
3. Now it starts every day at the set time. I would like a more detailed schedule e.g. it starts only on weekends. How can I do this?
Thanks in advance.
BR,
Barna
Quote 0 0
thiagoralves
What exactly do you want to achieve with this program? What is the purpose of loop 1, 2 and 3?
Quote 0 0
kingcorn
LOOPs open valves. Every day in the set time the or start button is pessed, program starts to open the valves for seconds one after another. Now this sequence runs correct, but I would like to add a button to stop this sequence, close all valves and wait for the next start.
When this program is uploaded into the PLC and PLC starts running, this sequence starts from the second valve, I don't know why.
I would like to add more detailed scheduler. Not just start every day at 5:00, but every 10th hour, or every second day etc. 
Quote 0 0
thiagoralves
Ok. So a few issues with your diagram. You shouldn't put coils in series on a ladder diagram. Even though the compiler fixed that for you, this is electrically incorrect. If you want to activate multiple coils, you must put them in parallel. The second issue about that is that the reset coil instruction only works for a coil that was previously set. In your case, you never set the coils, they are activated by the timer. What you need to do is create a latch logic to lock and unlock the timer inputs. This would also take care of valve 2 starting when the PLC starts. The only issue with this latch logic is that if you press the reset button, all your valves will turn off, but then you would have to wait until your cycle ends (timers for loop 1 2 and 3 expires) for you to be able to press the start button again. If that's not an issue for you, then problem solved.
Quote 0 0
thiagoralves
Actually, this is a better approach. Build a TP timer with a RESET input:
Untitled.png 

Attached is the full project. Hope it helps.
Quote 0 0
kingcorn
GREAT! Thanks. This is what I wanted.
I'll dive in deep into building of custom blocks.
Thank you again
Quote 1 0
thiagoralves
Take a look at the OSCAT library here: https://openplc.discussion.community/post/oscat-basic-333-oscat-building-openplc-10284818?pid=1310418069

There are a lot of interesting blocks. I remember seeing one (I think it was on the building section) of a timer that can be activated based on days of the week.
Quote 0 0
we4321
Is there a guide on how to use/build custom blocks?
Quote 0 0
thiagoralves
No, but there isn’t much into how to do it anyway. To build a block all you have to do is click on the grey “+” round button on the left panel and select Function Block. Then you give it a name, select which language you want, and that’s it. A new block will show up on your POU list. Double click this block and start writing/wiring your code. Variables of class “input” will be input pins of your block. Variables of class “output” will be output pins of your block. When your ready to use it, just drag and drop the block from the left panel list to your main program.
Quote 1 0