Issues Controlling a MOSFET as a curent source with a Raspberry Pi

Thread Starter

phillipsoasis

Joined Aug 22, 2022
75
I have a circuit with a Raspberry Pi Zero driving a IRLZ34N MOSFET through a MCP4921 DAC and a TLV2462 op-amp as a voltage follower. The Pi also reads the current value from a 0.100 Ohm resistor (R5) in the source of the MOSFET, through a MCP3008 ADC and a Sallen-Key low pass filter using a TLV2462 op-amp. The load in the drain of the MOSFET is a rocket igniter. For testing, I am using a 12 V car light bulb to simulate the igniter. The goal of the circuit is to (1) activate the MOSFET to drive ~10 mA through the igniter to test continuiity in the ignition circuit and (2) drive ~1000 mA through the igniter to ignite the rocket.

The circuit works ok for large currents (see the test data). There is up to a 6 mA difference between the desired current and the current measured (see the chart from the test data). That really does not matter, as the igniter won't really care. But, when I program the DAC for 0 current through the igniter, there is about 8-10 mA flowing through the sensor resistor R5. Again, this is not a huge issue, as the igniter should not ignite at that low of a current. But no one wants to be installing the leads on the igniter when the rocket is on the launch pad, knowing there is some amount of current flowing in the igniter circuit.

I had three thoughts on how to solve the 0 current issue. One, to add a positive voltage bias to the bottom of R5 so the gate will effectively be at a lower voltage than the source for a certain range of values sent to the DAC, so the MOSFET is shut off. Two, I could change the power supply to U3 to be dual sided (+/-3.3V), and drive the output of U3 less than zero volts for a certain range of DAC outputs, which would also cut off the MOSFET. Three, I could add a relay controlled by the Pi in the igniter circuit that effectively disconnects the 12 V supply from the drain of the MOSFET when I want it to be off. The real downside of this approach is that it depends on the PI software to be bullet proof, which is not what the safety officers will accept.

I don't need the whole dynamic range of the DAC for this application controlling the MOSFET. The MOSFET needs to be "on a little" to test continuity, "on a lot" to ignite the rocket, and rock solid "off" the rest of the time.

I am looking for some guidance on which option (1 or 2) is most feasible and some guidance on how to implement the design.

Thanks!

Mark
 

Attachments

LowQCab

Joined Nov 6, 2012
4,072
I don't think I've ever seen such a simple problem made so complex.

A Mono 1/4" Phone-Plug, and matching Jack,
will make a perfect, and cheap, "Safety-Key" for insuring that
the Igniter-Wiring can not possibly be "Hot",
because the person connecting the Igniter-Wiring must have
the "Safety-Key" in his hand while connecting the Igniter-Element.

An LED, with it's requisite Current-Limiting Resistor,
could be connected across the "Launch" Push-Button,
and/or, a Count-Down-Timer-operated-Relay,
this will visually confirm good continuity through the Igniter-Element.
A small Piezo-Beeper could also be added in with the LED, or, instead of an LED.
This would add an audible warning that continuity is good,
and the system is ready for launch.
.
.
.
 

Thread Starter

phillipsoasis

Joined Aug 22, 2022
75
I don't think I've ever seen such a simple problem made so complex.

A Mono 1/4" Phone-Plug, and matching Jack,
will make a perfect, and cheap, "Safety-Key" for insuring that
the Igniter-Wiring can not possibly be "Hot",
because the person connecting the Igniter-Wiring must have
the "Safety-Key" in his hand while connecting the Igniter-Element.

An LED, with it's requisite Current-Limiting Resistor,
could be connected across the "Launch" Push-Button,
and/or, a Count-Down-Timer-operated-Relay,
this will visually confirm good continuity through the Igniter-Element.
A small Piezo-Beeper could also be added in with the LED, or, instead of an LED.
This would add an audible warning that continuity is good,
and the system is ready for launch.
.
.
.
Thanks for your comments. All your suggestions are great, assuming there is a wire between the launch button and the igniter circuit. In my application, there is no wire. The launch button is on my cell phone, and it talks to the Pi over WiFi. The box with the above circuit is on the launch stand.
 

Ian0

Joined Aug 7, 2020
9,817
Your problem would seem to be the op-amp's offset voltage, which could be as much as 2mV.
At 10mA with a 0.1Ω current sense resistor, you are trying to measure 1mV.
My suggestion would be to make two separate current sink circuits, each with its own MOSFET and source resistor, 0.1Ω for the high-current one, and 10Ω for the low current one.
The easy way to detect if the output is open circuit is to look at the op-amp output (the one driving the MOSFET). If it is hard against the 3.3V rail then the output is open circuit.
 

Thread Starter

phillipsoasis

Joined Aug 22, 2022
75
Not really. Use a voltage divider to sense continuity.
View attachment 297821
Thank-you for your input. I can measure continuity and ignite the igniter with the current circuit. The main issue is how to shut off Q1 completely so there is no current flowing except when I want to measure continuity or ignite the igniter. I don't want to measure continuity all the time, as in your circuit. Why? When attaching the leads to the igniter when the rocket is on the launch pad, I don't want any current flowing through Q1 in order to prevent an accidental ignition. I had hoped that entering 0 into the DAC would shut off Q1, but that is not happening because of offset voltages etc.
 

Thread Starter

phillipsoasis

Joined Aug 22, 2022
75
Your problem would seem to be the op-amp's offset voltage, which could be as much as 2mV.
At 10mA with a 0.1Ω current sense resistor, you are trying to measure 1mV.
My suggestion would be to make two separate current sink circuits, each with its own MOSFET and source resistor, 0.1Ω for the high-current one, and 10Ω for the low current one.
The easy way to detect if the output is open circuit is to look at the op-amp output (the one driving the MOSFET). If it is hard against the 3.3V rail then the output is open circuit.
I agree with your analysis about the offset voltage as well as just stray noise in the physical circuit is preventing the DAC from shutting off Q1. I don't understand how you would connect two MOSFETS as you describe. Can you elaborate or add a circuit diagram?
 

kaindub

Joined Oct 28, 2019
132
Change your current sense resistor to something like 10 ohms. youre then developing 100mV across it at at 10mA but brings it into a range where the op amp can work. rather than being right in the offset "noise'
That also is a safeguard as the maximum current you can pull is about 1.2A
 

Ian0

Joined Aug 7, 2020
9,817
I agree with your analysis about the offset voltage as well as just stray noise in the physical circuit is preventing the DAC from shutting off Q1. I don't understand how you would connect two MOSFETS as you describe. Can you elaborate or add a circuit diagram?
Just duplicate the DAC-OpAmp-MOSFET circuitry and connect the two MOSFET drains together.
Or you could use @sghioto 's circuit, and if you don't want it powered all the time, just switch the bottom resistor with another MOSFET.
 

sghioto

Joined Dec 31, 2017
5,390
and if you don't want it powered all the time, just switch the bottom resistor with another MOSFET.
That won't work because the voltage is almost 12 volts at the GPIO when not connected. Switching the high side would work using two transistors or an optocoupler.
 
Last edited:

Ian0

Joined Aug 7, 2020
9,817
Thinking a little further outside the box. . .
It must be either a fully floating power supply, or the load must be between the switch and earth.
If it is a 12V supply with 0V earthed, then an accidental connection from the ignitor to earth will ignite the rocket.
And if it is double-pole isolated fully floating power supply, then one must take steps to ensure it stays that way. i.e no input connection can accidentally ground the 0V
 
Top