Author Topic: Calculating Rsense resistor value for motor driver  (Read 1777 times)

0 Members and 1 Guest are viewing this topic.

Offline newtekuserTopic starter

  • Frequent Contributor
  • **
  • Posts: 401
  • Country: us
Calculating Rsense resistor value for motor driver
« on: January 18, 2024, 11:04:20 pm »
I am using a DRV8825 motor driver with its VREF pin connected to 3.3v coming from a SPX1117 fixed voltage regulator. My stepper is a 12v drawing max 1.25A and want to size the Rsense resistor appropriately for current limitation.

I am using the following formula:

Rsense = 0.2V / 8 x 1.25 = 0.02

Based on this I should need a resistor of 20 milli-ohm. Is this correct?


https://www.digikey.com/en/products/detail/texas-instruments/DRV8825PWPR/2695909
https://www.digikey.com/en/products/detail/maxlinear-inc/SPX1117M3-L-3-3-TR/2472291
« Last Edit: January 18, 2024, 11:21:10 pm by newtekuser »
 

Offline HwAoRrDk

  • Super Contributor
  • ***
  • Posts: 1561
  • Country: gb
Re: Calculating Rsense resistor value for motor driver
« Reply #1 on: January 19, 2024, 02:32:37 am »
I'm not sure where you got that formula from, and some of the values in it. According to the DRV8825 datasheet the formula for current sensing is:
$$I_{FS} = {{xVREF}\over{{5}\times{R_{SENSE}}}}$$

So, solving for:
$$1.25 = {{3.3}\over{{5}\times{R_{SENSE}}}}$$
gives you RSENSE = 0.528 ohms.

That's going to dissipate quite a lot of power in the sense resistors - about 0.8W! You should probably lower the VREF voltage, like in the application example in the datasheet. Using a voltage divider of 47k/10k gives you a reference voltage of approx. 0.58V, and that'll mean you only need a current sense resistor of 0.1 ohms, which will only dissipate about 0.15W at the full 1.25A.

Edit: Oops, sense resistor of 0.1 ohms will only get you full-scale current of 1.16A. A resistor value of 0.091 ohms will give you 1.27A.
« Last Edit: January 19, 2024, 02:46:03 am by HwAoRrDk »
 
The following users thanked this post: newtekuser

Offline newtekuserTopic starter

  • Frequent Contributor
  • **
  • Posts: 401
  • Country: us
Re: Calculating Rsense resistor value for motor driver
« Reply #2 on: January 19, 2024, 07:06:18 am »
I'm not sure where you got that formula from, and some of the values in it. According to the DRV8825 datasheet the formula for current sensing is:
$$I_{FS} = {{xVREF}\over{{5}\times{R_{SENSE}}}}$$

So, solving for:
$$1.25 = {{3.3}\over{{5}\times{R_{SENSE}}}}$$
gives you RSENSE = 0.528 ohms.

That's going to dissipate quite a lot of power in the sense resistors - about 0.8W! You should probably lower the VREF voltage, like in the application example in the datasheet. Using a voltage divider of 47k/10k gives you a reference voltage of approx. 0.58V, and that'll mean you only need a current sense resistor of 0.1 ohms, which will only dissipate about 0.15W at the full 1.25A.

Edit: Oops, sense resistor of 0.1 ohms will only get you full-scale current of 1.16A. A resistor value of 0.091 ohms will give you 1.27A.

Thanks much for this!

Is it ok if I round up the resistor value? For example, instead of using the 47k/10k resistor divider as suggested, I'd like to to with 50k/30k so I can get 1.23v to also power an LED connected to the nFault pin of the driver.
However, with 1.23v for ref I get a value for Rsense of 0.19ohm and I'm not able to find any resistors of this size either on Digikey or Mouser (they're sold out). Instead I can find plenty of 0.20 ohm resistors.
 

Offline HwAoRrDk

  • Super Contributor
  • ***
  • Posts: 1561
  • Country: gb
Re: Calculating Rsense resistor value for motor driver
« Reply #3 on: January 19, 2024, 08:17:01 am »
Is it ok if I round up the resistor value? For example, instead of using the 47k/10k resistor divider as suggested, I'd like to to with 50k/30k so I can get 1.23v to also power an LED connected to the nFault pin of the driver.

Huh? ??? Why do you think you need 1.23V to power an LED for the fault output? I think you have a misunderstanding of how LEDs work and how to use them.

