Stepper Motor Identification

Advert

Stepper Motor Identification

Home Forums General Questions Stepper Motor Identification

Viewing 25 posts - 26 through 50 (of 50 total)
  • Author
    Posts
  • #377780
    Joseph Noci 1
    Participant
      @josephnoci1

      Hi Dave,

      "Given a stepper motor, micro-step and gear ratio combination, and the requirement to divide by 'n', what is the best way of compensating for rounding error by finessing the number of microsteps taken to move a blank to the next division such that any error cannot accumulate. Hmmm."

      That is taken care of nicely by Bresenham's line draw algorithm.

      It appears you are quite comfortable writing code for these things – I do not know anything about the Arduino dev environment, 'sketches', and the like ( sketches are what I make on scrap paper before I built the part..). However, if you are game, I can give you the C code as we used on the Hobber and on the Lathe ELS for the implementation of Bresenhams. It might not fit your application directly, but may help your grasp?

      If so, probably best via email I guess.

      Joe

      Advert
      #377781
      SillyOldDuffer
      Moderator
        @sillyoldduffer
        Posted by Joseph Noci 1 on 26/10/2018 14:17:49:

        Hi Dave,

        "Given a stepper motor, micro-step and gear ratio combination, and the requirement to divide by 'n', what is the best way of compensating for rounding error by finessing the number of microsteps taken to move a blank to the next division such that any error cannot accumulate. Hmmm."

        That is taken care of nicely by Bresenham's line draw algorithm.

        It appears you are quite comfortable writing code for these things – I do not know anything about the Arduino dev environment, 'sketches', and the like ( sketches are what I make on scrap paper before I built the part..). However, if you are game, I can give you the C code as we used on the Hobber and on the Lathe ELS for the implementation of Bresenhams. It might not fit your application directly, but may help your grasp?

        If so, probably best via email I guess.

        Joe

        Yes please Joe.

        I have Ammeraal's 'Programming Principles in Computer Graphics', which has a good description of Bresenham's Line and Circle algorithms, and how he deals with a straight line is easy enough. I don't see how to apply it in this case though. Probably me!

        I'll send you a PM with my email address shortly.

        Many thanks,

        Dave

        #377783
        John Haine
        Participant
          @johnhaine32865

          As I understand it Arduino sketches are essentially C++….

          #377787
          SillyOldDuffer
          Moderator
            @sillyoldduffer
            Posted by John Haine on 26/10/2018 14:59:35:

            As I understand it Arduino sketches are essentially C++….

            Yes, that's right. For simplicity most Arduino tutorials stick to 'C' syntax which is a sub-set of C++ and plenty powerful enough most of the time. Under the bonnet the compiler is full blown C++ and modern, so you can write things like:

            char s[] = "Hello World";
            for (auto ch: s)
                Serial.print( ch );

            Mainly because memory is limited C++ is distinctly cramped on a small microcontroller. For example, you shouldn't use heavy duty C++ features like the Standard Template Library. I find being able to write C++ classes jolly useful though.

            Dave

            #377788
            John Haine
            Participant
              @johnhaine32865

              So hopefully Joe's C code should be usable then?

              #377795
              duncan webster 1
              Participant
                @duncanwebster1

                This is all getting a bit heavy for my od brain. Surely all we need to do is to work out how many steps from zero to each tooth, make sure the integer arithmetic rounds to the nearest rather than always down, then subtract the steps to the previous tooth. Something like

                unsigned long lastSteps = 0, nextSteps = 0;

                unsigned int teeth, increment;

                for (teeth = 1; teeth <=127; teeth++)

                {

                wait to be told to move to next tooth;

                nextSteps = (teeth*4800*40+63)/127); //the +63 makes it round to nearest

                increment = nextSteps – lastSteps;

                lastSteps = nextSteps;

                whatever function moves the motor by increment steps;

                }

                I've tried the logic on a spreadsheet and it works, the nextStep position is never more than 0.5 a motor step out, an error of <0.5/1512 = 1 part in 3024

                #377798
                SillyOldDuffer
                Moderator
                  @sillyoldduffer
                  Posted by duncan webster on 26/10/2018 16:41:35:

                  This is all getting a bit heavy for my od brain. Surely all we need to do is to work out how many steps from zero to each tooth, make sure the integer arithmetic rounds to the nearest rather than always down, then subtract the steps to the previous tooth.

                  I've tried the logic on a spreadsheet and it works, the nextStep position is never more than 0.5 a motor step out, an error of <0.5/1512 = 1 part in 3024

                  My old brain isn't up to much either either and I admit Duncan's suggestion looks much better than my first attempt! Not only is my effort far more complicated, it also plonks corrections in the same positions each time round the blank. Not ideal, because certain teeth get particularly thinned in order to make the others better.

                  To answer John's point about re-using Joe's code, more likely I shall have to adapt rather than cut and paste it directly, but just seeing how he did it will save a lot of time. As it's not arrived yet I shall have a play with Duncan's suggestion first.

                  Dave

                  #377799
                  Neil Wyatt
                  Moderator
                    @neilwyatt
                    Posted by SillyOldDuffer on 26/10/2018 14:39:07:

                    I have Ammeraal's 'Programming Principles in Computer Graphics', which has a good description of Bresenham's Line and Circle algorithms, and how he deals with a straight line is easy enough. I don't see how to apply it in this case though. Probably me!

                    If you plot number of teeth as X and number of steps as Y, then draw a line from the origin to the point that represents a full rotation.

                    If you go along X in steps of of one tooth bressenham will give you the best Y value to use distributing the error evenly.

                    Neil

                    #377801
                    Neil Wyatt
                    Moderator
                      @neilwyatt
                      Posted by duncan webster on 26/10/2018 16:41:35:

                      This is all getting a bit heavy for my od brain. Surely all we need to do is to work out how many steps from zero to each tooth, make sure the integer arithmetic rounds to the nearest rather than always down, then subtract the steps to the previous tooth. Something like

                      Bressenham does this without having to keep track of how far you have come.

                      Basically you round to the nearest integer position keep track of the cumulative error, when this becomes more than half a step, you take an extra step, adjusting the error by -1 so it is now just less than half a step the opposite way.

                      The advantage is you don't need to now your start or end points, but just the slope of your intended path.

                      Neil

                      #377802
                      SillyOldDuffer
                      Moderator
                        @sillyoldduffer
                        Posted by Neil Wyatt on 26/10/2018 17:14:18:

                        Posted by SillyOldDuffer on 26/10/2018 14:39:07:

                        I have Ammeraal's 'Programming Principles in Computer Graphics', which has a good description of Bresenham's Line and Circle algorithms, and how he deals with a straight line is easy enough. I don't see how to apply it in this case though. Probably me!

                        If you plot number of teeth as X and number of steps as Y, then draw a line from the origin to the point that represents a full rotation.

                        If you go along X in steps of of one tooth bressenham will give you the best Y value to use distributing the error evenly.

                        Neil

                        Ah, daylight! Even better, I'll try that first.

                        Thanks,

                        Dave

                        #377809
                        Michael Gilligan
                        Participant
                          @michaelgilligan61133

                          Posted by SillyOldDuffer on 26/10/2018 13:17:13:

                          [ … ]

                          Sort of makes my point about rounding error though. If you can't detect the effects rounding may not matter.

                          Dave

                          .

                          Thanks, Dave … I can live with that ^^^ and I particularly like your inclusion of the word 'may' yes

                          I will now happily leave you clever chaps to your coding.

                          MichaelG.

                          #377836
                          SillyOldDuffer
                          Moderator
                            @sillyoldduffer

                            My entry for the Most Boring Post contest:

                            756 1512 1512 1512 1512 1511 1512 1512 1512 1512 1512 1511
                            1512 1512 1512 1512 1511 1512 1512 1512 1512 1511
                            1512 1512 1512 1512 1511 1512 1512 1512 1512 1512 1511
                            1512 1512 1512 1512 1511 1512 1512 1512 1512 1511
                            1512 1512 1512 1512 1512 1511 1512 1512 1512 1512 1511
                            1512 1512 1512 1512 1511 1512 1512 1512 1512 1512 1511
                            1512 1512 1512 1512 1511 1512 1512 1512 1512 1511
                            1512 1512 1512 1512 1511 1512 1512 1512 1512 1512 1511
                            1512 1512 1512 1512 1511 1512 1512 1512 1512 1511
                            1512 1512 1512 1512 1512 1511 1512 1512 1512 1512 1511
                            1512 1512 1512 1512 1511 1512 1512 1512 1512 1511
                            1512 1512 1512 1512 1512 1511 1512 1512 1512 1512

                            Starting 756 is a bug. Otherwise this is Bresenham stepping a 127 tooth gear. I'll try Duncan's method next, I think the advantage may be it's more obvious how it works, even if it's slower.

                            Dave

                            Edited By SillyOldDuffer on 26/10/2018 21:32:45

                            #378029
                            Alan Charleston
                            Participant
                              @alancharleston78882

                              Hi,

                              Thanks for all the comments. I don't think lost steps are a problem. I've reduced the speed to about 60rpm to reduce the acceleration when starting each step and the registration pin on the head engaged the built in indexing plate at 0 degrees before and after 40 steps of 9 degrees each.

                              If I was confident of programming the Arduino I think I'd follow Duncan's approach and calculate the number of cumulative pulses for each tooth as the gear is cut, subtract the total for the previous tooth and round it to the nearest integer.

                              Alas I'm not. I have tried for years to get my head around programming the Arduino but I've got a teflon brain that nothing computer oriented will stick to. I'm in the frustrating position of understanding enough to see what can be done but not being able to do it.

                              That's one of the reasons I'm keen to stick with the simple solution I outlined in my last post. I take the point that it's probably not wise to do all the residual pulse correction on consecutive teeth but rather spread them out over the whole tooth. I can do that by using the two outputs from the Stepduino as I outlined earlier. I need some way of easily swapping between the two outputs as the gear is cut. My first thought was to have a plug from each of the outputs and switch the motor plug between the two at regular intervals throughout the cutting operation. It would be better however to have a rotary switch between the controller and a single plug. The operation of the switch would need to carry out the operation shown in the photo.

                              switch.jpg

                              It would need to switch the 4 wires of the motor between the 4 outlets from controller one and the 4 outlets of controller two. I don't know what the name of such a switch is which makes it hard to find out where to get one. Can anyone tell me?

                              Regards,

                              Alan

                              #378048
                              John Haine
                              Participant
                                @johnhaine32865

                                Alan, I'm afraid that won't work, for two reasons. First, stepper drivers do not like having their outputs disconnected when energised and may just retire from the fray. Second, when you disconnect the stepper it will jump to the nearest whole step from whatever microstep state it was in so you will lose the accuracy you are trying to achieve.

                                I suggest that you should look at the software that was written for the Arduino divider controller described in MEW. I'm sure someone here can point you to it. If that works anything like my Ward indexer, you just configure it with the number of (micro)steps per full rev of the divider head spindle, than tell it on the mmi how many divisions you want and it does all the rest for you. Or you could just go to **LINK** and buy one of his controllers as I did. You would need to buy a stepper driver but as I pointed out those are very cheap and easy to get.

                                #378080
                                SillyOldDuffer
                                Moderator
                                  @sillyoldduffer
                                  Posted by John Haine on 28/10/2018 09:42:29:

                                  Alan, I'm afraid that won't work, for two reasons. First, stepper drivers do not like having their outputs disconnected when energised and may just retire from the fray. Second, when you disconnect the stepper it will jump to the nearest whole step from whatever microstep state it was in so you will lose the accuracy you are trying to achieve.

                                  I suggest that you should look at the software that was written for the Arduino divider controller described in MEW. I'm sure someone here can point you to it. If that works anything like my Ward indexer, you just configure it with the number of (micro)steps per full rev of the divider head spindle, than tell it on the mmi how many divisions you want and it does all the rest for you. Or you could just go to **LINK** and buy one of his controllers as I did. You would need to buy a stepper driver but as I pointed out those are very cheap and easy to get.

                                  Agreed. Also, as I know to my cost, there's a third reason! My stepper-controller connects the motor via a 5-pin DIN connector. If the motor is plugged after the unit is powered on the resulting electrical misbehaviour is enough to corrupt the Arduino's memory, and the Arduino has to be reloaded from scratch.

                                  The MEW Article is based on Gary Liming's original and it was widely discussed on the forum. I think I'm correct in saying that Gary's code doesn't correct for rounding error, no doubt because usually it doesn't matter. (See my earlier post showing how the error is distributed.)

                                  An alternative is my stepper which uses a keypad rather than nested menus. As a result of your question I will modify it to minimise rounding error later this week. Unfortunately the hardware build instructions aren't newbie friendly because they're out of date.

                                  Neither my effort or Gary's would transfer easily to the StepDuino hardware because they both use input buttons.

                                  If I were you, I'd write some simple code to drive the StepDuino and try it. There's a good chance rounding error won't matter in practice.

                                  Dave

                                  #378083
                                  Neil Wyatt
                                  Moderator
                                    @neilwyatt

                                    My advice is to decide what level of precision you need to machine to and multiply the number of steps to give about ten times that resolution.

                                    You can then use integer division by the number of teeth required and divide the number of step moves outputted by 10.

                                    N.

                                    #378090
                                    SillyOldDuffer
                                    Moderator
                                      @sillyoldduffer
                                      Posted by SillyOldDuffer on 28/10/2018 12:26:04:

                                      Posted by John Haine on 28/10/2018 09:42:29:.

                                      If I were you, I'd write some simple code to drive the StepDuino and try it….

                                      Dave

                                      Alan : as I'm testing Duncan's rounding suggestion anyway on a Uno, I did it so it should work on your stepduino. The code should turn your table through one complete turn taking 127 steps to do so. There is a 3 second pause between each step.

                                      /**
                                      * StepDuino example
                                      */

                                      const int Stepper1Step = 5;
                                      const int Stepper1Direction = 2;
                                      const int StepsPerRev1 = 1600;
                                      const int ratio = 120;

                                      const int PAUSE_BETWEEN_DIVISIONS_mS = 3000; // 3 seconds

                                      /**
                                      * Set pin assignments
                                      */

                                      void divide( long n, long microStepsPerTurn ) {
                                      // Divides with rounding correction
                                      // Duncan Webster's algorithm
                                      long lastSteps = 0, nextSteps = 0;
                                      long increment, halfn = n / 2;

                                      for (long step = 1; step <= n; step++) {
                                      nextSteps = ( step * microStepsPerTurn + halfn ) / n; //the +halfn makes it round to nearest
                                      increment = nextSteps – lastSteps;
                                      lastSteps = nextSteps;
                                      stepMotor( increment );
                                      delay( PAUSE_BETWEEN_DIVISIONS_mS );
                                      }
                                      }

                                      void stepMotor( long microSteps ) {
                                      while ( microSteps– ) {
                                      stepper1Forward();
                                      }
                                      }

                                      void setup() {
                                      pinMode(Stepper1Step, OUTPUT);
                                      pinMode(Stepper1Direction, OUTPUT);
                                      Serial.begin(9600);
                                      }

                                      /**
                                      * Main loop
                                      */
                                      void loop() {
                                      divide( 127, (long) StepsPerRev1 * ratio );
                                      delay( 4000 );
                                      }

                                      /**
                                      * Rotate stepper 1 forward by 1 step
                                      */
                                      void stepper1Forward()
                                      {
                                      digitalWrite(Stepper1Direction, HIGH);
                                      digitalWrite(Stepper1Step, HIGH);
                                      delayMicroseconds(2); // 1uS minimum pulse duration for DRV8811
                                      digitalWrite(Stepper1Step, LOW);
                                      delayMicroseconds(100);
                                      }

                                      I can't test it with a motor but the pulses look reasonable on my oscilloscope.

                                      Dave

                                      #378172
                                      Alan Charleston
                                      Participant
                                        @alancharleston78882

                                        Hi,

                                        Thanks for all your comments.

                                        I'm not worried about plugging and unplugging the motor as the way I have it set up is that the power to the stepduino and motor is only on when the button is pressed i.e. the power is off, the button is pressed which supplies power, the motor advances the set number of steps, the button is released and the power is off again. I like this way of working as I can do as many teeth as I want then leave it and come back again the next day and continue where I left off. I'm not sure if that applies to the other programmes that are around.

                                        I wasn't aware that each time I put the power to the system that it will restart at the beginning of a full step. I'm not sure that this matters however. As long as each pulse produces the expected rotation, and the number of pulses are correct to give the rotation required, I don't think it matters whether the new rotation restarts from the same stage during a step or from the beginning of a step.

                                        Thanks for the sketch Dave. I put it into the Stepduino and it seems to make the motor rotate about the right amount. Is it supposed to stop after 127 iterations? I set a microscope above the pulley to see if it would return to the same point after 127 turns but it didn't stop. I'll have a closer look at the sketch and see if I can figure it out. I slowed it down to about 60 rpm by putting a 500 microsecond delay for the pulse HIGH time. This gave a much higher torque.

                                        Regards,

                                        Alan

                                        #378174
                                        Joseph Noci 1
                                        Participant
                                          @josephnoci1

                                          Alan, I think you are not aware of some of the fundamentals of steppers and what you are doing in your last post is not viable.

                                          I am also confused as to how you are driving the stepper – in your earlier posts you intimated you had set the controller to 4800 steps/stepper revolution and later in the same post you state 1600 steps/revolution, so not sure what it actually is. Nevertheless, it appears you are microstepping. In such a mode a specific index position, eg, tooth number 111 of your 127 tooth gear, may place the stepper rotor between the full step magnetic detent ( what you feel when you rotate the motor by hand..) of the motor. At this point the RMS current flowing in the two stepper windings is balanced such that the resulting electromagnetic field keeps the rotor in that place. Turning off the power removes that field, and the rotor will wish to rotate to the nearest magnetic FULL STEP detent position, In other words you have lost the microstep position FOREVER. The next time you power on the driver, the rotor will just stay put, or move to the nearest detent if not there, and you have lost your microstep position – you will never keep accurate index positions this way. You CANNOT turn off the power to the system while indexing with a stepper, which is not an absolute reference device.

                                          This has been pointed out as you acknowledge it in your second paragraph, but you seem to think the misplaced position will not have any deleterious effect..It sure will! If the rotor was say midway between full steps when you turned off power, and the rotor naturally moved to a full step detent, say the one just before the current half position. The next time you turn on and do the Nsteps for the next tooth, it will step Nsteps from the CURRENT detent position, not from the desired midpoint position where it was when you removed power previously. You will end up in the wrong position.

                                          ' As long as each pulse produces the expected rotation, and the number of pulses are correct to give the rotation required, I don't think it matters whether the new rotation restarts from the same stage during a step or from the beginning of a step.'

                                          The last part of your sentence does not make sense..the rotor position is ALL that matters, and it has to be at the correct start position for it to end up at the correct NEXT index position after N steps..starting at a random position will set the rotor at a new position that is the correct number of steps away, but it is still the incorrect position!

                                          With regard to slowing the stepper down – you did it by increasing the length of the pulse on time – normally the stepper drivers require a pulse period of 1us to 10us – some controllers go into a 'low-current' hold mode if the pulse on time is excessive, or if the time between pulses is long ( normally seconds..). To slow things down, it is normal to add a delay between step pulses..

                                          Joe

                                          #378189
                                          SillyOldDuffer
                                          Moderator
                                            @sillyoldduffer

                                            Posted by Alan Charleston on 29/10/2018 03:13:35:

                                            Thanks for the sketch Dave. I put it into the Stepduino and it seems to make the motor rotate about the right amount. Is it supposed to stop after 127 iterations? I set a microscope above the pulley to see if it would return to the same point after 127 turns but it didn't stop. I'll have a closer look at the sketch …

                                            Regards,

                                            Alan

                                            Is it supposed to stop after 127 iterations? No, it delays 4 seconds, and then repeats.

                                            On an Arduino, there are two main functions called automatically:

                                            • setup() runs once as soon as the Arduino is powered up. It usually contains instructions that only need to be done once, like allocating pins to Input/Output and activating the Serial link.
                                            • the loop() function is where your main control code goes. loop() starts again immediately it finishes, causing whatever logic is inside to repeat forever.

                                            In the example code, I said:

                                            void loop() {
                                            divide( 127, (long) StepsPerRev1 * ratio );
                                            delay( 4000 );
                                            }

                                            This calls the divide() function, which outputs 127 steps and then returns control to the next statement in loop().

                                            Then delay( 4000 ) is called. It does nothing for 4000mS before returning control to loop() again. As delay() is the last instruction in loop() the function is ended, but – automagically – restarted from the top. The effect is to do 127 division steps, pause 4 seconds, and then repeat, forever. (Until the power is turned off.)

                                            All practical dividing code provides some way of allowing the user to decide when he wants to turn the table to the next working position. It's usually done by pressing a 'GO' button on the controller. The StepDuino diagram shows a number of breakout pins are available. Any of these 'spare' pins can be wired to a button and the Arduino programmed to detect when that button is pressed. I'll update the example later to show one way of doing it.

                                            As Joe explained, I'm afraid your switch-off plan won't work. Top marks for cunning though!

                                            Dave

                                            #378227
                                            John Haine
                                            Participant
                                              @johnhaine32865

                                              As I mentioned the Ward divider a few posts back I started wondering how that dealt with the problem of "relatively prime" step numbers. I contacted Steve Ward through CNC Zone where there's a long thread on his design and got this very quick and helpful response – many thanks Steve if you read this forum!

                                              So basically internally it multiplies the number of divisions by the actual division its on then divides the result by the number of steps for a full circle – this gives it the nearest number of steps it needs to get to that division (doing the multiply first prevents loss of resolution although it means it needs 32 bit maths which is why the max steps per rev is 16 bit).

                                              Internally it knows exactly how many steps it's currently taken so simply adds (or subtracts) that from the answer above to get the number of steps to take.



                                              This means there isn't a constant number of steps since it may need to take an extra step (or lose one to be accurate).



                                              In practice the accuracy of the maths is half the single step resolution, so a 400 step driver on a 90:1 worm gives you 0.01 degrees per step so the accuracy is 0.005 degrees. (Mechanical accuracy not withstanding).

                                              #378248
                                              SillyOldDuffer
                                              Moderator
                                                @sillyoldduffer
                                                Posted by SillyOldDuffer on 29/10/2018 09:57:17:

                                                Posted by Alan Charleston on 29/10/2018 03:13:35:

                                                 

                                                 

                                                All practical dividing code provides some way of allowing the user to decide when he wants to turn the table to the next working position. It's usually done by pressing a 'GO' button on the controller. The StepDuino diagram shows a number of breakout pins are available. Any of these 'spare' pins can be wired to a button and the Arduino programmed to detect when that button is pressed. I'll update the example later to show one way of doing it.

                                                 

                                                 

                                                 

                                                According to the stepduino documentation pin A1 is available on the bottom right hand side of the board.

                                                The example makes pin A1 an input and also sets it HIGH by putting 5V on it via a built-in resistor.

                                                divide() has been modified so that after each step it waits for Pin A1 to be momentarily connected to ground with a push-button (or spare bit of wire!).

                                                <pre>
                                                /* StepDuino example */

                                                const int Stepper1Step      = 5;
                                                const int Stepper1Direction = 2;
                                                const int GoButton          = A1;  // Analog Pin A1 can be used as a digital pin
                                                const int StepsPerRev1      = 1600;
                                                const int ratio             = 120;
                                                const int PAUSE_BETWEEN_DIVISIONS_mS = 3000; // 3 seconds

                                                void divide( long n, long microStepsPerTurn ) {
                                                  // Divides with rounding correction – Duncan Webster's algorithm
                                                  long lastSteps = 0, nextSteps = 0;
                                                  long increment, halfn = n / 2;

                                                  for (long step = 1; step <= n; step++) {
                                                    nextSteps = ( step * microStepsPerTurn + halfn ) / n; //the +halfn makes it round to nearest
                                                    increment = nextSteps – lastSteps;
                                                    lastSteps = nextSteps;
                                                    stepMotor( increment );
                                                    waitForButton( GoButton );         
                                                  }
                                                }

                                                void stepMotor( long microSteps ) {
                                                  while ( microSteps– ) {
                                                    stepper1Forward();
                                                  }
                                                }

                                                void waitForButton( int GoButton ) {
                                                  while ( digitalRead( GoButton ) == HIGH ) ;  // Wait until the go button goes LOW
                                                }

                                                void setup() {
                                                  pinMode(Stepper1Step,      OUTPUT);
                                                  pinMode(Stepper1Direction, OUTPUT);
                                                  pinMode( GoButton,  INPUT_PULLUP ); // Make pin an INPUT with 5V on it so grounding with a switch can be detected
                                                }

                                                /* Main loop */
                                                void loop() {
                                                  divide( 127, (long) StepsPerRev1 * ratio );
                                                  delay( 4000 );
                                                }

                                                /* Rotate stepper 1 forward by 1 step */
                                                void stepper1Forward()
                                                {
                                                  digitalWrite(Stepper1Direction, HIGH);
                                                  digitalWrite(Stepper1Step, HIGH);
                                                  delayMicroseconds(2); // 1uS minimum pulse duration for DRV8811
                                                  digitalWrite(Stepper1Step, LOW);
                                                  delayMicroseconds(100);
                                                }
                                                </pre>

                                                 

                                                Dave

                                                Edited By SillyOldDuffer on 29/10/2018 17:23:49

                                                #378286
                                                Alan Charleston
                                                Participant
                                                  @alancharleston78882

                                                  Hi Joseph,

                                                  Thanks for putting me right as regards the motor resetting itself to the nearest step each time it powers up. I thought what I was doing was OK because I set the motor to run with 4800 pulses which resulted in the stepper motor rotating 3 times and the business end of the dividing head rotating 9 degrees which is what is needed for a 40 tooth gear. I set the head up to start at 0 degrees using the indexing pin, then went through the process of turning the Stepduino on and off 40 times. The indexing pin slid smoothly into the plate at 0 degrees, indicating an accurate process. The reason it worked, is that 4800 is divisible by 8 (the number of microsteps) so the rotor stopped at a full step rather than halfway through a step. My method would probably work if there was no microstepping, but the accuracy of the system would be less.

                                                  As far as the confusion regarding the steps/revolution is concerned, that was my fault. I could have set the steps/revolution to be 1600 (which is true) and the number of revolutions to be 3, but instead I set the steps/revolution to be 4800 (which is not true) and the number of revolutions to be 1 (which is also not true) but which also results in the stepper motor turning 3 times.

                                                  As far as the duration of the pulse to the motor goes, Dave had an ON time of 2 microseconds and an OFF time of 100 microseconds. I believe this gives a speed of about 375rpm. I found the motor was easily stalled. I wanted to reduce the speed and hence the acceleration at start-up and to increase the torque so I increased the ON time to 500 microseconds. The torque was much better and the speed went down to about 60 rpm. I ran the motor through 127 iterations when connected to the dividing head and the motor temperature didn't go up so I'm assuming I'm not damaging anything.

                                                  Hi Dave,

                                                  I loaded your first sketch into the Arduino and hooked the motor up to the dividing head. I set the head up to start at 0 degrees using the indexing pin, then applied power to the Stepduino and let it run until I counted 127 iterations. The indexing pin slid smoothly into the plate at 0 degrees so it looks like your solution works a treat.

                                                  Thanks for your latest sketch. There is a "Buttons" tutorial in an Arduino kit I've got so I'll work my way through it (again!) and see if I can get one to work with your sketch.

                                                  I'm really greatful for the help you've given me.

                                                  Regards,

                                                  Alan

                                                  #378289
                                                  Joseph Noci 1
                                                  Participant
                                                    @josephnoci1

                                                    Hello Alan.

                                                    All I can say is it's great to see you doing this! You said at the beginning you did not really know what you were doing, but you climbed in undaunted and, with Dave's splendid support as well, are making things turn the way you want.

                                                    Well done, and may the Force be with You!.

                                                    Joe

                                                    #378293
                                                    John Haine
                                                    Participant
                                                      @johnhaine32865

                                                      Alan, I still think you are not appreciating the significance of the pulse length. This is NOT the pulse length to the motor but to the driver IC. Each time it gets a pulse POSITIVE EDGE it changes the balance of currents in the motor windings to advance the rotor by the selected microstep amount (which can be 1). All that is happening when you adjust the on time, keeping the off time the same, is that you are reducing the pulse FREQUENCY and of course this also increases torque, this being a stepper motor. This is not a dc motor where you can change speed or torque by varying mark/space ration.

                                                      But sounds like good progress!

                                                    Viewing 25 posts - 26 through 50 (of 50 total)
                                                    • Please log in to reply to this topic. Registering is free and easy using the links on the menu at the top of this page.

                                                    Advert

                                                    Latest Replies

                                                    Home Forums General Questions Topics

                                                    Viewing 25 topics - 1 through 25 (of 25 total)
                                                    Viewing 25 topics - 1 through 25 (of 25 total)

                                                    View full reply list.

                                                    Advert

                                                    Newsletter Sign-up