PLC oddities!

MarioM

Member
Join Date
Nov 2011
Location
Milan
Posts
71
Hello all, I'm writing my first ladder program o_O and I've a rung in which a boolean variable (FLAG) and a digital output (O3.1) that should follow a digital input switch (I2.0), but it happens that the output O3.1 follows the input, but the variable FLAG toggle continuously without following the input.
I inserted a wait of 200-300 ms to avoid input debauncing, is it ok?
The rungs:

| +-----+ +------+ |
|---||-----| TON |---||----(L)----(L)---|RETURN|-|
| I2.0 +-----+ I2.0 FLAG O3.0 +------+ |
0-300 ms
|---(U)----()------------------------------------|
FLAG O3.0



What the hell? Thanks to all
 
Last edited:
Hi reporst your code inside code tags , see # in menu bar of posting area

Code:
your code here
 
What software are you using?
Your diagram indicates that you have both a latching coil and an engergize coil of the same address. Generally not a good idea.

Why not simply...


|---||-----| TON |-----( )----( )----|
___I2.0___+-----+____FLAG____O3.0____

0-300 ms
 
Last edited:
Thanks for the answer Damian, I'm using RSLogix5000 with ComactLogix 1769-L32E controller. I have tried the code:


|---||---|TON|---||---(L)---(L)----|RETURN|----|
I2.0 300ms I2.0 FLAG O3.0
|---(U)---(U)----------------------------------|
FLAG O3.0



both, with latching coil and energize coil, but the result is always the same: the output O3.0 follows the input swith I2.0 (on->on, off->off) and instead the boolean variable FLAG does what he pleases and I do not know how to solve the problem because I need of the variable FLAG to toggle the page displayed on a PanelView terminal.
 
Last edited:
Do a cross reference on your FLAG variable as you are probably writing to it again inadvertantly somewhere else in the program. That is the most likely cause of why they are not acting identically.

Why are you using OTL and OTU coils instead of OTE coils? Using a subroutine return to bypass the Unlatches is a very odd way to accomplish what you are trying to do.

Definitely there is no reason to use a RETURN call for low level logic like this.
 
Also, I just noticed in your example as well, the TIMER function block does not in and of itself output a boolean for done. Therefore you still need to have a tag of the type "timer_name".DN to actually implement the delay.
 
This is just the firs two rungs of a long function that should not be executed when the boolean variable FLAGS in ON. I use more easily OTL and OTU instead of OTE because I come from C programming. In any case, I discovered that if I use a bit within a word (PLC_Status.7 set and clar using OTL and OTU) in place of the logical variable FLAG, the program works as intended. What is the magic? I am sure that the FLAG is not used inadvertently in other parts of the program, I only clear it at the start of the program.
 
Under what conditions does it clear it at the start of the program? Based on your description it sounds as though it is geting cleared every scan.

So are your tags I2 and O3 declared as INT or DINT?
What data type is your FLAG variable declared as?

I program in C and VB quite often as well. I won't tell you how ladder should be done, because everyone has their own view on the subject. All I will say though if you program ladder using a "C" philosophy you will lose a lot of what makes ladder so popular in the first place. And that is for lower level technicians and programmers to be able to understand your code.

Also, what version of RSLogix5000? You may have available the ability to program in ST which is very C like.
 
I called the timer T1. I have to use the instruction T1.DN after performing the wait?

Yes, the function block itself only passes through the enabled condition of the timer as if it was a shorted wire. To reference the timers functions, you have available.

Timer.DN
Timer.TT
Etc.
 
So basically without a contact T1.DN in your case, the timer is executing but your output and flag are not being delayed. They are happening the very instant that network is executed and I2.0 is true. Your not really "using" the timer.
 
One of my first questions was whether it was to avoid the bouncing of the signal input I2.0 is correct to use a rung of the type:

|------||-----|T1 timer |---||-----(L)----(L)------|
| I2.0 |Preset=300| I2.0 FLAG O3.0



so have I to check with ---||--- on T1.DN (Ti Done) if it has finished to count for 300 ms ?

Thank you Damian, I had some doubts on this point and now it is clear.

As I use a bit within a word as word.7 the main problem also is solved but I don't understand why there is this difference.
 
so have I to check with ---||--- on T1.DN (Ti Done) if it has finished to count for 300 ms ?
quote]


Yes, otherwise the delay isn't really happening. You can prove it to yourself easily by setting the delay to something large like 2000ms and you will notice that it still is executing the instructions after the timer almost immediately.

What data type is your FLAG variable declared as? BOOL?
 

Similar Topics

Dear All, Currently i'm working with Endress Hauser flowmeter and AB PLC and try to integrate with 2 items. Flow meter spec using is Promass...
Replies
2
Views
26
Can I connect two A-B Panel View 7 to a A-B PLC. Same graphics etc. One on the local control panel and the other Panel View 7 in a remote control...
Replies
2
Views
35
Hello, I'm working with Studio 5000 and ME Station, and I'm trying to find a way to detect if the PC with the HMI is shut down or not. I've tried...
Replies
5
Views
99
Hi all smart and knowledgeable people.I have a hmi connected to 2 Plcs via ethernet.These 2 Plcs connected to control 2 systems in one machine...
Replies
2
Views
104
Dear Experts, I've come across an unusual piece of hardware for AB PLC-5 racks. I mean the NT-1776-HSD-R resolver input module. I have tried...
Replies
0
Views
58
Back
Top Bottom