Skip to content
  • MySensors
  • OpenHardware.io
  • Categories
  • Recent
  • Tags
  • Popular
Skins
  • Light
  • Brite
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Brand Logo
  1. Home
  2. Troubleshooting
  3. Stepper don't work with Mysensors library

Stepper don't work with Mysensors library

Scheduled Pinned Locked Moved Troubleshooting
4 Posts 2 Posters 1.4k Views 2 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • TON RIJNAARDT Offline
    TON RIJNAARDT Offline
    TON RIJNAARD
    wrote on last edited by
    #1

    Mary Cristmas to all

    I try to make a sketch with a A4988 driver. When i activate mysensor library the stepper dont work not good any more.
    The stepper is not turning well.
    When i remark the my sensor library the everything is working okee.
    Can some one help me and give me a good advise.
    The sketch is a beginning and not ready yet.
    /* Gordijn aansturing
    *

    • Benodigd 1 arduino pro/mini
    • 1 stepper motor
    • 1 stepper driver A4988
    • 2 switch (begin en eind)

    */
    // =========================== Zet de serielle monitor aan ========================
    #define MY_DEBUG
    // ********************************************************************************

    // =========================== Radio instelling RFM 69 ============================
    //#define MY_RADIO_NRF24
    #define MY_RADIO_RFM69
    #define MY_RFM69_FREUENCY RF69_433MHZ
    #define MY_RFM_PA_LEVEL RF69PA_LOW
    #define MY_ISRFM69HW
    //********************************************************************************

    //=========================== Node en Child infomatie ============================
    #define MY_NODE_ID 13
    #define CHILD_ID 20
    //********************************************************************************
    // defines pins numbers
    int stepPin = 8;
    int dirPin = 9;
    // ========================= Libraries ===========================================
    #include <SPI.h>
    //#include <MySensors.h>
    #include <Wire.h>
    // *******************************************************************************

    void setup() {
    // Sets the two pins as Outputs
    pinMode(stepPin,OUTPUT);
    pinMode(dirPin,OUTPUT);
    }
    void loop() {
    digitalWrite(dirPin,HIGH); // Enables the motor to move in a particular direction
    // Makes 200 pulses for making one full cycle rotation
    for(int x = 0; x < 200; x++) {
    digitalWrite(stepPin,HIGH);
    delayMicroseconds(500);
    digitalWrite(stepPin,LOW);
    delayMicroseconds(500);
    }
    delay(1000); // One second delay

    digitalWrite(dirPin,LOW); //Changes the rotations direction
    // Makes 400 pulses for making two full cycle rotation
    for(int x = 0; x < 400; x++) {
    digitalWrite(stepPin,HIGH);
    delayMicroseconds(500);
    digitalWrite(stepPin,LOW);
    delayMicroseconds(500);
    }
    delay(1000);
    }

    Greatz Ton

    mfalkviddM 1 Reply Last reply
    0
    • TON RIJNAARDT TON RIJNAARD

      Mary Cristmas to all

      I try to make a sketch with a A4988 driver. When i activate mysensor library the stepper dont work not good any more.
      The stepper is not turning well.
      When i remark the my sensor library the everything is working okee.
      Can some one help me and give me a good advise.
      The sketch is a beginning and not ready yet.
      /* Gordijn aansturing
      *

      • Benodigd 1 arduino pro/mini
      • 1 stepper motor
      • 1 stepper driver A4988
      • 2 switch (begin en eind)

      */
      // =========================== Zet de serielle monitor aan ========================
      #define MY_DEBUG
      // ********************************************************************************

      // =========================== Radio instelling RFM 69 ============================
      //#define MY_RADIO_NRF24
      #define MY_RADIO_RFM69
      #define MY_RFM69_FREUENCY RF69_433MHZ
      #define MY_RFM_PA_LEVEL RF69PA_LOW
      #define MY_ISRFM69HW
      //********************************************************************************

      //=========================== Node en Child infomatie ============================
      #define MY_NODE_ID 13
      #define CHILD_ID 20
      //********************************************************************************
      // defines pins numbers
      int stepPin = 8;
      int dirPin = 9;
      // ========================= Libraries ===========================================
      #include <SPI.h>
      //#include <MySensors.h>
      #include <Wire.h>
      // *******************************************************************************

      void setup() {
      // Sets the two pins as Outputs
      pinMode(stepPin,OUTPUT);
      pinMode(dirPin,OUTPUT);
      }
      void loop() {
      digitalWrite(dirPin,HIGH); // Enables the motor to move in a particular direction
      // Makes 200 pulses for making one full cycle rotation
      for(int x = 0; x < 200; x++) {
      digitalWrite(stepPin,HIGH);
      delayMicroseconds(500);
      digitalWrite(stepPin,LOW);
      delayMicroseconds(500);
      }
      delay(1000); // One second delay

      digitalWrite(dirPin,LOW); //Changes the rotations direction
      // Makes 400 pulses for making two full cycle rotation
      for(int x = 0; x < 400; x++) {
      digitalWrite(stepPin,HIGH);
      delayMicroseconds(500);
      digitalWrite(stepPin,LOW);
      delayMicroseconds(500);
      }
      delay(1000);
      }

      Greatz Ton

      mfalkviddM Offline
      mfalkviddM Offline
      mfalkvidd
      Mod
      wrote on last edited by
      #2

      @TON-RIJNAARD the way this code drives the motor requires 100% cpu all the time, so it will have trouble co-existing with almost any library.

      To my knowledge, you'll either need to write custom code that doesn't use delay, something similar to what is discussed in http://forum.arduino.cc/index.php?topic=137269.0 or you need to use a stepper motor library that already does that. I am not sure if http://www.airspayce.com/mikem/arduino/AccelStepper/ supports the A4988 but it might be worth a shot.

      1 Reply Last reply
      0
      • mfalkviddM Offline
        mfalkviddM Offline
        mfalkvidd
        Mod
        wrote on last edited by
        #3

        Stumbled on an Instructables that could be useful:
        http://www.instructables.com/id/Control-a-Stepper-Motor-With-PWM/?ALLSTEPS

        1 Reply Last reply
        0
        • TON RIJNAARDT Offline
          TON RIJNAARDT Offline
          TON RIJNAARD
          wrote on last edited by
          #4

          @mfalkvidd Tanks for the help i give it atry. I am new to arduino so maby i need more help. I let you now when it is nessesary.

          Greatz Ton

          1 Reply Last reply
          1
          Reply
          • Reply as topic
          Log in to reply
          • Oldest to Newest
          • Newest to Oldest
          • Most Votes


          18

          Online

          11.7k

          Users

          11.2k

          Topics

          113.1k

          Posts


          Copyright 2025 TBD   |   Forum Guidelines   |   Privacy Policy   |   Terms of Service
          • Login

          • Don't have an account? Register

          • Login or register to search.
          • First post
            Last post
          0
          • MySensors
          • OpenHardware.io
          • Categories
          • Recent
          • Tags
          • Popular