3
$\begingroup$

I am using an Arduino Mega 2560 and RAMSP 1.4 shield with Marlin firmware to control my machine (not exactly a 3D printer). Marlin has G-code:

  • M42 P20 S255 ==> Turn on pin 20 of the microprocessor
  • M42 P20 S0     ==> Turn off pin 20 of the microprocessor

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 AtMega, this works. Pin goes high only when I send code to turn it ON.

But when I place the shield on top of the Mega 2560 (No 12 V 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 without sending the ON command. when sending M42 P20 S0 this goes away (0 V) and get 5 V for M42 P20 S255. Without shield there's no voltage when connecting USB to Mega 2560; with shield there's 2 V on the pin and this causes the 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 in many circuits), but it didn't work. But placing a 100 Ohm works. Is this safe?

$\endgroup$
3
$\begingroup$

Connecting a 100 Ohm resistor is definitely not safe. This load is far too high for an AtMega2560 output pin. 100 Ohms at 5 V (when the pin is high) is 50 mA, whereas the recommended maximum for an AtMega2560 pin is 20 mA (and it would be better to stay well below this maximum). You should use a higher value pull-down resistor (at least 250 Ohms, more would be better) or find out where the stray voltage is coming from (it could be an internal pull up on the AtMega, since pin 20 is also the SDA pin which Marlin might enable).

| improve this answer | |
$\endgroup$
  • $\begingroup$ But if it is due to the internal pull up, then voltage should show when measured directly from Mega(I mean with out shield). It only present when RAMPS shield is placed on top of Mega. With out shield voltage on pin is 0, with shield 2 V. No command is given , no power supply (12 V) given to RAMPS board. Only USB is connected on both cases $\endgroup$ – Athul Feb 2 '19 at 17:51

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.