Forum

Welcome Guest 

Show/Hide Header

Welcome Guest, posting in this forum requires registration.





Pages: [1]
Author Topic: harmonograph
dickholmer
Beginner
Posts: 39
Permalink
Post harmonograph
on: November 14, 2015, 11:21
Quote

hi,
i found some really nice videos about harmonographs on YouTube and i thought why not make a polar-harmonograph 🙂 due to my really really low level of program skills it took some time to understood everything, find the correct parameters and get the steppers running more or less smooth. last challenge is the real random issue with arduino.

thomas
Image
Image
Image

sandy
Administrator
Posts: 1317
Permalink
sandy
Post Re: harmonograph
on: November 14, 2015, 22:11
Quote

These look great Thomas, is the behaviour programmed in the firmware, or is it in an app on the PC?

I've wanted to make a harmonograph or a lissograph machine for just about as long as I've had some youtubes - never got around to it!

sn

dickholmer
Beginner
Posts: 39
Permalink
Post Re: harmonograph
on: November 15, 2015, 17:04
Quote

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;
};

dickholmer
Beginner
Posts: 39
Permalink
Post Re: harmonograph
on: November 15, 2015, 17:14
Quote

PS: it's with a ramps 1.4

sandy
Administrator
Posts: 1317
Permalink
sandy
Post Re: harmonograph
on: November 15, 2015, 17:22
Quote

Beautifully simple - nice work 🙂

dickholmer
Beginner
Posts: 39
Permalink
Post Re: harmonograph
on: November 16, 2015, 11:40
Quote

maybe too simple. the more the pen leaves the rectangular area of the two belts the picture becomes a little bit tweeked, which does not really look very nice. So maybe i really have to leave the plain XY system and convert to the real coordinate system of the polargraph.

Thomas

ilkirius
Newbie
Posts: 3
Permalink
Post Re: harmonograph
on: January 13, 2016, 14:38
Quote

yeah good job ! not possible to implement this on the polargraph firmware ?

Pages: [1]
Mingle Forum by cartpauj
Version: 1.0.34 ; Page loaded in: 0.027 seconds.