Trig functions in S5 CPU945

Hi Martin,

Not sure there are too many complex arithmetical functions in S5, even for a 945; I remember sending numbers to a PC for Sqrt rather than do it in the PLC. you can of course use pythagarean triangular methods such as Tan = Op/Adj etc.

I nearly won a trip over your way yesterday on a service visit but sadly I'm in China for another week or so.

all the best,

Nick
 
Hi Nick

You can probably guess that I'm looking at unload angles. The machine in question was made in Stevenage (!), and strangely uses a Tan approximation.

The existing function has rewind arm length (hypot.) roll radius + freefall height (opposite) so according to my understanding of basic trig should be using Sin?

I'm not sure why they're using Tan?

Cheers,

Martin
 
You've been over there for a while now haven't you? Nearly as long as Neil's been in Pakistan!
 
Even if you can it will be a lot of work. Sometimes there is an easier way.

Hi,

I'm looking to do some trig functions in a CPU945. Is this possible?

Thanks,

Martin
A lot depends on whether the S5 can multiply a 16 by 16 bit number and get a 32 bit result and then divide that 32 bit number by a 16 bit number to get a quotient and remainder.

I approximated trig functions on a 80186, a 16 bit microcontroller, by using a 256 entry trig lookup table. I converted all angles from 0 to 2*PI or 0 to 360 degrees to a 16 bit number 0 to 65535. If the angle was over 65536 I still used only the lower 16 bits. The upper 8 bits of the lower 16 bits were used to index into the table and the lower 8 bits were used to do an linear interpolation between the two table entries. I represented PI by multiplying by 355 and then dividing by 113. This provided more than the 16 bits of precision that I could use.

I used this table to make sinusoidal motions for test systems and the s-curves used the trig tables too.

Sometimes people ask the wrong question. What are you going to do with the trig functions? Sometimes the trig functions are not necessary.
 
Hi Peter,

The application is an arm holds a roll of rewound material of a given radius. The arm unloads radially onto a trolley which is of fixed height.

We know the length of the rewind arm (hypotenuse) and we know the radius of the roll + our "freefall" distance above the trolley. This is the distance above the trolley that the drive should switch off and allow the arm to coast down. These two dimensions together are the "opposite" side of the triangle.

I guess one way to do it, as you say, is to create a DB which has a range of pre-calculated values of the relevant function. For example, divide the radius range by 255 and then calculate the trig function required for each "segment".

Thanks again,

Martin
 
I think there is no instructions for trig in s5. But I know there is/was additional function blocks you could buy from siemens to do trig functions. They had somekind of limitations.

S5 cpu945 has 32bit accus.

I suggest you take Peters formula and make your own FB.
 
I get really frustrated when it takes takes two posts just get this far.

Hi Peter,

The application is an arm holds a roll of rewound material of a given radius. The arm unloads radially onto a trolley which is of fixed height.

We know the length of the rewind arm (hypotenuse) and we know the radius of the roll + our "freefall" distance above the trolley. This is the distance above the trolley that the drive should switch off and allow the arm to coast down. These two dimensions together are the "opposite" side of the triangle.
So you do you need to know the angle between the arm and the trolley?
That would be the arcsin(). The adjacent side length. That only requires a square root.

I guess one way to do it,
Do what? What trig function?
If you just want to turn off a drive can you you a photocell or prox switch. If you have an encoder then then you can do this by the angle above the trolley.

It is obvious that you don't need all trig functions and perhaps you don't need any trig functions.
 
Here's the results using S7 for computing 1200.0*sinx using the in-built sin function (DB3),
and also using the approximation
sin(x)= x-(x^3)/3! + (x^5)/5! - (x^7)/7! (DB2)

If your arm is approx 1200 long then the error using the approximation is less than 1mm

You can convert the S7 math to S5

sinx.JPG
 
Hi Martin,

I should be home for Easter and Neil is already home from Pakistan... I wonder if he's been out for a curry yet?

Anyway, Do you really need the accuracy? My reccolection is that we used diameter - Min_Diameter * X + Min_Diameter_Offset right up to 1998 at the point where everything was re-written in S7. Seems like only yesterday that we sat down to discuss changing the world to S7. This method is increasingly innacurate the bigger the diameter roll you produce but how accurate do you need to be? You could always add an extra factor of diameter to get you closer scaled between 1 with the unload arm horizontal and the calcualted error at maximum diamter - you wouldn't be more than a couple of mm off.

Are you looking to servo to a postion for some unloading kit?

It puts me in mind of a story:

An engineer and a mathematician (men in this case) were walking together down a country road when the spot a beautiful naked woman standing in the middle of a field. A leperachaun pops up and says to the men "If you can reach the woman, you can have your way with her; but you can only reach her by jumps and each jump will be half the distance between you and the woman."

The mathematican thinks about it, the engineer gets out his note book and makes a quick calculation. "I'm off" says the engineer, "but you never actualy reach the woman" retorts the mathematician. The engineer replies "but after 7 jumps I'll be close enough for all practical purposes"

Nick
 
I really hate it people will not say what they really need to do.

MartinW, why didn't simply say you needed a tan() function that can must be implemented in floating point if the S5 doesn't support floating point then say you need a tan() function implemented using integers.

Even L D [AR2,p#0.0] didn't know what you wanted and he provided a sin() function.
 

Similar Topics

salve, qualcuno mi può suggerire alternative all'uso dei fronti di salita e discesa su siemens, e nel caso se ci sono relativi vantaggi ? grazie
Replies
5
Views
2,350
I wonder if anyone knows the time-lenght of the output-pulse from a f_trig or r_trig function. If I use one of the above in one POU to activate a...
Replies
2
Views
1,458
Find the length of the dotted line. I blew through it and got the wrong answer, then realized the complication. My second attempt was correct but...
Replies
8
Views
1,981
What is the most inexpensive PLC that supports trig functions (sin, cos, tan). Thanks in advance
Replies
5
Views
3,203
Hello all, I am feeling math stupid today and maybe somebody can give me the nudge on this one. I have a function I am trying to implement in a...
Replies
8
Views
1,965
Back
Top Bottom