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.

---------->>>>>Get FREE PLC Programming Tips

New Here? Please read this important info!!!


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

PLC training tools sale

Reply
 
Thread Tools Display Modes
Old October 18th, 2017, 04:22 PM   #1
defcon.klaxon
Lifetime Supporting Member
United States

defcon.klaxon is offline
 
Join Date: Feb 2015
Location: Far NorCal
Posts: 328
Proficy scaling; not sure what previous programmer is doing here

Hey guys,

I've come across some code that is scaling an analog value in a GE 90/30 (now porting to RX3i). There's some oddity going on that I'm trying to figure out, screen capture is below (and I can provide project if that would be helpful).



Starting on row 1, you can see that the analog input for turbidity is moved into another register, R00800 that is a WORD. Then R800 is multiplied by 1, the product is R802 (DINT). Then R802 is divided by 32, quotient is R804 (DINT). But then R00804 (WORD) is moved into *another* register, R1840, which is an INT (this value is then packed and sent to the master PLC).

I'm having a hard time understanding exactly what is going on here. First, is there an advantage of copying the INT raw input into a WORD before scaling? Second, what's up with the italic register R800 being different than R00800? Is it some sort of local to the program block alias? Third, why would the scaled value be moved back into an INT at the very end? What am I missing here?

Regardless I'm going to go to a SCALE block to make things more simple since I have the RX3i but I do want to make sure I understand what's going on here.
  Reply With Quote
Old October 18th, 2017, 04:50 PM   #2
Steve Bailey
Lifetime Supporting Member + Moderator
United States

Steve Bailey is offline
 
Steve Bailey's Avatar
 
Join Date: Apr 2002
Location: The boondocks of Western Massachusetts USA
Posts: 6,212
The MUL_INT function in a 90-0 multiplies TWO INTs (IN1 and IN2) and puts the result (Q) in another INT. It doesn't require two particularly large values in IN1 and IN2 to result in a product that overflows the destination.
The MUL_DINT function multiplies two DINTs and puts the result in another DINT. The DIV_DINT divides a DINT by a DINT with the result in another DINT. In a 90-30, a DINT takes up two consecutive %R addresses.
The first rung effectively converts the INT value in TURBRAW to a DINT in the two consecutive addresses %R800 & %R801. Although to be 100% sure the programmer should have moved a zero into %R801 before doing the MUL_DINT.
The second rung makes the assumption that the DINT value in the two consecutive addresses %R802 & %R803 will always be small enough so that the quotient can fit in the address %R804.
Its a lot of unnecessary code to simply divide TURBRAW by 32, but it allows for the possibility of a larger value than 1 for the IN2 node of the MUL_DINT in the first rung.
It also doesn't accommodate negative values in TURBRAW.
In the Rx3i function set you can use the MUL_MIXED instruction which multiplies two INTs with the result in a DINT and the DIV_MIXED which divides a DINT by an INT with the result in an INT. Or you can use the INT_TO_REAL instruction and do the rest of the arithmetic in floating point.
  Reply With Quote
Old October 18th, 2017, 04:54 PM   #3
defcon.klaxon
Lifetime Supporting Member
United States

defcon.klaxon is offline
 
Join Date: Feb 2015
Location: Far NorCal
Posts: 328
Quote:
Originally Posted by Steve Bailey View Post
The MUL_INT function in a 90-0 multiplies TWO INTs (IN1 and IN2) and puts the result (Q) in another INT. It doesn't require two particularly large values in IN1 and IN2 to result in a product that overflows the destination.
The MUL_DINT function multiplies two DINTs and puts the result in another DINT. The DIV_DINT divides a DINT by a DINT with the result in another DINT. In a 90-30, a DINT takes up two consecutive %R addresses.
The first rung effectively converts the INT value in TURBRAW to a DINT in the two consecutive addresses %R800 & %R801. Although to be 100% sure the programmer should have moved a zero into %R801 before doing the MUL_DINT.
The second rung makes the assumption that the DINT value in the two consecutive addresses %R802 & %R803 will always be small enough so that the quotient can fit in the address %R804.
Its a lot of unnecessary code to simply divide TURBRAW by 32, but it allows for the possibility of a larger value than 1 for the IN2 node of the MUL_DINT in the first rung.
It also doesn't accommodate negative values in TURBRAW.
In the Rx3i function set you can use the MUL_MIXED instruction which multiplies two INTs with the result in a DINT and the DIV_MIXED which divides a DINT by an INT with the result in an INT. Or you can use the INT_TO_REAL instruction and do the rest of the arithmetic in floating point.
Wow Steve thanks so much for all this info. Having never programmed 90-30s, a lot of what is going on here was obviously lost on me.

