Sign in to follow this  
Followers 0
Bering C Sparky

Another Newbee Question

5 posts in this topic

Hello agian, Trying to write a program for water tank levels, problem is the tanks have over 37000 gallons of water in each but I can only get sums up to 32767 before I get a math overflow fault. Could somone please explain how to get values greater than 32767. ( floats??? double integers???? something else???) and if so how to set it up and make it work. I realize that I can scale it down to smaller #s for the math in the program its self but eventually I will need to be able to set a value of almost 38000 onto the HMI. Need to be able to go higher than 32767 or need a way to work with decimal. ( K 37.725 ) Also tried to install a reset instruction with S:5/0 for math overflow trap and get ERROR " Invalid Data Type?????????? Any thoughts on this one also. Using ML1400. Thanks in advance for you help. Charles

Share this post


Link to post
Share on other sites
It's a great question. Because you are using a MicroLogix 1400, you can use either Long Integers or Floating Point values. Long integers keep their resolution of "1" up to the maximum value of 2^31 = 2,147,483,648. Floating Point values go up to roughly 2^23, but because they are an approximation you lose resolution as the values get higher. It's a classic PLC conundrum that programmers use a Floating Point value to get large totalizers, then are baffled when adding 1 to a floating point number of about 7 million has no incremental effect. I would stick with Long Integers. You can't use them with Counters, but you can certainly use them with ADD/SUB/MUL/DIV. About the Reset instruction; "RES" is specifically a Reset function for Timers or Counters. If you need to set a Bit value to zero, either use the OTE instruction with sustained false pre-conditions, or use the OTU instruction with temporarily true preconditions (it's a Latch False instruction). Typically when you are overriding the S:5/0 bit for testing, use a rung with nothing but "OTU S:5/0". What's your ship and homeport ?

Share this post


Link to post
Share on other sites
Hello Ken, Thanks for the reply. Could you go into more detail on using the long Interger for me. How to set it up and use it. Unfortunatly the laptop that is provided to me on board the ship has Danish windows installed on it, and I only speak english. ( we have people from about 20 different countries onboard but none speak danish) so using the help menu or figuring out driver errors can be a hair pulling experience. I am enjoying working with the plc's and automation onboard but it is a learn as you go process. Ship is the Northern Jaeger Home port is Seattle Washington ( although we spend most of our time fishing the Bering Sea and offloading/resupplying from Duth Harbor ) I personally live in Florida. Thanks again for the reply and I hope you can give me more details about using Long Intergers, ( Love this site, its great to be able to get advice from people who are in the know ) Charles

Share this post


Link to post
Share on other sites
You can use an "L" data file element in almost every instruction that you could use an "N" data file element. Data file 7 is the default Integer file, and there's no default Long Integer file, so you just create the file(s) as needed in the program organizer. L10:5, for example, can be used as the source or destination of a math instruction like ADD, SUB, DIV, MUL, etc. Your HMI might natively support access to "L" data types, or you might have to trick it a little bit into thinking that the "L" is two ordinary Integer elements. I think you mentioned one of the PanelView family operator interfaces before.

Share this post


Link to post
Share on other sites
I come from a different background than Ken so I see things a little differently. Doesn't make him wrong. Doesn't make me right. It's just the difference in how different businesses handle programming. I come from the natural gas processing / crude oil pipeline side of things. To me an average tank has a floating roof and holds 60,000 barrels of crude oil. That said, this is how I would handle your situation. (1) I would use the SCP function to scale all of my analog values. Even if they aren't used. For instance, if I had an 8 point AI card I would have 8 SCP's, one for each point, in their own routine. I would assign the output to a floating point. F8:0 would hold the scaled value for I0:0. F8:1 would hold the scaled value for I0:1. etc. Unused points get scaled 0-100%. Why do I do this some would ask. Lets say it's 2 am and a critical IO point failed on the card (trust me, it happens). I never fill a card up so I always have a couple of spare points. Rather than replace the card, I move a pair of wires over to the new (spare) IO point (all of my IO is wired to individual fuses so that's easy), change the scaling. Search for F8:? and replace with the new value, and bam... I'm done and we are back online. Plan for the future, the future could be now... (2) I use floating points for all of my scaled analogs because I want decimal point resolution for my analogs. For a tank level I scale the input for the number of feet (or inches if it's a smaller tank) that the tank can hold. I do this because we always have low level shutdown, low level alarm, high level alarm, and high level shutdown for tank levels and the number of feet of fluid in the tanks is something that an operator can relate to better than gallons or barrels. (3) All of the alarm and shutdown setpoints are held in consecutive floating point registers so they can be changed on the fly or from an HMI. I can hear you saying "but I want to know how many gallons are in the tank". So calculate it. Lets say your 32000 gallon tank is 10' tall. 10' x 12" = 120". 32,000 gallons / 120" = 266.67 gallons per inch. So multiply your scaled feet number by (12 x 266.67). Do it with two MULT's so you can copy the function and reuse it by changing the scaling factor or just use 3200 (gallons per foot). Store the result in a floating point register. They are there. Use them. Give the SCP a try Input= Address of input Input Min.= 6400 (depends on what kind of card you have, which PLC, and what you can set the type of AI to. Scaled for PID (my favorite) is 0-16383 so for the In Min it would be 0 but I don't think the 1400 lets you use scaled for PID ) Input Max.= 32000 (depends on what kind of card, PLC, and what you can set the type of AI to. Scaled for PID (my favorite) is 0-16383 so for the In Min it would be 16383 ) Scaled Min.= zero value of transmitter range Scaled Max.= 100% value of transmitter range Output= F8:? or whatever your floating points registers are As a side note, some people will put a LIM in front of the SCP (same rung) and set the low and high limit just above the min and just below the max (test = IO point) so that scaling doesn't occur unless the IO point is within range. Then set the in min and in max to the same value as low lim and high lim in the SCP. I don't usually do this. I've had good luck with IO points and don't feel the need to "jink" with normal scaling If you want I can send you a little LACT program that has a lot of different functionality in it. It's for a 1200 and as a complete program it's not going to do you much good. However, for individual ideas it might be useful. PM me your email address and I'll send it on. Mike Edited by Michael Lloyd

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0