How fast should we expect our stepper motors to spin? - Stepper Motor max USEFUL RPM Test

Поділитися
Вставка
  • Опубліковано 3 гру 2024

КОМЕНТАРІ • 111

  • @CyberOne
    @CyberOne 4 роки тому +21

    Stepper motors are a funny beasty, they are a current driven motor.
    The thing is, the faster you go, the more back EMF is generated and the current will be reduced.
    When the current reduces, such as when you have reached max voltage, then the torque of the motor will fall of as the speed increases.
    You will have to overcome the back EMF to maintain the current, you have to increase the voltage.
    Thats what the stepper driver is supposed to do.
    The higher the voltage you can supply the better.
    Also make sure you the set current is correct.
    Now acceleration is also a very critical thing to consider.
    Acceleration is torque/mass, so if you want to accelerate the motor to a speed in almost no time, then your gonna need a lot of torque, the thing with stepper motors is if you exceed the torque rating of the motor, it will skip steps and or not even move.
    You showed that at higher RPM settings, if you started it spinning by hand, you couldn't stop it.
    So when starting a stepper motor, ramp the speed up over time and you can get some very reliable operation from it.
    I would like to see you re-visit this subject using a speed ramp up and see how much better the performance will be.
    Keep up the good work.
    Ray

    • @WhitmanTechnological
      @WhitmanTechnological  4 роки тому +3

      Awesome information, thank you. Interesting note about raising the voltage to overcome the back EMF. I'm making a CNC router right now, and I picked up NEMA 23's and a 24V power supply to drive them. If I have trouble getting the table to move at an acceptable speed, maybe I'll need to move up to a 48V supply.
      In my reply to parin dave, I revised the Arduino code to include an adjustable ramp-up period and then posted it so people can copy/paste it. When testing that code, I was surprised to see that even with gradual acceleration the motor still didn't want to go much more than 350rpm. I adjusted the current on the driver to match the specs for my stepper, and also played with the setting to see if I could get better results slightly above or below the rating. No significant change at all - 350 or maybe 400 was the cap, even with a gradual ramp-up in speed. I was also curious if having something heavy to spin, so the inertia helped with the transition between steps, would affect the max usable speed, but didn't do anything with that.
      I think you revealed what the real limiting factor is. The back EMF. The motor's coils just barely get the circulating current to stop and start going the other way just in time for it to switch again. The time from backward spin to neutral is probably very close to balanced against the time from neutral to forward spin for each step. There's very little additional torque being supplied by the motor at that point. Raising voltage would shorten the time to reverse the current in the coils, allowing for faster stepping before that same tipping point is reached.
      I really like your comment, thank you.

    • @CyberOne
      @CyberOne 4 роки тому +1

      @@WhitmanTechnological The biggest cause in this type of motor as far as the generation of back EMF is the fact the coils are just big inductors.
      At DC the coils have a resistance.
      When you reverse the current however, the magnetic field needs to collapse, this collapse will induce a voltage that opposed the the change in direction, this is seen as an impedance until the current flow establishes a magnetic field in the opposite direction.
      The more rapidly the direction reverses, the higher the impedance will be.
      This follows the Maxwell laws governing inductors and inductance.
      This is not like a normal motor where the actual rate of rotation governs the amount of back EMF.
      Ray

    • @OMNI_INFINITY
      @OMNI_INFINITY 9 місяців тому

      Are the TB6600 drivers simply very slow motor drivers (thus they can't forward messages fast enough) or is the motor the main factor for determining how fast the commands can be processed?

    • @OMNI_INFINITY
      @OMNI_INFINITY 9 місяців тому

      PS: So a bldc with a worm gear is best in the budget/accessible range for relatively high speed AND torque or there is a better solution? Thanks in advance for answering these questions.

    • @CyberOne
      @CyberOne 9 місяців тому

      @@OMNI_INFINITY This is more an issue of the motor and the voltage the driver can control.
      The stepper motor is really just two big inductors.
      The coils have a max current they will safely conduct before they overheat and burn out.
      When the stepper is on and stationary, the resistance of the coils determines the DC voltage that can be applied to the stepper motor.
      As the motor starts to spin, the controller is now applying an AC voltage, an inductor with an AC voltage will produce a back Electro Motive Force (EMF) with the back EMF increasing with the frequency. The Frequency of the AC is determined by the speed of the motor in RPM x steps per revolution.
      We see this as an impedance which is added to the resistance of the coils.
      When you increase the impedance of the inductor (Motor winding) you will reduce the current flowing and in turn the torque the stepper motor is producing.
      Stepper motor drivers overcome this by increasing the voltage being sent to the motor.
      The max speed determined by the voltage the stepper driver can supply and the max voltage the stepper motor can withstand.

  • @robjones1500
    @robjones1500 3 роки тому +10

    If you accelerate it and play with the microstepping you should be able to get 1,100RPM.

  • @masterzerox2009
    @masterzerox2009 4 роки тому +4

    So the max if the max revolutions of our stepper motor are 350 rpm. Excellent video!

  • @gearhed78
    @gearhed78 9 місяців тому +1

    how is this project going these days?

    • @WhitmanTechnological
      @WhitmanTechnological  9 місяців тому

      It's been almost a year since my last video on this channel. In that time I started fresh with the fourth iteration of the robot. It's been a long adventure, mostly fun, with one fairly major roadblock that took me a long time to identify. It's a big step forward from the last Nephele video with the robot kinda moving on its own. I picked materials more carefully for the gears and structure. The roadblock that held me up for a long time was the ringing in the ribbon cables between the microcontroller and the analog-digital-converter chips embedded within each joint. I was getting a bunch of bad data from the ADC chips, and only through months of trial-and-error, research, and careful review of the oscilloscope did I eventually discover that the high-low signals are ringing in the ribbon cabled like a bell. The ADC interprets the fluctuation of the voltage from the ringing as extra high-low pulses, and sends back more bits of data than the microcontroller reads. It was a brutal but fascinating lesson to learn, and I think I have a fix for it. With any luck I'll have the hardware for Nephele 3 working in the next few months - and I can post a new videos. I have about 100 GB of raw footage from the last year, but three months of "I don't know why it's not working" and 20 hours of cutting nearly identical iterations of the same circuit board on my CNC router isn't enough substance to make an entertaining video. Lots of progress, but no functional milestone worth bundling into a video just yet. Thanks for asking :)

  • @OMNI_INFINITY
    @OMNI_INFINITY 9 місяців тому +1

    Are the TB6600 drivers simply very slow motor drivers (thus they can't forward messages fast enough) or is the motor the main factor for determining how fast the commands can be processed?

    • @WhitmanTechnological
      @WhitmanTechnological  9 місяців тому

      I'm using an A4988 driver in this video. I'm not driving the motor anywhere near it's theoretical maximum. I was testing for a use case with a relatively high torque load where I wanted to be able to reliably begin spinning at max speed with minimal ramping. Most stepper drivers can probably go much, much faster than I do in this video. As other commenters have pointed out, ramping up the speed instead of just starting from a dead stop will get the motor spinning a lot faster. Higher voltages can also help overcome the inductance of the motor coils as the speed increases, too. ~300 RPM is the fastest I want the motor to go when I designed the gearbox for a robot wheel system, but the motor/driver could easily double (maybe even triple?!) that if it was completely unloaded and I ramped up the speed more gradually.

  • @mathid3012
    @mathid3012 2 роки тому +1

    Can anyone help me ?. I have followed this video but my motor was not rotating fast, I can't vary the speed and I had more vibration. how to solve this problem?
    Thanks in advances

    • @WhitmanTechnological
      @WhitmanTechnological  2 роки тому

      It sounds maybe like the motor is miswired. The ones I used in this video have just four wires coming out. Some stepper motors have additional pairs of wires and if those are wired backwards (or the pairs are mismatched), the coils won't energize in the correct pattern and you'll get some random twitching but not coherent rotation. Some helpful diagrams:
      knowledge.ni.com/KnowledgeArticleDetails?id=kA00Z000000PAkPSAW
      Using a multimeter to test the resistance between pairs of wires you can probably identify which wires are looped together. If it's 6-wire, you might see higher resistance across the whole loop and less resistance when measuring to a center tap. Let us know if you figure out the problem.

  • @shinysquirrelclub
    @shinysquirrelclub Рік тому +1

    I looked at your code, and you're doing a 50% duty cycle. That driver really only wants about 10ms high and the rest of the cycle low. I think if you ramp up speed and you only send 10ms per on pulse, you'd get a lot better results.

    • @WhitmanTechnological
      @WhitmanTechnological  Рік тому

      Thanks for the info. If I do some manual controlling of steppers in the future, I'll write it up to trigger pulses instead of toggle the pin. Woot!

  • @sarahnasser6603
    @sarahnasser6603 Рік тому +1

    Please I need clear image of the connection..

    • @WhitmanTechnological
      @WhitmanTechnological  Рік тому +1

      A quick search will show how to run the wires for an stepper driver like this: www.google.com/search?tbm=isch&q=stepper+motor+wiring

  • @majdalzahrani1229
    @majdalzahrani1229 Рік тому +1

    Could you please explain how can I control the speed in code 1?

    • @WhitmanTechnological
      @WhitmanTechnological  Рік тому

      This part here:
      //pulseDelay = RPM / sec/min * micros/sec and divided by two because each step requires going high and then going low (two toggles).
      unsigned long pulseDelay = 100 / 60 * 1000000 / 2;
      The RPM is set to 100. If you wanted 40 rpm, you'd change it like this:
      unsigned long pulseDelay = 40 / 60 * 1000000 / 2;

    • @WhitmanTechnological
      @WhitmanTechnological  Рік тому

      I just noticed this is missing a piece, the steps-per-revolution of the stepper motor.
      unsigned long pulseDelay = 100 / 60 * 1000000 / 2;
      It'd be more like:
      //pulseDelay = RPM / (sec/min) * (micros/sec) / (steps/rev) and divided by two because each step requires going high and then going low (two toggles).
      unsigned long pulseDelay = 100 / 60 * 1000000 / 200 / 2;

  • @easy_engineering_drawing
    @easy_engineering_drawing 2 роки тому +1

    Can we use both Nema 17 (DRV8825) and Nema 23 (TB6650) on same Arduino simultaneously?

    • @WhitmanTechnological
      @WhitmanTechnological  2 роки тому +1

      Sure you can. The drivers get their power directly from a power source, and not from the pins of the Arduino. The current needed for the logic pins on the drivers to indicate the direction and step pulses is very close to zero. An Arduino can happily supply the stepping signals to any driver, and the driver is pulling the power to drive the motor directly from its power pins. I have a video on my channel where I build a CNC router, and it has four NEMA23's and three NEMA17's, using TB6600's to drive the big motors, and A4988s to drive the smaller ones.

    • @easy_engineering_drawing
      @easy_engineering_drawing 2 роки тому +1

      @@WhitmanTechnological Wow, awesome reply. I was looking for this kind of variation in stepper motor, but I found none. Surely I will watch your recommended video. Thank a ton for your reply.

  • @sarahnasser6603
    @sarahnasser6603 Рік тому +1

    Hello,
    Thanks for the code it worked well,
    Is it possible to control the number of revolution of the motor?
    For example if I wanted 30 revolutions then it stops, how can I do this?
    Thanks again

    • @WhitmanTechnological
      @WhitmanTechnological  Рік тому +1

      You'd count the number of pulses, and stop sending pulses when you hit the desired amount of turning. Adding a target step count, counting the steps, and stopping the pulses when we've hit the target. We'd wrap that into example #1 something like this:
      int stepPin = 5;
      int dirPin = 6;
      long stepsPerRevolution = 200; //how many steps to turn the motor one time.
      long targetRotation = 30; //Number of revolutions to turn
      long totalSteps = targetRotation * stepsPreRevolution; //How many steps we need to take to rotate the desired amount
      long stepsCounted = 0; //Track the number of steps we've rotated the motor
      unsigned long currentTime;
      unsigned long nextStamp;
      bool isOn = false;
      //pulseDelay = RPM * steps/rev / sec/min * micros/sec and divided by two because each step requires going high and then going low (two toggles).
      unsigned long pulseDelay = 100 * stepsPerRevolution / 60 * 1000000 / 2;
      void setup() {
      pinMode(stepPin, OUTPUT);
      pinMode(dirPin, OUTPUT);
      digitalWrite(stepPin, LOW);
      analogWrite(dirPin, LOW);
      currentTime = micros();
      nextStamp = currentTime;
      }
      void loop() {
      currentTime = micros();
      //Add a check to stop rotating once we hit the desired amount of rotation.
      if (currentTime - nextStamp >= pulseDelay && stepsCounted < totalSteps) {
      //The pulseDelay has elapsed and it's time to toggle the pin.
      isOn = !isOn;
      digitalWrite(stepPin, isOn); //Toggle the pin.
      nextStamp += pulseDelay;
      if (!isOn) stepsCounted++; //When the pulse turns off, we count it as a step.
      }
      }

    • @sarahnasser6603
      @sarahnasser6603 Рік тому

      @@WhitmanTechnological Thanks for your time again.
      The second code worked for me. But still I could not control the number of revolutions using the same code.
      Can you help me do it?

    • @WhitmanTechnological
      @WhitmanTechnological  Рік тому

      @@sarahnasser6603 Did it stop after 30 turns?
      long targetRotation = 30; //Number of revolutions to turn
      That should be telling it to turn 30 times and then stop. You could make that a 2, if 30 rotations is too long to wait. I don't have a stepper driver and stepper handy to test the code, but my reply above looks like it should work properly.

    • @WhitmanTechnological
      @WhitmanTechnological  Рік тому

      @@sarahnasser6603 there is a typo in there:
      long totalSteps = targetRotation * stepsPreRevolution; //How many steps we need to take to rotate the desired amount
      stepsPreRevolution would need to be stepsPerRevolution for it to compile. I'm sure you fixed that already.

    • @sarahnasser6603
      @sarahnasser6603 Рік тому

      @@WhitmanTechnological
      No, the first code haven’t actually worked even after fixing the bug, the motor didn’t start at all. It makes sound as if it’s working but not rotating not even with a push.
      However, the second code worked well, the motor rotates. In my project, i need it to rotate 30 times and then have a 2 seconds delay.
      If you don’t mind, can you help me with that or just further explain the code and what is considered a revolution.
      Thank you so much for your help so far

  • @EdwardYamunaque
    @EdwardYamunaque 2 роки тому +1

    what is the way to burn, spoil a nema 17 motor?

    • @WhitmanTechnological
      @WhitmanTechnological  2 роки тому +2

      Stepper motors like these (nema17, nema23, etc.) are pretty resilient. They usually have a working temperature range that goes well above what's comfortable for a human. They're built to hold position with maximum torque, so they're capable of sitting, stalled out, at their max rated current indefinitely. The only electrical way to burn them out is to exceed the rated current and/or temperature long enough to actually melt the wire coils of the motor (or at least the insulation). They're heavy and bulky, but they're pretty bullet-proof against all but the most malicious miswiring.

  • @Robert-zx2df
    @Robert-zx2df 3 роки тому +1

    I was doing about 700 rpm with nema 23. Not much load though .
    30 volts ,1.5amps

  • @jeevaa5966
    @jeevaa5966 2 роки тому +1

    I want to uce tmc2209 driver, when I connect the driver motor is not rotating

    • @Kalvinjj
      @Kalvinjj 2 роки тому +2

      Is it vibrating at least? If it is, then you probably have one motor coil disconnected, could be one pin or both of them.
      If it's not even vibrating, you could either have both coils with a bad connection, or the coils connected wrong, like one pin of a coil into the output of the right coil and the other pin on the wrong coil, dunno what behavior the TMC2209 would do in that case.
      Other than that, you could have problems on the TMC itself, like no motor voltage, no logic voltage or it's configured for SPI but you're trying to run it stand-alone, or the SPI connection is not communicating properly.

    • @mathid3012
      @mathid3012 2 роки тому

      @@Kalvinjj Can anyone help me ?. I have followed this video but my motor was not rotating fast, I can't vary the speed and I had more vibration. how to solve this problem?
      Thanks in advances

  • @ohm.3768
    @ohm.3768 3 роки тому +1

    Can I use this motor for skateboard to make it (electric skateboard🛹) becoz it's having high torque will u give me code for running at high torque and speed plzz🙂

    • @WhitmanTechnological
      @WhitmanTechnological  3 роки тому +1

      I'm digging pretty deep into brushless motors right now. They have most of the benefits of stepper motors, but are more power efficient and better suited to applications where you want to accelerate or decelerate. Compare that to stepper motors where the main use case is being able to rotate exactly the specified amount. The controllers ("ESC's") for a brushless motor are more expensive at around US$15 and up. But the power, torque and speed they can produce are going to do a much better job than a stepper motor will. I was going to use steppers for my robots foot wheels, but I switched to brushed motors, and now I'm looking into brushless ones.
      A stepper in a skateboard would work until the load exceeds the holding torque, but a brushless motor will provide a uniform amount of push, and consume the least amount of power doing it. In terms of battery life, I'd expect power consumption with a brushless DC motor to be 10x less than with a stepper motor for something like wheeling a robot around or pushing a skateboard.
      In any case, I posted some Arduino code as a stickied comment on this video to run a stepper at a specific RPM so you can grab it and try it out with your steppers.

    • @ohm.3768
      @ohm.3768 3 роки тому +1

      @@WhitmanTechnological thanks a lot 🙏❤🌹 uncle ur means a lot for me it's truly helpful I subscribe ur channel ur channel is helpful for me.

  • @roghibashfahani15
    @roghibashfahani15 2 роки тому +1

    Hello, i already buy a4988. Can u give me a tutorial a4988 serial input using millis..
    So when i input some number it Will move as much as typing.

    • @WhitmanTechnological
      @WhitmanTechnological  2 роки тому +2

      If we take the code from #1 in the pinned comment and slap in some step counting and reading from serial it would look like this:
      int stepPin = 5;
      int dirPin = 6;
      unsigned long currentTime;
      unsigned long nextStamp;
      bool isOn = false;
      //pulseDelay = RPM / sec/min * micros/sec and divided by two because each step requires going high and then going low (two toggles).
      unsigned long pulseDelay = 100 / 60 * 1000000 / 2;
      int halfStepCount; //Steps taken so far
      int halfStepsTotal; //Steps requested by serial.
      void setup() {
      pinMode(stepPin, OUTPUT);
      pinMode(dirPin, OUTPUT);
      digitalWrite(stepPin, LOW);
      analogWrite(dirPin, LOW);
      currentTime = micros();
      nextStamp = currentTime;
      Serial.begin(115200);
      }
      void loop() {
      currentTime = micros();
      if (Serial.available()){
      halfStepCount = 0; //Reset step progress.
      halfStepsTotal = Serial.parseInt() * 2; //Steps from serial doubled to be half-steps needed.
      }

      if (currentTime - nextStamp >= pulseDelay && halfStepCount < halfStepsTotal) {
      //The pulseDelay has elapsed and it's time to toggle the pin, and we still have steps to take.
      isOn = !isOn;
      halfStepCount++; //Took another half step.
      digitalWrite(stepPin, isOn); //Toggle the pin.
      nextStamp = currentTime;
      }
      }

    • @roghibashfahani15
      @roghibashfahani15 2 роки тому

      @@WhitmanTechnological thanks sir, i was try to combine your 1st program with my other programs. But the stepper doesnt move. I change the micros() with millis() and still didnt get it. Can i share my program here..

    • @WhitmanTechnological
      @WhitmanTechnological  2 роки тому

      @@roghibashfahani15 To change micros to millis, lower this value from:
      unsigned long pulseDelay = 100 / 60 * 1000000 / 2;
      to this:
      unsigned long pulseDelay = 100 / 60 * 1000 / 2;
      That might help.

    • @roghibashfahani15
      @roghibashfahani15 2 роки тому

      @@WhitmanTechnological hello sir the code doesnt work out, when i click serial monitor icon, the stepper is shaking and i try input some number at serial monitor, it do nothing.

    • @roghibashfahani15
      @roghibashfahani15 2 роки тому

      @@WhitmanTechnological no sir, the sepper just move +- 1mm /s i think it bcause micros more small than millis()

  • @carbusolaya1998
    @carbusolaya1998 2 роки тому +1

    how much would the torque be?

    • @WhitmanTechnological
      @WhitmanTechnological  2 роки тому

      Usually, the holding torque at the rated maximum continuous current of a specific motor is listed by the manufacturer. It can vary quite a bit from motor to motor even when both motors use the same Nema specification for their mounting holes. Personally, if I knew how much torque I needed to ensure rotation at the correct speed, I'd shoot for a motor that could maybe go 25% beyond that for its holding torque - for hobby applications. Last thing I want is a system stalling out because of underpowered motors.

  • @diegoalbertoramirezlopez2060
    @diegoalbertoramirezlopez2060 2 роки тому +1

    Can You pass me the code of video? Pls

  • @Robert-zx2df
    @Robert-zx2df 3 роки тому +2

    Increasing voltage and amps will fix this issue.

  • @deeepakkushwah2503
    @deeepakkushwah2503 3 роки тому +1

    Can you please help me to make a dmx stapper motor with encoder

    • @deeepakkushwah2503
      @deeepakkushwah2503 3 роки тому

      Please help me

    • @WhitmanTechnological
      @WhitmanTechnological  3 роки тому

      I don't have a solution for you, but I can definitely walk with you through figuring out a reasonable angle to approach the problem.
      If your needs can be met by a DMX servo, I would seriously look into just buying a DMX servo controller and servo motor. There are DMX servo controllers that can control multiple servos for relatively little cost ($40 on eBay for an 8 servo controller). Servos are common enough to be cheaper than an equivalent encoded stepper motor.
      Barring that, we can build our own...
      I'm going to assume you're already using a DMX512 controller and you want it to let you control the rotation of a stepper motor.
      I don't actually know what DMX is, so let me learn that real quick... According to Wikipedia, DMX512 started as a standardized stage lighting control interface and expanded to enable other effects like fog machines. The protocol itself has a few steps to unwrap the data (differential signaling with variable packet length just like Ethernet on CAT5/6 wires), so a prewritten library is going to help with the heavy lifting of wrapping and unwrapping the data. Fortunately, Arduino has a DMXSerial library so all the heavy lifting for the protocol is already available.
      Depending on your threshold for pain, you can take one of two routes to get the DMX signal unwrapped into an Arduino:
      Make your own DMX circuitry. The Arduino DMXSerial library's documentation has sample wiring schematics for how to connect an Arduino to a DMX system. It'll be a lot more technical, but you can perhaps save some money.
      -or-
      DFRobot.com sells a DMX Shield that has the DMX connector and includes an Arduino library and samples for handling DMX communication. It's well within the hobbyist price range, probably not more expensive than the components required in the schematic from the DMXSerial documentation, actually. Barring DFRobot, you could look for another DMX shield for Arduino, as there seem to be a few options out there.
      At this point, if you didn't need an encoder to track the movement of the motor, then you could just hook up any stepper driver (like the A4988 I use in this video) and start coding the Arduino to send steps to the motor based on your DMX input.
      Assuming the encoder is a critical part of the design because you expect the motor will miss steps and you definitely need to correct for those missed steps, probably the best solution is to just buy a stepper motor with a built in encoder. (Side note: We could also use a servo motor here and control it like a servo instead of controlling steps on an encoded stepper motor.) Making our own encoder means we need to work with the mechanical aspects of the motor's drive train, and then we're probably doing some combination of the following: losing quality from mechanical and electrical underengineering and mistakes; wasting time to engineer everything really well; spending a lot more money to build something from scratch that is already affordable off-the-shelf. At least, those are the reasons that if I needed an encoder on the motor itself, I'd just buy a stepper with the built-in encoder.
      StepperOnline has a selection of stepper motors with encoders, and I've been happy with my experience with their (non-encoder) motors so far. Because of the extra cost, I haven't used an encoded stepper myself on any projects yet.
      That's the process I'd use - get the signal onto an Arduino, then write some Arduino code to read the DMX signal and then trigger the steps on the stepper accordingly. And I guess also check that the motor rotated to the correct position on the encoder and correct the steps if it didn't...
      Hope this helps you get started on your project :)

    • @deepeshkushwah607
      @deepeshkushwah607 3 роки тому +1

      You can make a code for me

    • @WhitmanTechnological
      @WhitmanTechnological  3 роки тому +1

      @@deepeshkushwah607 No. You'll need to write your own code.

    • @deepeshkushwah607
      @deepeshkushwah607 3 роки тому +1

      I will pay you for that code 26$

  • @Blendershick
    @Blendershick 4 роки тому +1

    Thank you

  • @Ankit.max.
    @Ankit.max. Рік тому +1

    give me code please

    • @WhitmanTechnological
      @WhitmanTechnological  Рік тому

      Check the pinned comment at the top. I have a couple versions of code to pulse a stepper driver that you can copy/paste.

  • @litshinkaflip1047
    @litshinkaflip1047 3 роки тому +1

    Idk but I think you could have prevented the drivers from getting destroyed by placing decoupling capacitors between VDD+GND and VMOT+GND
    Nice informative video tho

    • @WhitmanTechnological
      @WhitmanTechnological  3 роки тому

      Thank you.
      The one I fried was from connecting the 12V source for the motor power to the driver's 5V logic power pin by mistake. Just way overvoltage. A decoupling capacitor wouldn't be able to do anything about that mistake. It was on a breadboard and the pin labels are on the underside of the driver. Killed it instantly. I still have it on my desk though, and at some point I'll probably triple-check if it's dead-dead or just mostly-dead.
      I got a couple ESP23-CAM modules about a month ago, and they're not only super power-thirsty, they're also really sensitive to fluctuations in the power supply. A strong decoupling capacitor is pretty-much mandatory to use those things.

    • @litshinkaflip1047
      @litshinkaflip1047 3 роки тому +1

      @@WhitmanTechnological Nice to know about the esp32cam power consumption, I use esp32 devkits for my stuff (also high power consumption when scanning for devices etc.)
      I'm sure my esp32 devkit uses this much power because it has the pcb antenna mounted directly at the pcb (copper inside the pcb isn't good for rf). Might be the case with your esp32cam too.

  • @parindave1814
    @parindave1814 4 роки тому +2

    Hi, your video cleared my doubts to not use stepper for high speeds.
    Thanks
    Could you share the code so that I could check the limit for my stepper

    • @WhitmanTechnological
      @WhitmanTechnological  4 роки тому +1

      Thanks for your comment! I rewrote that program for you - or actually a better version of that code - since I had reused that file for a later video and all that was left was some PWM adjusting routines that wouldn't do anything like what was shown in the video. In this rewrite, I put in a variable that lets you set the time for it to ramp the speed up to the max. www.joshwhitman.com/stepper-motor-arduino-code.aspx

    • @parindave1814
      @parindave1814 4 роки тому +1

      @@WhitmanTechnological thank you friend.....
      Our community grows with efforts of persons like you who are there to help others......
      Once again Thanks for the code......

  • @shamssalehin2376
    @shamssalehin2376 Рік тому

    Mine just stuck at 300, all 3 of em.

  • @driversteve9345
    @driversteve9345 Рік тому +1

    You're doing it all wrong!!
    Try using the AccelStepper library! You'll get a way higher speed because you are ramping up to that speed! No motor, unless you're Tesla, ramps up to 100% immediately on command! You should know this!

  • @WhitmanTechnological
    @WhitmanTechnological  3 роки тому +2

    A few people have asked for code, so here are two versions for you to play with and customize:
    #1 - Simple Run at a fixed speed: ##################################
    int stepPin = 5;
    int dirPin = 6;
    unsigned long currentTime;
    unsigned long nextStamp;
    bool isOn = false;
    //pulseDelay = RPM * steps/revolution / sec/min * micros/sec and divided by two because each step requires going high and then going low (two toggles).
    unsigned long pulseDelay = 100 * 200 / 60 * 1000000 / 2;
    void setup() {
    pinMode(stepPin, OUTPUT);
    pinMode(dirPin, OUTPUT);
    digitalWrite(stepPin, LOW);
    analogWrite(dirPin, LOW);
    currentTime = micros();
    nextStamp = currentTime;
    }
    void loop() {
    currentTime = micros();

    if (currentTime - nextStamp >= pulseDelay) {
    //The pulseDelay has elapsed and it's time to toggle the pin.
    isOn = !isOn;
    digitalWrite(stepPin, isOn); //Toggle the pin.
    nextStamp += pulseDelay;
    }
    }
    #2 - Ramping up the speed from zero to some max RPM: ##################################
    int stepPin = 3; //Set to whatever pin will trigger steps.
    int dirPin = 2; //Set to the pin that tells the stepper driver if it's forward or backward.
    int enablePin = 4; //Turn the stepper driver on or off.
    unsigned long rpm = 300; //Target max RPM of the stepper for this test.
    unsigned long stepsPerRevolution = 200; //Enter the number of steps for your motor to make a full revolution.
    bool forward = true; //Toggle to switch motor direction.
    unsigned long accelTime = 2; //Second to accelerate the motor up to the max RPM (use 0 to just start the motor at full speed)
    unsigned long firstStamp; //When the warmup began.
    unsigned long lastStamp; //Stamp from the previous toggle.
    unsigned long curStamp; //Stamp from the current iteration.
    unsigned long rampTime = accelTime * 1000000; //How long to accelerate in microseconds.
    bool warmup = true; //Track if we've made it through the initial acceleration stage or not.
    bool pinOn = false;
    unsigned long toggleTime;
    void setup() {
    pinMode(stepPin, OUTPUT);
    pinMode(dirPin, OUTPUT);
    pinMode(enablePin, OUTPUT);
    pinMode(LED_BUILTIN, OUTPUT);
    digitalWrite(stepPin, pinOn); //Set the step pin low.
    digitalWrite(dirPin, forward); //Set the direction.
    digitalWrite(enablePin, LOW); //Pull the enable pin low to turn on the stepper driver.
    firstStamp = lastStamp = micros(); //Note the start time.
    //Determine the number of microseconds per toggle of the step pin at the target RPM.
    toggleTime = 60000000; //Number of micros in one minute
    toggleTime /= rpm; //divid by number of times per minute to revolve
    toggleTime /= stepsPerRevolution; //divide by number of steps to complete a full revolution. Now we have the number of micros per step.
    toggleTime /= 2; //Cut in half so half the time it's on, half off.
    }
    void loop() {
    curStamp = micros(); //Get the timestamp for this loop.
    unsigned long toggleTarget = toggleTime;

    if (warmup){ //Still accelerating at the outset, we'll increase the toggle time proportionally.
    if (curStamp - firstStamp > rampTime) warmup = false; //We've amde it to the end of the speed ramp.
    else {
    //Increase the toggle time proportional to how far along the acceleration ramp we are, longer at the start, no increase at the end.
    unsigned long tempToggle = (rampTime - (curStamp - firstStamp)) * toggleTime / rampTime; //less and less added time to the toggle.
    toggleTarget += tempToggle; //Add this extra toggle delay to the motor start.
    }
    }
    unsigned long elapsed = curStamp - lastStamp;
    if (elapsed >= toggleTarget) {
    //Toggle the step pin.
    pinOn = !pinOn;
    digitalWrite(stepPin, pinOn);
    digitalWrite(LED_BUILTIN, pinOn);
    //Update the tracking variables.
    lastStamp += toggleTarget; //Advance the stamp by the amount of time that was meant to have occurred between pins.
    }
    }
    Good luck, have fun!!

    • @RushitShukla
      @RushitShukla 2 роки тому

      I'm using a NEMA17 with A4988 driver. I tried to run the above fixed speed code and it doesn't have any errors, but the shaft of the stepper doesn't move at all. Later, I tried to change the values in the unsigned long pulseDelay and by trial and error the motor did run at lesser values(still not at what RPM was specified). For example instead of 1000000, I reduced it to 1000. If you can help me explain this.

    • @WhitmanTechnological
      @WhitmanTechnological  2 роки тому

      @@RushitShukla I think the problem is where pulseDelay is set to 100 * 60 * 1000000 / 2. I say "RPM * seconds per minute" in the comment, but that doesn't make sense. It should be "RPM / sec/min". If we look at the units - rev/min * sec/min = rev*sec/min^2. But rev/min * min/sec = rev/sec which is what we want. It should be 100 / 60 instead of 100 * 60. That's a factor of 3600 different. Try swapping the multiply for divide and that should give more reasonable speeds. Oh good, it let me edit the original comment. Thanks for taking the time to describe this problem. :)

    • @roghibashfahani15
      @roghibashfahani15 2 роки тому

      hello, how i can set up if im using adafruit motor shield L293D?

    • @WhitmanTechnological
      @WhitmanTechnological  2 роки тому

      @@roghibashfahani15 This code won't be super useful with an L293D shield.
      To compare a stepper driver like an A4988 chip with the L293D, we can split the functions of the 4988 into two groups: logic and power management. The logic on the 4988 takes step and direction inputs and decides which of the motor wires go to positive and which go to ground. These logical processes happen at very low voltage and current - much lower than would be required to drive a motor. The power management functions of the chip A4988 then take the low power decision of which wires are + and which are - to the motor and amplifies the voltage and current significantly using sets of much more powerful transistors.
      The L293D is only the second half - you give it a low voltage signal that you want wire 1 to go high and wire 2 to go low, and it will amplify the power of that weak signal so it's strong enough to drive the motor.
      Happily, others have already done the coding and this is what Arduino's Stepper library is for. Here's a tutorial that shows how to wire up the L293D and it has sample code to run it. lastminuteengineers.com/stepper-motor-l293d-arduino-tutorial/

    • @roghibashfahani15
      @roghibashfahani15 2 роки тому

      I'am so desperated with this motor driver. By the way im using l293d motor driver shield and can't make the stepper move more faster, to slow. I was try zk-5ad ta6586 it is so powerfull but once again i can't make it to push the power. Hahhaa

  • @MrJPI
    @MrJPI 3 місяці тому

    Why didn't you use a ramp to accelerate the motor_

    • @WhitmanTechnological
      @WhitmanTechnological  3 місяці тому +1

      I wasn't looking for the laboratory maximum speed. I wanted a reasonable upper end I could design for in a specific use on a robot.

    • @MrJPI
      @MrJPI 3 місяці тому +1

      @@WhitmanTechnological Ok, nice video you had. I have been playing with steppers for years and I accelerate them by a totally digital ramp generator of my own design. It uses binary rate multipliers, up/down counters and comparators. You can program in the acceleration, initial (starting) speed and final speed. After that (keeping the accel constant) you just output new higher or lower speed and you get the stepping frequency for that.

    • @WhitmanTechnological
      @WhitmanTechnological  3 місяці тому

      @@MrJPI That sounds awesome.