117
edits
No edit summary |
No edit summary |
||
Line 108: | Line 108: | ||
float one_gearrotation_cycle_count = gear_factor * one_motorrotation_cycle_count; | float one_gearrotation_cycle_count = gear_factor * one_motorrotation_cycle_count; | ||
float one_gearrotation_step_count = one_gearrotation_cycle_count * one_cycle_step_count; | float one_gearrotation_step_count = one_gearrotation_cycle_count * one_cycle_step_count; | ||
int full_track_minutes = 0; | int full_track_minutes = 0; | ||
float rest_track_seconds = 5; | float rest_track_seconds = 5; | ||
float track_length_in_seconds = full_track_minutes * 60 + rest_track_seconds; | float track_length_in_seconds = full_track_minutes * 60 + rest_track_seconds; | ||
float track_length_in_milliseconds = track_length_in_seconds * 1000; | float track_length_in_milliseconds = track_length_in_seconds * 1000; | ||
float motor_power_time_in_mikroseconds = track_length_in_milliseconds / (one_gearrotation_cycle_count * one_cycle_step_count) * 1000; | float motor_power_time_in_mikroseconds = track_length_in_milliseconds / (one_gearrotation_cycle_count * one_cycle_step_count) * 1000; | ||
short i = 0; | short i = 0; | ||
bool break_ = true; // "Bremse": Bei schneller Drehung dreht der Motor nach, sobald keine Spannung mehr anliegt. Die Bremse soll dies verhindern. | bool break_ = true; // "Bremse": Bei schneller Drehung dreht der Motor nach, sobald keine Spannung mehr anliegt. Die Bremse soll dies verhindern. | ||
void setup() { | void setup() { | ||
pinMode(2, OUTPUT); | pinMode(2, OUTPUT); | ||
Line 126: | Line 122: | ||
pinMode(6, OUTPUT); | pinMode(6, OUTPUT); | ||
pinMode(7, OUTPUT); | pinMode(7, OUTPUT); | ||
Serial.begin(9600); | Serial.begin(9600); | ||
digitalWrite(2, LOW); | digitalWrite(2, LOW); | ||
digitalWrite(3, LOW); | digitalWrite(3, LOW); | ||
Line 138: | Line 131: | ||
Serial.println("motor_power_time"); | Serial.println("motor_power_time"); | ||
Serial.println(motor_power_time_in_mikroseconds); | Serial.println(motor_power_time_in_mikroseconds); | ||
Serial.println("track_length_in_milliseconds"); | Serial.println("track_length_in_milliseconds"); | ||
Serial.println(track_length_in_milliseconds); | Serial.println(track_length_in_milliseconds); | ||
Serial.println("one_gearrotation_cycle_count"); | Serial.println("one_gearrotation_cycle_count"); | ||
Serial.println(one_gearrotation_cycle_count); | Serial.println(one_gearrotation_cycle_count); | ||
Serial.println("one_cycle_step_count"); | Serial.println("one_cycle_step_count"); | ||
Serial.println(one_cycle_step_count); | Serial.println(one_cycle_step_count); | ||
Serial.println("one_gearrotation_cycle_count"); | Serial.println("one_gearrotation_cycle_count"); | ||
Serial.println(one_gearrotation_cycle_count); | Serial.println(one_gearrotation_cycle_count); | ||
Serial.println("one_gearrotation_cycle_count"); | Serial.println("one_gearrotation_cycle_count"); | ||
Serial.println(motor_power_time_in_mikroseconds); | Serial.println(motor_power_time_in_mikroseconds); | ||
} | } | ||
void loop() { | void loop() { | ||
while(i < one_gearrotation_cycle_count) | while(i < one_gearrotation_cycle_count) | ||
{ | { | ||
Line 181: | Line 166: | ||
i++; | i++; | ||
} | } | ||
if(break_ == true) //Halte den Motor um ein ausrollen zu verhindern. | if(break_ == true) //Halte den Motor um ein ausrollen zu verhindern. | ||
{ | { |
edits