AB Math instruction SQR

Jnelson

Member
Join Date
Apr 2002
Location
Philadelphia, PA
Posts
198
I've decided, having some extra time on my hands, to learn some more about some of the AB instructions that I do not use often. Some of these instructions might benefit me greatly in my programming, but are unknown to me. Primarily because my SLC manual lacks clear examples of how to use some of them or because I havent had adequate education to understand them.

Anyway, I am just starting at the front of the manual and going through it, if I find a instruction that I do not understand I will post it here and hopefully someone could help me. My hope is that one of you could give me an explanation and possibly a simple example of the use, and in what type of industry/equipment it might be used in.

I am sure that there are more people out there that would like to learn how some of these instructions work. Most of these instructions are the same for all brands, just called something different, so it should help people even if they do not use AB.

So here is my first one SQR (Square Root)

This instuction calculates the square root of source A and places the result in the destination. What reason would one have to know the square root of a number in a plc?

Thanks for your time.
 
Three reasons come to mind

1. Pressure or Flow
Here ganutenator ( what is a ganutenator? It sounds like a mythical creature ) needs to calculate flow through a valve using the differential pressure across the valve. The flow is proportional to the square root of the pressure across the valve.

2. Calculating the velocity after ramping at acceleration rate A for distance D. V = sqrt(2*A*D)

3. Pythagorean theorem

C = sqrt(A*A+B*B)

I have used this in some X Y positioning.
 
Peter,

As a simple example of your number 1 explanation.

If I have two pressure transducers, one on each side of a pressure regulator. The incoming pressure is 100 psi and the outgoing pressure is 80 psi, so the differential pressure is 20 psi. That means that the flow is 4.472 gpm correct? Since this is an entirely pressure dependent equation, than pipe size should have no effect on it?

For your number 2 example.

basically this is velocity=speed, acceleration rate=time distance=well, distance.

So if it takes me 15 minutes to walk 1 mile than.

2*15*1 = 30sqrt = 5.477 mph is that right? Seems like it should be 4 mph.

Where does the 2 come from?

I know this might seem elementary and most people might know it, but you would be
suprised at how many people don't know.

I am not touching number three since I cannot even pronounce it.
 
Last edited:
NO!!!!!

Jnelson said:
Peter,

As a simple example of your number 1 explanation.

If I have two pressure transducers, one on each side of a pressure regulator. The incoming pressure is 100 psi and the outgoing pressure is 80 psi, so the differential pressure is 20 psi. That means that the flow is 4.472 gpm correct? Since this is an entirely pressure dependent equation, than pipe size should have no effect on it?

NO!!!! I said the flow is PROPORTIONAL to the sqrt(pressure difference). The proportional term is the valve constant. See ganutenator's press or flow thread.

Jnelson said:
For your number 2 example.

basically this is velocity=speed, acceleration rate=time distance=well, distance.

So if it takes me 15 minutes to walk 1 mile than.

2*15*1 = 30sqrt = 5.477 mph is that right? Seems like it should be 4 mph.

No!!!! If one accelerates at 100 inches per second per second, at .5 inch the velocity is 10 inches per second.

In this case D = .5 inches and A = 100 inchess/sec/sec.

v=sqrt(2*.5*100)

v=10

In your example, 15 minutes to walk 1 mile is not an acceleration, it is a rate or velocity. That is why your equation doesn't work.

Jnelson said:

Where does the 2 come from?

Dist = .5 * accel * time * time

time = velocity / accel

therefor:

Dist = .5 * accel * ( velocity / accel ) * ( velocity / accel )

one of the accels on top and bottom cancel out

Dist = .5 * velocity * velocity / accel

mulitply both sides by accel * 2

Dist * accel * 2 = velocity * velocity

Now take the square root of each side

sqrt(Dist*accel*2) = velocity


Anybody. How do I use the Pythagorean theorem to calucalte velocity in the x and y directions when I know the desired speed along the hypotenuse?
 
Last edited:
Jnelsen,

3. If you have ever used the 3x4x5 measurement for checking if something is square, then you have used Pythagorean theorem.

Example: If you were placing forms for concert and you want to measure if the corner was square you would measure 3’ on one side and mark then measure 4’ on the other side and mark and then measure the distance between the marks and it should be 5’ if the forms are perpendicular (square).

Peter,

r=[((r*cos(theta))^2+r*sin(theta)^2)]^1/2

Bob O.
 
Last edited:
Square root is such basic instruction for just about
any calculation. You might not need it in your applications
but did you try to think what does it take to make one
on your own if you need it?
We use it often to calculate position in space...
 
Looks that Peter AND Bob beat me in posting,

Well thanks Peter for the great examples and Jnelson for the thread

To clarify more the answer

proportional NOT equal

Acceleration NOT speed
 
Last edited:
I done a good job on that one.

Peter,

To be perfectly honest with you, if what I did was wrong than I have no idea what you are talking about. I guesss a couple math courses at the community college would help.

I need to look this over a little longer to try to figure it out. I understand the 345 method as I use that quite often, I just didn't know it had a fancy name.

I will work on it.
 
NO!!!! I said the flow is PROPORTIONAL to the sqrt(pressure difference). The proportional term is the valve constant. See ganutenator's press or flow thread

Peter,

So basically you are just saying that the flow proportionaly follows the pressure difference. I thought you were showing how to detirmine flow rate from pressure differential.

