WhyD register increases 2 times when timer is activated

hello again

basically what I wanted to find was a solution to increase a register (D) every 1 second

So, I combining a timer and a counter seems to be a good solution
Yes it works, but there are simpler ways; see two examples below.

The bottom approach below will certainly work. On some PLC brands, depending on the specifics of the internal TON implementation, the top approach might work as well.

BITnnn is a PLC-internal bit (discrete tag).

Caveat: with both your working approach and these simpler rungs, D0 will increment at intervals slightly greater than 1s, on average it will be 1s plus the mean scan cycle time,, probably between every 1.001s and 1.010s, possibly longer if the scan times are long.
2.png
 
Or even a simpler solution if you want to increment it every second use M8013 I think it is as a pulse contact or even just the contact & I assume as it's based on Mitsi use the ADDP function this is rising edge add.
so it would be
AND M8013 [ADDP D1 K1 D1]
Simple
 
Hereare the different add methods, note the reciprocating timer set for one second, it is only on for one scan so acts like a pulse (oneshot).
The next rung is just the same but instead of using the ADD it uses the increment function
The next rung uses M8013 I second clock (0.5 S on 0.5 S off) but using the pulse contact (UP ARROW) of M8013 to ADD 1 to the D word
The last rung uses the normal contact of M8013 instead of the pulse version and uses the pulse version of the ADD, i.e. ADDP.
You will notice the difference in the counts on the ones driven by the timer, there are two reasons for this, it was done on the simulator so the timings are not accurate by any means, in areal PLC the timers will drift a little due to the fact that the reset of the timer when the contact goes off is virtually one scan out each time the timer resets. so in a real PLC for every 1000 counts incremented you probably loose about 4 or 5.
But for the purpose of demonstrating these are just some of the ways. generally, if you want to increment or run something on multiple of seconds or minutes etc. use timers, however, a more accurate way is to use the internal clock pulse and increment a counter then use the counter contact to add the count for example drive a counter with a one second clock, have a preset of the counter say for example 3, then reset the counter using the counter contact. this will give a pulse every 3 seconds.

Add Methods.png
 
my last post above showing 2.png is

LD M3995 ---> OUT T298 K100
LDP T298 ----> ADD K1 D0 D0
OUT C0 K1
LD C0 ---> RST T298
RST C0

it works as follows, current cycle is say N:

rung@0
IF M3995 is ON then timer T298 accumulates time in TD298; if it exceeds preset time 100 then T298 becomes ON (but becomes ON not for the entire cycle N, it becomes ON until the next instruction involving T298, if any..in this example it becomes ON until the reset from rung@14)

rung@5
if T298 is ON following rung@0, then D0 is incremented by 1 and also counter C0 is incremented by 1; since counter C0's preset value 1 is reached C0 becomes ON

rung@14
if C0 became ON at rung@5 (this can happen only if T298 was ON at rung@5) then: (a) T298 is reset (and thus, since this is the last instruction involving T298 then cycle N ends with T298 being OFF and its TD298 reset to 0) and (b) C0 is reset

So cycle N ends with T298 OFF, C0 OFF and D0 incremented by 1

Then in the next cycle N + 1 if M3995 is still ON then timer T298 starts accumulating time again from 0

At some cycle N + X, T298 will reach its preset value 100 again..(of course, assuming that M3995 remains ON for all next X cycles after current cycle N)

I already tested it and it works fine; however you say RST T298 from rung@14 should be replaced with something else ?
 
or even a simpler solution if you want to increment it every second use m8013 i think it is as a pulse contact or even just the contact & i assume as it's based on mitsi use the addp function this is rising edge add.
So it would be
and m8013 [addp d1 k1 d1]
simple


+1!!!!!
 
Look at my code I just posted, there is no need for another timer, although M3995 appears to be on in my PLC as well it is probably something to do with another function I have had a look at the manual for your PLC and the special relays etc. are basically the same, in actual fact M800 is the normally on bit, normally off is M8001 pulse on first scan is M8002 M8003 is pulse off first scan.
No idea why M3995 is on but it is not mentioned in the manual nor are timers 298 etc. althogh these are special timers in Mitsi, also in the XC3 it does not actually mention timers T298 & 9 as if they do not exist, I suspect the manual is of poor quality and they only show a portion of the actual internal memories.
This often happens with clones, for example aclone of an mitsubishi FX3U (looks identicle & seems to work identical) actually does not have a way to change the PLC Parameters in the real FX3U you can set a number of things like retentive memory areas, certain other parameters.
The clone will only communicate at 19600 Baud whereas the Mitsi default is 9600 but some HMI's & mitsi IDE can auto change this on the fly so basically Misubishi GX software if you set the coms up at 115kb GX IDE will talk at 9600 & force the FX to 115kb.
 
there is nothing special with M3995, T298 .. it was just some example of mine

the fact that D0 gets incremented while M3995 is ON is just some example of "something happening when something else switches to ON"
 
recently we attached a button to the PLC, so I didn't take it with me for the weekend to make sure I don't do some damage..

so until Monday have a nice weekend..
 

Similar Topics

I am attempting to reject a bottle If the label fails. The rejection works fine at normal line speed but at low speed the rejector fires (air...
Replies
35
Views
1,137
Hi everyone, I am working on a project that needs to expose the SV (Set Value) of a temperature controller to a SCADA system. SCADA <-...
Replies
4
Views
158
I'm pretty new to PLC's, so forgive me if I use the wrong terminology and whatnot. We have an issue at work where we have a flow meter that is...
Replies
10
Views
290
I would like to copy register N61:131 thru N61:147 into ST252:0 I keep failing What happens is I copy into ST252:0,1, 2 etc. What am i missing...
Replies
18
Views
574
Hello Siemens experts. I am trying to register a GSDML file for an Endress & Hauser's Profinet IO over APL (Profile 4.0) compliant device. TIA...
Replies
2
Views
207
Back
Top Bottom