rslogix lite carry flag confusion

AndrewM

Member
Join Date
Sep 2011
Location
west yorks.
Posts
49
Hi,
Just wondered if someone could give me some guidance on what would seem a simple problem, I am experimenting with the maths on an RSlogix lite on Emulate 500 and just doing a simple ADD 1 to N7:0 in a loop, at what value should the carry flag set?

Regards Andrew
 
No replies?
Alternatively does anyone know where I might get a good explanation of the maths flags on AB micrologix 1000?
Regards Andrew
 
I have seen the overflow flag come on which has to be dealt with immediately or it will cause a major fault. This upon trying to add above 32767 for an N register.

I'm not sure where the carry flag comes on.
 
I was sleeping

No replies?
The carry flag is to unsigned math what the over flow flag is to signed math. Real computer languages allow for signed and unsigned integers. If the math operation of signed integers goes above 32768 or below -32768 the over flow bit is set. You guy are use to this. If the math operation uses unsigned values and the number goes above 65535 or below 0 then the carry bit is set.
So if I want to make a 32 bit accumulator in a SLC using N7:0 for the least significant word and N7:1 for the most significant word, I would add the least significant N register of the addend to the N7:0. I would ignore the overflow bit but if the carry bit was set I would add 1 to the the N7:1. Then I would add the most significant word of the addend to N7:1.

The trick can be used to extend accumulators to 64 bits easily so hell would freeze over before the 64 bit accumulator overflowed or Obama get another term in office.
 
The carry flag comes on if a mathematical carry or borrow is generated. The only time I've ever seen it used in a program is when 32 bit math or unsigned math was required on older SLCs or PLC/5s and some ugly programming gymnastics were required to perform the operation. There are some technotes in the AB KB on how to do that if you feel an itch that wont go away until the OCD part of you tries it.

Since the ML family supports 32 bit math I don't see where you would use it unless you for some torturous reason feel the need to attempt 64 bit math or unsigned math.


Edit: I see Peter beat me to it. 🍺
 
Last edited:
so hell would freeze over before the 64 bit accumulator overflowed or Obama get another term in office.
His chances look good right now. The people who voted for him have not learned anything.
 
The carry flag is to unsigned math what the over flow flag is to signed math. Real computer languages allow for signed and unsigned integers. If the math operation of signed integers goes above 32768 or below -32768 the over flow bit is set. You guy are use to this. If the math operation uses unsigned values and the number goes above 65535 or below 0 then the carry bit is set.
So if I want to make a 32 bit accumulator in a SLC using N7:0 for the least significant word and N7:1 for the most significant word, I would add the least significant N register of the addend to the N7:0. I would ignore the overflow bit but if the carry bit was set I would add 1 to the the N7:1. Then I would add the most significant word of the addend to N7:1.

The trick can be used to extend accumulators to 64 bits easily so hell would freeze over before the 64 bit accumulator overflowed or Obama get another term in office.

Thanks everybody for the replies, Peter the scenario you describe above is exactly what I am trying to achieve, the problem for me is that the carry bit sets for every single addition on N7:0, could this be a problem in the emulator 500?

Regards Andrew
 
I suspect it might be an issue for the emulator. I just tried it on an ML1400 and the carry flag only sets when going from FFFFhex to 0000hex (carry) or from 0000hex to FFFFhex (borrow) which is how I would expect it to work.
 

Similar Topics

Hello, first assignment with A-B stuff. The CPU is a MicroLogix 1000. Have a serial interface, so RS Linx Classic to edit the driver (AB-DF1) with...
Replies
7
Views
1,691
Hello all, I am new here and a beginner when it comes to PLC's. I have an RSS file from an former project we have done but I can not open it with...
Replies
12
Views
2,274
Oh, I hope someone can help! I have one little problem holding me up from studying this weekend. I'm using Rslogix micro starter light, it's a...
Replies
7
Views
2,987
Hello, I'm using RSLogix Micro Starter Lite and am attempting to update the RI data table. Is this due to the fact that it's a light version and...
Replies
7
Views
1,181
I've created a test program in Micro Starter Lite and attempting to set up communications with the emulator and run the program. In the...
Replies
3
Views
1,577
Back
Top Bottom