projekte:kameraslider
Unterschiede
Hier werden die Unterschiede zwischen zwei Versionen der Seite angezeigt.
Vorherige Überarbeitung | |||
— | projekte:kameraslider [2021/01/17 20:19] (aktuell) – thorsten | ||
---|---|---|---|
Zeile 1: | Zeile 1: | ||
+ | ====== Kameraslider ====== | ||
+ | ---- datatemplateentry project ---- | ||
+ | template | ||
+ | # Kurzer Name des Projekts | ||
+ | name : Kameraslider | ||
+ | |||
+ | # Bilddateiname relativ zum Ordner projekte: | ||
+ | # Wenn (noch) kein Bild vorhanden, bitte none.png lassen | ||
+ | imgname_img90 | ||
+ | |||
+ | # Links zu Seiten der Mitglieder, die am Projekt beteiligt sind, also intern: | ||
+ | person_pages | ||
+ | |||
+ | # Start- und Enddatum im Format JJJJ-MM-TT | ||
+ | start_dt | ||
+ | end_dt | ||
+ | |||
+ | # Aktueller Status des Projekts, z.B. fertig, in Arbeit, eingestellt, | ||
+ | status_ | ||
+ | ---- | ||
+ | **Einführung** | ||
+ | |||
+ | Bei diesem Projekt handelt es sich um einen Kameraslider zur Montage einer Kamera (Spiegelreflex, | ||
+ | |||
+ | ---- | ||
+ | |||
+ | **Aufbau** | ||
+ | |||
+ | Der Schlitten läuft auf zwei parallel gelegten Edelstahl Stangen welcher über einen GT2 Zahnriemen mit einem Schrittmotor angetrieben wird. Die Steuerung erfolgt auf einem Raspberry Pi auf dem ein Skript mit freier Eingabe der Variablen (Belichtungszeit der Kamera, Schrittzahl bis zum nächsten Foto, Geschwindigkeit und Richtung) läuft. | ||
+ | |||
+ | ---- | ||
+ | |||
+ | **Hardware** | ||
+ | |||
+ | - | ||
+ | |||
+ | ---- | ||
+ | |||
+ | **Programmablauf** | ||
+ | |||
+ | Das Python-Skript frägt am Anfang die benötigten Informationen wie oben genannt ab. Danach kommt die Initialisierung, | ||
+ | *** Die Entprellung ist für einen sauberen Programmablauf notwendig, da sonst evtl. Funktionen mehrmals aufgerufen werden.** | ||
+ | |||
+ | ---- | ||
+ | |||
+ | **Materialliste** | ||
+ | |||
+ | * 2x Edelstahlstab Durchmesser 8mm | ||
+ | * 4x Aufnahme 8mm | ||
+ | * 4x Schraube M5 Länge 80mm mit Muttern | ||
+ | * 2x Linearlager Durchmesser 8mm | ||
+ | * 2x Endschalter Öffner/ | ||
+ | * 2x Riemenscheibe für GT2 Riemen | ||
+ | * 1x Schrittmotor | ||
+ | * 1x Pololu | ||
+ | * 1x Axiallager 5mm (Umlenkrolle) | ||
+ | * 1x Stab 5mm (Achse für Umlenkrolle) | ||
+ | * 1x Spannungsversorgung min. 12V | ||
+ | * Xx Diverse Kabel | ||
+ | * 1x Raspberry Pi | ||
+ | ---- | ||
+ | |||
+ | **Videos** | ||
+ | |||
+ | https:// | ||
+ | |||
+ | ---- | ||
+ | |||
+ | **Code** | ||
+ | |||
+ | <file python script_final_version_1.1.3.py> | ||
+ | |||
+ | ####################################################### | ||
+ | ## Script by Markus Buecher | ||
+ | ## GPIO Pins for Raspberry Pi B+ and 2B | ||
+ | ####################################################### | ||
+ | #This script is written to use an A4988 Stepper Driver like an Pololu, a Stepper Motor, | ||
+ | #2 Endswitches and to trigger an Relayboard to trigger a camera with its remote connector. | ||
+ | #Please pay attention while connecting your camera to the remote connector. This could cause | ||
+ | #damage to your camera. Use this script at your own risk!! Have fun | ||
+ | |||
+ | from __future__ import division | ||
+ | import time | ||
+ | import RPi.GPIO as GPIO | ||
+ | |||
+ | #Deactivate warnings | ||
+ | GPIO.setwarnings(False) | ||
+ | |||
+ | #Configure the GPIO-Pins to Input and Output: | ||
+ | #GPIO Number = Pin-Number at Board | ||
+ | GPIO.setmode(GPIO.BOARD) | ||
+ | |||
+ | #Variables | ||
+ | zeit=int(raw_input(" | ||
+ | dire=int(raw_input(" | ||
+ | numStep=int(raw_input(" | ||
+ | sps=int(raw_input(" | ||
+ | tick= 1 / sps | ||
+ | a=15 | ||
+ | b=16 | ||
+ | |||
+ | #Input | ||
+ | |||
+ | GPIO.setup(15, | ||
+ | GPIO.setup(16, | ||
+ | #Output | ||
+ | |||
+ | #Output for Stepper | ||
+ | |||
+ | GPIO.setup(35, | ||
+ | GPIO.setup(36, | ||
+ | |||
+ | #Output Trigger | ||
+ | |||
+ | GPIO.setup(29, | ||
+ | |||
+ | stopFlag = False | ||
+ | |||
+ | def initStep(): | ||
+ | counter = 0 | ||
+ | print(" | ||
+ | global stopFlag | ||
+ | while not stopFlag: | ||
+ | GPIO.output(36, | ||
+ | time.sleep(tick) | ||
+ | GPIO.output(36, | ||
+ | time.sleep(tick) | ||
+ | |||
+ | def initStop(a): | ||
+ | ctr = 0 | ||
+ | global stopFlag | ||
+ | stopFlag = True | ||
+ | print(" | ||
+ | while (dire == 1 and ctr < 200): | ||
+ | GPIO.output(35, | ||
+ | GPIO.output(36, | ||
+ | time.sleep(tick) | ||
+ | GPIO.output(36, | ||
+ | time.sleep(tick) | ||
+ | ctr = ctr + 1 | ||
+ | |||
+ | while (dire == 0 and ctr < 200): | ||
+ | GPIO.output(35, | ||
+ | GPIO.output(36, | ||
+ | time.sleep(tick) | ||
+ | GPIO.output(36, | ||
+ | time.sleep(tick) | ||
+ | ctr = ctr + 1 | ||
+ | |||
+ | def normalStop(b): | ||
+ | ctr = 0 | ||
+ | global stopFlag | ||
+ | stopFlag = True | ||
+ | print(" | ||
+ | while (dire == 1 and ctr < 200): | ||
+ | GPIO.output(35, | ||
+ | GPIO.output(36, | ||
+ | time.sleep(tick) | ||
+ | GPIO.output(36, | ||
+ | time.sleep(tick) | ||
+ | ctr = ctr + 1 | ||
+ | |||
+ | while (dire == 0 and ctr < 200): | ||
+ | GPIO.output(35, | ||
+ | GPIO.output(36, | ||
+ | time.sleep(tick) | ||
+ | GPIO.output(36, | ||
+ | time.sleep(tick) | ||
+ | ctr = ctr + 1 | ||
+ | if (ctr == 200): | ||
+ | exit() | ||
+ | |||
+ | def trigger(): | ||
+ | print(" | ||
+ | print(" | ||
+ | print(" | ||
+ | time.sleep(0.5) | ||
+ | GPIO.output(29, | ||
+ | time.sleep(zeit) | ||
+ | GPIO.output(29, | ||
+ | time.sleep(0.5) | ||
+ | |||
+ | def step(numStep): | ||
+ | print(" | ||
+ | counter = 0 | ||
+ | while (counter < numStep): | ||
+ | GPIO.output(36, | ||
+ | time.sleep(tick) | ||
+ | GPIO.output(36, | ||
+ | time.sleep(tick) | ||
+ | counter = counter + 1 | ||
+ | if counter % 100 == 0: | ||
+ | print(counter) | ||
+ | |||
+ | def right(): | ||
+ | GPIO.output(35, | ||
+ | |||
+ | |||
+ | def left(): | ||
+ | GPIO.output(35, | ||
+ | |||
+ | def switch(m): | ||
+ | GPIO.add_event_detect(15, | ||
+ | GPIO.add_event_detect(16, | ||
+ | if (m == 1): | ||
+ | GPIO.add_event_callback(15, | ||
+ | GPIO.add_event_callback(16, | ||
+ | elif (m == 0): | ||
+ | GPIO.add_event_callback(15, | ||
+ | GPIO.add_event_callback(16, | ||
+ | |||
+ | |||
+ | def init(): | ||
+ | if (dire == 1): | ||
+ | switch(1) | ||
+ | left() | ||
+ | initStep() | ||
+ | |||
+ | elif (dire == 0): | ||
+ | switch(1) | ||
+ | right() | ||
+ | initStep() | ||
+ | |||
+ | def rightMainLoop(): | ||
+ | right() | ||
+ | step(numStep) | ||
+ | trigger() | ||
+ | |||
+ | def leftMainLoop(): | ||
+ | left() | ||
+ | step(numStep) | ||
+ | trigger() | ||
+ | |||
+ | init() | ||
+ | |||
+ | time.sleep(3) | ||
+ | raw_input(" | ||
+ | print (" | ||
+ | while (dire == 1): | ||
+ | GPIO.remove_event_detect(15) | ||
+ | GPIO.remove_event_detect(16) | ||
+ | switch(0) | ||
+ | rightMainLoop() | ||
+ | |||
+ | while (dire == 0): | ||
+ | GPIO.remove_event_detect(15) | ||
+ | GPIO.remove_event_detect(16) | ||
+ | switch(0) | ||
+ | leftMainLoop() | ||
+ | |||
+ | |||
+ | |||
+ | </ | ||
+ | |||
+ | <file C SLIDER_NO_UI.ino> | ||
+ | /* | ||
+ | SLIDER_NO_UI.ino | ||
+ | created by Markus Buecher | ||
+ | markus@lug-saar.de | ||
+ | |||
+ | Feel free to contact me if you have any questions, ideas, critics or improvements. | ||
+ | |||
+ | RELEASE NOTES | ||
+ | Please note that this Version doesn' | ||
+ | in the head of this program. Feel free to copy this and build your own camslider. | ||
+ | **Version 1.0** | ||
+ | First release of the Arduino Program for Camslider. | ||
+ | ***WORKING: | ||
+ | -Initialisation | ||
+ | -Move from point to point | ||
+ | -Auto Reset after reaching the other end of line | ||
+ | |||
+ | ***NOT WORKING / NOT IMPLEMENTED*** | ||
+ | -RUNTIME (means to set a time which gives the duration of the real time duration of a timelapse for example) | ||
+ | | ||
+ | -Cameracontrol | ||
+ | -lots of more ideas | ||
+ | */ | ||
+ | |||
+ | //Pinout | ||
+ | const int END_STOP_LEFT = 5; //Left Endstop | ||
+ | const int END_STOP_RIGHT = 6; // | ||
+ | const int STEP_SIGNAL = 3; //Step Signal for Pololu --> STEP | ||
+ | const int DIRECTION_SIGNAL = 4; // | ||
+ | const int LED_INDICATOR = 2; //LED-Pin for Status Signal | ||
+ | |||
+ | //Global Variables | ||
+ | |||
+ | int STATE = 0; | ||
+ | int RUNTIME = 1000; | ||
+ | int long STEP_COUNTER = 0; //Counts the amounts of Step-Signals from the Arduino to the Driver | ||
+ | int MOVE_STEP_FROM_SWITCH = 200; //defines the amount of steps, the cartridge moves back from a collision with the endswitch | ||
+ | int MOVE_STEP = 1200; // | ||
+ | int EXPOSURE_TIME = 1; // | ||
+ | int FREQUENCY = 3000; //Set frequency for Step Signal (Steps per Second) | ||
+ | |||
+ | void setup() { //set pinModes to In- or Output | ||
+ | pinMode(END_STOP_LEFT, | ||
+ | pinMode(END_STOP_RIGHT, | ||
+ | pinMode(LED_INDICATOR, | ||
+ | pinMode(STEP_SIGNAL, | ||
+ | pinMode(DIRECTION_SIGNAL, | ||
+ | } | ||
+ | |||
+ | void step() { | ||
+ | digitalWrite(STEP_SIGNAL, | ||
+ | delayMicroseconds(1000000/ | ||
+ | digitalWrite(STEP_SIGNAL, | ||
+ | delayMicroseconds(1000000/ | ||
+ | ++STEP_COUNTER; | ||
+ | } | ||
+ | |||
+ | void loop() { // | ||
+ | |||
+ | switch (STATE) { // | ||
+ | case 0: // | ||
+ | while (digitalRead(END_STOP_RIGHT) == LOW) { | ||
+ | digitalWrite(DIRECTION_SIGNAL, | ||
+ | step(); | ||
+ | if (digitalRead(END_STOP_RIGHT) == HIGH) { | ||
+ | digitalWrite(DIRECTION_SIGNAL, | ||
+ | STEP_COUNTER = 0; | ||
+ | while (STEP_COUNTER <= MOVE_STEP_FROM_SWITCH) { | ||
+ | step(); | ||
+ | } | ||
+ | STATE = 1; | ||
+ | } | ||
+ | break; | ||
+ | } | ||
+ | break; | ||
+ | |||
+ | case 1: // | ||
+ | delay(1000*(EXPOSURE_TIME)); | ||
+ | while (1) { | ||
+ | digitalWrite(DIRECTION_SIGNAL, | ||
+ | STEP_COUNTER = 0; | ||
+ | while (STEP_COUNTER <= MOVE_STEP) { | ||
+ | if (digitalRead(END_STOP_LEFT) == HIGH) { | ||
+ | STATE = 2; | ||
+ | break; | ||
+ | } | ||
+ | else | ||
+ | step(); | ||
+ | } | ||
+ | break; | ||
+ | } | ||
+ | |||
+ | case 2: // | ||
+ | while (digitalRead(END_STOP_RIGHT) == LOW) { | ||
+ | digitalWrite(DIRECTION_SIGNAL, | ||
+ | step(); | ||
+ | if (digitalRead(END_STOP_RIGHT) == HIGH) { | ||
+ | digitalWrite(DIRECTION_SIGNAL, | ||
+ | STEP_COUNTER = 0; | ||
+ | while (STEP_COUNTER <= MOVE_STEP_FROM_SWITCH) { | ||
+ | step(); | ||
+ | } | ||
+ | STATE = 3; | ||
+ | } | ||
+ | break; | ||
+ | } | ||
+ | break; | ||
+ | |||
+ | case 3: //Indicates with a LED that the Slider is ready with taking photos | ||
+ | while(1) { | ||
+ | digitalWrite(LED_INDICATOR = HIGH); | ||
+ | delay(200); | ||
+ | digitalWrite(LED_INDICATOR = LOW); | ||
+ | delay(200); | ||
+ | | ||
+ | } | ||
+ | |||
+ | | ||
+ | } | ||
+ | } | ||
+ | |||
+ | </ |