Counting down from 10000???

Hopefully, your "Lifetime Count" was a DINT and you are retired before the count reaches too high. Since there is no trap for the sign bit, it can be hard to explain, why the count is going negative.
 
Yes, the LifetimeCount is a dint (as evidenced by "+ L#1"). I normally work on processes that only produce a few million units per year, so I'm sure we'll all be long gone before it goes negative. :)

But yes, if this is a machine that makes aspirin or something like that, then the max positive value might have to be evaluated. Or, a person could count increments of 1000, and the dint would then suffice for any process.
 
I've got a problem again.

I tryed to substract 1 from a double integer and the value just goes to -1 and all the devices that are on profibus go berserk????What's wrong???

This is the network.
NW1

A I 0.4
JNB _01f
L MD 0
L L#1
-D
T MD 0
_01f: NOP 0

NW2

L MD 0
L L#0
==D
= M 25.6
 
The plc's is probably going to stop??? Or trying to check the diagnostic buffer and check that the sf diod on the cpu isent lit. There is nothing wrong with the instruction but MD0 might be used somewhere else in the program causing a fault
 
The first thing I see is that you didn't use a one-shot to trigger the math function in the first network. So, the 1 will be subtracted on each scan for as long as I0.4 is high.

As for why the devices are going crazy, I see that you used MD 0. Did you write the original program? Sometimes, a programmer will use the very low bytes as clock pulses or temp markers or something like that, and if they are used indirectly, they won't even show up in the cross reference. Since MD 0 uses bytes 0, 1, 2, and 3, and a -1 is actually Hex FFFFFFF, all of the bits will go true at once. If these bits are used elsewhere, things could go haywire.

Try programming a one-shot, and use a different dint to see if that fixes it.

Edit: I forgot to mention that I don't see where you are loading a value into MD0 to count down from. Are you doing it elsewhere in the program? Somewhere, you will have to reload it, or at least you will want to stop counting down once it reaches zero (and if you use a one-shot, combined with stopping the machine, that would probably solve that problem since I0.4 would stop going high, I assume).
 
Last edited:
A one shot is, positive RLO detection right? I'll try a diferent MD now, and I hope that it'll work then. Thank you for the help!
 
Yes, you would want to detect the rising edge. I'm not sure about Ladder, but in STL it would look like this:

A I 0.4
FP M30.0
= M30.1

M30.1 would be true for one scan, and would not go true again until I 0.4 switched states.
 
Yep it works now, thank you. I have one question thoug.Let's say that I have MD30, wich MD addres is avalible next??? MD32?? or higher addres??
 
If you use MD30, MD34 would be the next dint (MD30 is composed of MB30, MB31, MB32, and MB33).

If you were using ints, MW32 would be the next int after MW30.
 

Similar Topics

Hello, all! Maybe someone had the same problem? I use the Rockwell Automation software. I need to make 24 hours timer indicator with minutes on...
Replies
6
Views
1,811
Hi, I am wanting to know if this is possible using S7: When a 1 hour timer has been triggered (count up timer), to detect when the 1 hour timer...
Replies
6
Views
2,155
Hi ,I need your help. I have Mitsubishi FX1N and GT-11 Nais screen and I have to show time counting down on the screen . May be someone knows how...
Replies
2
Views
2,090
Hello I am looking for tips on how to count the duration of a given function and then how to display it on the hmi panel in the hh:mm:ss format...
Replies
4
Views
1,703
Guys, I know it will be silly but can't get my head around it. I have 3 conveyors, every one on a separate servo drive, and 2...
Replies
25
Views
3,506
Back
Top Bottom