Proficy scaling; not sure what previous programmer is doing here

defcon.klaxon

Lifetime Supporting Member
Join Date
Feb 2015
Location
Far NorCal
Posts
616
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).

NtuCxwQ.png


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.
 
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.
 
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.
 
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.
 
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?
 
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.
 

Similar Topics

Hey guys, I've already searched the forums and think I've figured this out, just wanted to make sure since the threads I found were all slightly...
Replies
8
Views
4,407
How do i scale analog values in "int" form to give a scaled "real" value on GE proficy machine edition. N.B: I couldn't find the SCALE_REAL block...
Replies
4
Views
6,525
Hi I am wondering if the RXI-042 PLC model (below PN) is programable via Proficy Machine Endition, if so, what is the firmware version needed for...
Replies
2
Views
68
Greetings, I am working on a project and I would like to scale %AI to -10.0 to 10.0 VDC. The module Input data is stored as a 16 bit Integer and...
Replies
4
Views
51
I am trying to download a program with usb to serial cable in rx3i IC695CPE305 while logic and configuration is equal but when i start downloading...
Replies
1
Views
31
Back
Top Bottom