Zum Inhalt springen

Stefan Hermann

Verfasste Forenbeiträge

Ansicht von 15 Beiträgen - 16 bis 30 (von insgesamt 67)
  • Autor
    Beiträge
  • als Antwort auf: Mega2560 an DRV8825 und Schrittmotor #8633
    Stefan Hermann
    Administrator

    Hi Clemens,

    vielen lieben Dank für die netten Worte! Dass du vorankommst ist wirklich toll und dass ich da ein wenig mithelfen konnte freut mich natürlich sehr.

    Bleib gesund und hab auch einen guten Rutsch! Liebe Grüße

    Stefan

    als Antwort auf: Mega2560 an DRV8825 und Schrittmotor #8613
    Stefan Hermann
    Administrator

    Ich hatte noch etwas Zeit und hab das noch mal ordentlich zusammen geschrieben. Die DRV8825 und NEMA17-Variante findest du nun unten im Beitrag :-) https://starthardware.org/automatischer-arduino-aufzug-fuer-ein-hochhausmodell/

    als Antwort auf: Mega2560 an DRV8825 und Schrittmotor #8606
    Stefan Hermann
    Administrator

    Hi Clemens,

    na ich hoffe, dass es auch bei dir funktioniert. Ansonsten schreib wieder. Das bekommen wir schon hin.

    Schöne Weihnachten und liebe Grüße

    Stefan

    als Antwort auf: Mega2560 an DRV8825 und Schrittmotor #8588
    Stefan Hermann
    Administrator

    So, jede Menge Try&Error und wenig Wissenschaft. Aber bei mir funktioniert diese Kombi:

    1. Library: StepperDriver by Laurentiu Badea (Kannst du über Sketch>Bibliotheken einbinden>Bibliotheken verwalten …) suchen und installieren.
    2. Schaltung:
      Ist im Grunde die, die du geschickt hattest, nur dass Pin 13 am Sleep hängt

      • Pin 13 -> SLEEP
      • Pin 9 -> DIR
      • Pin 8 -> STEP
      • GND -> GND
      • 5V+ -> RESET
    3. Strom habe ich per Poti auf 1,6A -> Zum Einstellen (Nur zum Einstellen! Der Code funktioniert bei mir nicht.) habe ich diese Anleitung verwendet: https://www.makerguides.com/drv8825-stepper-motor-driver-arduino-tutorial/
    4. Code ist aus dem Beispiel der Library Datei>Beispiele>StepperDriver>AccelTest. Da musst du noch den richtigen Treiber einkommentieren oder du nimmst den Code hier:
    /*
     * Using accelerated motion ("linear speed") in nonblocking mode
     *
     * Copyright (C)2015-2017 Laurentiu Badea
     *
     * This file may be redistributed under the terms of the MIT license.
     * A copy of this license has been included with this distribution in the file LICENSE.
     */
    #include <Arduino.h>
    
    // Motor steps per revolution. Most steppers are 200 steps or 1.8 degrees/step
    #define MOTOR_STEPS 200
    // Target RPM for cruise speed
    #define RPM 120
    // Acceleration and deceleration values are always in FULL steps / s^2
    #define MOTOR_ACCEL 2000
    #define MOTOR_DECEL 1000
    
    // Microstepping mode. If you hardwired it to save pins, set to the same value here.
    #define MICROSTEPS 16
    
    #define DIR 8
    #define STEP 9
    #define SLEEP 13 // optional (just delete SLEEP from everywhere if not used)
    
    /*
     * Choose one of the sections below that match your board
     */
    
    //#include "DRV8834.h"
    //#define M0 10
    //#define M1 11
    //DRV8834 stepper(MOTOR_STEPS, DIR, STEP, SLEEP, M0, M1);
    
    // #include "A4988.h"
    // #define MS1 10
    // #define MS2 11
    // #define MS3 12
    // A4988 stepper(MOTOR_STEPS, DIR, STEP, SLEEP, MS1, MS2, MS3);
    
    #include "DRV8825.h"
    #define MODE0 10
    #define MODE1 11
    #define MODE2 12
    DRV8825 stepper(MOTOR_STEPS, DIR, STEP, SLEEP, MODE0, MODE1, MODE2);
    
    // #include "DRV8880.h"
    // #define M0 10
    // #define M1 11
    // #define TRQ0 6
    // #define TRQ1 7
    // DRV8880 stepper(MOTOR_STEPS, DIR, STEP, SLEEP, M0, M1, TRQ0, TRQ1);
    
    // #include "BasicStepperDriver.h" // generic
    // BasicStepperDriver stepper(DIR, STEP);
    
    void setup() {
        Serial.begin(115200);
    
        stepper.begin(RPM, MICROSTEPS);
        // if using enable/disable on ENABLE pin (active LOW) instead of SLEEP uncomment next line
        // stepper.setEnableActiveState(LOW);
        stepper.enable();
        // set current level (for DRV8880 only). Valid percent values are 25, 50, 75 or 100.
        // stepper.setCurrent(100);
    
        /*
         * Set LINEAR_SPEED (accelerated) profile.
         */
        stepper.setSpeedProfile(stepper.LINEAR_SPEED, MOTOR_ACCEL, MOTOR_DECEL);
    
        Serial.println("START");
        /*
         * Using non-blocking mode to print out the step intervals.
         * We could have just as easily replace everything below this line with 
         * stepper.rotate(360);
         */
         stepper.startRotate(360);
    }
    
    void loop() {
        static int step = 0;
        unsigned wait_time = stepper.nextAction();
        if (wait_time){
            Serial.print("  step="); Serial.print(step++);
            Serial.print("  dt="); Serial.print(wait_time);
            Serial.print("  rpm="); Serial.print(stepper.getCurrentRPM());
            Serial.println();
        } else {
            stepper.disable();
            Serial.println("END");
            delay(3600000);
        }
    }

    Hoffe, das klappt auch bei dir.

    als Antwort auf: 6 Volt modelbaumotoren #8576
    Stefan Hermann
    Administrator

    Wenn es mit Arduino sein muss, wäre ein Relais zu empfehlen. Im Idealfall als fertige Platine: https://amzn.to/2M14eJu

    Liebe Grüße

    Stefan

    als Antwort auf: Mega2560 an DRV8825 und Schrittmotor #8575
    Stefan Hermann
    Administrator

    Hi Clemens,

    ich hab deine Daten bekommen, kann da aber leider nicht weiterhelfen. Vielleicht hat Franz-Peter eine Idee. Er ist aber nicht über diese Email erreichbar. Was für einen Stepper-Motor verwendest du und welche Daten hat das externe Netzteil?

    Liebe Grüße

    Stefan

    als Antwort auf: LED Brückenlampe #8288
    Stefan Hermann
    Administrator

    :-)

    als Antwort auf: LED Brückenlampe #8286
    Stefan Hermann
    Administrator

    Hi Stephan,

    das ist ein Easy-fix. Scheinbar hast du in dieser Zeile (145) nur den Doppel-Slash // gelöscht. Wenn man ihn dort einfügt, läuft der Code wieder.

    Liebe Grüße

    Stefan

    /*Led Bridge lamp code v1b
    Led strip is WS2811, data wire is on pin 2
    Standart rotary encoder
    Janis Jakaitis 03.08.2016
    absolutelly no varranty of any kond, use ta your won risk
    GPL licence
    */
    
    #include <Encoder.h>
    #include <NeoPixelBus.h>
    #include <EEPROM.h>
    
    //configuration
    const uint8_t PixelPin = 2;
    const uint8_t encButtonPin = 4;
    const uint16_t PixelCount = 119; 
    
    //objects
    Encoder myEnc(5, 6);
    NeoPixelBus<NeoGrbFeature, Neo800KbpsMethod> strip(PixelCount, PixelPin);
    
    //variables
    uint8_t oldPosition  = 0;
    int buttonState = 0;
    bool waitingForPress = true;
    bool waitingForRelease = false;
    bool confRGBIDone = false;
    bool confRGBInprogress = false;
    int confRGBIparamater = 0;
    int confR = 255;
    int confG = 255;
    int confB = 255;
    int confI = 255;
    long newPosition = 0;
    RgbColor curentColor(0, 0, 0);
    
    void setup() {
     Serial.begin(9600);
     Serial.println("Basic Encoder Test:");
    
     //setup encoder
     pinMode(encButtonPin, INPUT);
     myEnc.write(255);
    
     //read RGBI values from EEPROM
     confR = EEPROM.read(0);
     confG = EEPROM.read(1);
     confB = EEPROM.read(2);
     confI = EEPROM.read(3);
    
     //display stored values
     Serial.print("EEPROM values R:" );
     Serial.print(confR );
     Serial.print(" / G:" );
     Serial.print(confG );
     Serial.print(" / B:" );
     Serial.print(confB );
     Serial.print( " / I: " );
     Serial.println(confI );
    
     //set strip to original color
     RgbColor curentColor(confR, confG, confB);
     strip.ClearTo(curentColor);
     strip.Show();
    
    }
    
    void loop() {
    
     if (confRGBInprogress == true) {
       newPosition = myEnc.read();
       if (newPosition != oldPosition) {
    
         //limit encoder values 0 to 2550
         if (newPosition > 255) {
           myEnc.write(255);
           newPosition = 255;
    
             curentColor = RgbColor(0, 0, 0);
             strip.ClearTo(curentColor);
             strip.Show();
             delay(300);
             curentColor = RgbColor(confR, confG, confB);
             strip.ClearTo(curentColor);
             strip.Show();
    
         }
         if (newPosition < 0) {
             curentColor = RgbColor(0, 0, 0);
             strip.ClearTo(curentColor);
             strip.Show();
             delay(300);
             curentColor = RgbColor(confR, confG, confB);
             strip.ClearTo(curentColor);
             strip.Show();
           myEnc.write(0);
           newPosition = 0;
         }
    
         oldPosition = newPosition;
         Serial.println(newPosition);
    
         // change colors on the fly according to encoder values
         switch (confRGBIparamater) {
           case 1:
             curentColor = RgbColor(newPosition, confG, confB);
             strip.ClearTo(curentColor);
             break;
           case 2:
             curentColor = RgbColor(confR, newPosition, confB);
             strip.ClearTo(curentColor);
             break;
           case 3:
             curentColor = RgbColor(confR, confG, newPosition);
             strip.ClearTo(curentColor);
             break;
           default:
             break;
         }
         strip.Show();
       }
     }
    
    // read encoder button press
     buttonState = digitalRead(encButtonPin);
    
     //wait for button to go LOW
     if (waitingForPress == true) {
       if (buttonState == LOW) {
         waitingForPress = false;
         waitingForRelease = true;
         // Serial.println("Press" );
       }
     }
    
     // button goes HIGH after LOW = begin strip config
     if (waitingForRelease == true) {
       if (buttonState == HIGH) {
         // Serial.println("Relese" );
         waitingForPress = true;
         waitingForRelease = false;
         confRGBInprogress = true;
    
    //    proceed according to button press counts
         switch (confRGBIparamater) {
           case 0:
             Serial.println("Config, set red" );
             myEnc.write(confR);
             curentColor = RgbColor(255, 0, 0);
             strip.ClearTo(curentColor);
             strip.Show();
             delay(500);
             curentColor = RgbColor(confR, confG, confB);
             strip.ClearTo(curentColor);
             strip.Show();
             break;
           case 1:
             Serial.println("Set green" );
             curentColor = RgbColor(0, 255, 0);
             strip.ClearTo(curentColor);
             strip.Show();
             delay(500);
             curentColor = RgbColor(confR, confG, confB);
             strip.ClearTo(curentColor);
             strip.Show();
             confR = +newPosition;
             myEnc.write(confG);
             break;
           case 2:
             Serial.println("Set blue" );
             curentColor = RgbColor(0, 0, 255);
             strip.ClearTo(curentColor);
             strip.Show();
             delay(500);
             curentColor = RgbColor(confR, confG, confB);
             strip.ClearTo(curentColor);
             strip.Show();
             confG = +newPosition;
             myEnc.write(confB);
             break;
          /* case 3:
           *  // intensidty code is nobready
             Serial.println("Set intenisty" );
             curentColor = RgbColor(255, 255, 255);
             strip.ClearTo(curentColor);
             strip.Show();
             delay(500);
             curentColor = RgbColor(confR, confG, confB);
             strip.ClearTo(curentColor);
             strip.Show();
             confB = +newPosition;
             myEnc.write(confB);
            */
           case 3:
             Serial.println("Done config" );
             curentColor = RgbColor(255, 255, 255);
             strip.ClearTo(curentColor);
             strip.Show();
             delay(500);
             curentColor = RgbColor(confR, confG, confB);
             strip.ClearTo(curentColor);
             strip.Show();
             confB = +newPosition;
             confRGBIparamater = 0;
             myEnc.write(confI);
             confRGBIDone = true;
             break;
           default:
             break;
    
         }
    
    // save data to EEPROM
         if (confRGBIDone == true) {
           //reset loop flags
           confRGBIDone = false;
           confRGBInprogress = false;
           confRGBIparamater = 0;
           // save to EEPROM
           EEPROM.write(0, confR);
           EEPROM.write(1, confG);
           EEPROM.write(2, confB);
           EEPROM.write(3, confI);
           //display
           Serial.print("EEPROM saved R:" );
           Serial.print(confR );
           Serial.print(" / G:" );
           Serial.print(confG );
           Serial.print(" / B:" );
           Serial.print(confB );
           Serial.print( " / I: " );
           Serial.println(confI );
         }
         else
         {
    
           confRGBIparamater++;
    
         }
    
       }
    
     }
    
    }
    als Antwort auf: Ein-und Ausschaltverzögerung mit Modulo-Trick #8284
    Stefan Hermann
    Administrator

    Hi Tapsi,

    danke für deine Mail. Irgendwie ist der Post im Spam-Folder gelandet. Diese Forumssoftware ist sehr eigen, wenn man Links einsetzt.

    Zu deiner Frage: Der Ansatz ist nicht schlecht, aber der Modulo-Trick ist hier schwer einzusetzen, weil der eher für Wiederholungen gedacht ist. Ich schlage vor, einfach eine Einschaltzeit zu setzen und eine Einschaltdauer festzulegen. Die Einschaltzeit kannst du ja auch später neu festlegen, z. B. wenn du einen Button drückst: if (digitalRead(button)==LOW) Zeitein = millis(); // Hierbei sollte Zeitein aber nicht als int, sondern als long deklariert werden.

    Ansonsten versuche das mal:

    int Buzzer = 2;             // Alarmhorn
    int Zeitein = 4000;        // Ein-Zeit = (Zeit + Zeitaus)
    int Dauer = 1000;        // Einschaltverzögerung (muss < Zeitein sein!)
    
    void setup() {
      pinMode(Buzzer, OUTPUT);
    }
    
    void loop() {
      if ((millis()>Zeitein)&&(millis() < Zeitein+Dauer)) {
        digitalWrite(Buzzer, HIGH);
      } else {
        digitalWrite(Buzzer, LOW);
      }
    }

    Hier noch die Variante mit Taster:

    int Buzzer = 2;             // Alarmhorn
    int Button = 13;
    int ButtonZeitverzoegerung = 1000;
    long Zeitein = 4000;        // Ein-Zeit = (Zeit + Zeitaus)
    int Dauer = 1000;        // Einschaltverzögerung (muss < Zeitein sein!)
    
    void setup() {
      pinMode(Buzzer, OUTPUT);
      pinMode(Button, INPUT_PULLUP);
    }
    
    void loop() {
      if (digitalRead(Button)==LOW) Zeitein = millis()+ButtonZeitverzoegerung;
      
      if ((millis()>Zeitein)&&(millis() < Zeitein+Dauer)) {
        digitalWrite(Buzzer, HIGH);
      } else {
        digitalWrite(Buzzer, LOW);
      }
    }

    Liebe Grüße :-)

    Stefan Hermann
    Administrator

    @Franz-Peter: Wow! Das ist ja eine wirklich coole Bibliothek! Die muss ich mir mal genauer ansehen :-)

    Stefan Hermann
    Administrator

    Hallo,

    das geht nicht direkt über eine Funktion in der Bibliothek aber man kann das natürlich selbst programmieren. Im Beispiel-Programm der Bibliothek (Arduino>Beispiele>Adafruit NeoPixel>Strandtest) werden ja schon verschiedene Funktionen vorgestellt. Du müsstest also so eine ähnliche für deine Zwecke schreiben.

    Liebe Grüße

    Stefan

    als Antwort auf: Beschleunigungssensor + Servo #7673
    Stefan Hermann
    Administrator

    Hi Blitzschnell,

    das ist ja eine schöne Idee. Ist das ein Setup, wo dein Sitz mitbewegt wird? Dann würden sich eher Stepper-Motoren anbieten.

    Liebe Grüße

    Stefan

    als Antwort auf: LED Gehwegbeleuchtung Taster im Programm einbinden #7672
    Stefan Hermann
    Administrator

    Hallo Markus,

    also wenn ich es richtig sehe, liest du zwar myCurrentButtonState ein, benutzt es aber nicht mehr, oder? Ich glaube, ich würde für so ein Programm eine State-Machine einsetzen. Ich hab das mal hier beschrieben: https://starthardware.org/tee-timer-mit-arduino/ Hoffentlich hilft dir das weiter.

    Liebe Grüße

    Stefan

    als Antwort auf: zwei Servomotoren SG-90 mit einem Motor Treiber L293D #7527
    Stefan Hermann
    Administrator

    Hi Basti,

    also ich glaube nicht, dass man Servos mit dem L293D steuern kann. Der Motortreiber ist ja schon im Servo verbaut. Ich habe das hier mal erklärt: Servo mit Arduino steuern. Man kann die Servos aber aufschrauben, die Treiberplatine und die mechanische Sperre im Getriebe rausoperieren und sie dann als normale DC-Motoren verwenden. Kann mir aber nicht vorstellen, dass sie sich überhaupt gleichschnell bewegen oder noch vernünftig steuern lassen. Wieso schließt ihr die beiden Servos nicht ganz normal an das Arduino an – also über einen digitalen Pin und die Servo-Library? Die Servos lassen sich übrigens höchstens von 0 bis 180 Grad drehen.

    Liebe Grüße, Stefan

    als Antwort auf: Wohnhausbeleuchtung #7506
    Stefan Hermann
    Administrator

    Hi Uwe,

    klar, das geht. Ich hab den Code mal für einen Button angepasst. Der Button ist an Pin 2 und am GND angeschlossen. Ich hoffe, das klappt so für dich:

    int ledPins[] = {3, 4, 5, 6, 7};                // Pins für die Zimmerbeleuchtung, 0 = Schlafzimmer, 1 = Küche, 2 = Esszimmer, 3 = Badezimmer, 4 = Hausnummer
    int anzahlLedPins = 5;                          // Anzahl der Einträge im Array ledPins
    int tvPins[] = {11, 10, 9};                     // Pins für den TV Rot, Grün, Blau
    
    int buttonPin = 2;                              // Pin für einen Taster
    
    int myState = 0;                                // Speichert den aktuellen Zustand der Animation
    long stateDauer[] = {50000, 20000, 30000, 10000, 10000, 30000, 10000}; // Wie lange dauert der jeweilige Zustand
    int stateAnzahl = 7;                            // 0 = Tag, 1 = Abendessen, 2 = TV Show, 3 = Zähneputzen, 4 = Kuschelzeit, 5 = Schlafen, 6 = Aufstehen
    long currentStateTimer = 0;                     // Timer für den aktuellen Zustand
    
    void setup() {
      randomSeed(analogRead(0));                    // Start des Zufallszahlen-Generators
      for (int i = 1; i < anzahlLedPins; i++) {     // erst ab 1, da der erste Pin (Pin 3) als analoger Output verwendet wird 
        pinMode(ledPins[i], OUTPUT);                // deklariere Pins 4 – 7 als digitale Outputs
      }
      pinMode(buttonPin, INPUT_PULLUP);             // Button mit internem Pullup wird konfiguriert
    }
    
    void loop() {
      if (currentStateTimer + stateDauer[myState] < millis()) {
        currentStateTimer = millis();               // resetted den Timer
        myState++;                                  // erhöht den aktuellen State
        if (myState >= stateAnzahl) myState = 0;    // falls myState größer als verfügbare States, dann myState=0;
      }
      
      switch (myState) {                            // Haupt-Statemachine
        case 0:                                     // State: Tag
          digitalWrite(ledPins[1], LOW);            // Küche aus
          digitalWrite(ledPins[2], LOW);            // Esszimmer aus
          digitalWrite(ledPins[3], LOW);            // Badezimmer aus
          digitalWrite(ledPins[4], LOW);            // Hausnummer aus      
          analogWrite(tvPins[0], 0);                // TV aus als Wohnzimmerbeleuchtung
          analogWrite(tvPins[1], 0);                // TV aus als Wohnzimmerbeleuchtung
          analogWrite(tvPins[2], 0);                // TV aus als Wohnzimmerbeleuchtung     
          currentStateTimer = millis();             // resettet den Timer kontinuierlich
          if (digitalRead(buttonPin)==LOW){         // wenn Taster gedrückt wird
            myState++;                              // wird der State um 1 erhöht
          }   
          break;
        case 1:                                     // State: Abendessen
          digitalWrite(ledPins[4], HIGH);           // Hausnummer an
          digitalWrite(ledPins[1], HIGH);           // Küche an
          digitalWrite(ledPins[2], HIGH);           // Esszimmer an
          break;
        case 2:                                     // State: TV Show
          digitalWrite(ledPins[2], LOW);            // Esszimmer aus
          if (random(400)==1) {                     // Licht in Küche ausschalten
            digitalWrite(ledPins[1], LOW);          // Küche aus
          }
          if (random(500)==1) {                     // Licht in Küche einschalten
            digitalWrite(ledPins[1], HIGH);         // Küche an
          }
          if (random(10)==1) analogWrite(tvPins[0], random(100,200));  // TV rot
          if (random(10)==1) analogWrite(tvPins[1], random(100,200));  // TV grün > für mehr Fussball einfach die Werte ändern ;-)
          if (random(10)==1) analogWrite(tvPins[2], random(100,200));  // TV blau
          break;
        case 3:                                     // State: Zähneputzen
          digitalWrite(ledPins[1], LOW);            // Küche aus
          digitalWrite(ledPins[2], LOW);            // Esszimmer aus
          analogWrite(tvPins[0], 0);                // TV aus
          analogWrite(tvPins[1], 0);                // TV aus
          analogWrite(tvPins[2], 0);                // TV aus
          digitalWrite(ledPins[3], HIGH);           // Badezimmer an
               
          break;
        case 4:                                     // State: Kuschelzeit?
          digitalWrite(ledPins[3], LOW);            // Badezimmer aus
          if (random(10)==1) analogWrite(ledPins[0], random(100,200));  // Schlafzimmer 
          break;
        case 5:                                     // State: Schlafen
          analogWrite(ledPins[0], 0);               // Schlafzimmer aus
          break;
        case 6:                                     // State: Aufstehen
          digitalWrite(ledPins[1], HIGH);           // Küche an
          digitalWrite(ledPins[2], HIGH);           // Esszimmer an
          digitalWrite(ledPins[3], HIGH);           // Badezimmer an
          analogWrite(tvPins[0], 255);              // TV an als Wohnzimmerbeleuchtung
          analogWrite(tvPins[1], 255);              // TV an als Wohnzimmerbeleuchtung
          analogWrite(tvPins[2], 255);              // TV an als Wohnzimmerbeleuchtung            
          break;
      }
      delay(20);                                    // kurze Pause
    }

    Liebe Grüße und ich würde mich über Fotos freuen: hallo@starthardware.org

    Stefan

Ansicht von 15 Beiträgen - 16 bis 30 (von insgesamt 67)