Nachdem dieses Projekt jetzt schon länger in Planung ist, habe ich mir gedacht, ich fang jetzt einfach mal damit an. Das Ziel dieses Projekts ist es, einen voll funktionsfähigen Remotehaed zu bauen. Aber nicht nur das. Es wird ein Elektronischer Follow Focus integriert, der bei Bedarf auch unabhängig vom Remote Head betrieben werden kann. Ich habe mich dafür ein bisschen umgeschaut, und bin auf den Arduino als relativ einfache, aber sehr für diesen Zweck geeignete Plattform gestoßen.
1. Der erste Schritt bestand darin mit der Open Source Software Fritzing einen ungefähren Entwurf vom Aufbau der Schaltung zu machen. Es gibt insgesamt 4 Potis (Pan, Tilt, Pan/Tilt Speed, Focus), 5 Schalter(Fokusendpunkt 1 setzten, Fokusendpunkt 2 setzten, Fokusendpunkte zurücksetzten, Pan/Tilt Bewegung aufnehmen, Pan/Tilt Bewegung wiedergeben), 1 Servo für Fokus, 2 Getriebemotoren für Pan/Tilt, Spannungsquelle, Arduino Uno und ein Motor Shield dazu.

2. Die Programmierung. Da ich derzeit noch keinen Arduino besitze, werde ich mich in nächster Zeit um die Programmierung kümmern. Dazu muss gesagt werden, das ich zwar Grundlegende Kenntnisse im Programmieren habe, aber nur mit GameMaker, nicht mit dem Arduino. Der untenstehende Code ist, was ich bis jetzt als Anfänger zusammengebracht hab, dank der umfangreichen Dokumentation mit Beispielen auf dem Arduino Playground. Falls ihr Erfahrung habt mit Arduino und einen Vorschlag habt was ich verbessern könnte, dann schreibt doch bitte einen Kommentar. Ich habe mir Mühe gegeben, den Code so aufgeräumt wie möglich zu halten. Alle Wichtigen Stellen sind Kommentiert.
Achtung: Alle Leser, die meinen Blogpost durch das Suchen nach „Remote Head Arduino“ oder ähnlichem auf Google gefunden haben, denen sei gesagt, das dies KEIN Tutorial ist, sondern lediglich eine Darstellung meines aktuellen Programmierstands ist.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 |
#include <Servo.h> //Integriert die Servo Libary für den Arduino Servo focus; //Servo Objekt wird erstellt //Pins //Konstante Werte für die Anschlüsse const int poti1 = A0; //Pan const int poti2 = A1; //Tilt const int poti3 = A2; //Speed const int poti4 = A3; //Focus const int swtch1 = 2; //Focuslimit Klein const int swtch2 = 5; //Focuslimit Gross const int swtch3 = 4; //Endpunkte löschen const int swtch4 = 6; //Bewegung aufnahmen const int swtch5 = 7; //Bewegung wiedergeben const int servo1pin = 9; const int panmotorpwm_slot = 3; const int panmotordir_slot = 12; const int tiltmotorpwm_slot = 11; const int tiltmotordir_slot = 13; //Wertevariablen(Interne Variablen) int panmotorpwm = 0; //Werte-Variablen für die Motoren int panmotordir = 0; int tiltmotorpwm = 0; int tiltmotordir = 0; int panpoti = 0; int tiltpoti = 0; int focuspoti = 0; int schalter1 = 0; int schalter2 = 0; int schalter3 = 0; int schalter4 = 0; int schalter5 = 0; //sontiges const int focusservo = 0; int focuslimitklein = 0; //Focuslimit 1 int focuslimitgros = 1023; //Focuslimit 2 //Focus Smoothing zeug const int numReadings = 10; int readings[numReadings]; // the readings from the analog input int index = 0; // the index of the current reading int total = 0; // the running total int durchschnitt_focuspoti = 0; // the durchschnitt_focuspoti void setup() { //Pins als INPUT und OUTPUT deklarieren focus.attach(servo1pin); pinMode(panmotorpwm_slot, OUTPUT); pinMode(panmotordir_slot, OUTPUT); pinMode(tiltmotorpwm_slot, OUTPUT); pinMode(tiltmotordir_slot, OUTPUT); pinMode(swtch1, INPUT); pinMode(swtch2, INPUT); pinMode(swtch3, INPUT); pinMode(swtch4, INPUT); pinMode(swtch5, INPUT); for (int thisReading = 0; thisReading < numReadings; thisReading++) readings[thisReading] = 0; //Smoothingzeug } void loop() { //Hier beginnt die Focussteuerung mit den Variablen Endpoints schalter1 = digitalRead(swtch1); //Focuslimit Klein setzten schalter2 = digitalRead(swtch2); //Focuslimit Gross setzten schalter3 = digitalRead(swtch3); //Endpunkte löschen //focuspoti = analogRead(poti4); // liest den wert des poti aus(zwischen 0 und 1023) //Smoothing total= total - readings[index]; // subtract the last reading: readings[index] = analogRead(poti4); // read from the sensor: total= total + readings[index]; // add the reading to the total: index = index + 1; // advance to the next position in the array: if (index >= numReadings) // if we're at the end of the array... { index = 0; } // ...wrap around to the beginning: // calculate the durchschnitt_focuspoti: durchschnitt_focuspoti = total / numReadings; delay(1); // delay in between reads for stability //Focussteuerung if (schalter1 == HIGH) { focuslimitklein = durchschnitt_focuspoti; } if (schalter2 == HIGH) { focuslimitgros = durchschnitt_focuspoti; } if (schalter3 == HIGH) { //Endpunkte löschen focuslimitklein = 0; focuslimitgros = 1023; } if (durchschnitt_focuspoti < focuslimitklein ) { durchschnitt_focuspoti = focuslimitklein; } if (durchschnitt_focuspoti > focuslimitgros ) { durchschnitt_focuspoti = focuslimitgros; } durchschnitt_focuspoti = map(durchschnitt_focuspoti, 0, 1023, 0, 179); // skaliert es auf werte zwischen 0 und 180 focus.write(durchschnitt_focuspoti); // setzt die entsprechende servoposition delay(15); // warten bis der servo die position erreicht hat //Focussteuerung Ende //Dieser Bereich ist noch nicht angefangen schalter4 = digitalRead(swtch4); //Bewegung aufnahmen schalter5 = digitalRead(swtch5); //Bewegung wiedergeben } |
Der Programmcode ist unter folgender Lizenz verfügbar: Attribution-NonCommercial-ShareAlike 4.0
Das wars erst mal von Teil 1. Sobald es wieder etwas Wichtiges zu berichten gibt, gibts hier natürlich einen neuen Post. Dabei möchte ich euch auch noch gerne auf die Mailliste aufmerksam machen. Dort könnt ihr eure Email Adresse eingeben und werdet automatisch benachrichtigt, sobald hier etwas neues gepostet wird. (Eure Daten werden natürlich nicht an dritte weitergegeben.) Ebenfalls lohnt es sich meinen Youtube Kanal zu abonnieren. Dort versuche ich zu allen wichtigen Projekten ein Video zu machen. Danke fürs Lesen und bis zum nächten Post.