Notifications
Clear all

[Solved] Mal-justed A4988

29 Posts
6 Users
15 Likes
1,953 Views
Inq
 Inq
(@inq)
Member
Joined: 2 years ago
Posts: 1900
Topic starter  

A4988 Current Limiting Revelation

... at least it was to me. 

I have some cheap ($1.20 a piece) A4988 drivers.  I've been using them with my MPU of choice being a 3.3V WeMos ESP8266.  I've been using the standard way of setting the current limiter potentiometer doing the calculation and checking the voltage using VREF=8IMAXRCS found in: https://www.pololu.com/product/1182#text=The%20A4988%20driver%20IC%20has,can%20keep%20the%20IC%20cool.

It was rather disappointing that I couldn't get the drivers to output more than about 1.1 Amps. I just chocked it up to cheap Chinese drivers and generally for the Inqling Jr bot, it's plenty.

But I had the opportunity lately to be forced to use a real-life Arduino Uno.  Who knew that thing would ever come back out of the box from... jeeze feels like a decade ago.

Anyway... the logic being 5 volts on an Uno apparently and being supplied to the logic side of the A4988 has something to do with the inner workings of the current limiting.  Now... I'm sure some of the hardware experts on the forum will tell me... of course it does.  Well... I didn't know that and nowhere on the Internet or on the forum have I run across that tidbit.

Anyway... with 5V logic, I'm getting the full 2 amp output, while using 3.3V logic only allows up to about 1.1 Amps.

Thought this might be of use to someone... someday.

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: 1680
 

Hi @inq,

  Note ... I haven't seen one of these boards ... and the available information is incomplete, and may not apply to the board you actually have.

   😀 So ... THIS IS YET ANOTHER HYPOTHESIS!! I can't test it at present 😀 

 Just had a quick glance at the Allegro A4988 datasheet.

https://www.allegromicro.com/-/media/files/datasheets/a4988-datasheet.pdf

  So far as I could see, the chip should be fine with 3.3V ... although FETs often struggle a bit with low gate voltage when driven by 3.3V chips, this chip has a buit-in charge-pump to create the higher voltage needed by the internal FETs, so assuming the chip you have behaves according to this data sheet, that is not the problem.

Furthermore, the logic drive from the Arduino does not directly drive the FETs responsible for supplying power to the motor, I would expect any problems with the logic drive to drastically affect the stepping action.

However, the A4988 chip has a voltage reference input which is used to control the microstepping mode is created by a potential divider between Vdd input and ground. The data sheet provides some information, but the resistor values for this potential divider are not obvious.

A search for a likely schematic of the board led to:

https://beta.ivc.no/wiki/index.php/MakerBot_Replicator_1_Adapting_A4988_Replacement_Driver

This shows the potential divider consisting of a 20 kOhm resistor and an unspecified potentiometer in series.

 

image

 And the accompanying text says:

Find the Vref you need using this equation Vref=(8*Rsense)*0.830, for instance 0.2 Ohm gives (8*0.2)*0.833=1.33V

Suggesting the voltage going to the REF pin should be about 1.33V

As I don't have a resistance value for the potentiometer, I can't estimate whether this will be high enough to be able to select 1.33V when VDD is only 3.3V.

So it could be that the main change of using a 5V Arduino is simply that it increases VDD to 5V, and hence the increasing the voltage range available from the potentiometer.

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

So does all this make any difference ... well obviously you have a solution if you are using a 5V Arduino.

However, if you need to use a 3.3V Arduino (ESP8266 maybe?) for a future project, then it might be possible to simply reduce the value of the fixed resistor in series with the potentiometer.

-------

Best wishes, Dave


   
ReplyQuote
Inq
 Inq
(@inq)
Member
Joined: 2 years ago
Posts: 1900
Topic starter  
Posted by: @davee

Note ... I haven't seen one of these boards ... and the available information is incomplete, and may not apply to the board you actually have.