For a start, LEDs need a minimum amount of voltage to work, known as their forward voltage (or VF). This is typically around 2V for modern LEDs. So trying to run an LED off 1.23V won't work. Second, in addition to the minimum voltage, LED brightness is dictated by the amount of current passed through them. Even if by some miracle you found an LED that has a VF less than 1.23V, if you feed it from a 50k/30k voltage divider, the current through the LED is effectively being limited by the upper 50k resistor. That would make for 26 microamps. A modern high-efficiency LED might start to emit light at that current, but you'll only barely see it in a dark room.

You should run your fault LED from the 3.3V supply with a modest current-limiting resistor such that the LED gets a few milliamps. I suggest somewhere from 330 ohms to 1k, depending on the brightness required. Note also the nFault pin is an open-drain output, so when it's active it pulls whatever's connected to the pin to ground. So you'd connect the LED's cathode to it. (The current-limiting resistor can go either side of the LED, it doesn't matter.)

However, with 1.23v for ref I get a value for Rsense of 0.19ohm and I'm not able to find any resistors of this size either on Digikey or Mouser (they're sold out). Instead I can find plenty of 0.20 ohm resistors.

Well, to 3 decimal places, the calculation actually gives you 0.197, so that's almost 0.2 anyway. :) But that 0.2 ohm resistor will be dissipating 0.25W at 1.25A, so like I said earlier, it's better to have a lower VREF which allows you to use a smaller value sense resistor for lower power dissipation. Oh, and 0.2 ohms will also limit you to a full-scale current of 1.23A.
 

Offline newtekuserTopic starter

  • Frequent Contributor
  • **
  • Posts: 401
  • Country: us
Re: Calculating Rsense resistor value for motor driver
« Reply #4 on: January 19, 2024, 04:18:42 pm »
Is it ok if I round up the resistor value? For example, instead of using the 47k/10k resistor divider as suggested, I'd like to to with 50k/30k so I can get 1.23v to also power an LED connected to the nFault pin of the driver.

Huh? ??? Why do you think you need 1.23V to power an LED for the fault output? I think you have a misunderstanding of how LEDs work and how to use them.

For a start, LEDs need a minimum amount of voltage to work, known as their forward voltage (or VF). This is typically around 2V for modern LEDs. So trying to run an LED off 1.23V won't work. Second, in addition to the minimum voltage, LED brightness is dictated by the amount of current passed through them. Even if by some miracle you found an LED that has a VF less than 1.23V, if you feed it from a 50k/30k voltage divider, the current through the LED is effectively being limited by the upper 50k resistor. That would make for 26 microamps. A modern high-efficiency LED might start to emit light at that current, but you'll only barely see it in a dark room.

You should run your fault LED from the 3.3V supply with a modest current-limiting resistor such that the LED gets a few milliamps. I suggest somewhere from 330 ohms to 1k, depending on the brightness required. Note also the nFault pin is an open-drain output, so when it's active it pulls whatever's connected to the pin to ground. So you'd connect the LED's cathode to it. (The current-limiting resistor can go either side of the LED, it doesn't matter.)

However, with 1.23v for ref I get a value for Rsense of 0.19ohm and I'm not able to find any resistors of this size either on Digikey or Mouser (they're sold out). Instead I can find plenty of 0.20 ohm resistors.

Well, to 3 decimal places, the calculation actually gives you 0.197, so that's almost 0.2 anyway. :) But that 0.2 ohm resistor will be dissipating 0.25W at 1.25A, so like I said earlier, it's better to have a lower VREF which allows you to use a smaller value sense resistor for lower power dissipation. Oh, and 0.2 ohms will also limit you to a full-scale current of 1.23A.

I did find an LED that would work with 1.2v, but you're right, it will require 20mA: https://www.digikey.com/en/products/detail/stanley-electric-co/HAN1102W-1-TR/8544250

Can I connect nFault pin to 3.3v though? According to the datasheet, the schematic shows it is connected to VP3VOUT, my understanding that is Vref, correct?
That's the reason I wanted more than 0.58v.
 

Offline tunk

  • Super Contributor
  • ***
  • Posts: 1057
  • Country: no
Re: Calculating Rsense resistor value for motor driver
« Reply #5 on: January 19, 2024, 04:36:37 pm »
If you're looking for a visible indicator light, 
then that LED is infrared and will not work.
 

