defcon.klaxon
Lifetime Supporting Member
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.
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.