Help needed for my ...
 
Notifications
Clear all

Help needed for my stepper-ballscrew project

132 Posts
9 Users
17 Likes
4,983 Views
Inq
 Inq
(@inq)
Member
Joined: 2 years ago
Posts: 1900
 

Posted by: @bradscopegems

Dear inq,

                 Your message is very helpful.  If I understand you correctly, I should switch on the Arduino and this would supply the voltage to the digital side of the driver board. Then I could switch on the power to the motor and  any spikes generated by induction in the coils would not harm the board or the Arduino, presumably partly because of the 100 uF capacitor across the power leads.  This is immediately relevant: if the stepper drives the carriage to the end of its travel on the ballscrew and my 'homing' or 'STOP' signal does not work, I will want to kill the power ...

      And the point about the use of a conductive screwdriver as a voltage probe was also most helpful.

I don't think it was me that said anything about power-on order.  I've made several robots that use stepper motors and use an ESP8266 (Different micro, but uses Arduino code and development environment).  The robots all have only one power source... typically 18650 batteries (4 for 14.8V or 6 for 22.2V).  The steppers motors are similar to yours. 

The power supply is switched on by only one switch and the power hits the high-power side of the A4988 immediately it also goes to a DC-DC converter to convert down to 5V to power the ESP8266.  The controller takes... probably about half a second to boot up before it starts setting the logic pins of the A4988.  I don't put in any artificial, software, hardware delays on one side or the other.  

Although I have the 100 uF capacitor in my circuits, @davee is the expert on what that capacitor actually does.  I assume it is merely to give an extra shot of current when the motors draws a lot.  I know sometimes when motors draw too much current away from the micro, the voltage will drop and the microcontroller will reboot.  The capacitor covers that voltage drop.  I think. 😉 

VBR,

Inq

 

3 lines of code = InqPortal = Complete IoT, App, Web Server w/ GUI Admin Client, WiFi Manager, Drag & Drop File Manager, OTA, Performance Metrics, Web Socket Comms, Easy App API, All running on ESP8266...
Even usable on ESP-01S - Quickest Start Guide


   
ReplyQuote
Bradscopegems
(@bradscopegems)
Member
Joined: 11 months ago
Posts: 25
Topic starter  

Dear inq,

                I have another question for you experienced stepper users. Should I not connect the Motor ground to the digital ground on the A4988 driver board?  Or are these connected anyway within the board?   At present, when I use the Arduino without connection to the computer USB, I am powering it with a 9v mains adaptor with a floating ground ( a UK three-pin 13 amp plug with a plastic non-conducting earth prong). The motor PSU is a similar device (at present a 5v adaptor, but I have noted the advice against this). This means that when there is no USB connection both of the ground connections to the driver board (A4988) are floating, which does not seem right.... but if people are using batteries for both it is presumably OK?


   
ReplyQuote
robotBuilder
(@robotbuilder)
Member
Joined: 5 years ago
Posts: 2043
 

@inq

Posted by: @inq
Although I have the 100 uF capacitor in my circuits, @davee is the expert on what that capacitor actually does.  I assume it is merely to give an extra shot of current when the motors draws a lot.  I know sometimes when motors draw too much current away from the micro, the voltage will drop and the microcontroller will reboot.  The capacitor covers that voltage drop.  I think. 😉

Out of curiosity I looked up some details on using the stepper motor.

https://lastminuteengineers.com/a4988-stepper-motor-driver-arduino-tutorial/

Regarding the 100μF capacitor it says.

"One way to protect the driver from such spikes is to put a large 100μF (or at least 47μF) electrolytic capacitor across the motor power supply pins."

I imagine a capacitor being used here to smooth out the (voltage) bumps much as a suspension system in a car. You can also have active smoothing which I guess is what a voltage regulator IC does such as the 7805 although capacitors are also recommended with that IC as well.

 

 


   
Inq reacted
ReplyQuote
Inq
 Inq
(@inq)
Member
Joined: 2 years ago
Posts: 1900
 

Posted by: @bradscopegems

Dear inq,

                I have another question for you experienced stepper users. Should I not connect the Motor ground to the digital ground on the A4988 driver board?  Or are these connected anyway within the board?   At present, when I use the Arduino without connection to the computer USB, I am powering it with a 9v mains adaptor with a floating ground ( a UK three-pin 13 amp plug with a plastic non-conducting earth prong). The motor PSU is a similar device (at present a 5v adaptor, but I have noted the advice against this). This means that when there is no USB connection both of the ground connections to the driver board (A4988) are floating, which does not seem right.... but if people are using batteries for both it is presumably OK?