They're the most common stepper motor driver in 3D Printers.  The little break-out boards handle 2 amps per coil (4 total) from a board the size of your thumbnail.  The board claims they can take logic from 3.0V to 5.5V.  

Posted by: @davee

So it could be that the main change of using a 5V Arduino is simply that it increases VDD to 5V, and hence the increasing the voltage range available from the potentiometer.

That makes sense to me... more voltage available from the source as it's tuned by the pot show a higher value on the output of Vref.  I recall getting only up to

Vref = 0.88V with the 3.3V logic => 1.1 amps and

Vref = 1.6V with the 5.0 volts... equating to 2 amp output. 

Are you saying I should be able to get the Vref than 0.88V or are you saying it is understandable that I only got 0.88V? 

Posted by: @davee

So does all this make any difference ... well obviously you have a solution if you are using a 5V Arduino.

However, if you need to use a 3.3V Arduino (ESP8266 maybe?) for a future project, then it might be possible to simply reduce the value of the fixed resistor in series with the potentiometer.

I don't use Arduinos.  I just have some left over from the ice age that come out when someone needs help and insists on using them.  Just happened across this 2.0 amps available on it.  Normally, I use the ESP8266 and Inqling Jr has these A4988 to drive the wheels.  Although normally I live by the motto, "There is no such thing as too much horsepower or too much torque."  however for Jr, 1.1 amps seems to get it into plenty of trouble just fine.

Now, Inqling 3rd will be using a big 2.5 amp capable steppers that put out about 10x the torque and I'd plan to switch to a TMC2209 driver that claims 2.5 capability.  I hope it doesn't have this 3.3/5.0 relative problem.

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
Will
 Will
(@will)
Member
Joined: 3 years ago
Posts: 2531
 
Posted by: @inq

Now, Inqling 3rd will be using a big 2.5 amp capable steppers that put out about 10x the torque and I'd plan to switch to a TMC2209 driver that claims 2.5 capability.  I hope it doesn't have this 3.3/5.0 relative problem.

Just use a transistor to drive it from your battery.

Anything seems possible when you don't know what you're talking about.


   
Inq reacted
ReplyQuote
Inq
 Inq
(@inq)
Member
Joined: 2 years ago
Posts: 1900
Topic starter  
Posted by: @will

Just use a transistor to drive it from your battery.

 🤣  At first I thought you were pulling my leg!  Drive a stepper motor with just a transistor.  Remember, I'm hardware challenged... then it just hit me.

You mean drive the driver board logic side with 5V from the battery.  I wonder if that would work... will it let me trigger the step and direction from 3.3V  ESP8266 pins, yet power it with 5V.

I'll wait for someone less challenged to say if it might work... then I'll see if the A4988 lets the smoke out.

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
Will
 Will
(@will)
Member
Joined: 3 years ago
Posts: 2531
 

@inq 

I thought it should work, you're just using the 3.3V to drive a 5V signal through a transistor.

I agree that it sounds stupid to me too, but I thought hey - IF it works ... My main concern is whether it would be fast enough to drive the wheels at speed.

Anything seems possible when you don't know what you're talking about.


   
ReplyQuote
Inq
 Inq
(@inq)
Member
Joined: 2 years ago
Posts: 1900
Topic starter  
Posted by: @will

@inq 

I thought it should work, you're just using the 3.3V to drive a 5V signal through a transistor.

I agree that it sounds stupid to me too, but I thought hey - IF it works ...

It's all black plastic magic to me... that setting the logic side to 3.3V limits my high-voltage 24V, high-current side to only 1.1 amps... yet changing it to 5V logic lets me go up to 2 amps... seems well ... like the typhoon in China causing the butterfly wings to flap in Florida.  I'm all for throwing 24, 5 and 3.3V at it if it gets me my 2.5 amps.

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
Will
 Will
(@will)
Member
Joined: 3 years ago
Posts: 2531
 

