# H-Bridge DC Motor - PWM Problem

Status
Not open for further replies.

#### rascupanamuha

##### Member
I have made PCB board based on this schematics.
When i put input A on +5V and input B on 0V, motor goes one way, and when A is 0V and B +5V, motor goes the other way. So this is great

The problem is when i try to control the speed with PWM. A is for example on 20% duty cycle, and B is 0% duty cycle, but the motor doesnt run at 20% of its max speed.

Also when inputs are manualy connected to A=+5V and B=0V (motor is running and current is 0.3A), and i disconnect input B (A is still on +5V), it stops and the current is now above 3A (mosfets are designet for 195A and 30A so 3A shouldnt be a problem, but it doesnt work)

Is something wrong with my hardware or with the software (Arduino)?

Code:
int potPin = 3;
int A = 1;
int B = 0;

void setup() {
pinMode(A, OUTPUT);
pinMode(B, OUTPUT);
}

void loop() {

if (value <= 510) {
value = map(value, 0, 510, 255, 0);
analogWrite(A, value);
digitalWrite(B, LOW);
delay(100);
}

if (value > 510) {
value = map(value, 510, 1023, 0, 255);
analogWrite(B, value);
digitalWrite(A, LOW);
delay(100);
}
}

#### Attachments

• 124 KB Views: 127

#### Tony Stewart

##### Well-Known Member
• 10K is a rather large value of R for given Ciss for transition turn-off delay and shootthru failure.
• losses will be excessive but dependant on PWM rate.
• R5,6 obviously enable shootthru failure with floating B

Analyze existing bridge driver chip designs before attempting your own.

#### MikeMl

##### Well-Known Member
The shoot-through currents on this design will be horrific. I recommend to newbies to use four port pins when controlling a H-bridge with a micro. Then you can use software delays to make sure that left P is off before you turn on left N and vice versa, and vice versa to the other side.

PWM becomes trivial if you have four port pins, too...

#### rascupanamuha

##### Member
Thank you both, I have seperated all inputs, now i control A, B, C and D, and it is working with PWM without any problem

#### Tony Stewart

##### Well-Known Member
Working is good but how much margin and load?

I dont recall control C&D unless a mirror like bridge.

FYI Shootthru margin degrades with EMF and high surge current induced with rapid changing directions.

Margin also changes with device junction temperature rise with faster turn-on.

Status
Not open for further replies.