Having trouble with drv8251 H-bridge - Page 1
Forum section: electronics / projects

author: lavaman
author_rank: Contributor
timestamp: March 04, 2025, 08:02:11 pm
content: Hello,I am having trouble working with this circuit (see the picture). It is supposed to be a DCC train decoder. I am decoding a signal from the power line and then using the attiny to control a motor with a DRV8251 motor driver. Everything is working absolutely fine, except that the motor runs much slower in one direction than the other. After some measurements, the h-bridge outputs a much lower voltage in one direction. I have tried replacing the H-bridge and even all the components. Tried measuring the voltage on IN1 and IN2 of the H-bridge, the voltage is the same in both directions. Could someone give me advice? This starts to drive me mad. Even with an oscilloscope, I can't find the problem

author: thm_w
author_rank: Super Contributor
timestamp: March 05, 2025, 01:09:32 am
content: Did you try flipping the motor around and seeing if that made any difference?If it switched which direction is slow, its a motor issue.If it didn't, continue to look at the PCB.What is the voltage on Vm when driven in one direction and the other?What is the voltage on OUT1 and OUT2 you measured.

author: mawyatt
author_rank: Super Contributor
timestamp: March 05, 2025, 01:15:32 am
content: Quote from: lavaman on March 04, 2025, 08:02:11 pmOver a decade ago when we were developing some linear rails for micron level camera positioning (for chip imaging), we tried the TI DRV Controllers. Recall they were not very good and had a horrid non-linearity when using micro stepping, after considerable test and eval efforts for different controllers we settled on the Trinamic controllers. These were quite good then, and suspect they still are.Might consider investigating the Trinamic controllers, think ADI acquired them a few years ago.Best

author: thm_w
author_rank: Super Contributor
timestamp: March 05, 2025, 01:19:58 am
content: Quote from: mawyatt on March 05, 2025, 01:15:32 amOP is talking about a DC h-bridge, nothing to do with stepper motors or drivers..We use DRV stepper and brushed motor drivers and they are good for our basic use cases. You are probably talking about the old DRV8825, which werent very good.

author: lavaman
author_rank: Contributor
timestamp: March 05, 2025, 07:10:57 am
content: It is not a motor issue, have tried flipping the motor and switching it for a new one.Voltage on Vm is 11,3V. This voltage does not change when changing the direction.Voltage on OUT1 around 11V. OUT2 is around 4V.I have a DRV8220 lying around. I will try it in the current setup and check the voltages

author: mtwieg
author_rank: Frequent Contributor
timestamp: March 05, 2025, 06:35:29 pm
content: Should explain a little more about how you are using the chip. Are you driving IN1/IN2 with PWM? If so, are IN1/IN2 driven complementary, or are you holding one low while applying pwm to the other?Were those voltages on OUT1/OUT2 measured with a DMM, or a scope? When spinning forward or backward?Have you checked whether the DRV8251 is hitting its current limit (should be 3.3A according to your schematic)?

author: lavaman
author_rank: Contributor
timestamp: March 05, 2025, 07:02:13 pm
content: In one direction I am applying PWM to IN1 and Ground to IN2, in the other I apply positive voltage to IN2 and inverted PWM signal to IN1. However when testing and measuring the circuit I applied HIGH on IN1, LOW on IN2 in one direction and vice versa.I am doing the whole inverted PWM thing because of PCB design limitations. This enables the layout to be much smaller, than if both pins were PWM. (only one of the pins I am using, supports PWM)Here is the logic written down:Regular operation (signal being send via the power line and decoded):Direction 1 IN1-PWM, IN2-LOWDirection 2 IN1-inverted PWM, IN2-HIGHWhile testing:Direction 1 IN1-HIGH, IN2-LOWDirection 2 IN1-LOW, IN2-HIGHThe voltage has been measured by a scope. Lower voltage was measured in the direction 2.Drv is not hitting its limit, I have it hooked on a lab bench power supply, and the current never goes above 200mA. Although thinking about the current... in the first direction (the one, where it runs as intended) the current drawn from the power supply is lower, something around 140mA. Could there be potentially mistake in the schematic causing this?Thinking back this started when I switched to a different ATTINY, before I was using attiny1606 which had a few drawbacks, but it was driving the motor without a problem. Along side this I changed the voltage from 3v3 to 5v.Can anyone make some sense out of this?

author: fourtytwo42
author_rank: Super Contributor
timestamp: March 05, 2025, 08:03:36 pm
content: Ohh dear it seems your schematic symbol is incorrect. I believe you have transposed pins 1 & 7 (Iprop & Gnd). If this is true the chip would certainly behave unpredictably

author: lavaman
author_rank: Contributor
timestamp: March 05, 2025, 08:19:13 pm
content: What do you mean exactly? I am not sure what you meant

author: fourtytwo42
author_rank: Super Contributor
timestamp: March 05, 2025, 08:23:18 pm
content: Quote from: lavaman on March 05, 2025, 08:19:13 pmLook at the data sheet & compare it with your schematic!!Another issue you will doubtless run into having apparently changed the MPU from a 5V to a 3V3 part is insufficient gate voltage for the 2N7002''s, again I suggest you carefully read there data sheet.