@inq 

Since you'll probably be using a lot of them, it may be easier to use level shifters.

Try looking up "3.3V 5V level shifter" on your Amazon site.

 

EDIT: or "level converter"

Anything seems possible when you don't know what you're talking about.


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

Hi @inq,

re: Are you saying I should be able to get the Vref than 0.88V or are you saying it is understandable that I only got 0.88V? 

I don't have a resistance value for the potentiometer R9 - as you can see, it was omitted on the schematic I showed above ... and I don't have a board, so I can't measure it ... so I can't directly estimate the voltage ... but I can tie the information you have tried provided to what I know.

I am saying:

  • You need to be able to get Vref up to about 1.33V to see 2A current ... 0.88V will not be enough
  • With VDD of 3.3V, the maximum voltage will only be about 66% of that available when VDD is 5V
  • If the resistor and potentiometer were chosen for a maximum voltage of 1.33V when VDD is 5V, then when VDD is 3.3V, the maximum voltage would be 66% of 1.33V = 0.88V ... which matches your experience! (Although I am not clear how you managed 1.6V with VDD of 5V)

So, although the chip is probably fine with 3.3V VDD and microcontroller logic interface, the board is not due to the choice of the resistor value for R5, shown as 20K in the schematic above.

If the value of that resistor in your board is 20k, then reducing it to about 10k would increase the maximum voltage to a little over 1.33V, when VDD is 3.3V ... a lower value would be required for 1.6V.

Hence, if you wanted to build a system using the A4899 board, with a 3.3V microcontroller, such as ESP8266 or 32,  then it should be possible by changing the resistor.

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

BTW, I note https://www.pololu.com/product/1182 says

(The A4988) ... can deliver up to approximately 1 A per phase without a heat sink or forced air flow (it is rated for 2 A per coil with sufficient additional cooling)

.. suggesting additional heatsink may be required for 2A operation

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

I just saw this photo of A4899 board at

https://www.pololu.com/product/1182#lightbox-picture0J10063;main-pictures

which showed a 30k resistor in series with the potentiometer in the corner of the board.

image

If your board is like this one, then this is the resistor to change ... but the value required for VDD of 3.3V  might be a bit higher ... say around 15k.

Changing the resistor takes a couple of minutes careful soldering, but is otherwise a cheap fix!!

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

A quick look at the TMC2209 chip data sheet ...

https://www.trinamic.com/support/eval-kits/details/tmc2209-bob/

it shows a power supply pin that may be driven to 3.3V or 5V that is only used for the I/O pins, so assuming the board you have has that connection point to your 3.3V supply, then I would hope it would be fine.

----------

Best wishes,

Dave


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

Hi @will 

re:Just use a transistor to drive it from your battery.

Sorry, perhaps I don't understand what you are suggesting, but powering the A4899 at a higher voltage than 3.3V means the I/O pins that connect to the controlling microcontroller will expect the microcontroller to be running at 5V

Connecting to a 3.3V processor like ESP8266 or 32 to a A4899 running at 5V is risks damage to to the microcontroller.

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

Using a level shifter circuit, either a board/chip designated 'level shifter' or one of the discrete equivalent circuits is a more plausible solution.

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

Although personally, I would start by trying to change the resistor on the A4899 board.

Best wishes, Dave


   
ReplyQuote
Will
 Will
(@will)
Member
Joined: 3 years ago
Posts: 2531
 

@davee 

What I was suggesting was to use the 3.3V signal from the ESP to drive a transistor to pass 5V from the battery to the A4988 for both the Step and Dir pins. The A4988 pins are meant for 5V and there is no chance of the voltage being passed back across from the A4988 to the ESP.

I prefer the level converter because it has 2-way conversion and is ready-made so no calculations or prep is required, just bolt it on and solder the wires.

Anything seems possible when you don't know what you're talking about.


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

