Math

Math Learn Direct Save Mathlearndirect E E Math Learn Direct F Learn S S Natural Math Learn Direct Szh Cn Subscriptions Ee Mail Index Mvp Math Learn Direct Scaling using y=mx+b – a “no-math” shortcut ... [Text] Math - PLCS.net - Interactive Q & A

Math Learn Direct Save Mathlearndirect E E Math Learn Direct F Learn S S Natural Math Learn Direct Szh Cn Subscriptions Ee Mail Index Mvp Math Learn Direct


Index osearch Mathlearndirect esearchrsearch Learn asearchh Mvp 0 Direct esearchr Math h Mathlearndirect Math a Mail e Mail c Direct M Learn t Mvp Math searchu Learn s Direct r Mvp psearchi Save ns Subscriptions ssearchD Learn r Index c s Mathlearndirect arsearchh Learn s Math asearchc Learn rs%D0%B2%D0%B5%D0%BA%D1%82%D0%BE%D1%80%D0%BD%D0%B0%D1%8F%20%D0%B3%D0%B5%D1%80%D0%B0%D0%BB%D1%8C%D0%B4%D0%B8%D0%BA%D0%B0%20%D1%81%D0%BA%D0%B0%D1%87%D0%B0%D1%82%D1%8C%20%D0%B1%D0%B5%D1%81%D0%BF%D0%BB%D0%B0%D1%82%D0%BD%D0%BEee Direct searcha Index lsearche Direct S Learn hsearchu Save L Math a Math nsearcho Mvp e Mvp rhsearch
May 23rd, 2005, 08:02 AM
Figure 16 shows a ladder logic program which will perform the scaling conversion that we just discussed ...



qanda/uploads/y=fig16.JPG


and as I mentioned earlier, programs like this one often need some type of “limiting” arrangement to keep the input values from getting out of hand ... one good programming habit to get into is to check the operation of your math functions by feeding in the extreme limits of what the input values might possibly be ... and don’t forget to check with extreme values of negative numbers too ...

Ron Beaufort
May 23rd, 2005, 08:04 AM
next we’ll take a look at a technique that often comes in handy when working with the SCL instruction ... in some cases, the ranges of values involved in a scaling operation exceed the capabilities of the SCL ... for a preview example: consider a situation where the value of “m\Slope\Rate” is 2.4997 ... now suppose that the input to the SCL is greater than 13108 ... in that case, the SCL would generate an internal value of something greater than 32767 ... oops! ... greater than 32767 is not allowed and so a “Math Overflow” bit S:5/0 will be set ... and if it’s not turned off again by the end of the scan, then the processor will fault ... and even if it IS turned off to prevent a fault condition, the math might not be “quite right” because the actual value could not be accurately stored ... in some applications, math which is not “quite right” can be a very bad thing ... you need to keep your eye on things like this ...



qanda/uploads/Y=fig17.JPG




the top of Figure 17 shows a situation where a 4 to 20 mA analog input signal is being used to control a 0 to 10 VDC analog output module ... if you solve this by using a calculator, you should find that the example raw input data reading (8127) will be converted to a scaled value of 12124 ... well, not quite ... actually the SCL will give you a scaled value of 12123 for this example ... why? ...



keep in mind that the values shown in Figure 17 are correct for working with the calculator ... but ... remember that the PLC handles this type of math using only integer numbers ... specifically, there is a certain amount of inconsistency to be expected due to “round off” issues ... in other words, we can accurately calculate “m/Slope/Rate” to be 2.499732967 as shown in the figure ... but when you use that value for the SCL instruction’s Rate entry, the closest that you can come to the calculator’s number is 2.4997 ... so the PLC loses a little bit of accuracy ...



likewise ... we can accurately calculate “b/Offset/Intercept” to be ‑8191.624933 as shown in the figure ... but when you type that value into the SCL instruction’s Offset entry, the closest that you can come to the calculator’s number is ‑8192 ... so the PLC loses a little bit more accuracy ... so don’t be surprised to see minor inconsistencies between what your TI-36X calculator says and what the PLC actually produces ... again, there are differences between the ways that the two devices handle “round off” issues ... but those types of issues are usually minor “nickel-dime” stuff that won’t significantly affect the operation of your system ...



but this next one is a major issue ...



suppose that you’re the programmer who’s setting up the scaling shown at the top of Figure 17 ... you’ve decided to use an SCL for this program ... you’ve calculated the value for “m/Slope/Rate” (2.499732967) and cranked it into the SCL as a Rate entry of 24997 ... and that’s fine because it’s as close as we can get with the system we’re working with ... you’ve also calculated the value for “b/Offset/Intercept” (‑8191.624933) and cranked it into the SCL as an Offset entry of ‑8192 ... and that’s ok too because it’s as close as we can get with the system we’re working with ... so now you’re ready to check things out ... you dial in an input signal of about 9.92 mA ... the raw input data reading at I:7.1 goes up to 8127 ... the TI-36X calculator says that we should expect our SCP to convert this to a scaled value of 12124 ... we see 12123 at O:8.1 ... we’re just one point off ... not too bad ... we knew we’d have a little bit of inconsistency due to “round off” ... so no problem ...



you keep cranking the input current up little-by-little and keep checking the scaled values – and the resulting output voltage ... everything is working fine ...



you’re finally up to 13108 for your raw input data reading ... the calculator tells you to expect a scaled value of 24575 ... the SCP gives you an actual scaled value of 24575 ... that ain’t bad at all ... and the output module’s voltage is tracking right along ... let’s go one more tiny itty-bitty step up ...