My electronic hardware experience comes from lots of trial and error and I always buy in bulk.  If I need 2, I'll buy 10.  I claim it is to save money and for un-planned future projects. 🙄  That's my story and I'm sticking to it. 😜 But I let a lot of magic smoke out of parts as a matter of course.  So, this is more of a question for @davee and some of our more hardware experts.  I don't know if the grounds are connected inside the A4988.  I tried it both ways and didn't notice a difference.  But I do ask myself, "why they have a ground for each."  I also, as a matter of course, connect all grounds, but @davee has said in the past that'd be a bad idea on some layouts but I don't recall the instance.  He'll give you the right gospel.  😉 

 

PS - if you precede someone's name with @ they'll get an email notifying them they were "mentioned".  For instance, @davee just got a double tripple dose!  🤩 

 

3 lines of code = InqPortal = Complete IoT, App, Web Server w/ GUI Admin Client, WiFi Manager, Drag & Drop File Manager, OTA, Performance Metrics, Web Socket Comms, Easy App API, All running on ESP8266...
Even usable on ESP-01S - Quickest Start Guide


   
ReplyQuote
Inq
 Inq
(@inq)
Member
Joined: 2 years ago
Posts: 1900
 

Posted by: @robotbuilder

@inq

Posted by: @inq
Although I have the 100 uF capacitor in my circuits, @davee is the expert on what that capacitor actually does.  I assume it is merely to give an extra shot of current when the motors draws a lot.  I know sometimes when motors draw too much current away from the micro, the voltage will drop and the microcontroller will reboot.  The capacitor covers that voltage drop.  I think. 😉

Out of curiosity I looked up some details on using the stepper motor.

https://lastminuteengineers.com/a4988-stepper-motor-driver-arduino-tutorial/

Regarding the 100μF capacitor it says.

"One way to protect the driver from such spikes is to put a large 100μF (or at least 47μF) electrolytic capacitor across the motor power supply pins."

I imagine a capacitor being used here to smooth out the (voltage) bumps much as a suspension system in a car. You can also have active smoothing which I guess is what a voltage regulator IC does such as the 7805 although capacitors are also recommended with that IC as well.

 

@bradscopegems

@robotbuilder is more expert than I with hardware.  I respect and often request and follow his advice, but he has a peculiar affinity for DC motors with and without encoders while I'm on the other side the fence and push steppers even when not necessary... like doing the Blink Sketch.

VBR,

Inq

 

3 lines of code = InqPortal = Complete IoT, App, Web Server w/ GUI Admin Client, WiFi Manager, Drag & Drop File Manager, OTA, Performance Metrics, Web Socket Comms, Easy App API, All running on ESP8266...
Even usable on ESP-01S - Quickest Start Guide


   
ReplyQuote
(@davee)
Member
Joined: 3 years ago
Posts: 1721
 

Hi @inq, @bradscopegems, @robotbuilder ,

 Capacitors connected across power lines can be 'required' for few different reasons, depending on the circuitry they are attached to.

Assume we are discussing a pair of DC power lines (e.g. Vcc and Ground). Ideally a voltage monitor across those lines would always see the same voltage. However, if a component connected across those lines at the same point as the voltage monitor, suddenly increased its current flow (between the lines), the intrinsic inductance and resistance of the wires would oppose the current increase, and the voltage monitor would observe a voltage drop.

Thus the simplest and most common case would be a capacitor also connected at the same point (or at least as close as posible) to act like a local reservoir of charge, so that if the locally attached circuit makes a 'sudden' demand for more current, the capacitor supplies some of that momentary current increase from its 'charge store', helping to maintain the voltage at a steady value.

Of course, the same principle applies in reverse, if the current demand suddenly decreases, then the voltage would tend to rise, and a capacitor would absorb some of the 'excess' charge, again helping the voltage to stay at a steady value.

----

Circuits with explicit inductors, such as motor windings, solenoid coils, relay coils, chokes, etc. can have a 'magnified' version of this effect. As I mentioned previously, an inductor will tend to oppose any change in current flow, so that if the inductor carrying a constant current is disconnected (or the current is switched off), the solenoid will create a voltage in an attempt to maintain the current flow. This voltage can be very high, and can easily destroy electronic components in its path, if suitable precautions are not taken.