author: lavaman
author_rank: Contributor
timestamp: March 05, 2025, 08:31:28 pm
content: In this circuit the gate voltage for the 2N7002 is 12V.And for the others it is 5V. I must have forgotten to change the voltage in the schematicthis is a schematic from the datasheet. I have based mine directly on it. I can't find what is wrong with my wiring

author: fourtytwo42
author_rank: Super Contributor
timestamp: March 05, 2025, 08:36:37 pm
content: I think your problem is you blindly copy things in a careless hurry without taking the time to find out if your assumptions are correct, then you are obtuse with people trying to help you! Instead of your rubbish positional diagram LOOK AT THE PIN NUMBERS!!

author: lavaman
author_rank: Contributor
timestamp: March 05, 2025, 08:42:50 pm
content: This is the pinout from the datasheet, to me it seems to be the same as in the schematic

author: lavaman
author_rank: Contributor
timestamp: March 05, 2025, 08:49:57 pm
content: I think I know where the misunderstanding came from. You are looking at the DRV8251A, this version has ground on pin7. DRV8251 (version I am using) has ground on pin1 and Isense on pin7, as shown in the pinout I sent and my schematic.

author: fourtytwo42
author_rank: Super Contributor
timestamp: March 05, 2025, 09:00:45 pm
content: Quote from: lavaman on March 05, 2025, 08:49:57 pmOMG I do apologize most sincerely, that's a nasty move by TI, normally the A part is a slight improvement not pin incompatible and I am afraid the 1st data sheet that came up was the A part and it looked like a dead ringer simple mistake! Sorry once more

author: lavaman
author_rank: Contributor
timestamp: March 05, 2025, 09:27:03 pm
content: Don't worry about that; the world of electronics sure can be confusing sometimes.Your comment sparked some hope in me, I have had trouble getting this thing to work for quite some time. I just can't wrap my head around this issue

author: thm_w
author_rank: Super Contributor
timestamp: March 05, 2025, 10:59:15 pm
content: Quote from: lavaman on March 05, 2025, 07:10:57 amSo in one direction:- IN1 is 3.3V, IN2 is 0V- OUT1 is 11V, and OUT2 is 4V (problem)In the other direction:- IN1 is 0V, IN2 is 3.3V- OUT1 is 0V and OUT2 is 11V (good)yeah?I can't think of what would cause that if it is the case. But if you don't see 0V, maybe there is an issue with your grounding. If IN1/2 don't match up then some software issue.Photo of board and layout might help.

author: mtwieg
author_rank: Frequent Contributor
timestamp: March 05, 2025, 11:32:03 pm
content: Quote from: lavaman on March 05, 2025, 07:02:13 pmOk, I understand your PWM scheme. It would probably work if each input was controlling an independent half bridge, but that's not actually how the chip works (per table 8-2 in the datasheet).For direction 1, your inputs are changing between the first two rows of the table, reverse and high-Z (high-Z will apply voltage of the opposite sign so long as there's current flowing).For direction 2, your inputs are changing between the last two rows of the table, forward and brake (brake will apply zero voltage).Because of the difference between the high-Z and brake states, the average voltage magnitude seen by the motor will be different between the two directions (how much depends on the duty cycle).QuoteOk so during this testing you're not using PWM at all on either pin? In that case what I said above won't apply.QuoteSo in this test (with IN1 and IN2 driven with constant levels, no pwm), are both OUT1 and OUT2 also constant when viewed on the scope? Or do one or both of them switch on and off? This could reasonably occur due to the current regulation feature of the chip. If the motor current reaches 3.3A (enough to trip its current regulation comparator), then it will basically generate its own PWM operation. And in such a case, the supply current may be much lower than the motor current, especially if the motor is stalled. I would probe the ISEN pin and see what's going on then. Alternatively you could disable the current regulation by shorting out the sense resistor. Beware though, if the motor was stalled then this might result in excessive currents damaging the driver/motor.

author: lavaman
author_rank: Contributor
timestamp: March 06, 2025, 07:19:16 am
content: Mtwieg, I have to really thank you. After some quick testing it seem that all you have pointed out in your post is correct.Whilst testing with a scope I discovered the OUT2 switching on and of. After adding a smaller resistor it is behaving as expected.The part where you described the PWM scheme is most likely correct too. Didn't have time to test it tho, but it seems to make sense.

author: mtwieg
author_rank: Frequent Contributor
timestamp: March 06, 2025, 12:08:31 pm
content: Glad to help.For your PWM scheme, if you want to get similar behavior in both directions with only one PWM signal from the MCU, consider adding some logic gates between the MCU and DRV8251 like in the attached schematic. When DIR=0, the PWM signal will switch the DRV8251 between the forward and brake states. When DIR=1, the PWM signal will switch the DRV8251 between the reverse and brake states. The coast/disabled state is never used.