Это видео недоступно.
Сожалеем об этом.

Controlling DC and Stepper Motors With A Raspberry Pi - How to use Adafruit DC & Stepper Motor HAT

Поделиться
HTML-код
  • Опубликовано: 17 авг 2024
  • This will demonstrate exactly how to control Standard Stepper Motors and DC Motors with a Raspberry Pi Single-Board Computer. To do this as fast and seamlessly as possible we will utilise an Adafruit HAT and the Python Programming Language.
    Full Article (with Terminal Commands) - core-electroni...
    Related Information
    Set Up a Raspberry Pi as a Desktop Computer - core-electroni...
    Controlling a Solenoid With Raspberry Pi - core-electroni...
    Controlling Standard Servos With Raspberry Pi - core-electroni...
    Project Auto Tracking Camera System - core-electroni...
    How to use Raspberry Pi Imager - core-electroni...
    Use Your Phone to Control Your Raspberry Pi - core-electroni...
    We want a fully customisable method of converting electrical energy into rotational energy (angular kinetic energy). This HAT is stackable up to 32 times. This means you can control independently up to 128 DC Motors or up to 64 Stepper Motors all through a single Raspberry Pi Single Board Computer
    Depending on your needs either a DC motor or a Stepper Motor is going to be preferable. You might want a device that can rotate at a certain speed (RPM, revolutions per minute). In that case, a DC motor is what you would want to use. You might want a device that rotates to a precise angular position, at a very precise speed, or a set amount of rotations. In this case, a Stepper motor is what you would want to use.
    DC motors are available in a huge range of sizes. You can get very tiny motors to very large industrial motors capable of many kilowatts, and everything in between. They are lightweight, reasonably efficient, and have good torque. They come in Brushless or Brushed variants. Stepper motors are DC motors that move in discrete steps. They have multiple coils that are organized in groups/phases. By energizing each phase in sequence, the stepper motor will rotate. Throw in some computer control and you can achieve very precise positioning and rotational speed control. For this reason, stepper motors are utilised in almost all precision motion control applications.
    The motor controllers on this HAT are designed to run from 5V to 12V. Weird motor problems are often due to voltage mismatches so double-check your specification sheets first when it comes to troubleshooting. Most tiny 1.5V-3V Motors are not going to work or will slowly become damaged by 5V power. It is OK to run Stepper Motors at lower-than-rated voltage. They will simply carry less current and deliver less torque. Each Motor Driver on the HAT is capable of pushing out 2A.
    If you have any questions about this content or want to share a project you're working on head over to our maker forum, we are full time makers and here to help - coreelec.io/forum
    Core Electronics is located in the heart of Newcastle, Australia. We're powered by makers, for makers. Drop by if you are looking for:
    Adafruit DC and Stepper Motor HAT - core-electroni...
    Adafruit DC and Stepper Motor Bonnet (Solderless Solution) - core-electroni...
    Raspberry Pi 4 Model B (4GB) Ultimate Kit Bundle (AVALIABLE!) - core-electroni...
    Standard 5V DC Motor - core-electroni...
    Standard 12V Stepper Motor - core-electroni...
    Raspberry Pi Single Board Computers and Gear: core-electroni...
    Stackable Headers - core-electroni...
    0:00 Intro
    0:18 HAT Overview
    0:56 What You Need
    3:11 Soldering Hardware
    3:55 Hardware Assembly
    6:12 Software Installation
    6:56 DC Motor Control Script
    7:33 Success 1!
    7:57 DC Motor Script Explanation
    9:32 Stepper Motor Control Script
    10:02 Success 2!
    10:19 Stepper Motor Script Explanation
    11:55 Where to Now
    12:35 Outro