"The proportional term is the valve constant", What do you mean by this?

Still working on the velocity.
 
Last edited:
Anybody. How do I use the Pythagorean theorem to calucalte velocity in the x and y directions when I know the desired speed along the hypotenuse?

I use the cosine of the angle between x and y, multiplied by the velocity, gives the velocity in the x direction. Sine multiplied by the velocity, gives the y direction. Not sure if this is the answer Peter was looking for, however......
 
Last edited:
Not the answer I was look for but correct anyway.

tom_stalcup said:


I use the cosine of the angle between x and y, multiplied by the velocity, gives the velocity in the x direction. Sine multiplied by the velocity, gives the y direction. Not sure if this is the answer Peter was looking for, however......

if I know the velocity needs to be 10 inches per second and the distance along the x axis is 4 and the distance along the y axis is 3 then I calculate the real distance traveled 5 = sqrt(3*3+4*4). I then Velocity X = 10 * 4 /sqrt(3*3+4*4) and Velocity y = 10 * 3/sqrt(3*3+4*4).

did you try to think what does it take to make one
on your own if you need it?

Try this when you don't have a calculator (y)

"The proportional term is the valve constant", What do you mean by this?

A flow control valve has a rating. Hydraulic valves have a rating of X GPM/(delta P). Most hydraulc servo quality valves are rated at 70 bar or about 1015 psid. If a hydraulic valve has a rating of 20 gpm at 1015 psid and the psid is actually 500 psid then

flow = 20 * sqrt(500/1015) or 14 GPM. This can also be done like this:

flow = K *sqrt(500) where

K = 20/sqrt(1015) THIS IS THE VALVE CONSTANT.
 
Hi, I'm new here and just learning programing. This use of controlling hydraulic proportional valves with a plc instead of a proportional valve controller sounds interesting. Do you need a special input and output card for these functions?

Thanks for your info.
 
Hydraulic motion/force control spoken here.

Mrnittny said:
Do you need a special input and output card for these functions?
Thanks for your info.

It depends on how demanding application is. In general I would say yes, a specail hydraulic controller is needed.

WHY?

Hydraulic controllers have a MDT interface for Temposonic or Balluff rods which are standard position feedback devices in the hydraulic industry.

Hydraulic controllers take into account the different gains in the extend and retract direction due to the different surface areas on the piston. Remember, one side of the piston had a rod so its surface area is less.

Some hydraulic motion controllers like the 1756-HYD02, 1756-M02AS, 1746-QS, and MMC120 ( Modicon Quantum ) fit in the back plane of the PLC. The Control Logix modules have nice motion control blocks that can be used in the ladder. Others like the RMC100 communicate with many different PLCs using Ethernet, Profibus, Modbus Plus etc...
The RMC100 has can execute on its own program if need be and the program can be changed on-the-fly from the PLC. MTS has a hydraulic contoller built into the MDT rod. Rexroth and Moog also have motion controllers. Norm can tell you more about the Rexroth controllers.

A PLC is not fast enough or have a regular enough scan time to do very good motion control.

In addition, the RMC100 can interface to many different feed back devices ( Analog, Encoder, SSI, and MDT ). It can control position or force or limit both. This is good when you want to grab a cinder block, but not turn it back into sand. In otherwords it has some very advanced algorithms that can be enabled by some very simple commands.

Google for "hydraulic motion control".
 
First I'll second all Peter said. An interface card is recommended.

Rexroth has been around for a while so it has a few generations of controls starting with ramp generators for open loop contorol. Then it has a card that was the "workhorse" for a while know as the DMX that will do closed loop position or pressure (force) control. A PLC will interface to a card such as this for start/stop and perhaps analog reference signals. The new generation HACD card has configurable control loop structure so you can feed contol loop signals into other loops or close loops around one another. Another rexroth option is the HNC with is actuall a CNC (Computer Numerical Control) controller programmed in "G Code" familiar to the machien tool industry.

One area I think may be up and coming is valves with more sophisticated "on board electronics" which already have been able to eliminate the interface card for simple applications.
 
We have often used square root for determining flow from a differential pressure transmitter connected to a Bernouli's Law type device. The primary device can be an orifice plate, a venturi, or a Pitot tube. In any of these devices the velocity of the fluid is proportional to the square root of the differential pressure.

I would never use the pressure drop across a valve for measuring flow. The valve constant, Cv, varies with valve position, fittings on the valve, etc. Manufacturing tolerances also impact the differential pressure. The most significant factor is valve position, which in a flow control application is always varying. This is certainly the case in process control applications.
 

Similar Topics

Hello, hope everyone is doing well. I'm programming on RS Logix 5000 / Studio 5000. Is there a way to do math inside an instruction using tag...
Replies
4
Views
2,860
Hi guys, I am trying to create a very basic totalizer in Logix; I need to keep track of runtime for pumps, their number of starts too; I need...
Replies
7
Views
4,316
Hi guys, I have a stupid question, I used a lot of Math & Compare instruction (MUL, CPT, .. )in my PLC, will it harm or one day PLC will cause...
Replies
8
Views
2,660
Hello all, I am fairly new to Allen Bradley programming so bear with me.. ( I have prgogrammed microcontrollers and computers before). Im working...
Replies
45
Views
11,922
Quick question about the order of execution of math instructions. Which ones execute first, second and so on? I have a rung that looks like it...
Replies
6
Views
5,576
Back
Top Bottom