Offline newtekuserTopic starter

  • Frequent Contributor
  • **
  • Posts: 401
  • Country: us
Re: Calculating Rsense resistor value for motor driver
« Reply #6 on: January 19, 2024, 07:22:17 pm »
If you're looking for a visible indicator light, 
then that LED is infrared and will not work.

Good catch, I missed that. I'm going to have to go with a higher voltage LED anyway.
 

Offline HwAoRrDk

  • Super Contributor
  • ***
  • Posts: 1561
  • Country: gb
Re: Calculating Rsense resistor value for motor driver
« Reply #7 on: January 20, 2024, 01:51:55 am »
Can I connect nFault pin to 3.3v though? According to the datasheet, the schematic shows it is connected to VP3VOUT, my understanding that is Vref, correct?
That's the reason I wanted more than 0.58v.

The V3P3OUT pin on the DRV8825 is a 3.3V supply pin for convenient use when you have no other source of 3.3V in your circuit. It's a built-in linear voltage regulator that takes VM (in your case, 12V) and regulates it down to 3.3V and outputs it on that pin. In your case, you say you have a separate SPX1117 3.3V regulator, so you don't need to use V3P3OUT (and should leave it unconnected). You don't have to use V3P3OUT for VREF. In fact, VREF can come from anywhere, so long as it is an appropriate voltage and is stable and noise-free enough (for instance, you probably wouldn't want to take VM and divide it down for VREF). Realise that the datasheet schematics are often suggestions, not requirements.

(BTW, note that if you are now thinking of ditching the SPX1117 and using V3P3OUT to power other things, the datasheet says V3P3OUT can only provide a maximum of 1 mA of output current, so it is not a general-purpose 3.3V power supply and you can't do that.)

As for VREF voltage, it is only needed for the AVREF & BVREF pins. Forget the notion that VREF is used by or required for anything else. The datasheet explains how VREF is used:

Quote
The PWM chopping current is set by a comparator which compares the voltage across a current sense resistor connected to the xISEN pins, multiplied by a factor of 5, with a reference voltage. The reference voltage is input from the xVREF pins.

In other words, the voltage dropped across the current sense resistors by the motor current passing through them (i.e. the measured difference in voltage level between GND and at the ISENA/ISENB pins) is multiplied by 5 and compared to VREF. If it's greater, then the DRV8825 will reduce the motor current; if lower it can increase the motor current.

Yes, you can connect nFAULT to 3.3V. In fact, because it's an open-drain output (as is nHOME) it doesn't really care what voltage is connected to it, because all it is capable of doing is switching whatever's connected to that pin to ground. It could be 3.3V, it could be 5V, whatever. (Although in reality, the datasheet states a maximum of 7V on all digital pins, so don't connect it to 12V, for instance.)
 
The following users thanked this post: newtekuser

Offline newtekuserTopic starter

  • Frequent Contributor
  • **
  • Posts: 401
  • Country: us
Re: Calculating Rsense resistor value for motor driver
« Reply #8 on: January 20, 2024, 07:12:06 am »
Can I connect nFault pin to 3.3v though? According to the datasheet, the schematic shows it is connected to VP3VOUT, my understanding that is Vref, correct?
That's the reason I wanted more than 0.58v.

The V3P3OUT pin on the DRV8825 is a 3.3V supply pin for convenient use when you have no other source of 3.3V in your circuit. It's a built-in linear voltage regulator that takes VM (in your case, 12V) and regulates it down to 3.3V and outputs it on that pin. In your case, you say you have a separate SPX1117 3.3V regulator, so you don't need to use V3P3OUT (and should leave it unconnected). You don't have to use V3P3OUT for VREF. In fact, VREF can come from anywhere, so long as it is an appropriate voltage and is stable and noise-free enough (for instance, you probably wouldn't want to take VM and divide it down for VREF). Realise that the datasheet schematics are often suggestions, not requirements.