In the specific case of the A4988 driving motor windings, the Pololu article

https://www.pololu.com/product/1182 includes:

image

Thus, they are advising a capacitor across the motor power input pins to absorb some of the motor coil energy and prevent it damaging other components on the board.

Note that in all of the cases I am describing, to be effective, the capacitor should be connected as close as possible to part of the circuit it is protecting ... attaching with long wires greatly reduces its effectiveness, sometimes to the point it is essentially useless.

------

For completeness, I'll briefly mention another case where it is common to see capacitors across power lines ... namely across the input and output of voltage regulators, such as the 7805 or AM1117. In these cases, in addition to acting as a charge reservoir, the capacitors may also help to prevent the regulator (which is essentially an adapted amplifier circuit in disguise) from oscillating.

---------------------------------------------------------------------------------

The question of connecting ground lines together was also raised in the preceding messages. Unfortunately, this is one of those cases in which it is necessary to understand what current flows are involved.

The most common cases, which would include the small stepper motor boards using A4988 and its many distant cousins such as TMC2310, should have the motor and computer (Arduino) grounds connected together, but (ideally) ONLY at one point.

--------

Please note ground connections may be required to complete a circuit to enable it to work, but also may be required as a safety measure to prevent electrical shock in the event of a fault occurring. The voltages involved with the system (excluding the mains power) are obviously low, so the risks of an electric shock are also low. Nevertheless, as I can't see your equipment, let alone perform any checks, please note that the advice here is only 'best efforts', and I cannot accept any responsibility for mistakes, etc. on my part.

-------

If ground circuits are connected together at more than 1 point, a loop circuit is created, and this can pick up a the residual magnetic field from nearby mains wiring, sometimes resulting in an appreciable voltage and current flow at 50Hz or 60Hz. The most obvious example is the buzz sometimes heard when an audio system is being set up.

Digital circuits, of which Arduinos and stepper motor drivers are classic examples, can reject small interferring signals, and hence in many cases it is possible and even necessary to break the 'no loop' rule, but they are not totally immune, especially in areas with high power electrical machines.

------

Thus, lets start by assuming the Arduino power supply and the motor power supply are independent units, and that the 'ground' power lines of the supplies are not connected to the mains earth.

Start by:

Connect the Arduino to its power supply, e.g. via the jack plug, and connect the Vcc and Ground pins of the A4988 board to the Arduino 5V and Gnd pins, as shown in Bill's diagram that I included previously.

Next, connect the positive power out and ground from the motor power supply to the Vmot and Gnd pins of the A4988 board.

At this point, you will have connected the two grounds together via the A4988 board, and it should all work correctly.

------

As the overall machine including motor is metallic, it should all be connected to mains earth. This might be achieved by bolting it to a larger machine which is itself also earthed, bearing in mind that aluminium readily oxidises, producing an excellent insulating layer, so some care to ensure the two units are electrically connected, typically using devices like sharp edged washers that 'bite' through the oxide as the nut is tightened. Sometimes extra strap wires are needed.

To complete the 'grounding', then take a wire from the mains earthed structure to the ground of the A4988 board, so that the motor and Arduino voltages are all referenced to mains earth.

---------

In the event that one of the Arduino power supply or motor power supply outputs are already grounded, then the last step of connecting the motor metalwork to the A4988 board is probably best omitted, as it will create a loop.

---------

Finally, all of the above regarding the stepper motor driver applies to the small A4988 style boards, similar to those shown in the photos of this thread.

In case you or anyone else decides to use one of the 'boxed' units, such as the MA860H shown in Bill's https://dronebotworkshop.com/big-stepper-motors/ article, the grounding rules may be different.

image

These 'boxed' units typically (Check the manual!) use opto-isolators for their control inputs (e.g. step or pulse, direction, enable).

For example, a snip from the MA860H manual taken from

https://images-na.ssl-images-amazon.com/images/I/81Cyu+2MjrL.pdf

image

These opto-isolators mean there is no electrical path between the computer (e.g. Arduino) side of the interface, and the stepper motor driver side, and hence they do not need to share a 'ground' connection.

