plc5 and trig

Thomas

Member
Join Date
Mar 2003
Posts
167
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 plc5/30 that works fine in a spreadsheet using the ATAN2. The plc only has an ATAN function. This is creating havoc (mostly with my coffee drinking). How can I do the equivelant of the ATAN2 function in a plc5?

I know this should be obvious to me, but I'm not getting it.

With great humility,

Thomas
 
I think what I am getting stuck on is the limits. ATAN works for +/- pi/2 while ATAN2 is good for +/- pi radians....
 
That's the result of the negative argument. ATAN can't tell whether the negative argument was caused by the x or the y coordinate. You'll have to add ladder logic to keep track. If x is negative, the angle is between 1.5 * PI and 2 * PI. If y is negative, the angle is between PI/2 and PI. If both x and y are negative, the argument is positive and the angle is between PI and 1.5 * PI.
 
I just realized that this is essentially the same as Steve said above me. (The Wiki article will probably help though).


I would do some compare statements on the x and y arguments, then implement it with the atan instruction and modify the output depending on the original quadrant.

This article may help.
http://en.wikipedia.org/wiki/Atan2
 
Last edited:
Progress

This is what I have so far.

N7:105 X value
N7:107 Y value
F8:23 quadrant value to be added to the arctan

 
SOR BST LES N7:105 0 MOV 0.0 F8:23
NXB GRT N7:105 0 MOV -3.141593 F8:23
NXB EQU N7:105 0 BST GRT N7:107 0 DIV 3.141593 2.0 F8:23
NXB LES N7:107 0 DIV 3.141593 -2.0 F8:23
NXB EQU N7:107 0 MOV 0.0 F8:23 BND BND EOR

 

Similar Topics

I am using the following formula and I am getting error, Invalid Expression - too many closing parenthesis. when i copy the formula to notepad or...
Replies
4
Views
152
Preface: Kinda long, so I made section titles Intro: I just want to see if anyone here has seen anything similar. A PLC5-40 series C enhanced...
Replies
3
Views
365
Hi, can anyone help me get a pdf file for this RSP files. They are from a PLC5. Thanks
Replies
5
Views
517
Hello all, I am seeing this behaviour where an integer file (N46:33), has an integer in binary (11110) which is 30 in decimal. I did a...
Replies
7
Views
516
Back
Top Bottom