You are not registered yet. Please click here to register!


 
 
plc storereviewsdownloads
This board is for PLC Related Q&A ONLY. Please DON'T use it for advertising, etc.
 
Try our online PLC Simulator- FREE.  Click here now to try it.

New Here? Please read this important info!!!


Go Back   PLCS.net - Interactive Q & A > PLCS.net - Interactive Q & A > LIVE PLC Questions And Answers

Reply
 
Thread Tools Display Modes
Old September 11th, 2015, 01:34 PM   #1
wildswing
Member
Canada

wildswing is offline
 
wildswing's Avatar
 
Join Date: May 2005
Location: Sault Ste Marie, Ontario
Posts: 281
PLC5 DIV rounding vs ControlLogix DIV truncating

Hey fellas,

I'm down to my last bug in an RSL5k ladder program converted from RSL5. In the 5 there's a DIV that divides an INT, by an INT and stores it in an INT. The subsequent logic depends on how it rounds off the result.

Now in 5000 I see that the DIV does not round. It truncates. This was screwing up the logic that depends on the properly rounded off result.

My solution was to put the result of the DIV into an intermediate REAL, then MOV the REAL to the original destination INT. See attached. This seems to work ok when I simulate the process. I'm just checking with y'all to see if you see anything wrong with doing it this way.
Attached Images
File Type: png CLX v PLC5 DIV rounding.PNG (10.4 KB, 139 views)
__________________
Mark
Hard work never killed anyone, but why take the chance?
  Reply With Quote
Old September 11th, 2015, 02:07 PM   #2
kamenges
Member
United States

kamenges is offline
 
kamenges's Avatar
 
Join Date: Nov 2002
Location: Brillion, WI
Posts: 4,194
In an interesting twist I think that the Logix processor handles that calculation correctly and the PLC5 handles it incorrectly. This is a calculation with two integers. The calculation should be done as an integer calculation. There should be nothing to round. If the calculation acts correctly the result shouldn't become "5" until Source A becomes "500". In other words, 499/100 should be 4 in an integer calculation.

That being said, I think your code change is fine with one possible issue. I THINK the PLC5 would always round up when presented with a 0.5 value. I THINK the Logix family rounds to even on a 0.5. So 1.5 would round to 2 but so would 2.5. You might want to test those conditions a little bit.

Keith
  Reply With Quote
Old September 11th, 2015, 02:54 PM   #3
Bullzi
Lifetime Supporting Member
United States

Bullzi is offline
 
Join Date: Jun 2012
Location: Colorado
Posts: 1,530
You solution seems like a reasonable one. Anytime you change platforms there is always some little thing like this that just makes you

Just curious, why did you go with the old PLC5 addressing in the new program instead of using tag names? I used to to a bunch of SLC and Micrologix programming but ever since I did my first RSL5K project I am totally sold on tag names. When I do a RSL500 project I use the hell out of the Symbols that it has just because it makes it kind of like a RSL5K project.

Like I said just curious as I have some upgrades coming the future and was wondering.
__________________
There is never enough money to do it right but there is always enough money to do it again.
  Reply With Quote
Old September 11th, 2015, 03:21 PM   #4
wildswing
Member
Canada

wildswing is offline
 
wildswing's Avatar
 
Join Date: May 2005
Location: Sault Ste Marie, Ontario
Posts: 281
Whether or not it rounds up or down at #.5 is not an issue. The process does not require that degree of precision, however, now that you've mentioned it I might run some more simulations. Thanks.

Why did I stick with the old addresses? Time. I'm an in-house, chief cook and bottle washer. I simply do not have the time to rewrite a complete plc program. I used RSL5000's conversion app. Besides, we have an entire staff of electrical techs, with a wide range of talents, that are accustomed to looking at RSL5 logic. Keeping things as similar to what they were in the 5 results in me receiving far fewer phone calls at 3 am.

Thanks for the replies guys. Much appreciated.
__________________
Mark
Hard work never killed anyone, but why take the chance?
  Reply With Quote
Old September 14th, 2015, 09:16 AM   #5
wildswing
Member
Canada

wildswing is offline
 
wildswing's Avatar
 
Join Date: May 2005
Location: Sault Ste Marie, Ontario
Posts: 281
Just a quick update. RA tech agrees with my solution. In fact, it's shown in the help file for the DIV instruction. I guess I should have looked there first.

Thanks for the feedback fellas.
__________________
Mark
Hard work never killed anyone, but why take the chance?
  Reply With Quote
Old July 29th, 2021, 11:35 AM   #6
TheWaterboy
Lifetime Supporting Member + Moderator
United States

TheWaterboy is offline
 
TheWaterboy's Avatar
 
