Calculating Rsense resistor value for motor driver - Page 1
Forum section: electronics / beginners

author: newtekuser
author_rank: Frequent Contributor
timestamp: January 18, 2024, 11:04:20 pm
content: 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.02Based on this I should need a resistor of 20 milli-ohm. Is this correct?https://www.digikey.com/en/products/detail/texas-instruments/DRV8825PWPR/2695909https://www.digikey.com/en/products/detail/maxlinear-inc/SPX1117M3-L-3-3-TR/2472291

author: HwAoRrDk
author_rank: Super Contributor
timestamp: January 19, 2024, 02:32:37 am
content: I'm not sure where you got that formula from, and some of the values in it. According to theDRV8825 datasheetthe 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.

author: newtekuser
author_rank: Frequent Contributor
timestamp: January 19, 2024, 07:06:18 am
content: Quote from: HwAoRrDk on January 19, 2024, 02:32:37 amThanks 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.

author: HwAoRrDk
author_rank: Super Contributor
timestamp: January 19, 2024, 08:17:01 am
content: Quote from: newtekuser on January 19, 2024, 07:06:18 amHuh?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 VFless 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 26microamps. 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.)Quote from: newtekuser on January 19, 2024, 07:06:18 amWell, 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.

author: newtekuser
author_rank: Frequent Contributor
timestamp: January 19, 2024, 04:18:42 pm
content: Quote from: HwAoRrDk on January 19, 2024, 08:17:01 amI 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/8544250Can 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.

author: tunk
author_rank: Super Contributor
timestamp: January 19, 2024, 04:36:37 pm
content: If you're looking for a visible indicator light,then that LED is infrared and will not work.

author: newtekuser
author_rank: Frequent Contributor
timestamp: January 19, 2024, 07:22:17 pm
content: Quote from: tunk on January 19, 2024, 04:36:37 pmGood catch, I missed that. I'm going to have to go with a higher voltage LED anyway.

author: HwAoRrDk
author_rank: Super Contributor
timestamp: January 20, 2024, 01:51:55 am
content: Quote from: newtekuser on January 19, 2024, 04:18:42 pmThe 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'thaveto 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 oftensuggestions, 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 isnota general-purpose 3.3V power supply and you can't do that.)As for VREF voltage, it isonlyneeded 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:QuoteIn 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 anopen-drainoutput (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.)

author: newtekuser
author_rank: Frequent Contributor
timestamp: January 20, 2024, 07:12:06 am
content: Quote from: HwAoRrDk on January 20, 2024, 01:51:55 amThank 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.

author: HwAoRrDk
author_rank: Super Contributor
timestamp: January 20, 2024, 07:51:49 am
content: Quote from: newtekuser on January 20, 2024, 07:12:06 amNo, 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]-->-->[A LED K]--> (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 ishigherthan 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 asthis oneto help you work it all out.Quote from: newtekuser on January 20, 2024, 07:12:06 amYes. 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.

author: Cuchi
author_rank: Newbie
timestamp: May 04, 2024, 08:58:50 am
content: Hello, I am new fellow and I do not yet know how to navigate the site to ask my questionmy 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 proceedMa question is as follow:I purchased a controller as specified belowa PWM type single channel H-Bridge DC brushed motor driver for automotive useThe 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 1PWM2: Driver control signal input pin 2ENGBD+12V OUTI 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 happensMy 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