I'm currently learning ladder logic and came across your site.
Firstly, Thank you for putting together openplc and sharing it for free.
Secondly, thank you for porting it to the Raspberry Pi!

So on to my question.

I have a switch which I want to turn on an LED. (which is part of the hello world so that's done)
However, after a short period I want to briefly turn on a warning buzzer then after a short period turn on an LED.

How do I reference reference the TON for the buzzer for the led to come on and stay on?
I thought the TON would have an address like T:01/en that I could reference as a switch so when it energises it kicks off the next timer? 

I'm still learning so be gentle with me 😉

Thanks in advance
Quote 0 0
OpenPLC follows the IEC 61131-3 programming standard. This T:01/en kind of programming seems more like Rockwell-style ladder logic. On the IEC standard, all features of a given block are within the block. So, for example, the Timer block TON has 4 features: a digital input (IN), the time constant (PT), the time elapsed (ET) and the output (Q). Those four features are on the four pins of the block. If you want to access any of those features, you just connect whatever you want on those pins. So, your T:01/en for example would be the output pin (Q) of your timer block. To make your code a little more elegant, instead of just wiring up a bunch of things into the output of blocks, you can use internal coils to store that value. This would be very similar to using your T:01/en "coil" that you're already used to. This screenshot gives you a little example:

I tried to create an example similar to the problem you described. So, initially, the button turns on the lamp, no big deal. Then, if the lamp is on for enough time (2 seconds), it activates the first timer (TON0), which in turn activates timer0_output (my internal coil). Internal coils behave like variables. You can name them whatever you want and have as many as you want. So, timer0_output then triggers the second timer (TON1) which in turn activates timer1_output after 3 seconds. Timer1_output then finally activates your LED at the last line of the ladder logic.

That's all! I hope it has helped.
Quote 2 0
That's an amazing response, the course I am enrolled on is a Rockwell Allen Bradley style course (I'm only 1/2 way through but when I saw open plc and raspberry pi I wanted to have a go!!)
When I am back at my computer I will go through your comments in more detail.

Thank you for taking the time to reply in such detail.

Warm regards

Quote 0 0
I have question, How i change TON PT value by one variable?
Quote 0 0
Your variable must be of type TIME, and connected to the TON PT input. Sometimes it is wise to convert the TIME variable to INT so that you can work with that using simple numbers, and then convert back from INT  to TIME to store the value there.
Quote 1 0