I've made a circuit to drive a magnetorquer using an L293D driver and an external H-bridge (reason being that the driver IC switches off at low PWM). It worked fine the first time, but now the load isn't drawing any current.
I'm using L293D as the gate driver. The top half uses two IRF9540N pmosfets and the bottom half, two IRFZ44N nmosfets. Poking around with a DMM, I saw that the source pin of the nmos that was supposed to be ON was pulled up to 2.3 V?? I figure it could be a breadboard problem or a wiring issue, but I'd appreciate any suggestion.
Code to drive L293D:
int pwm1 = 8; //pmos control (violet) these are the colours of the jumper wires
int pwm2 = 9; //pmos control (blue)
int pwm3 = 10; //nmos control (yellow)
int pwm4 = 11; //nmos control (red)
int pval = 255;
void setup() {
pinMode(pwm1, OUTPUT);
pinMode(pwm2, OUTPUT);
pinMode(pwm3, OUTPUT);
pinMode(pwm4, OUTPUT);
}
void loop() {
analogWrite(pwm1, 0); //mosfet(p) 1 on
analogWrite(pwm2, 255); //mosfet(p) 2 off
analogWrite(pwm3, pval); //mosfet(n) 3 on
analogWrite(pwm4, 0); //mosfet(n) 4 off
}
I would connect the P MOSFET gates to 5V with a 5.1K resistor and the N MOSFET gates to ground with a 5.1K resistor. That will ensure that all the MOSFETs are OFF, until the Uno can set the pinModes to outputs.
In your code, make sure to set the output levels so that all MOSFETs are OFF in setup()
It's never a good idea to leave a MOSFET gate floating. It could go high or low or somewhere inbetween until power is applied and the gate voltage is set.
Be sure on the same side you do not turn on the top and bottom half of the bridge at concurrently. If you do parts will probably fry and interesting things could happen, mostly not good. During switching be sure one is off before the other is turned on,
Can you please post a copy of your circuit, a picture of a hand drawn circuit in jpg, png?
Hand drawn and photographed is perfectly acceptable.
Please include ALL hardware, power supplies, component names and pin labels.
So I solved the problem partially by grounding the nmos source pins individually. The circuit is drawing more current, but it's well below the calculated value.
I think some of the MOSFETs are not switching on properly, but I think I can solve it now. Thanks for your help.
Turns out it was a breadboard issue. Touched the ends of two wires shorted to ground placed far from each other, and got more than 0.5 V on DMM. Problem is more or less solved.