The advantage of this arrangement is the reduced chance of voltage spikes, etc. from heavy electrical machines corrupting the relatively sensitive computer (Arduino). The disadvantage is that the 'box' version has more components, costs more, is larger, etc.

Of course, it does not preclude the need for proper electrical safety, such as ensuring metallic structures are earthed, etc.

-------------

Sorry this is rather a long sermon ... I have tried to explain a couple of tricky, but fundamental topics that regularly appear on this forum, but are frequently ignored in the Web.

Best wishes, Dave


   
Inq and byron reacted
ReplyQuote
byron
(@byron)
No Title
Joined: 5 years ago
Posts: 1123
 

@davee

Hi Dave, that was a very good explanation, meaning a clear and understandable explanation for electronic dummies such as me.  I knew about connecting the ground of the mc board, power and motors together, and vaguely understood that a failure to do so would potentially leave the circuits with a potential difference if not done, but the understanding of the potential for creating ground loops had been quite missed by me.   As its a bit hot today I was having a lolly pop break instead of a tea break, and your post made jolly good lolly time reading. 😎 

Its been cut and pasted into my electronics folder, but next time please include a pdf file for handy downloading. (only joking 😀)


   
DaveE reacted
ReplyQuote
robotBuilder
(@robotbuilder)
Member
Joined: 5 years ago
Posts: 2043
 

FYI @inq, @bradscopegems,@byron

@davee

Unfortunately as a visual learner for me a verbal description quickly becomes blah blah blah 🙂

As a visual aid in understanding electronics I used water analogs so I could "see" what was happening.

My analog of an inductor was a water wheel (or turbine). When you apply water pressure (voltage) the wheel resists the flow until it starts turning. When you release the presssure the wheel keeps the water flowing until it stops turning.

To even follow a verbal description you need a firm understanding of the electrical concepts and how to measure them in real circuits.

Ultimately it comes down to mathematics and measurement. I still have my little book "Basic Math Course For Electronics" by Henry Jacobowitz 1965.


   
ReplyQuote
robotBuilder
(@robotbuilder)
Member
Joined: 5 years ago
Posts: 2043
 

@inq 

 

@inq

... but he (robotBuilder) has a peculiar affinity for DC motors ...

Not really. It depends on the application. For simple accurate control of positioning the stepper motor reigns supreme which is why it is used in 3d printers and other devices that need exact fast positioning. @bradscopegems project is such an example.  But in some applications you need a closed loop to make sure it is working properly. All goal orientated behaviors involve feedback.


   
ReplyQuote
(@davee)
Member
Joined: 3 years ago
Posts: 1721
 

Hi @robotbuilder,

  Sorry if my sermon is a tough item to swallow ... I do understand that, but I am not sure there is an easy solution ... I actually spend quite a long time just getting some words on paper. Plus there are actually several discussions or mini-chapters concatenated together .. often the line breaks are a suggestion to take a break.

Of course, much of my last two sermons have been aimed at questions/discussions arising between @inq and bradscopegems, so I hope they are helpful in that context, though I appreciate I have presented some concepts that will be difficult to those new to the topics discussed.

I am more than happy to try to clarify any items, but sorry, I don't have a clue about turning all of that into a picture book .. my drawing skills are totally naff and while it may not look like much, it actually it includes quite a lot of aspects that are rarely discussed, yet can all be rabbit holes.

-----------

I do always try to have a simple notion of what is going on, but sorry I can't imagine a waterwheel as having much in common with an inductor ... I can see it providing an analogy for the overall 'inertia' of the system, but I would really struggle to see how it produces the voltages seen when the current flow is abruptly stopped.

And whilst electronics can indeed involve maths, in practice V=IR and P=VI covers a lot of the situations I have encountered.

----------

By the way, I note a banter between you and @inq regarding stepper motors and servos. Please bear in mind that stepper motors are often driven in an open loop mode, but that is only for cheapness and simplicity. Of course in an ideal world, a stepper motor would always obey the commanded signals, so there would be no need for monitoring. But to cope with the fallibility of the real world, sensors, etc. can be added to close the loop. e.g. At least one of the TMCxxxx 'upgraded' distant cousins of the A4988 claim to include some provision to detect missed steps.

--------------------

Best wishes, Dave


   
Inq reacted
ReplyQuote
(@davee)
Member
Joined: 3 years ago
Posts: 1721
 