(BTW, note that if you are now thinking of ditching the SPX1117 and using V3P3OUT to power other things, the datasheet says V3P3OUT can only provide a maximum of 1 mA of output current, so it is not a general-purpose 3.3V power supply and you can't do that.)

As for VREF voltage, it is only needed for the AVREF & BVREF pins. Forget the notion that VREF is used by or required for anything else. The datasheet explains how VREF is used:

Quote
The PWM chopping current is set by a comparator which compares the voltage across a current sense resistor connected to the xISEN pins, multiplied by a factor of 5, with a reference voltage. The reference voltage is input from the xVREF pins.

In other words, the voltage dropped across the current sense resistors by the motor current passing through them (i.e. the measured difference in voltage level between GND and at the ISENA/ISENB pins) is multiplied by 5 and compared to VREF. If it's greater, then the DRV8825 will reduce the motor current; if lower it can increase the motor current.

Yes, you can connect nFAULT to 3.3V. In fact, because it's an open-drain output (as is nHOME) it doesn't really care what voltage is connected to it, because all it is capable of doing is switching whatever's connected to that pin to ground. It could be 3.3V, it could be 5V, whatever. (Although in reality, the datasheet states a maximum of 7V on all digital pins, so don't connect it to 12V, for instance.)

Thank you! So It looks like my best option is to ditch V3P3OUT and use the SPX1117 instead. I then can use a voltage divider to supply VREF and another voltage divider to power the LED going to the nFault pin.

And to double check, I need to feed in the new VREF value of 0.58v into the IFS formula and not the original 3.3v, correct? This will result in an Rsense resistor value of 92 mOhm.

« Last Edit: January 20, 2024, 07:28:53 am by newtekuser »
 

Offline HwAoRrDk

  • Super Contributor
  • ***
  • Posts: 1561
  • Country: gb
Re: Calculating Rsense resistor value for motor driver
« Reply #9 on: January 20, 2024, 07:51:49 am »
I then can use a voltage divider to supply VREF and another voltage divider to power the LED going to the nFault pin.

No, you don't need a voltage divider for the LED. Just a single resistor to limit the current through the LED. Like this: [3.3V]-->[resistor]-->[A LED K]-->[nFAULT] (where A and K are the LED's anode and cathode)

I think you should do some reading about how to drive LEDs, as you seem to have a fundamental misunderstanding of how to work with them. You don't need to lower the voltage being supplied to an LED to that of its forward voltage (VF) rating. All an LED cares about is that the supply voltage is higher than the VF - whether it's by 1V or 10V or more. Then you just need to limit the current through the LED according to its maximum rating and the desired brightness. Don't take the maximum rating as how much current you need to supply - that is just the max. permissible without damaging (i.e. overheating) the LED. Most LEDs are perfectly bright enough at 1/10 of their max. rated current. Use a calculator such as this one to help you work it all out.

And to double check, I need to feed in the new VREF value of 0.58v into the IFS formula and not the original 3.3v, correct? This will result in an Rsense resistor value of 92 mOhm.

Yes. Assuming you are going to use the 47k/10k voltage divider resistors I suggested earlier.

91 milliohm is the nearest standard, common resistor value that should be readily available, so use that.
 
The following users thanked this post: newtekuser

Offline Cuchi

  • Newbie
  • Posts: 3
  • Country: fr
Re: Calculating Rsense resistor value for motor driver
« Reply #10 on: May 04, 2024, 08:58:50 am »
Hello, I am new fellow and I do not yet know how to navigate the site to ask my question
my question is other than the one discussed in this section but a knowledgeable person like you could either answer the question or tell me in which section to ask it in the forum and how to proceed
Ma question is as follow:
I purchased a controller as specified below

a PWM type single channel H-Bridge DC brushed motor driver for automotive use

The pin assignment is as follow: an Output high-side current monitoring function (OCM pin):+VIN; GND and M+;M-

the Microcontroller (inputs):
PWM1: Driver control signal input pin 1
PWM2: Driver control signal input pin 2
EN
GBD
+12V OUT

I plan to use it to vary the speed of a 12 volt electric motor (a motorcycle starter) connected to a 12 volt motorcycle battery as well.
The problem is that when I connect the throttle to the controller inputs (+12v pin; Gnd pin and signal pin) with the output signal of the throttle connected to the PWM1 input of the controller I obtain an inverted effect, i.e. the motor spins when the throttle is closed and at rest and the engine stops when the throttle is opened with the lever pushed all the way. If I connect the throttle signal terminal to the PWM2 of the controller nothing happens

My question is how to reverse things, i.e. make the engine spins as the throttle is applied towards more gas and not the other way around.
Thanks
 


Share me

Digg  Facebook  SlashDot  Delicious  Technorati  Twitter  Google  Yahoo
Smf