Go Down

Topic: SplinesMaster Library - How the add additional graphes? (Read 368 times) previous topic - next topic

BlueGene

Hi,
I am using the SplinesMaster Library to control stepper motors:
https://github.com/kerinin/arduino-splines

It works fine with one motor, but now i want to use up to five motors. To get better performance from the arduino, I want to calculate the values in advance, save them in a txt-file on a SD-card and read them when its necessary.

It should look like this:

X U V W Y Z
-------------
0 0 0 0 0 0
1 2 3 4 5 6
2 4 8 10 12 16
3 1 2 2 3 4
...
1200 1000 500 200 800 300

U,V,W,Y and Z depend on X, which is the current position from the stepper.

Now I need your help:

What is the easiest way to add additional graphes(U,V,W and Z) and save them as mentioned above?

I want to use 9 points (incl. the both Catmull points at the ends).

PaulS

What part of this project are you having problems with? Calculating the values? Storing them on the SD card? Reading the file on the Arduino? Parsing the data? Using the data?

BlueGene

Calculating the values and storing it to the SD works fine, but I´ve only tried with one graph, as in the catmull-example. Now I want to calculate 4 other graphes at the same time.

Here is the original example:

Code: [Select]
  float x[7] = {-1,0,1,2,3,4, 5};
  float y[7] = { 0,0,8,5,2,10,10};
  tempCurve.setPoints(x,y,7);
  tempCurve.setDegree( Catmull );
 
  for( float i = 0; i <= 4; i+= .1 ) {
    float temp = tempCurve.value(i);
    Serial.print(i);
    for(float j=0; j<= temp; j += .2) {
      Serial.print( "*" );
    }
    Serial.print( "   " );
    Serial.println(temp);
  }


The function in the for-loop only calculates the values for x and y.

Now I want to have a working code which looks like this:

Code: [Select]


float u[7] = {-1,0,1,2,3,4, 5};
float v[7] = { 0,0,8,5,2,10,10};
float w[7] = { 0,0,8,5,2,10,10};
float x[7] = {-1,0,1,2,3,4, 5};
float y[7] = { 0,0,8,5,2,10,10};
float z[7] = { 0,0,8,5,2,10,10};
  tempCurve.setPoints(u,v,w,x,y,z,7);
  tempCurve.setDegree( Catmull );
 
  for( float i = 0; i <= 4; i+= .1 ) {
    float temp = tempCurve.value(i);
    Serial.print(i);
    Serial.print( "   " );
    Serial.println(temp);


And temp should output the values for u,v,w,y and z. Now my problem ist, that I don´t know which parts of the  main code I have to modify to add additional graphes.

PaulS

The setPoints() method defines the X and Y values that a spline is going to be created through. The setDegree() method defines how close the spline will come to the points.

The value() method gets the coordinate of a point at a location along the spline.

Quote
The function in the for-loop only calculates the values for x and y.

Yes.

Quote
Now I want to have a working code which looks like this:

The original function takes a collection of coordinates on a plane, and creates a 2 dimensional curve.

What would your function do, taking 6 sets of values? That would be a curve in 6 dimensions. Is that what you expect? The library would certainly need to be expanded to deal with a more-than-2D-curve. The math for a 6D spline gets pretty hairy.

BlueGene

I dont want 6 dimensions, I need 5 2D graphes.
It should look like the graph in the picture

PaulS

Quote
I need 5 2D graphes.

Then, you need 5 instances of the spline class.

Go Up