adccommunitymod (AutomationDirect) asked a question.

Analog Scaling and HMI's

Created Date: June 17,2000

Created By: Michael Lloyd

**** This post has been imported from our legacy forum. Information in this post may be outdated and links contained in the post may no longer work.****

Hi again, I have a temperature transmitter input to an analog input (current) card that I need to scale. The range is -50 degrees F to 150 degrees F. I used a LD Vxxx, MUL K200, DIV K4095 to get almost there. My next line was a SUB K50 which of course didn't work. My last line is an OUT V2xxx by the way. What am I missing here? Should I just "know " that in my program my temp value is 50 degrees high and scale it with the HMI? I want to do a comparison to an alarm (and shutdown) setpoint (V memory addresses that the HMI or programmer puts in) and trigger some things (Ie shutdowns and alarms). I would rather not unscale my HMI input and then ship the value to the PLC. The scaling is for we humans. The PLC could care less. I also want to display the value on the HMI. Any ideas? Has anyone ever used a PLC Direct PLC with a Siemens OP7 or OP17? Any cabling issues? Address issues. Alternate to the OP7 / 17? Thanks, ML


  • adccommunitymod (AutomationDirect)

    Created Date: June 18,2000

    Created by: ericn

    Hi Michael,

    I'm not really sure why you can't use constants with certain math instructions, maybe someone can enlighten me on the reason? Anyway, here's one method I use to overcome this fact. Just use a V-memory location that has the value of 50 for your SUB operand. Preset this value with a rung like this: STR SP0 (first scan), LD K50, OUT Vxxx. Now the value in Vxxx can be considered the same as using the constant K50.

    Hope this helps,

    -Eric

    Expand Post
  • adccommunitymod (AutomationDirect)

    Created Date: June 19,2000

    Created by: Tom Jenkins

    We always use real engineering units in our laddder logic - it makes troubleshooting ever so much easier. I wouldn't use an assumed 50 degree offset - that can lead to trouble and confusion for every one but the programmer.

    One additional caution. You are using integer math instructions, and so you can't have negative numbers. (This may be why the problem with subtraction by K50 exists).

    After you get your 0 to 200 value, you need at least two rungs if you want to work in deg F. If the value is greater than 50, use Eric's technique and subtract the K50 Vxxxx from the 0-too "scratch " value. If the value is less than 50, set a bit (coil) to indicate negative temperature, and then subtract the "scratch " temperature from the K50 Vxxxx register.

    You will then need to use the negative value bit and two rungs in all your compares if you stay in deg F, and use the negative value bit in your O/I. To avoid all of this extra stuff, we use degrees R for all of our internal logic. (deg R = Deg F + 460). You still need to account for the below zero temperature in your initial conversion, but all of your compares and logic are straightforward. Just make sure you add 460 to all of your setpoints!

    One last tip - if you use 2000 instead of 200 in your conversion you can have an implied decimal point and values to +/- 0.1 degree.

    Expand Post
  • adccommunitymod (AutomationDirect)

    Created Date: June 19,2000

    Created by: franji1

    You are allowed to use 32bit (double word) instructions on 16 bit values. Believe it or not, SUBD does support constants!

    I'm not sure which PLC you are using, but try SUBD instead of SUB, and enter K50.

    Hence, the following should work

    LD Vxxx

    MUL K200

    DIV K4095 // this combination of instructions guarantees that the high 16 bits of the accumulator will all be 0

    SUBD K50 // hence, when we do a sub "double ", the result will be OK, but be careful of those negative BCD values!

    As to the reason why some instructions take constants, some do not, it's how the PLC instruction set was originally defined.

    Just remember, you CAN use the 32 bit instructions on 16 bit values, but NOT the other way around.

    Expand Post
  • adccommunitymod (AutomationDirect)

    Created Date: February 16,2006

    Created by: gebfixit

    Sir,

    Can you help with this BCD thing. I followed what you said but now I have a 9900 number.

    Originally posted by franji1:

    You are allowed to use 32bit (double word) instructions on 16 bit values. Believe it or not, SUBD does support constants!

    I'm not sure which PLC you are using, but try SUBD instead of SUB, and enter K50.

    Hence, the following should work

    LD Vxxx

    MUL K200

    DIV K4095 // this combination of instructions guarantees that the high 16 bits of the accumulator will all be 0

    SUBD K50 // hence, when we do a sub "double ", the result will be OK, but be careful of those negative BCD values!

    As to the reason why some instructions take constants, some do not, it's how the PLC instruction set was originally defined.

    Just remember, you CAN use the 32 bit instructions on 16 bit values, but NOT the other way around.

    Expand Post
  • adccommunitymod (AutomationDirect)

    Created Date: February 16,2006

    Created by: Michael Lloyd

    Wow... I posted this back in 2000 and this was the first time that I have received a notice that someone replied...

  • adccommunitymod (AutomationDirect)

    Created Date: February 17,2006

    Created by: franji1

    Originally posted by gebfixit:

    Sir,

    Can you help with this BCD thing. I followed what you said but now I have a 9900 number.

    I'm guessing you are getting a negative number. BCD cannot represent negative numbers - you must handle this on your own using a C bit to flag whether something is negative or not, along with the BCDCPL instruction.

    You should really only do this type of scaling in BCD (where you are subtracting an offset) when you know you cannot have a negative value in the scaled result.

    If you truly need to represent negative numbers, convert everything to binary (use the BIN instruction), and use the Binary version of the various math instructions (e.g. SUBB vs. SUB). 16 bit 2's complement can handle -32768 to +32767.

    Expand Post
  • adccommunitymod (AutomationDirect)

    Created Date: March 20,2006

    Created by: franji1

    The new DirectSOFT Rel 5 can do this calculation using the MATHBIN or MATHBCD IBox using typical Excel, VB, or C syntax:

    ((V2000 * K200) / K4095) " K50

    http://hosteng.com/forumimages/mathbin1.jpg

    You always enter K's values as you would expect. From your perspective, K10 is one more than K9. No need to worry any more if you should use KA or K10 for the number between 9 and 11! Just use what you expect it SHOULD be. The MATHBIN and MATHBCD IBoxes handle the proper conversions for you. There is also a MATHR for doing Real/Floating Point math. The Math expressions can be as complex as you need them to be.

    Note: Support for IBoxes is only available for the 05, 06, 250-1, 260 and 450 CPUs and may require a firmware upgrade.

    Expand Post
  • adccommunitymod (AutomationDirect)

    Created Date: March 22,2007

    Created by: m anwar

    hi

    how are u dear

    i am learner of S7 can u guide me about scaling of an anlog value

    thanks

  • adccommunitymod (AutomationDirect)

    Created Date: March 22,2007

    Created by: m anwar

    hi

    how are u

    i am learning PLC programming

    but finding prblem in analog value scalling can u help me

    thanks

  • adccommunitymod (AutomationDirect)

    Created Date: March 23,2007

    Created by: Tom Jenkins

    FOr temperature and pressure that are non-zero based I just go to absolute temperature (F + 460) and absolute pressure (psig + barometric (14.7 at sea level)). Then all calculations work out OK, and for most HMIs and so on it is easy to subtract the offset. On a few occassions I have used duplicate logic for everything, with a bit set to indicate if the value is positive or negative. A pain, and I'd avoid it if possible.

    As for the HMI, anything is better than Siemens in my opinion. I strongly endorse the C-More products.

    Expand Post
10 of 11