I am using Arduino Mega + RAMSP 1.4 with Marlin firmware to control my machine(not exactly a 3d printer). Marlin has gcode
M42 P20 S255 ==> Turn on 20 the pin of Mega
M42 P20 S0 ==> Turn off 20 the pin of Mega
I am using this command to turn ON a MOSFET switch connected to pin 20.
When i have not put the RAMPS shield on top of mega, this works. Pin goes high only when I send code to turn it ON.
But when I place shield on top of Mega (No 12V power is given to RAMPS, only 5 V from USB), when I first connect USB to it, I find around 2 V on Pin 20 even with out sending ON command. when sending
M42 P20 S0 this goes away (0V) and get 5V for
M42 P20 S255. With out shield there's no voltage when connect USB to Mega, With shield there's 2 volts on the pin and this cause MOSFET switch to turn on. Where does this voltage comes from.? First I thought this must be some noise, so added a 10K pull down resistor (since that is the common value I have seen many circuits), but it didn't work. But placing a 100 ohm works. I am not sure it's safe???
LED on drain is to represent load, in actual circuit, power supply will e 24 V and load is fluid dispenser. My purpose is when I I send
M42 P20 S255 mosfet will turn ON and give 24 V signal to liquid dispense controller. Upon receiving 24 V signal, liquid dispenser controller will dispense liquid for a set duration
No need for MOSFET switch, connect and led to pin 20 of Mega. When only mega is connected to US, LED turns OFF
with Shield on Top, LED turn ON (Not fully)