Reactions:
|
Working people make mistakes, some people do never make mistakes!
I work to live, my boss thinks I live to work!
Here are the functions i've made using mathematical functions for movement with a XY-axis (FM353/4) in a plc.
Javascript
download awl source (incl. functions.)
Symbol table:
Calc. X,Y Position | FC 1045 | FC 1045 | Calculate X,Y position from P1, P2, cols, row and position. |
Calc. X,Y Speed | FC 1046 | FC 1046 | Calculate X,Y Speed for a linear XY movement. |
Matrix position: FC 1045: Calculate X,Y position in a matrix
Input: |
EN |
Enable function (Here the function is started once if the program goes from step[10] to step[11]) |
P1_X P1_Y |
First coordinate of the matrix (X,Y) |
P2_X P2_Y |
Last coordinate of the matrix (X,Y) |
n_X |
Number of positions in the X line. |
n_Y |
Number of positions in the Y line. |
position |
The required position in the matrix. (starting on the X line.)
Minimum value is 1 (the first in the matrix)
Maximum value is X times Y (the last in the matrix)
|
Output: |
Pos_X & Pos_Y |
Calculated coordinate of the position required |
ENO |
ENO = high (error) if Position > n_X ·n_Y
OR position < 1
OR n_X = 0 OR n_Y = 0
OR n_X and n_Y are both 1. |
Positions are calculated as Double integers. (max. L#+2.147.483.647)
Formal used inside:
offset (X,Y) |
= |
(P2_X - P1_X) / (n_X - 1) ,
(P2_Y - P1_Y) / (n_Y - 1) |
position (X,Y) |
= |
P1_X + ((Position - 1) MOD n_X) ·offset_X ,
P1_Y + ((Position - 1) DIV n_X) ·offset_Y
|
Linear speed: FC 1046: Calculate X,Y Speed for a linear XY movement
top
Input: |
EN |
Enable function |
P1_X P1_Y |
First coordinate of the line |
P2_X P2_Y |
Last coordinate of the line |
MAX_Speed |
the maximum speed the axis may drive |
Output: |
Speed_X Speed_Y |
Calculated Speed of the X and Y axis |
ENO |
ENO = high if error |
|