Hi @will,

  OK, that makes a bit more sense ... you are using the transistor as a level shifter, though it will probably be open-drain or open-collector. which is an inverter circuit, so the software will need changing.

But if the A4988 is running on a 5V supply, why would you need a battery?

I too think the packaged level converter would be more convenient than this ...

  and fixing the resistor on the A4988 board better still ... providing you have the stuff to solder a surface mount resistor.

Best wishes my friend, Dave


   
ReplyQuote
Ron
 Ron
(@zander)
Father of a miniature Wookie
Joined: 3 years ago
Posts: 6969
 

@davee I think this is what @will is suggesting. The transistor is a normal method for 3.3V to control a 5V circuit.

https://amz.run/5z7Y

First computer 1959. Retired from my own computer company 2004.
Hardware - Expert in 1401, and 360, fairly knowledge in PC plus numerous MPU's and MCU's
Major Languages - Machine language, 360 Macro Assembler, Intel Assembler, PL/I and PL1, Pascal, Basic, C plus numerous job control and scripting languages.
Sure you can learn to be a programmer, it will take the same amount of time for me to learn to be a Doctor.


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

I've been doing some experiments to quantify what I have been seeing while using the A4988.  @davee has leveled some education on us in the Railroad Elevator project thread and with new knowledge, I went back to the Internet to explain what I reported in this thread.

Experiment 1 - Using Vref method

I started out using the Pololu method.  You change the potentiometer that changes a voltage reading that then is used to calculate the maximum current.  The equation is:

Imax = Vref / 8 / Rcs

Rcs is the resistance of resistor on the A4988.  The clones seem to have either 0.05, 0.1 or 0.2 ohms.  Mine uses 0.1 ohm version, so my equation becomes

Imax = Vref / 0.8

For my test:

  1. I got a fresh A4988 out of a package
  2. I did not touch the potentiometer. 
  3. Using an ESP8266 WeMos since it has both 3.3V and 5V output pins.
  4. The 5V pin, reads 4.96V.
  5. Connect to the A4988 VDD pin
  6. Ground to ground
  7. Took a Vref reading of 0.80V
  8. Using the equation of Imax = VREF / 0.8
  9. Imax is calculated as 1.0A

Same test, but...

  1. Using 3.3V pin, reads 3.29V.
  2. Took a Vref reading of 0.54V
  3. Imax is calculated as 0.678A

Note:  How this is dead-on a ratio of 0.678*5/3.3 = 1.0A

Although the Pololu site mentions that the pot calibration must be redone when changing the VDD voltage, it does not mention that we can get the full potential of the A4988 while using a 3.3V on the VDD input.

Experiment 2 - Measuring Coil Current

I now hooked it up in-series with one of the coils as Bill has recommended in his video.  

When using a VDD power of 5V, we get a coil current of 0.61A.  When using a VDD power of 3.3V, we get a coil current of only 0.38A. 

Three things come out of this experiment.

  1. The output current to the stepper is dependent on VDD voltage.
  2. The equation Imax = Vref / 8 / Rcs is not correct.  It needs to also be a function of VDD.
  3. That the equation is still not predicting the coil current.  We were supposed to get 1.0A with VDD of 5V.  We're only getting 0.61A.

Experiment 3 - Adjusting potentiometer for maximum Vref.

  1. Using a VDD input of 3.3V, I adjusted the Vref for its maximum value.
  2. This gave a reading of 1.08V.
  3. Imax(3.3V) = 1.08/0.8 = 1.35A
  4. Using the same setting, but with 5V on VDD, we get a reading of 1.614V
  5. Imax(5V) = 1.614/0.8 = 2A

Experiment 4 - Measuring Coil Current at this "max" setting.

  1. Using VDD=3.3V, read 0.85A.
  2. Using VDD=5V, read 1.3A

So far, I have not found any reference to this behavior of dependency on the VDD input voltage.  

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
Page 2 / 2