Join Date: May 2006
Location: State of Denial
Posts: 1,212
Div then use the S:13 and 14 registers ?

Yes this thread is old but this is relevant.
in Logix 500 the DIV command does this same rounding - but the instruction help says that the unrounded answer is contained in S:13 and S:14. How are these registers then captured? Wouldn't capturing the math registers allow for a MOD functionality to be attained?

Thinking that would work I tried to capture these S registers and MOV them to N registers on the rung following the DIV of 2 integers... but I can't seem to capture them nor do I see a change in the math registers.

What am I missing here?
  Reply With Quote
Old July 29th, 2021, 11:46 AM   #7
plvlce
Member
United States

plvlce is offline
 
Join Date: May 2017
Location: Michigan
Posts: 269
Quote:
Originally Posted by TheWaterboy View Post
Yes this thread is old but this is relevant.
in Logix 500 the DIV command does this same rounding - but the instruction help says that the unrounded answer is contained in S:13 and S:14. How are these registers then captured? Wouldn't capturing the math registers allow for a MOD functionality to be attained?

Thinking that would work I tried to capture these S registers and MOV them to N registers on the rung following the DIV of 2 integers... but I can't seem to capture them nor do I see a change in the math registers.

What am I missing here?
Check out the attachments posted by bernie in this thread, they may be what you're looking for.
  Reply With Quote
Old July 29th, 2021, 12:07 PM   #8
TheWaterboy
Lifetime Supporting Member + Moderator
United States

TheWaterboy is offline
 
TheWaterboy's Avatar
 
Join Date: May 2006
Location: State of Denial
Posts: 1,212
plvce...

Answer = DIV N7:0 60 S:13

I would never have thought to place anything into those registers on purpose. This has been a valuable post. Thank You!
  Reply With Quote
Old July 29th, 2021, 12:09 PM   #9
plvlce
Member
United States

plvlce is offline
 
Join Date: May 2017
Location: Michigan
Posts: 269
I wouldn't have thought of it either, but I remembered having run across a thread on the topic and just hunted it down for you. Cheers.
  Reply With Quote
Old July 29th, 2021, 02:27 PM   #10
drbitboy
Lifetime Supporting Member
United States

drbitboy is online now
 
drbitboy's Avatar
 
Join Date: Dec 2019
Location: Rochester, NY
Posts: 3,336
As a bit more documentation for folks who find this thread:


Cf. https://literature.rockwellautomatio...df#G14.1050611


yyyflip.png

yyy.png
__________________
i) Take care of the bits, and the bytes will take care of themselves.
ii) There is no software problem that cannot be solved with another layer of indirection.
  Reply With Quote
Old July 29th, 2021, 03:37 PM   #11
TheWaterboy
Lifetime Supporting Member + Moderator
United States

TheWaterboy is offline
 
TheWaterboy's Avatar
 
Join Date: May 2006
Location: State of Denial
Posts: 1,212
Yes, but look at that example in the help file, nowhere does it demonstrate to put the result *into* the S13 register, It just says the unrounded and remainder just wind up there. That example pic is misleading, at least in todays experience.

DIV.jpg

Last edited by TheWaterboy; July 29th, 2021 at 03:45 PM.
  Reply With Quote
Old July 29th, 2021, 09:47 PM   #12
drbitboy
Lifetime Supporting Member
United States

drbitboy is online now
 
drbitboy's Avatar
 
Join Date: Dec 2019
Location: Rochester, NY
Posts: 3,336
Quote:
Originally Posted by TheWaterboy View Post
Yes, but look at that example in the help file, nowhere does it demonstrate to put the result *into* the S13 register...

Hah, agreed.
__________________
i) Take care of the bits, and the bytes will take care of themselves.
ii) There is no software problem that cannot be solved with another layer of indirection.
  Reply With Quote
Reply
Jump to Live PLC Question and Answer Forum

Bookmarks


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

Similar Topics
Thread Thread Starter Forum Replies Last Post
Migration PLC5 Ethernet to Controllogix with ethernet port connect with DCS system huynt LIVE PLC Questions And Answers 8 June 15th, 2014 07:03 PM
PLC5 to ControlLogix translated indirect addr JamesL LIVE PLC Questions And Answers 15 May 10th, 2014 02:36 PM
Panelview convert PLC5 to Controllogix NetNathan LIVE PLC Questions And Answers 19 January 30th, 2014 04:11 PM
Intouch plc5 to Controllogix asterof LIVE PLC Questions And Answers 11 May 15th, 2012 11:40 AM
PLC5 to ControlLogix Upgrade Steve Crotty LIVE PLC Questions And Answers 11 January 13th, 2009 09:58 AM


All times are GMT -4. The time now is 04:51 PM.


.