Why am I not seeing an effect from an M42 command on Marlin?
I'm trying to use one of the RAMPS GPIOs to control an external device that requires a 5V low-current logic level signal from Marlin. In order to do this programmatically, my host software (Octoprint) is sending an M42 command. I am using the following syntax:
M42 P4 S255
according to the pinout in the following image:
However, the pin appears to not be driven to a logic HIGH level. Is there firmware-level configuration I need to do as well, or is my syntax/pin number incorrect?
@StarWind I'll follow up with the printer vendor regarding board source. There are no configuration elements specific to pins or GPIOs that I see in `Configuration.h` or `Configuration_adv.h`.
I'd try M42 P4 S0 just in case it's somehow inverted. If so, then and only then I'd worry about why.
Did Mark's answer help at all. If so, please could you mark it as accepted. If it didn;t and you have resolved your issue, could you post an answer and accept that, please. As a beta site we need to keep our unanswered question list to a minimum. Thanks
@Greenonline Unfortunately, the printer is no longer in my possession (I no longer work in that lab and am in a different city hours away altogether), and the issue was worked around by somebody else in a manner unknown to me. Mark's answer does seem sensible but I can't confirm that it works--shall I select it regardless?
Maybe not then, in that case. Thanks for the update. I'm not sure what to do in this situation... it seems like it will be forever uncertain whether it worked or not. Not to worry :-)
I looked at the current Marlin code and the P24 command should work as you expect it unless the pin you are trying to use in listed as the "SENSITIVE_PINS" list:
#define SENSITIVE_PINS { 0, 1, \
X_STEP_PIN, X_DIR_PIN, X_ENABLE_PIN, X_MIN_PIN, X_MAX_PIN, \
Y_STEP_PIN, Y_DIR_PIN, Y_ENABLE_PIN, Y_MIN_PIN, Y_MAX_PIN, \
Z_STEP_PIN, Z_DIR_PIN, Z_ENABLE_PIN, Z_MIN_PIN, Z_MAX_PIN, Z_MIN_PROBE_PIN, \
PS_ON_PIN, HEATER_BED_PIN, FAN_PIN, FAN1_PIN, FAN2_PIN, CONTROLLER_FAN_PIN, \
_E0_PINS _E1_PINS _E2_PINS _E3_PINS _E4_PINS BED_PINS \
_H0_PINS _H1_PINS _H2_PINS _H3_PINS _H4_PINS \
_X2_PINS _Y2_PINS _Z2_PINS \
X_MS1_PIN, X_MS2_PIN, Y_MS1_PIN, Y_MS2_PIN, Z_MS1_PIN, Z_MS2_PIN \
}These pins are printer specific; so, without access to your Marlin build, I can't see if pin 4 corresponds to one of these. If this is the problem, the command should be returning an error. If there is no error, I would look closely at the hardware.
Does this affect the ability to drive the GPIO? I don't need a 5V power supply, just a TTL signal.
I cannot say for sure. Tomorrow I will check on my board. If you want to check the working of `M42` using marlin, send 'M42 S255` since no pin number is given, by default `LED_PIN`(pin number 13, RAMPS LED is attached to this pin.) pin will turn ON. You can send `M42 P20 S255` and get gpio output from 20th pin (In your image I2C section pin 20 or 21). I have checked this. it works.
It's not a strong concern regardless; I haven't had access to the printer in question for a number of years now (since I graduated/moved), but I suspect that because the atmega2560 drives the pins from its internal supply, setting that jumper would power the fixed 5V pin but not affect the IO/signal pin.
May be that pin is already used by firmware for some other purpose like servos are enabled
License under CC-BY-SA with attribution
Content dated before 7/24/2021 11:53 AM
StarWind0 6 years ago
Post your firmware settings. Also verify your source for the board. If it is a cheap knockoff board...