calculate x positions and transfer to array in Step 7

BNA

Member
Join Date
Sep 2003
Location
Give
Posts
117
Hi'

I am writing some software where I calculate a number of encoder stop points, from a teached start and stop point with a pre defined distance between.

My problem is that it became very complicated, so I was hoping that one of you could give me a hint to make it a bit smarter.

My first idea and what i made was, I make a calculation (Stop-Start)/distance this gives me the number of points and from there multiply my way to each point.

What I would like was, to make an FB calculating the actual position and putting each position into a datablok, perhaps an array, and from there let my program acces the individual points.

Any ideas ?

Regards
Brian
 
Atleast for me its not clear what you actually want. The language barrier;) Do you have fixed start and stop, then you want dynamically modify amount of stops in between? or does your start and stop point also vary?

Do you have SCL?
 
My start and stop points is being teached by the operator, he moves the machine to the starting point and saves this by pressing a button, then he moves to the stop point and saves this one to.

It is predefined that I have to move 220 counts between each stop, starting from the teached start point until it reaches the stopping point.

I hope this makes sense and Yes I have SCL.
 
I still don't get it. How can you have 220 counts between each stop when there is only one stopping point.
 
Eksample:
The user teaches from where the machine should pick the first items lets say 1000 (Value from encoder) then he teaches how far it is allowed to work let say 2000.

He the set the machine in automatic and it moves to point 1 = 1000 and picks an item up, brings it to a default position.
The I move to Point 2 = 1220
and to Point 3 = 1440
and to point 4 = 1660
and to point 5 = 1880
and when i reach the Stop = 2000 I start all over again.
 
Is it so that you have, Area start and end point, and in that area you have stop between 220 counts and machine does something then. After finished doing it it goes another 220 etc. And stops when it is at end position?
 
It is a cranesystem with x and y coordinates, the user defines the working area by pointing out 2 corners, then I calculate the digging points X and Y with a distance of 220 counts.

Perhaps this makes more sense.
 
Hi there
Make two memories say MD10 and MD20
MD10-->Current_pos_count_store
MD20-->Actual_counts (here encoder counts are coming)

At all the stop points you just need to make these two memory contents equal.
Say you start machine by making MD10 and MD20 having 1000 counts
Now when operator presses GO button MD20 starts increasing and if MD20-MD10>220 then stop and Make MD20=MD10, wait till Go button is pressed again.

And if at any point MD20 crosses Stop Counts value then STOP again. In this way you can make backward journey too.
 
Sorry, but we are getting away from my actual question, so let me try again.

I am looking for an easy way to calculate all the points and then moving them into a DB.

As it is now I am doing it like this.

(2 Teached point - 1 Teached point)/Distance between = Number of positions.

Then i calculate the points one by one.

1. Pos = 1 Teached point
2. Pos = 1 Teached point+distance between
3. Pos = Result from pos 2 + distance

And so on until I reach Teached end position, all the results is moved into a DB.

This works, but when the number of positions is different from each time the working area is teached it is getting a bit complicated and gives me a lot of calculations.

So what I was looking for is a way to calculate all the positions and moving them into an array in an more compact equation handling the varios number of positions.
 
I decided to do like this :

FUNCTION FC100: VOID
VAR
x : BOOL;
x_old : BOOL;
xEdgeDetected : BOOL;
END_VAR
xEdgeDetected:= x AND NOT x_old;
x_old:=x;

IF xEdgeDetected THEN;
teach.X_Step_Current := teach.X_Step_Current + 1 ;
END_IF;

x := teach.count_up;

// Calculate steps from Delta max
teach.x_Steps := (Teach.x2 - Teach.x1) / teach.Delta_Max ;

// Add 1 to avoid rounding errors
teach.X_Steps_Calc := teach.x_Steps + 1 ;

// Calculate new Delta X
teach.Delta_Calc := (Teach.x2 - Teach.x1) / teach.X_Steps_Calc ;

// Calculate target X
teach.X_Target := Teach.x1 + ( teach.X_Step_Current * teach.Delta_Calc) ;

// Reset
IF teach.X_Target > teach.x2 THEN ;
teach.X_Step_Current := 0 ;
teach.x_Target := teach.X2 ;
END_IF ;
END_FUNCTION

The only problem is that the rising egde detection (Found the code somewhere in here) is not working, I have tried several solutions but with out any luck, can anyone see whats wrong.

Thanks
Brian
 

Similar Topics

Hi everyone, This is my first time posting, so please forgive any omissions or mistakes. I am attempting to control the velocity of a stepper...
Replies
18
Views
1,003
Good morning, I have a question. I don't know much about ST yet I would like to calculate the average number of products per hour. how do I do...
Replies
22
Views
2,963
Can someone help me with this? I'm no good at SCL - virtually everything I've done so far has been ladder logic. The return value from the...
Replies
13
Views
1,107
I want to calculate the energy consumed from instantaneous power. Can this be done using the TOT block with timebase set to Hour?
Replies
2
Views
691
Hi everyone, I have to calculate the length in millimeters of a glass that enters a transport (I don't know the speed yet) through a barrier...
Replies
15
Views
3,464
Back
Top Bottom