SLC 5/03 and 32 bit adding

You can do 32 bit operations in the SLC5/03, but it requires a bit of programming legerdemain. Its much easier to use a floating point register unless you are counting to something greater than 16.7 million (then you loose resolution in the 1's column). But if you insist on using 32 bits, see this technote in the AB KB about unsigned integers and using the carry bit.
 
Thanks guys for reply. I still can’t figure out how to calculate carry (if overfill bit is set) from this:



for ADD
Carry = (x1 & x2) | (~y & x2) | (~y & x1)

for SUB Source1 - Source 2
Carry = (~x1 & x2) | (y & x2) | (y & ~x1)

for DIV/MUL
Carry = 0

for Floating Pt:
Carry = 0




That is from tehch note that Alaric pointed. Does anyone have idea?
 
I'm with everyone else. Use a floating point element. Using double integers in the 5/03 is next to useless unless you need the numbers for some other device, like a motion controller or an HMI. Internal to the 5/03 a double integer does you very little good as there is only one instruction (DDV) that lets you use it.


Keith
 
I guess the tone of "...but if you insist..." just doesnt make it across a message board. 🍺 Its understandble, especially since there is often a language barrier as well.


InputPulse B3/??
---] [--------[OSR]--------+-ADD------+-
|A 1.0 |
|B F8:0 |
|DEST F8:0 |
+----------+

 
Yes as Alaric said it is the best way to use floating point, but I'm not sure that I can do that. These data I’m sending to two SCADA computers and I’ve already sorted my data for sending into one file N7 for optimised communication. I think that reading some other area like F8 will very likely crash my very weak communication. It already happened in past so I made this optimisation. So I would be very happy if I could find way to use just N7 area that is signed integer even if I need to use two registers for one number! Is there a way to convert floating-point number to integer?



Thanks.
 
Well, if you absolutely must make that 'kludge', just keep adding to an N (16 bit integer) register. At 32767 + 1, it will suddenly just go from 32767 to -32768. Or, put another way:
0111 1111 1111 1111 + 1 = 1000 0000 0000 0000.

Just interpert the value on your 'reader side' as unsigned.
 
I think you need to make sure that S:2/14 is set when you do this. If you don't set this bit when you add 1 to 32767 the processor will limit the value to 32767.Keith
 
kamenges said:
I think you need to make sure that S:2/14 is set when you do this. If you don't set this bit when you add 1 to 32767 the processor will limit the value to 32767.Keith

As tested in my 5/04, you are correct, Keith.
It will stop at 32767 unless S:2/14 is set. With S:2/14 set, it will continue to increment, and could be used as an unsigned integer that would count from 0-65535. Of course, in RSLogix, it will still be displayed as a signed integer.
 
Thanks for that note, I was unaware of (or forgot) that fact :)

kamenges said:
I think you need to make sure that S:2/14 is set when you do this. If you don't set this bit when you add 1 to 32767 the processor will limit the value to 32767.Keith
 
And don't forget to clear the overflow bit S:5/0 as well.

From the technote I linked earlier:
ALSO REMEMBER, since you will be generating overflows to:
1) Clear the S:5/0 bit before reaching the end of scan or you will get a FAULT.
2) Set the S:2/14 bit to allow overflows.
 

Similar Topics

All, Forgive my lack of attention to detail, today a student asked me why when he printed his ladder in an RSLogix 500 report, even though he had...
Replies
10
Views
1,946
Good Afternoon, I’m looking at some examples in a SLC 500 and I took notice of a Bit Shift that has the File position with a # B3:25 . What...
Replies
4
Views
1,724
Hello, i need an advice regarding a quite old system that i would like to upgrade to windows 7 (x86 or x64) It is a win XP 32bit with an IFIX...
Replies
1
Views
1,159
I have a SLC 5/05 that faulted with a S:5 minor error bit and I can't figure out what that is. It says "A minor error bit is set at the end of...
Replies
2
Views
4,427
There is any way to upload program from SLC 5/04 which is protected by oem bit...??
Replies
9
Views
4,232
Back
Top Bottom