Thanks @byron,

  for the comments ... I hope most of what write is comprehendable, though I realise it is rarely easy reading.

  As for the pdf ... I haven't tried it for the forum, but I do sometimes pdf other web pages, simply by printing and choosing the 'pdf printer' option.

Personally I think the 'Wiki' approach can be effective.

Best wishes, Dave


   
ReplyQuote
robotBuilder
(@robotbuilder)
Member
Joined: 5 years ago
Posts: 2043
 

@davee 

We all have different understanding styles.

It wasn't meant as a criticism of your explanation.

For me a picture or animation replaces a thousand words.

Today the internet provides plenty of animations for those that are helped by being able to visualize what is happening in a circuit.

And whilst electronics can indeed involve math, in practice V=IR and P=VI covers a lot of the situations I have encountered.

Well that is math for static dc circuits where a capacitor is an open circuit and an inductor is a closed circuit. However this was about the role a capacitor plays in a circuit controlling an electric motor.  The math becomes more complex in understanding circuits which involve reactance where capacitors store energy as an electric field and inductors store energy as a magnetic field.


   
DaveE reacted
ReplyQuote
Inq
 Inq
(@inq)
Member
Joined: 2 years ago
Posts: 1900
 

Posted by: @robotbuilder

@inq 

 

@inq

... but he (robotBuilder) has a peculiar affinity for DC motors ...

Not really. It depends on the application. For simple accurate control of positioning the stepper motor reigns supreme which is why it is used in 3d printers and other devices that need exact fast positioning. @bradscopegems project is such an example.  But in some applications you need a closed loop to make sure it is working properly. All goal orientated behaviors involve feedback.

Surely you understood that was tongue-in-cheek.  As the next sentence I said I would use a stepper motor to blink the LED instead of the just using a delay() for the Blink Sketch.  When it comes to robot movement, you are clearly of the DC motor with encoder camp.  I am clearly stepper motor camp.  I'll concede you are in the majority... but through education of the masses, diligence (and sacrifice) I hope to educate and prove to you-all that I'd rather K.I.S.S. a stepper motor than flog myself with an encoder.  

VBR,

Inq

PS - The request for advice (on non motor issues) on mapping, vision, sensors... etc and respect for your background and knowledge was sincere!  I hope I'll benefit from your expertise in the future.  ...and maybe get you to try stepper motors for fine navigations of a room! 😉 

 

3 lines of code = InqPortal = Complete IoT, App, Web Server w/ GUI Admin Client, WiFi Manager, Drag & Drop File Manager, OTA, Performance Metrics, Web Socket Comms, Easy App API, All running on ESP8266...
Even usable on ESP-01S - Quickest Start Guide


   
ReplyQuote
Inq
 Inq
(@inq)
Member
Joined: 2 years ago
Posts: 1900
 

Posted by: @davee

Hi @robotbuilder,

  Sorry if my sermon is a tough item to swallow ... I do understand that, but I am not sure there is an easy solution ... I actually spend quite a long time just getting some words on paper. Plus there are actually several discussions or mini-chapters concatenated together .. often the line breaks are a suggestion to take a break.

Keep up the fantastic sermons!  I do read them and they always improve my knowledge... and sometimes they're above me.  But I bookmark and categorize them and think someday... I'll need that and it'll make sense then!  

I can breadboard a project and C++ the hail out of it in less time than I can write in English.  Again... thank you for the time you devote to helping us out.  It might be why I burn your ears all the time on threads you've not participated yet.  Let me know... if I'm requesting your experience too much.  I'll try to curb my curiosity. 😒 

3 lines of code = InqPortal = Complete IoT, App, Web Server w/ GUI Admin Client, WiFi Manager, Drag & Drop File Manager, OTA, Performance Metrics, Web Socket Comms, Easy App API, All running on ESP8266...
Even usable on ESP-01S - Quickest Start Guide


   
DaveE reacted
ReplyQuote
(@davee)
Member
Joined: 3 years ago
Posts: 1721
 

Hi @inq,

  I have no problem with your curiosity, so don't try to curb it!

   And if something isn't clear, please flag it up ... I make no promises of success, but I'll usually try to clarify, albeit probably with yet more words!

Obviously, it is sometimes difficult to imagine the whole scene if it isn't your project, but remember that I am also usually struggling with the same limitation, and hence unintentionally miss out important details. So querying my mistakes is really useful!

Best wishes,

Dave


   
ReplyQuote
Page 2 / 9