To put it another way...
Wanted to explain the problem better:
Imagine this Sequence: A typical "S"curve ... generally starts from zero accelerates by a specified amount, then moves at a constant velocity until nearing the end point of the move, where it decelerates by a selected amount and stops at the "end point" .. a distant positive value. Then after a few seconds, another move, slower than the first slowly ramps at a constant speed back to zero... and, awaits the next move programmed and launched by a NA HMI
That sequence is what I'm trying to do.
In Ladder (Omron), you would probably use the MC_MoveAbsolute function block to make this move. Very easy, and almost intuitive...
But.. what if that "curve has to be a "cosine wave"? It starts at zero and moves to the positive end position, and only the "path" is programmed,
not the velocity or the acceleration.
Now you would probably use the MC_SincMoveAbsolute fb. And the "path" would be calculated in ST .. with the only inputs from the HMI as "Amplitude" and "Period". The final positive end position (amplitude), and the time (in seconds) it would take to get there. As we are not moving in a complete cycle, only a half cycle ... the "time" could be thought of as half the period.
This is some brute force programming, I cannot do .. yet
I can generate a sin or cos routine in ST (With some help from Tyler Corbett):
(1) Pi:=3.141592;
(2) SampleTimeSec:=
TOLREAL(
TimeToNanoSec(GetMyTaskInterval()))*1e-9;
(3) SinTime:=
ModReal(SinTime+SampleTimeSec,
Period);
(4) FSin:=(
Amplitude *
SIN( 2 * Pi * SinTime/
Period);
(5)
Sine:=
Sine + Fsine
The global variable
Sine is sent to the Position input of the MC_SyncMoveAbsolute (or some
Final_Move sequence in ST)
Now, The
trick is to use 1/2 a Cosine wave (a 90 degree phase shift of a sine wave), and only use the first 180 degrees of the wave.. where it goes from zero to maximum positive (yes, it really goes from -1.0 to +1.0 .. but.. there will be an final rung for OFFSET (6)
Final_Move:=
Offset + Sine so that all moves are positive)
This equation must run only once, unlike the above example which would run forever. After doing that one move.. there is a time delay (TON) then the position ramps slowly back to zero .. and waits for another run.
I'm asking for any programming ideas that would control the equation for use of only a half cycle.. which starts at zero and moves positive to
the input: Amplitude. I don't expect the actual program.. just some text explaining a good method to control the process. Please.
I assume the COS instruction would work just as well .. I just don't know how to use the best instructions to control the position equation...
Thanks Much, Regards, Michael