Комментарии • 85

  • @fredwupkensoppel8949
    @fredwupkensoppel8949 Месяц назад

    Clear instructions, simple language, safety advice where necessary - that's a good tutorial, great even!

  • @awensman25
    @awensman25 5 месяцев назад +1

    I've done nothing with rasberry Pi, but your explanations make it so easy to understand. Keep it up!

  • @Roxomus
    @Roxomus 3 месяца назад +1

    You have a really good way of explaining things. Clear, at a good pace, and in the right amount. Thanks for this video!

  • @marlonsamaniego7884
    @marlonsamaniego7884 Год назад +4

    Excellent video. I am trying to get a very similar setup to work so this was very helpful.

  • @minhtruong9408
    @minhtruong9408 4 месяца назад

    Thank you so much to show how to working with i2c stepper motor control. have a nice day.

  • @zechenwei1139
    @zechenwei1139 Год назад +4

    Thank you for the video! Exactly what I needed

  • @user-cf4rw6bt4h
    @user-cf4rw6bt4h 4 месяца назад +1

    In your video, you used separate power sources for the motor controller and the Raspberry Pi, totaling two power sources. Instead of doing that, isn't there a Raspberry Pi component, similar to a computer supply unit, that automatically supplies the necessary power to each module?

  • @barrythelad7793
    @barrythelad7793 Год назад +2

    incredible video, thank you so much

  • @fosterdexing5673
    @fosterdexing5673 10 месяцев назад

    Great Video! Very informative and useful links too. Thanks!!

  • @YINGAI1995
    @YINGAI1995 Год назад +1

    Just stumbled upon your channel, great production quality and steps!! Subscribed

  • @lukalovric4872
    @lukalovric4872 Год назад +2

    Great video!
    Can you show us how to control more than 4 stepper motors with this HAT?

    • @Core-Electronics
      @Core-Electronics  Год назад

      The full written up article explains how to stack multiple HATs 😊 the trickiest part is assigning I2C Addresses in the script which requires only one line to be altered in the demo Python scripts.

  • @DanielGeri
    @DanielGeri Год назад +2

    This is great! Any chance you have advice on how to add a "homing" mechanism to the stepper?

    • @Core-Electronics
      @Core-Electronics  Год назад

      The Free and unused GPIO pins are shown in this forum post - forums.adafruit.com/viewtopic.php?f=8&t=115770
      With that knowledge you can then add limit switches coming from those previously free GPIO pins. Then you just got to program in what you need 😊

  • @shubhamkale7420
    @shubhamkale7420 4 месяца назад

    Have the same setup as you but motor is not giving the required output. Any suggesttions?

  • @richardliu6163
    @richardliu6163 Год назад

    Good tutorial.

  • @ownage3523
    @ownage3523 Год назад +2

    When soldering the piece at 3:37, is it ok if the solders on different pins end up connecting? Will this mess up anything electronically?

    • @Core-Electronics
      @Core-Electronics  Год назад +1

      Definitely could cause issues (including the dreaded puff of magic smoke)! For instance if you accidentally electrically connected a 5V Pin to the 3.3V Pin that will break your Raspberry Pi. pinout.xyz/
      Removing solder can best be done with a lot of flux and solder wick - core-electronics.com.au/solder-wick-desolder-braid-0-8mm-5ft-8015.html
      You can flick off solder by heating it up and whipping the soldering pencil away from you but it is no where near as elegant or as easy to do.

  • @gilles4332
    @gilles4332 Год назад +1

    Hello and thank you for your work, could you show the hall effect sensor connection for the direction limits and the home return with this configuration and the stepper motors, no information on this subject, thank you.

    • @Core-Electronics
      @Core-Electronics  Год назад +1

      Love your idea! That is something I'm definitely interested in pursuing. Until I get to it here is a fellow using hall effect sensors with a Raspberry Pi - ruclips.net/video/Pvk-f6q3-Cc/видео.html
      Then all you need to do is write up a Python script to turn it into a Edge/Limit Switch

  • @KSp33dlin
    @KSp33dlin Год назад

    Hi @core electronics!
    Thanks for the very informative video. I’ve learned to control step motors using a DRV8825 driver with which one usually tunes the step motor current using a potentiometer. Could you explain to me why this board does not require this kind of tuning? Also, what happens if I connect, say, a 1.5A motor to the board? Will the motor try to draw too much power from the board?
    Sorry if these questions have obvious answers - I’m just getting into electronics.
    Thanks again and best wishes!

  • @mickzexe3086
    @mickzexe3086 3 дня назад

    Hey there, can i also stack the Adafruit 16-Channel PWM + Servo HAT on top of this?

    • @Core-Electronics
      @Core-Electronics  2 дня назад

      These use I2C which can have (theoretically) dozens of them stacked on top of each other. As long as you solder the right pin headers to stack them, it should work!

  • @fonz7697
    @fonz7697 Год назад +2

    Where can I find the wires used at 5:39

    • @Core-Electronics
      @Core-Electronics  Год назад +1

      I used these Jumper wires here and cut/stripped off one end with my clippers - core-electronics.com.au/catalog/product/view/sku/ADA1954

  • @flickmew99
    @flickmew99 Год назад

    If I don't have those hat for running my stepper motor, could I directly connect my raspberry pi directly to the regular stepper driver? I heard that you should convert the logic level from the stepper driver first (because most of the pinout using 5v logic), so it would not damage your Pi. But I have seen people directly connect the driver to Pi and had no issued with it. I'm confused

  • @ownage3523
    @ownage3523 Год назад +1

    I have a power supply that delivers 12V at 2A. If I have a stepper motor rated for 12V at 1.68A, will the extra 0.32A from the power supply damage the motor?

    • @Core-Electronics
      @Core-Electronics  Год назад +1

      You are totally safe. The system will only pull the amps that it requires. Come check here if you want to know my Golden Rules when it comes to Power supply selection 😊 core-electronics.com.au/guides/prototyping/power-supply-which-to-choose/

  • @gilles4332
    @gilles4332 Год назад +1

    as I told you issac uses an arduino and I want to replace it with an rpi with the hat that you present, I have already printed and assembled all the parts, and modify for the rpi, I also have the stepper motor and my two cameras (an rpi hq and a usb), the one in usb to serve me as a pointer, I think to use open cv, and have an automatic mode and a manual mode, if you can help me it would be great otherwise thank you anyway

    • @Core-Electronics
      @Core-Electronics  Год назад +1

      Sounds like a formidable project 😊 the best place to get help for big project knowledge is our Core Electronics Forum, definitely come write up a post there if you need - forum.core-electronics.com.au/

  • @leftmindmedia
    @leftmindmedia 9 месяцев назад

    Is it possible to connect other things with the hat on? I'd like to control both a motor and a light.

    • @Core-Electronics
      @Core-Electronics  9 месяцев назад

      That depends on what light you are trying to control and how you are setting it up. You can think of the M terminals as a controllable voltage. You can increase and decrease or swap the polarity of the voltage. So if your light is suitable, you can happily run it off another motor channel, and you could even change the brightness of it the same way you would control motor speed, but it all depends on the light.
      If you want some more help, chuck us a post on our forums, we have a lot more eyes on there. Just give us some more details of the light you are using and the setup: forum.core-electronics.com.au
      Cheers!

  • @wamtm
    @wamtm Год назад +1

    could I stack another board on top of the ada that gives me access to the underlying gpio pins so i can run some solonoids in addition to the stepper motor? Thanks

    • @Core-Electronics
      @Core-Electronics  Год назад +1

      I've added a comment to the bottom of the Article that Address just this 😊. The HAT has pads that break out the unused GPIO pins. That means you won't need to add anything extra to gain access to the GPIO for your Solenoids/Relay Control.
      Check here for more information - forum.core-electronics.com.au/t/guide-by-tim-how-to-use-stepper-motors-and-dc-motors-with-a-raspberry-pi-adafruit-dc-stepper-motor-hat/15071

    • @wamtm
      @wamtm Год назад

      @@Core-Electronics thank you so much for your fast reply and resource . Really helpful

  • @PickYourPoisons
    @PickYourPoisons Год назад +1

    can u add other sensors/inputs with the hat?

    • @Core-Electronics
      @Core-Electronics  Год назад +1

      Absolutely, that protoboard section is ready to be utilised on the HAT and a number of GPIO pins are not being used by the HAT and are free to power/control other hardware - pinout.xyz/pinout/adafruit_dc_stepper_motor_hat

  • @gilles4332
    @gilles4332 Год назад +2

    Thank you the problem is that I do not speak English, the subtitles are not available and therefore the translation either, despite everything I can understand the principle, is if you could make a video on the subject using the dc stepper hat would be great, my current project is to take the turret from isaac879 and replace the Arduino with the rpi and make it a stellar observation turret, thank you.

    • @Core-Electronics
      @Core-Electronics  Год назад +1

      Subtitles should be available now, sometimes it takes a couple of days. Hopefully that will help.
      And I would love to see that project completed! Pointing Pan-Tilt systems are the Stars are the best possible use case (in my opinion). Come check out project which does a very similar thing as to what you want - core-electronics.com.au/projects/auto-camera-tracking-system/

    • @gilles4332
      @gilles4332 Год назад

      @@Core-Electronics Yes thank you, looking on my side I was stumbling on this project, unfortunately it uses an arduino for engine control, and on my side I do not know programmed in python, it would help me a lot to know how can self-control the engine step by step with video detection (either motioneye or opencv) via the hat, Is there a code that I could import, in any case thank you anyway.

  • @vincentma6792
    @vincentma6792 9 месяцев назад

    I am receiving an error when running the installation package for the adafruit circuit python motorkit. It is saying that it is an "externally-managed-environment". What could be causing this issue?

  • @zakariatamzarti8034
    @zakariatamzarti8034 Год назад +2

    what is the maximum speed of the stepper motot

    • @Core-Electronics
      @Core-Electronics  Год назад

      This 12V stepper motor hums along nicely at 50 RPM with the Adafruit Arduino Motor HAT. The Adafruit Arduino Motor HAT has the exact same Driving IC's as the Raspberry Pi Motor HAT so that's your answer 😊.

  • @anneother6224
    @anneother6224 6 месяцев назад

    I kind of imagined that I'd be able to buy some kit which would allow the pi to control a stepper with very high level commands such as " rotate clockwise at rate n"
    But I'm not finding it. Looks like I need something like a pico or arduino. But hasn't someone bundled all that stuff and the driver for me?

    • @fredwupkensoppel8949
      @fredwupkensoppel8949 Месяц назад

      Well, you can basically do that yourself - write a function that converts mm/s into steps/s (clockwise can be found in the example code shown in the video), then you can pass "rotate clockwise at 10 mm/s" to that function.

  • @Wizardnil
    @Wizardnil Год назад

    Can you use this on top of the servo hat?

  • @X-Ray76
    @X-Ray76 Год назад

    Does this hat also work with an Arduino Mega 2560 board? (With loose wire connections)

  • @danachristie3862
    @danachristie3862 Год назад +1

    is there a way to run a python script using gcode, such as the ending script gcode of a 3d printer?

    • @Core-Electronics
      @Core-Electronics  Год назад

      Sweet question and there is indeed come check out these two resources - www.reddit.com/r/klippers/comments/nlxx59/run_python_script_with_gcode/ and github.com/th33xitus/kiauh/blob/master/docs/gcode_shell_command.md

  • @HairyHitman
    @HairyHitman 10 месяцев назад

    Hi @core celectronics
    Awesome video which I'm using as a base to build a dog treat dispenser with a stepper motor. I've bought the none- soldering version and have set it all up but I'm getting an error on the stepper motor script saying it can't find the i2c devices. I've googled and ran i2cdetect which isn't bring back anything. I've double checked I've enabled i2c, is there a step I've missed? The bonnet does seem loose but I don't know if I'm meant to use too much force putting it on. Any help would be appreciated, thanks!

    • @Core-Electronics
      @Core-Electronics  10 месяцев назад

      Hey Hitman, flick us the question over on our forums: coreelec.io/forum
      Our staff check there several times a day during work hours and someone can help you out with that (and if anyone is having the same issue its easier for them to find), we aren't as frequently on RUclips support.

  • @petrasvestartas4359
    @petrasvestartas4359 Год назад

    Is it normal that the stepper motor moves and vibrates a lot and in microsteps the sound is like breaking glass?

  • @carloscabrera6683
    @carloscabrera6683 Год назад +1

    Can I use a Dc encoder with this motor hat?

    • @Core-Electronics
      @Core-Electronics  Год назад

      This simple questions is an excellent one. The libraries made for this HAT won't know what to do with the encoded data from the DC Motor. You can just hook up a DC Motor (which has an encoder) and not use the encoder part just fine with this HAT.
      There are empty/free pins on the Raspberry Pi. You could write your own script that runs along side the Adafruit scripts that would analyse the encoding for you.
      You could also use a board more designed for DC Encoded Motors like this one here - ruclips.net/video/2bganVdLg5Q/видео.html
      I hope that helps you\ - Tim

  • @brasportt4667
    @brasportt4667 7 месяцев назад

    Top 😊

  • @chrisoology6932
    @chrisoology6932 5 дней назад

    How would I install motor kit on the pi 5 ... it does not install?

    • @Core-Electronics
      @Core-Electronics  4 дня назад

      The Pi 5 has the same 40 GPIO pinout as the previous Pi's so the installation should be the same!

  • @hghlndr2
    @hghlndr2 Год назад

    i tried installing the dependencies and now the module board has no attribute I2C

  • @ownage3523
    @ownage3523 Год назад +1

    If I instead wanted to use a stepper motor and a servo motor, would the setup be similar? What if the servo motor needs to be connected to the same pins as the stepper? Is it ok to connect wires from the servo and the stepper to the same pins?

    • @Core-Electronics
      @Core-Electronics  Год назад +1

      Heyya champ 😊 come check it out here as it is exactly what your interested in - learn.adafruit.com/adafruit-motor-shield-v2-for-arduino/using-rc-servos

    • @ownage3523
      @ownage3523 Год назад +1

      @@Core-Electronics Thank you! This looks like it will allow me to easily control a servo and stepper at the same time! Unfortunately, however, it looks like the shield is out of stock.

    • @ownage3523
      @ownage3523 Год назад +1

      Is this compatible with the Raspberry Pi 3 Model B V1.2?

    • @ownage3523
      @ownage3523 Год назад

      If not, would you have any similar recommendations that would work for that model of Raspberry Pi?

    • @Core-Electronics
      @Core-Electronics  Год назад

      Both shields are compatible with that model of Raspberry Pi and much like how that Motor shield has GND, 5V and Data pins right next to each other so does the DC and Stepper Motor HAT (from above video). You'll be able to set up servo control with the exact same connection set up for both of them 😊

  • @abu8422
    @abu8422 Год назад

    how many dc motors raspberry pi can move

  • @demetriuscurry2697
    @demetriuscurry2697 Год назад +1

    What if someone is using a unipolar stepper motor?

    • @Core-Electronics
      @Core-Electronics  Год назад

      You will need to identify which wire is the Centre Tap and connect that one to the Center GND Screw-Down Terminal. The remaining 4 wires make up Two Coil Loops. You can Identify a Coil Pair by checking the end of two wires for continuity with a Multimeter. If the Multimeter beeps (confirming continuity) you have identified coil pair. Come check the full written up article for more help if you need 😊 core-electronics.com.au/guides/raspberry-pi/raspberry-pi-dc-stepper-motor-guide/

  • @bhandarkarvivekvasanta8464
    @bhandarkarvivekvasanta8464 Год назад

    but the hat hides camera slot! Further, we wont be able to add any other device to be controlled1

    • @Core-Electronics
      @Core-Electronics  Год назад +1

      "There are not solutions... only tradeoffs!"
      Perhaps you can work around this constraint by extending the Pi's headers

  • @bridgetclinch3678
    @bridgetclinch3678 2 года назад

    Ah my first pi hat

  • @That_droper
    @That_droper Месяц назад

    Hello I am new to ras pi but u have an 80 dollar gift card for micro center and I want to know what raspberry pi and what stepper motor to get and how to connect them and power it. thanks guys and is there a way to connect more than on stepper motor to only one ras pi thanks again

    • @Core-Electronics
      @Core-Electronics  Месяц назад

      This depends on what the project you are using it for. Raspberry Pis come in their main series boards, the Pi4 is the last Gen, and the Pi 5 is the newer generation which is a tad more expensive but worth the upgrade. They also come in different RAM sizes, for general day to day tasks I've had no issus on 2 or 4gb. The Pis also come in a much cheaper Rsapberry Pi Zero form factor, which is a fair bit slower, but great for simple tasks that don't need the power.
      As for what stepper you need, it also depends on the project. We have a comprehensive guide here on different motors that has a lot of good information:
      core-electronics.com.au/guides/digital-electronics/servos-steppers-or-solenoids-choosing-an-actuator-to-move-your-project/
      Happy making!

    • @That_droper
      @That_droper Месяц назад

      @@Core-Electronics thanks would you know where to find a power cable for the raspberry pi 4 and a 12 volt stepper motor

  • @codiegagne7055
    @codiegagne7055 10 месяцев назад +1

    does this guy only wear one shirt....?