you finally reach 13109 for your raw input data reading ... the calculator has told you to expect a scaled value of 24577 ... BUT ... the SCP goes nuts and gives you an actual scaled value of 32767 ... WIDE OPEN! ... all of a sudden you notice that the analog output module is cranking out a wide open value of 10 VDC ... glad we didn’t have this thing wired up as the speed control signal of a motor drive just yet ... and if you didn’t have that “unlatch” rung for S:5/0 at the end of ladder File #2, then the processor would have faulted ... but come to think of it, maybe a “shut-down-everything-fault” would have been a better thing that suddenly driving an output signal wide open ... we’ll have to think about that later on ...



but back to our nutty signal problem ... this is NOT a simple “round off” issue ... and there’s nothing wrong with your math solution either ... the problem lies in the PLC’s method of handling its internal calculations as integer values ... let’s nail the problem down so that we’ll know what to look for from now on ... and then we’ll finish up for today with a practical way to fix it ...



here’s the play-by-play ... consider what the SCP was doing when you had the raw input data simmering along at a reading of 13108 ... each time the SCP was executed, it took the “Rate” entry (24997) and divided it by 10000 and got an internal result of 2.4997 ... so far so good ... next it multiplied that internal number (2.4997) times the “Source” value from I:7.1 (13108) and got a result of 32766 ... still chugging along just fine ... next the faithful SCP added the “Offset” value (‑8192) to the previous result (32766) and came up with a result of 24574 ... close enough to the 24575 that the calculator told you to expect ...



now consider what the SCP was doing when you finally cranked the raw input data signal up just one point higher to a new reading of 13109 ... the very next time that the SCP was executed, it took the “Rate” entry (24997) and divided it by 10000 and got an internal result of 2.4997 ... still ok ... next it multiplied that number (2.4997) times the “Source” value from I:7.1 (13109) and got a result of 32769 ... oops! you just broke the bank ... the integer-type math of the SCP can’t store a number bigger than 32767 ... so it does the best it can (bless its little heart) and stores the maximum (32767) and turns on the “Math Overflow” bit (S:5/0) to tell you that something went wrong with the math somewhere along the way ... and that’s about it ... once that internal overflow had been generated, the SCP didn’t even try to add in the “Offset” value (-8192) which would have brought us back within range with a final scaled result of 24575 ... so the sad story is, that even though it’s been set up “right”, this particular SCP will “hit the wall” when its raw input data reading comes in at 13109 or anything above ... from there on up, the scaled value just runs wide open at 32767 ... rats! ...



ok ... so now how do we fix this type of scaling problem? ...



take a look at the chart at the bottom of Figure 17 ... here we’ve “shifted” the entire raw input data range to the left on the chart ... basically we’ve subtracted the input range’s minimum value (3277) from the minimum end (3277-3277=0) ... and from the maximum end (16384-3277=13107) ... and from the sample raw input data signal (8127-3277=4850) ... now notice that all of this “shifting” didn’t affect the value of “m/Slope/Rate” at all ... but the “b/Offset/Intercept” value is now a nice round even (and easy to deal with) 0 ... and even after we’ve “shifted” things around, our 9.92 mA sample input reading still converts to the same 12124 (or 12123 “rounded off”) corresponding scaled value ...



so now what about that “breaks the bank” raw input signal of 13109? ... well look at the chart ... as long as the field signal doesn’t exceed its 20 mA maximum, then our sensitive SCP won’t ever see another raw input signal above 13107 ... and if you want some good advice, some systems should have this type of input signal “clamped” between a suitable maximum and a suitable minimum ... and you should consider programming suitable alarms to let someone know if the signals ever try to get out of range ...

Ron Beaufort
May 23rd, 2005, 08:07 AM
Figure 18 shows one common approach to programming the “shifted” x-axis which we just discussed ...



qanda/uploads/y=fig18.JPG




and again, remember that this demonstrates a bare-bones minimum ... many systems require that the input signals be “clamped” and also possibly “alarmed” to insure safe, reliable operation ...



in closing, both the SLC-500 Instruction Set Reference Manual and the SLC-500 Analog I/O Modules User Manual have several examples about this subject that you might find helpful ... just be aware that there are MANY typographical errors in the “scaling” sections of both of these official books ... and there are also a few places where unconventional “rounding off” can cause some confusion ... if you try working through these samples and have any trouble getting the numbers to “work-out-right” then post your specific questions and I’m sure someone with a TI-36X calculator will be able to help you out ...

Ron Beaufort
May 23rd, 2005, 08:12 AM
Greetings Phil Buchanan,



thank you so very much



you’re quite welcome ... actually I’ve been meaning to tackle this particular subject for about a year or two ... thanks for providing the incentive to get it done ... and enough detail about your process to make the examples easier to set up ...



i have taken a lot of plc classes and this was never covered in any of them.



it’s been included in all of mine for several years now ... once in awhile I think about dropping it – but the companies that we work for always say that this is one of the subjects where their employees need the most help ... as I said in the beginning, you’re certainly not alone in needing this material ...


dMath Learn Direct Save Mathlearndirect E E Math Learn Direct F Learn S S Natural Math Learn Direct Szh Cn Subscriptions Ee Mail Index Mvp Math Learn Direct Scaling using y=mx+b – a “no-math” shortcut ... [Text] Math - PLCS.net - Interactive Q & Aa Learn Math Learn Direct %20e45645w cMath Learn Direct Save Mathlearndirect E E Math Learn Direct F Learn S S Natural Math Learn Direct Szh Cn Subscriptions Ee Mail Index Mvp Math Learn Direct Scaling using y=mx+b – a “no-math” shortcut ... [Text] Math - PLCS.net - Interactive Q & As a g Div Zebrareeks%20crypto