hi sandy,
it's Firmware. plan was to have a complete stand-alone solution (for whatever reason). turn the harmono-polargraph on and you will receive each time a new Picture.
firmeware is (my first real own arduino software, so don't laugh 🙂 ):
#define Y_STEP_PIN 60
#define Y_DIR_PIN 61
#define Y_ENABLE_PIN 56
#define Z_STEP_PIN 46
#define Z_DIR_PIN 48
#define Z_ENABLE_PIN 62
long frequency1;
long frequency2;
long frequency3;
long radius1;
long radius2;
long radius3;
long radius4;
float px, py, px1, py1, d, d1, t, mot1, mot2;
float angle1 = 0;
float angle2 = 0;
float angle3 = 0;
float a1 = -0.002;
float a2 = -0.002;
float a3 = -0.002;
float t1 = 0.001;
void setup() {
Serial.begin(9600);
randomSeed(analogRead(0));
radius1 = random(4000)+2000;
radius2 = random(4000)+2000;
radius3 = random(4000)+2000;
radius4 = random(4000)+2000;
frequency1 = random(9)+1;
frequency2 = random(9)+1;
frequency3 = random(9)+1;
Serial.println("RADIUS");
Serial.println(radius1);
Serial.println(radius2);
Serial.println(radius3);
Serial.println(radius4);
Serial.println("FREQUENCY");
Serial.println(frequency1);
Serial.println(frequency2);
Serial.println(frequency3);
pinMode(Y_STEP_PIN , OUTPUT);
pinMode(Y_DIR_PIN , OUTPUT);
pinMode(Y_ENABLE_PIN , OUTPUT);
pinMode(Z_STEP_PIN , OUTPUT);
pinMode(Z_DIR_PIN , OUTPUT);
pinMode(Z_ENABLE_PIN , OUTPUT);
digitalWrite(Y_ENABLE_PIN , LOW);
digitalWrite(Z_ENABLE_PIN , LOW);
}
void loop() {
px = (exp(a1*t) * sin(t*frequency1+angle1))*radius1 + (exp(a2*t) * sin(t*frequency2+angle2)*radius2);
py = (exp(a3*t) * sin(t*frequency3+angle3))*radius3 + (exp(a2*t) * cos(t*frequency2+angle2)*radius4);
d = (px-px1);
d1 = (py-py1);
if(d < 0){digitalWrite(Y_DIR_PIN, HIGH);}
if(d > 0){digitalWrite(Y_DIR_PIN, LOW);}
if(d1 < 0){digitalWrite(Z_DIR_PIN, HIGH);}
if(d1 > 0){digitalWrite(Z_DIR_PIN, LOW);}
mot1=abs(d);
mot2=abs(d1);
// Serial.println(mot1);
// Serial.println(mot2);
if (t>t1){
do{
if(mot1>0){
mot1=mot1-1;
digitalWrite(Y_STEP_PIN, HIGH);
digitalWrite(Y_STEP_PIN, LOW);
delayMicroseconds(250);};
if(mot2>0){
mot2=mot2-1;
digitalWrite(Z_STEP_PIN, HIGH);
digitalWrite(Z_STEP_PIN, LOW);
delayMicroseconds(250);};
}while (mot1+mot2>0);
}
px1 = px;
py1 = py;
t=t+t1;
};
|