Sine function for wave simulation with a linear actuator

I'm trying to simulate the vertical movement of a wave with a pneumatic cylinder. I have a wave function [Asin(2pi*f)] for the speed that the rod of the cylinder must have at every instant. The problem is that I can't implement it on Arduino.

I'm sure it must be something very easy for the most experienced programmers, but all I could find on the internet were constant speed codes.

I'd be very thankful if someone helped me with this.

All the best.

Are you using an adjustable needle valve? Do you have constant air pressure? What have you tried and what did it actually do?
Are you using a DOUBLE cylinder?

don't you mean position?

consider

output

0.00
0.59
0.95
0.95
0.59
-0.00
-0.59
-0.95
-0.95
-0.59
0.00
0.59
0.95
0.95
0.59
-0.00
-0.59
-0.95
-0.95
-0.59
0.00
0.59
0.95
0.95
0.59
-0.00
const int Period = 10;
int n;

void
loop (void)
{
    float x = sin (2 * PI * n++ / Period);
    Serial.println (x);
    delay (500);
    
}

void
setup (void)
{
    Serial.begin (9600);
}

The OP should gain some practical experience with pneumatic cylinders before contemplating any critical movements by adjusting air pressure, if that is what is being contemplated.

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.