How to change tag to minus value in CLX

Join Date
Jul 2007
Location
Kiruna
Posts
600
Hi Guys,

I need to write a routine to calculate direction based on 2 Velocities. I'm trying to implement an ATAN2 VB script i found online into ladder as follows:

If y > 0 Then
If x >= y Then
Atan2 = Atn(y / x)
ElseIf x <= -y Then
Atan2 = Atn(y / x) + Pi
Else
Atan2 = Pi / 2 - Atn(x / y)
End If
Else
If x >= -y Then
Atan2 = Atn(y / x)
ElseIf x <= y Then
Atan2 = Atn(y / x) - Pi
Else
Atan2 = -Atn(x / y) - Pi / 2
End If
End If

The problem i have is here: ElseIf x <= -y Then

I want to use a LEQ instruction but how can I make Y a minus value?
 
If you are using ladder logic:
NEG.JPG
 

Similar Topics

Basically I have created a bunch of local tags, is it possible to convert all of these to a global tag? Or would I need to re-add everything all...
Replies
5
Views
1,126
I have a Red Lion G09 scanning 8 Invertek P2 VFDs via modbus RTU - I've setup necessary comms and tags and all works well. I have a 'Settings'...
Replies
3
Views
1,864
Hello all, wondering if there's a simple way to detect when a tag's value has changed. I have some tags whose values get updated every so often...
Replies
4
Views
1,650
Is it possible to dynamically change Tag Names (in real-time) on these PLCs? I'm guessing the answer is "NO", right? Just externally, then...
Replies
10
Views
3,845
Hi All. I have been tasked with the HMI aspect of a PLC 5 to Logix 5000 upgrade. The plc code has been completed by others, it's up to me to...
Replies
6
Views
2,183
Back
Top Bottom