Ich habe einen Kameraslider zusammengebastelt (IGUS Schiene 1,5 m, endlos Zahnriemen, Stepper). Er funktioniert einwandfrei.
Als Sketch verwende ich SliderCam v0.2 - Rob Taylor (@robtaylorcase) June 2014 GPL 3.0, leicht, soweit mir möglich, modifiziert.
Nun mein Problem:
Sobald ich "Duration" z.B. auf 100 Sekunden und "Steps" höher als 9 setze, also das Verhältnis gleich oder kleiner als 100/10 ist bricht der Sketch ab.
Ich komme nicht darauf, wo der Fehler liegt.
Eventuell kann sich mal jemand den Sketch ansehen und mir z.B. die Rechenlogik dahinter erklären...?
Viele Grüße
Stephan
(ca. 4 verrauchte Arduino...)
(macht aber auch mit "60" Spaß)
Dann hänge Dir doch mal einige Serial.println-Ausgaben rein an verschiedenen Punkten Deines Sketches und mit Deinen Werten. Damit Du siehst, was in Deinem Sketch passiert.
Ich bin 60, Hobbybastler, begeisterter Knipser usw....
Ich bin kein Programmierer. Die Sequenz:
int motionControl() {
totalMotorSteps = currentDistanceInt * 2; //calculate total steps (0.2mm = 20-tooth gear on 2mm pitch belt; 40mm per rev, 200 steps per rev, ergo 1/5th mm per step)
if (travelDir == 0) digitalWrite(dir, LOW);// Modifiziert auf Optibelt 21 T5 18 + passenden Zahnriemen
else if (travelDir == 1) digitalWrite(dir, HIGH);
pulseDelay = (1000L * (currentDurationInt - (currentStepsInt * shutterDuration))) / totalMotorSteps; //how long to pause in ms between STP pulses to the motor driver
intervalDistance = totalMotorSteps / currentStepsInt;
//once per overall run
Serial.begin(9600);
Serial.println(pulseDelay);
//step loop
do {
digitalWrite(stp, HIGH); //fire motor driver step
delay(pulseDelay);
digitalWrite(stp, LOW); //reset driver
//btnVal = readLcdButtons(); //check there's no stoppage - this takes too long and significantly slows motor; use reset for stop!
currentStep++;
//at end of each step
if (currentStep % intervalDistance == 0) { //if current number of motor steps is divisible by the number of motor steps in a camera step, fire the camera
Serial.begin(9600);
delay(100); //TestVersion Verzögerung, um Vibrationen abklingen zu lassen
digitalWrite(trig, HIGH); //trigger camera shutter
Serial.println(trig);
delay(12000);
digitalWrite(trig, LOW); //reset trigger pin
delay((shutterDuration * 1000UL)-80); //delay needs changing to timer so stop button can be polled
}
}
while (currentStep < totalMotorSteps);
} //end motion control
Beinhaltet wohl eine Rechenlogik (die ich nicht verstehe). Dabei ist wohl ein Rechenschritt, der zu einem Fehler führt.
int motionControl() {
totalMotorSteps = currentDistanceInt * 2; //calculate total steps (0.2mm = 20-tooth gear on 2mm pitch belt; 40mm per rev, 200 steps per rev, ergo 1/5th mm per step)
if (travelDir == 0) digitalWrite(dir, LOW);// Modifiziert auf Optibelt 21 T5 18 + passenden Zahnriemen
else if (travelDir == 1) digitalWrite(dir, HIGH);
pulseDelay = (1000L * (currentDurationInt - (currentStepsInt * shutterDuration))) / totalMotorSteps; //how long to pause in ms between STP pulses to the motor driver
intervalDistance = totalMotorSteps / currentStepsInt;
//once per overall run
Serial.begin(9600);
Serial.println(pulseDelay);
//step loop
do {
digitalWrite(stp, HIGH); //fire motor driver step
delay(pulseDelay);
digitalWrite(stp, LOW); //reset driver
//btnVal = readLcdButtons(); //check there's no stoppage - this takes too long and significantly slows motor; use reset for stop!
currentStep++;
//at end of each step
if (currentStep % intervalDistance == 0) { //if current number of motor steps is divisible by the number of motor steps in a camera step, fire the camera
Serial.begin(9600);
delay(100); //TestVersion Verzögerung, um Vibrationen abklingen zu lassen
digitalWrite(trig, HIGH); //trigger camera shutter
Serial.println(trig);
delay(12000);
digitalWrite(trig, LOW); //reset trigger pin
delay((shutterDuration * 1000UL)-80); //delay needs changing to timer so stop button can be polled
}
}
while (currentStep < totalMotorSteps);
} //end motion control
Achte auf die Wertebereiche der Variablen! int * int = int. unsigned int * unsigned int = unsigned int. int * unsigned int = unsigned int. Das ist nicht viel. Und wenn das nicht reicht muss man eine der Variablen auf long casten