Welcome! Log In Create A New Profile

Advanced

Switching external MOSFETs with RAMPS 1.4

Posted by zipfactor 
Switching external MOSFETs with RAMPS 1.4
November 19, 2014 12:27PM
Hi Everyone,

I've run into a few unexpected problems with my RAMPS 1.4 board switching external n-channel MOSFETs. My setup is in the attached sketch.

I reconfigured the Marlin firmware so that pins D8, D9, and D10 could be used for my purposes, along with making the outputs bang-bang in place of PID. In this case, pins D8 and D9 are used to drive two externally mounted n-channel MOSFETs (STP40NF12). I've got gate resistors for each of the MOSFETs with a value of 25 ohm. There are also two gate-to-source pull-down resistors with a value of 1kohm. The flywheel diode is an ordinary IN4001.

The issue I'm experiencing is when I switch pin D8 ON using "M42 P8 S255" through pronterface, pin D9 will inadvertently turn ON. Pin D8 will inadvertently turn ON if the command "M42 P9 S255" is issued through pronterface.

With the MOSFET connections to pins D8 and D9, I can toggle pin D10 (nothing connected) using "M42 P10 S255", and only pin D10 will be ON.

If I remove the connections from pin D9, I can toggle pin D8 (connected to MOSFET) and only pin D8 will turn ON. The same occurs if I remove pin D8's connections, and toggle pin D9.

If both the connections are removed from both pins D8 and D9, they can individually be toggled ON without causing the other pin to turn ON.

Because this is in an enclosure, I've tried different wire routings thinking it may be a grounding issue without any change in behavior.

The MOSFETs are mounted externally from the RAMPS 1.4 board, both FETs being on the same board.

Any help would really be appreciated.

Edited 1 time(s). Last edit at 11/19/2014 12:30PM by zipfactor.
Attachments:
open | download - MOSFET_switch.png (206.4 KB)
Re: Switching external MOSFETs with RAMPS 1.4
November 19, 2014 02:11PM
Hmmm this is really interesting...double check your diode orientation. I haven't quite wrapped my mind around your setup but I've experienced something similar so i'll throw some ideas out there.

What happens when you send S200 or 150? See how low you can get it while still triggering the MOSFETs. I don't know if the PWM coming out of the RAMPS transistors will give you a smooth enough curve but its worth a shot. I looked at their datasheet an it looks like they'll go on as little as 2 volts. Also try changing resistor values to get to different points within the acceptable range. (not sure how to word that, if it doesn't make sense forget it.)

Have you tried without an actual load on the MOSFETs? I'm sure you have but if not try this. Otherwise replace the solenoid with like a 100k resistor and give it a shot. Even though it seems like it shouldn't matter, solenoids are really strange and I've never used them without having to make some weird consideration. Also maybe try giving them 12V rather than 24 and see what happens. Again it shouldn't make a difference, but it rules out a lot of things.

Do you need a MOSFET here? I'm not sure how quickly you're attempting to switch these but if you only need to every so often I would just throw some relays in there instead. It makes the circuit much simpler, and you can completely separate your solenoid power circuits and your coil circuits.

Good luck.
Re: Switching external MOSFETs with RAMPS 1.4
November 19, 2014 03:00PM
Your diodes aren't doing anything. They need to be across the inductive load with the stripe towards the positive lead.

There are also several other issues with your circuit. The +12v that you have labeled coming from D8 and D9 are only 5V if you are using the actual pins from the microcontroller. If you're using the 12V outputs that normally would power the fan and extruder, those are switched on the negative connection. 12v is always present so your mosfets are always on.

Your D8 side of the schematic has the +12V connected to a shunt that goes to ground. The voltage doesn't connect to the resistor to to go the gate, at least with any breadboard that I've ever used. As you have them oriented, the vertical holes are interconnected except the red and blue rows at the top and bottom that are horizontally connected.
Re: Switching external MOSFETs with RAMPS 1.4
November 19, 2014 04:08PM
Quote
cdru
Your diodes aren't doing anything. They need to be across the inductive load with the stripe towards the positive lead.

There are also several other issues with your circuit. The +12v that you have labeled coming from D8 and D9 are only 5V if you are using the actual pins from the microcontroller. If you're using the 12V outputs that normally would power the fan and extruder, those are switched on the negative connection. 12v is always present so your mosfets are always on.

Your D8 side of the schematic has the +12V connected to a shunt that goes to ground. The voltage doesn't connect to the resistor to to go the gate, at least with any breadboard that I've ever used. As you have them oriented, the vertical holes are interconnected except the red and blue rows at the top and bottom that are horizontally connected.

The outputs being used are 12v, and are in fact the ones that were used to power the fan / extruder.

This is making sense. So if I understand this correctly, right now I'm trying to sink current with the external n-channel MOSFET to the n-channel MOSFET which is on the RAMPS 1.4 shield, which is also sinking current. If I configured the n-channel MOSFET in a high side configuration, I would assume this would work because it would then be sourcing current, correct? But the downside to n-channel as a high side switch is that I would need the gate voltage to be higher than the drain voltage, which in my case would have to be upwards of +30v for gate voltage. A p-channel MOSFET would be the ticket then, I assume?

I apparently missed that connection when I was moving components around in software. Thanks for pointing that out, as well as the incorrect diode placement.
Re: Switching external MOSFETs with RAMPS 1.4
November 24, 2014 05:41AM
Here's a working schematics: [reprap.org]

Breadboards aren't capable of driving multi-ampere loads anyways.


Generation 7 Electronics Teacup Firmware RepRap DIY
     
Re: Switching external MOSFETs with RAMPS 1.4
April 08, 2015 09:26PM
care to elaborate on the whole circuit? I understand what the resistors do, but what does the diode do?
Re: Switching external MOSFETs with RAMPS 1.4
April 09, 2015 09:05AM
Quote
aduy
but what does the diode do?
The diode used in conjunction with a transistor is referred to as a flyback diode. When an inductive load (such as a fan or motor) is normally operating, the diode just sits there doing nothing. When the circuit is broken, the inductive load can produce a voltage spike which can damage electronics. The flyback diode allows the inductive load to draw current from itself, dissipating the spike without damaging other components.

If the load is purely resistive such as a heated bed, then it's probably not really necessary as the inductive load is minimal. But it's a good circuit design to include the protection, especially if the circuit could be used for both inductive and resistive loads such as how the SevenSwitch can be used.
Sorry, only registered users may post in this forum.

Click here to login