Now that I'm using an RX3i, is it still true that a DINT would be two consecutive register addresses? I've taken the four day course from my local GE rep and he never mentioned anything like that at all.
  Reply With Quote
Old October 18th, 2017, 05:05 PM   #4
Steve Bailey
Lifetime Supporting Member + Moderator
United States

Steve Bailey is offline
 
Steve Bailey's Avatar
 
Join Date: Apr 2002
Location: The boondocks of Western Massachusetts USA
Posts: 6,212
The Rx3i supports both addressed and symbolic variables. If you choose assign a %R address to a DINT variable, it will consume two consecutive addresses. GE does not have a separate address area for INTs, DINTs, REALs similar to Logix500's N, L and F.
  Reply With Quote
Old October 18th, 2017, 05:16 PM   #5
defcon.klaxon
Lifetime Supporting Member
United States

defcon.klaxon is offline
 
Join Date: Feb 2015
Location: Far NorCal
Posts: 328
Quote:
Originally Posted by Steve Bailey View Post
The Rx3i supports both addressed and symbolic variables. If you choose assign a %R address to a DINT variable, it will consume two consecutive addresses. GE does not have a separate address area for INTs, DINTs, REALs similar to Logix500's N, L and F.
Thanks Steve, this is really helpful info. As far as the italic variables, can you provide any help with what that is all about?
  Reply With Quote
Old October 18th, 2017, 08:37 PM   #6
Steve Bailey
Lifetime Supporting Member + Moderator
United States

Steve Bailey is offline
 
Steve Bailey's Avatar
 
Join Date: Apr 2002
Location: The boondocks of Western Massachusetts USA
Posts: 6,212
Proficy Machine Edition from which the screen capture was made is set up to display only the variable name. You can optionally set it up to display addresses and variable descriptions as well.
I'm guessing, based on context, that the variable TURBRAW has a %AI (Analog Input) address. There is a WORD variable named R00800 defined in the variables table. That is the default name for variable addressed to %R800. The programmer has also defined a DINT named R800 also addressed to the address %R800. That variable most likely uses two consecutive %R addresses, %R800 and %R801. Likewise, the programmer has defined two additional DINTs named R802 and R804 which each use two consecutive %R addresses, most likely %R802, %R80 and %R804,%R805. The programmer has also defined another WORD variable named R00804, probably addressed to %R804 and an INT variable named R1840, probably addressed to %R1840.
WORD and INT variables are both 16-bits. DINT variables are 32-bits. Word variables are unsigned so the most significant bit of the word is evaluated as 32768. INT variables. are signed, so the most significant bit of the word is evaluated as the sign bit. When the sign bit is true the remaining bits are evaluated as twos-complement. The MOVE_INT instruction simply copies the sixteen bits from the source to the destination, so a WORD variable as the source and an INT variable as the destination is valid.
  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
Scaling in Proficy Machine 8.6; seriously, no scaling to a REAL? defcon.klaxon LIVE PLC Questions And Answers 8 October 16th, 2017 08:08 PM
Scaling to parameter on GE Proficy Machine Edition Taiwo88 LIVE PLC Questions And Answers 4 March 19th, 2016 11:37 PM
PLC5 Scaling Question jrowe4 LIVE PLC Questions And Answers 3 July 18th, 2014 06:27 PM
how to determine low,high,and mean scaling for Omron? kartika LIVE PLC Questions And Answers 5 August 2nd, 2011 02:20 AM
ControlLogix PID Scaling - Help! kdcui LIVE PLC Questions And Answers 4 May 10th, 2011 06:09 PM


All times are GMT -5. The time now is 02:36 PM.


.