He all.
In the past there was a code for the Expression1. It called Adv Smoother.
Code E1:
Code:
n@Advanced_Smoother
i@Target Speed Acceleration
o@Value Active
# Activate when target has been set
~Target -> Active = 1;
# Main computation loop
first() | clk() ->
# Precomputation of inputs
!Acceleration -> Acceleration = Speed * 50 * 2;
AccLength = Speed^2 / Acceleration / 2
AccRate = min(Speed, Acceleration / 50)
# Precomputation of variables
Distance = Target - Value
Direction = Distance >= 0 ? 1 : -1
# Calculate ideal speed modifier
IdealRate = Speed * Direction
abs(Distance) <= AccLength ->
IdealRate *= sqrt(abs(Distance - Rate / 50) / AccLength);
# Calculate final speed for iteration
Rate += clamp(IdealRate - Rate, -Acceleration / 50, Acceleration / 50)
Value += Rate / 50
# Check if value has reached target
Active = abs(Rate) > AccRate
| abs(Distance) > AccRate / 50
!Active -> Rate = 0, Value = Target;;
# Schedule the main loop if active
Active -> interval(20); Because E1 no longer exists i want to make it E2
Well...
Code E2:
Code:
@name Advanced Smoother
@inputs Target Speed Acceleration
@outputs Value Active
@persist AccRate AccLength Distance Direction Rate IdealRate
# Activate when target has been set
if(~Target) {Active=1}
# Main computation loop
if(first() | clk()){
# Precomputation of inputs
if(!Acceleration){
Acceleration = Speed * 50 * 2
AccLength = Speed^2 / Acceleration / 2
AccRate = min(Speed, Acceleration / 50)
}
# Precomputation of variables
Distance = Target - Value
Direction = (Distance >= 0 ? 1 : -1)
# Calculate ideal speed modifier
IdealRate = Speed * Direction
if(abs(Distance) <= AccLength){
IdealRate *= sqrt(abs(Distance - Rate / 50) / AccLength)
}
# Calculate final speed for iteration
Rate += clamp(IdealRate - Rate, -Acceleration / 50, Acceleration / 50)
Value += Rate / 50
# Check if value has reached target
Active = ((abs(Rate) > AccRate)|(abs(Distance) > AccRate / 50))
if(!Active){
Rate = 0
Value = Target
}
}
# Schedule the main loop if active
if(Active==1){interval(20)} Well the code worked so far.
But the only thing is that the hydrolics don't stop!
if the target is 50 then it swings between 40 and 60.
It don't stop.
if the target is 0 its the same.!
Can someone help me?`
Q: Why you use not the Gate Time - Smoother
A: Becouse its not that smooth then the old E1 Adv Smoother
Bookmarks