BenvanderMarel
The problem I’m having is that when the AND block becomes true, the things that are set and reset shouldn’t happen immediately, but after a short delay — like one second (I’m not sure exactly how long yet).
But when I add a TON timer in between, it doesn’t work at all. If I don’t use the TON, it does work. It also doesn't move on to the next step.
I also can’t move the sensor that measures the distance to fix the timing.
Does anyone have a working solution? In the simulation, the code works fine.
[203128%2F9333765%2Fmceclip0]
Reply 0 0
thiagoralves
It is hard to provide guidance without seeing the full source code. You mentioned distance sensor, steps, but none of these things are clear in your code snippet. Just for this snippet, it seems like it would work just fine, like, the coils will be triggered 1 second after the AND becomes true. However, there might be other parts of your code that is affecting the logic you want to build.
Reply 0 0
BenvanderMarel
This is all the code I have for now.
I don’t know why it’s not working.
I also have Arduino code to read the sensors.
The only thing I changed is that I left out the TON timer.
 
Nothing should be in the way to stop it from working, because when I remove the TON and run my code, it does work.
Do you know what else could be wrong?
[203128%2F9333807%2Fmceclip0]
Reply 0 0
thiagoralves
Uploading the full project folder as a .zip archive is usually better than just screenshots with pieces of code. Your screenshot, for example, is still missing the variables definitions, your arduino code, your resources configuration, etc. What exactly do you want to mean by "it won't work"? Does it do something different than expected or does it crash?
Reply 0 0
fg71
I find your Ladder Diagram to be very confusing. Its not recommended to use coil (output) in serie. They should be parallel.
 
The difference between serial coils (output) and parallel is:
  1. Coils don’t work sequentially when placed in series.
  2. Earlier coils may not activate correctly.
  3. Debugging becomes harder when multiple coils depend on each other
  4. Scan logic top-to-bottom, so series coils may conflict during execution.
 
OpenPLC do not have restriction to use coil (output) in serie but other PLC IDE could have it, I believe what you see in rung it same
think what the device is compiled into instruction and execute order. If a logic, instruction or block output is True it will set output to True
and all other output on the same rung to True. That is exactly what a parallel coils does. In other words the logic, instruction or block become
the condition for the all outputs in the same rung. If you have the output in serie it would make sense to believe a coil (output) become a input
for or condition to other coil. It become very difficult to debug or knowing if a coil (output) is a output or input.
 
The order of execution is left to right and from top to bottom in Ladder Diagram.
 
And by having coils in serie they also become outputs and inputs on the same rung and that is the reason to avoid it.
 
The way I see Ladder Diagram is, contact is inputs and blocks are logic (instruction) and coils are output.
In programing when you assign a value to variable, it contains a value. This variable could be input to other variable, condition....
If we translate it to Python that would be like if (x and y == 1): a = b = c = 1
There x and y are input and a, b, c are output. If we later change a, we also change b and c and that is maybe not what we want.
Reply 0 0
Reply