m42 PWM backwards?

I have a mech. relay hooked up to P4 which in turn is used to power on/off the spindle and vacuum. My gcode to turn it on is M42 P4 S0 and M42 P4 S255 to turn it off. It works great but the problem is that I want to use that same pin for a 2.5W laser (replace spindle/vacuum). Problem is that Image2gcode has a power setting for min/max (0/255). Would my current setup (S0=on/S255=off) be an issue or is there a way I can change it?

S0 is off, no current, so no relay activation, S255 is full power=relay activation. That is how the laser power supply should see it as well 255 = full power, 0=off.

Does that make sense? The relay is what is reversing the logic not the board, right?

That’s what I’m trying to figure out. When I power on my machine it sits idle with the motors disengaged and the spindle relay off (not active). It’s not until I send my gcode:

program start:

G90
M03 S
M106 //fan on
M42 P4 S0 //relay for spindle on

program end:

M05
M107 //fan off
M42 P4 S255 //relay for spindle off

 

If the board defines S0 as off then the pin P4 would not see a signal thus the relay would not get a signal and should remain inactive. As you can see from my gcode, when the board first executes command S0 it doesn’t shut off a signal but rather it sends a signal to the relay which activates it. Make sense or am I missing something?

Your relay may be driven with inverted logic.

That doesn’t mean the laser will be inverted.

You aren’t planning on running image2gcode against your mechanical relay are you? That will destroy it.

No I’m removing the relay to use that Ramps pin as my laser signal. I’ll try it out… what’s the worst that could happen?

Fire. But that’s unlikely :slight_smile: