Welcome to Our Community

Some features disabled for guests. Register Today.

How to control the stepper using a mini PC?

Discussion in 'General Talk' started by paulwece, Jul 2, 2019.

  1. paulwece

    paulwece New
    Builder

    Joined:
    Mar 14, 2019
    Messages:
    16
    Likes Received:
    0
    Hi,

    I got the ACRO gantry and the NEMA 17 motors. I also bought a driver for the stepper motor:
    STR Stepper Drives | Applied Motion

    I originally planned to use a Raspberry Pi, but due to other needs, I want to use a mini PC for my project. It's a Windows 10 mini PC with USB, Ethernet, everything...

    Is it possible to use the PC to control the stepper motor or must I have something like the Pi or Arduino with output pins? For the PC, I hope to be able to control the stepper using Python (Anaconda).

    Thanks
     
  2. Peter Van Der Walt

    Peter Van Der Walt OpenBuilds Team
    Staff Member Moderator Resident Builder Project Maker Builder

    Joined:
    Mar 1, 2017
    Messages:
    2,313
    Likes Received:
    1,131
    Depends largely on What your use case is? Acro as per the original build (XY plotter/Laser?) = get a BlackBox or xPro from the openbuildspartstore.com

    If something else, tell us what you have in mind to best recommend
     
  3. Rob Taylor

    Rob Taylor Journeyman
    Builder

    Joined:
    Dec 15, 2013
    Messages:
    476
    Likes Received:
    196
    With a Raspi, you could output step/dir pulse trains directly from the I/O header. With a PC, you either have to be able to physically install and access (through Python) a parallel port, which would allow you to individually manipulate pin levels, or use a breakout board (bare Arduino Uno with grbl, or BlackBox/xPro for more features) that you can communicate with over serial through USB.
     
  4. paulwece

    paulwece New
    Builder

    Joined:
    Mar 14, 2019
    Messages:
    16
    Likes Received:
    0
    thanks,

    what about using a package like pyFirmata and write a Python program on the PC that can control the Arduino (which will move a stepper) and also do other things, (like taking an audio recording)?
     
  5. Rob Taylor

    Rob Taylor Journeyman
    Builder

    Joined:
    Dec 15, 2013
    Messages:
    476
    Likes Received:
    196
    Sure, that seems perfectly doable. Remember, if you're directly controlling the stepper, you're on the hook for things like acceleration (real objects have momentum, depending on what you're moving and how fast), pulse width, pulse spacing, dir setup time, etc.

    I wrote a very barebones on-board stepper driver and GUI here, but it seems embarrassingly simplistic and inefficient now: RobTC/SliderCam - note how short the motionControl() function is compared to the rest of the program!

    Different drivers need specific timings and orders of signals, but they should usually be in the datasheet/manual. If you're not moving anything very fast (millisecond-level pulses) it likely doesn't matter anyway.
     
  6. paulwece

    paulwece New
    Builder

    Joined:
    Mar 14, 2019
    Messages:
    16
    Likes Received:
    0
    Thanks.

    I've decided to use an Arduino to talk to the stepper driver, and then use a PC with Python to talk to the Arduino. With Python, I can use Pyserial or Pyfirmata, I'm not sure which one to use. It seems with Pyfirmata, I can have all the Arduino logic inside my Python code (rather than the Arduino IDE) in that I can directly control the pins with Python code. WIth Pyserial, it seems more difficult to have direct access to the pins in Python. Rather, I can write functions in the Arduino IDE, upload the sketch to Arduino, and within the sketch, I can wait for serial communication from Python to do certain function.

    That's what I think after watching a few videos. They both use serial communication. Please correct if I'm wrong.

    I'm using the NEMA 17 bipolar motor. Lots of videos use the A4988 driver, and it seems pretty straight forward to use it. But you recommended a "real" driver last time. What exactly is the drawback of the A4988?

    Thanks
     
  7. Peter Van Der Walt

    Peter Van Der Walt OpenBuilds Team
    Staff Member Moderator Resident Builder Project Maker Builder

    Joined:
    Mar 1, 2017
    Messages:
    2,313
    Likes Received:
    1,131
    Max 0.5A to the motor before they start shutting down (overtemp)
    Our NEMA17s need up to 1.7A (3x as much as a A4988 can provide)
    A proper driver like a DQ542MA is both powerful, and easier to hook up (proper screw terminals, no fiddly pin headers, etc) and also a host of other advantages (higher microstepping, more torque, faster acceleration, quieter, etc)
     
    Rob Taylor likes this.
  8. Rob Taylor

    Rob Taylor Journeyman
    Builder

    Joined:
    Dec 15, 2013
    Messages:
    476
    Likes Received:
    196
    The main drawback is the lack of protection diodes. The second biggest is the terrible thermal properties. And then yeah, the rest of those. Removable screw terminals are super nice!
     
    Peter Van Der Walt likes this.
  9. paulwece

    paulwece New
    Builder

    Joined:
    Mar 14, 2019
    Messages:
    16
    Likes Received:
    0
    Is the current draw of the stepper determined by the load or is it determined by the driver setting? I got an Applied Motion Products STR3 driverwhich is a legit driver:

    STR3 - Miniature Advanced Microstep Drive | Applied Motion

    and I can select the motor current via some switches on the driver. In addition, I can also select the idle current (50% or 90%) of the selected running current.

    The machine will be ran pretty much all day, so thermal considerations is pertinent. The load itself is minimal (it moves an attachment horizontally with a microphone) and then the microphone will record an audio which then gets processed by the PC (Python). During this time, the stepper is not moving, so I'd like to minimize the current draw as much as possible. If you don't send any STEP signal to the driver during this time, is the current 0?

    Also, must one power the the NEMA using 12V? If you lower the voltage to 5V, will it draw less current and create less heat?

    Thanks
     
  10. Rob Taylor

    Rob Taylor Journeyman
    Builder

    Joined:
    Dec 15, 2013
    Messages:
    476
    Likes Received:
    196
    Drivers actively limit maximum current draw. Up to that point, it's determined by load (and voltage, impedance, etc).

    The "idle current" is what the motor is drawing (or what the driver is allowing it to draw) whilst not moving but the driver is still enabled. If your control software disables the driver when it's stopped, there's no current draw. The ENA line is a third line from your controller to your drivers (usually ganged together, but sometimes Z will be separated to fight gravity, etc).

    12V is pretty much the lowest viable voltage for consistent motion at moderate accelerations with NEMA17s. You can go lower, but performance may be spotty. Normally going up on the voltage is a better option for reducing power draw (less current at the same power level, P=IV). I've personally noticed less heat coming from drivers at 24V than 12V.
     
  11. paulwece

    paulwece New
    Builder

    Joined:
    Mar 14, 2019
    Messages:
    16
    Likes Received:
    0
    Thanks.

    So if I set the peak current on the driver to 1.2 A, but the load is super tiny, the motor might draw less than that. But if the load gets too big, the driver will "limit" the current to 1.2A and if that's insufficient torque the motor will "slip" then?

    I also bought the limit switch found in OpenBuilds store, used for homing and avoid crashes. It's a Normally Open switch, so when the stepper reaches the end, it'll close the switch, which would complete a circuit. Not too sure what to wire this limit switch to...the video shows it being wired to the driver board sold by OpenBuilds, but I plan to use an Arduino with the STR3 driver that I mentioned above.

    I guess I can wire the limit switch to the Arduino? I can use a pull down resistor to one of the GPIOs, and then if the circuit is closed with the limit switch, it can set the GPIO to HIGH, and then the Arduino will stop sending signals to the driver and thus stopping the stepper?

    Thanks
     
  12. David the swarfer

    David the swarfer OpenBuilds Team
    Staff Member Moderator Builder

    Joined:
    Aug 6, 2013
    Messages:
    1,354
    Likes Received:
    690
    I would load GRBL firmware on the Arduino. GRBL is very good at acceleration planning etc.
    Then your Python can send it standard Gcode to achieve the movements you want.
     
  13. Rob Taylor

    Rob Taylor Journeyman
    Builder

    Joined:
    Dec 15, 2013
    Messages:
    476
    Likes Received:
    196
    Precisely, yeah. I usually have NEMA 17s set to 1.2A. Runs a little cooler and gives some headroom to increase if necessary, but I haven't had to so far.

    Just wire it to some empty pins and set up a way to listen for it in the software. You may need to attach an interrupt somewhere in the Arduino code; if so, make sure it's on interrupt-enabled pins. I'm assuming that you can still use the Arduino as an Arduino whilst the PyFirmata manipulates pins and recovers data. The GitHub makes it seem so. Helpfully, you generally won't be doing any motion control while data collecting and vice-versa. It looks like the Arduino is still independent enough that if you need an interrupt to take over, it can. Just write your ISR such that any Python pin pulsing is immediately stopped and then you do something else appropriate to recover. Maybe some kind of homing cycle.

    Usually Normally Closed is a safer option for limits, since if the line drops to 0V, it's either a ground fault (the most common type) or a crash. With Normally Open, a fault is undetectable. Arduino has internal software-accessible pullup resistors that you can use for NC switches, but to hold it at ground for NO, you'll have to physically add some grounding resistors.
     
  14. paulwece

    paulwece New
    Builder

    Joined:
    Mar 14, 2019
    Messages:
    16
    Likes Received:
    0
    Thanks.

    Another issue I have is the power supply. I got the 12V Mean Well power supply from OpenBuilds, but it seems you have to connect wires from 120VAC to the terminals via screws, and all of that is exposed, which is hazardous for my application. Are there power supplies that only have the lower voltage (12V) exposed?
     
  15. Rick 2.0

    Rick 2.0 OpenBuilds Team
    Staff Member Moderator Resident Builder Builder

    Joined:
    Dec 20, 2013
    Messages:
    2,232
    Likes Received:
    1,086
    Consider adding a PowerCase Kit to the power supply. I'm not sure if they have different versions for the 12V and 24V power supplies but you might specify which model it is for when you order. If you have a 3D printer there are also a number of cover designs on Thingiverse.
     
    Peter Van Der Walt likes this.
  16. Rob Taylor

    Rob Taylor Journeyman
    Builder

    Joined:
    Dec 15, 2013
    Messages:
    476
    Likes Received:
    196
    Basically all PSUs come like that. Normally it's shielded and secured in operation, inside an electronics cabinet or similar.

    The PowerCase kit is a good idea if the PSU has to be out in the open for some reason, whether the OB one or a DIY version. Otherwise... Maybe use an ATX power supply instead?
     
  17. paulwece

    paulwece New
    Builder

    Joined:
    Mar 14, 2019
    Messages:
    16
    Likes Received:
    0
    I got the power bundle but they only sent me the bare power supply...

    Anyway, would something like this work: It's 12V, 60W, and I only need to power 1 NEMA 17

    [​IMG]
     
  18. Peter Van Der Walt

    Peter Van Der Walt OpenBuilds Team
    Staff Member Moderator Resident Builder Project Maker Builder

    Joined:
    Mar 1, 2017
    Messages:
    2,313
    Likes Received:
    1,131
    Check with [email protected] its probably just on backorder and on its way to you in a seperate shipment
     
  19. paulwece

    paulwece New
    Builder

    Joined:
    Mar 14, 2019
    Messages:
    16
    Likes Received:
    0
    Thanks,

    I also need to have a mechanism to push a button on a device that I'm recording the noise of. This mechanism would be attached to the moving gantry slide. The distance to push the button is small, around 2cm. The force required is not that much.

    I looked at solenoid but the movement is too fast and may damage things. So far I'm thinking about using a RC servo or a small stepper motor like the 28byj48 to drive a rack and pinion. The RC servo can also be used with rack and pinion I suppose, but those usually are meant for pushrod.

    Just wondering what your thoughts are on the best options. Ideally I can power it thru the same Arduino and power supply. This movement can be independent of others, ie, won't happen at the same time as the NEMA 17 movement or even the recording.

    Thanks

    Edit: I'm seriously considering this:
    PQ12-R Micro Linear Servo | Actuonix
     
    #19 paulwece, Jul 10, 2019
    Last edited: Jul 10, 2019

Share This Page

  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice