Adding relay to the router

I know this topic has come up before and my head is starting to hurt from reading…

I am using a mini-rambo board.

I currently have the board in an enclosure. I’ve added start Gcode that sends a M106 P0 command at the start of a print to turn on the fans on the enclosure.

I’d like to take advantage of the M3 command to turn on a relay and start the spindle/router.

Can someone point me in the right direction for this? I’m assuming there’s something I’d have to do in Marlin to fix this. The mini-rambo has a second fan port I’m assuming I could use to implement this.

It is easier if you are just concerned with on/off. If you search for “arduino relay” on amazon, you’ll find a lot of choices that can be triggered by 5V. You need one with a big rating on the VAC. Alternatively, the IOT Relay on amazon has nice plugs, and takes almost any input to turn it on/off. It looks like it is “currently unavailable” though…

In the software, it’s already set to pin 18:

That looks like it’s used for the LCD though, so unless you have that turned off, I think we need to change it.

https://www.reprap.org/wiki/File:MiniRambo1.3a-connections.png

There is a P3 expansion port, with nothing on it.

https://www.reprap.org/mediawiki/images/e/ef/MiniRambo1.3a-schematic-pg2.svg

The third pin on P3 is arduino pin 13, if I’m reading this right, so that might be a good candidate. I do not know if any of the P3 pins are PWM capable, but if you’re hoping to speed control or dimming control, then we might have to look a little harder to find a good candidate.

1 Like

I’m really only looking to do on/off. This is just to power the dewalt 660 on/off as needed. I’m using CNC.js, so every time I run the machine right now I have to hit resume on both cnc.js and on the LCD.

Oh… and I am using the LCD. Not sure why at this point. I do all my work from CNC.js.

Thanks for pointing me in that direction. If I get some time, I’ll try compiling the firmware and installing it. I don’t think I left an easy way to get a USB cable into the controller box I designed. Hindsight :roll_eyes: I’ll hook up the multimeter and run a test job to see if it goes high.

I figured pretty much any relay should work. I think all of mine are only 5 amp, though.

I wouldn’t mess with any of those pins unless you disable the LCD in the firmware. You wouldn’t want to be milling, and having Marlin decide it wants to adjust the LCD brightness and turn off your spindle, or power cycle the relay at 8kHz. I think if you turn off the LCD, the pause acts differently and only need cncjs to resume, but I’m not 100%.

You should be able to use that other fan port too, with M106 P1 S255. But it also might be configured to do something else in your current firmware, like a case fan which comes on when the motors are enabled, or an extruder fan that comes on when the hot end temp is over 50C.

Since you have a pi attached to the USB, you can install the firmware updater plugin in Marlin, and then install avrdude through ssh. You can then use arduino to compile a .hex file, and then use octoprint to flash the .hex onto the rambo. It is a bit of a pain to set up, but the really nice thing is, you can save that .hex file and use it again if you want to revert, or have more than one configuration. Plus, you don’t have to unplug anything…

For that matter, I can install avrdude onto the pi and just run the command manually to flash the hex. I don’t have Octoprint on this Pi. Just cnc.js.

I like the idea of using the P3 pin and I’ll try to go down that route.

1 Like

I bought this:

Solid state relay

Says it works on as low as 3V, will have to test it out, someone mentioned current draw might be an issue. Not sure if I want to use the mini rambo and have m3 involved or just a button on the raspberry pi. My plan is to control an entire power bar at once.

Cheers!

I’m using a similar one to that as a relay for my dust collector controlled by a pi zero.

You might want to get a good heatsink for it.

Open Builds has it for sale: https://openbuildspartstore.com/iot-switching-relay-power-strip/

1 Like

Saw that a while ago, neat, but too big for me, also $15 with free amazon shipping vs $4x + who knows shipping in $cdn. :slight_smile:

Heatsink, maybe, it’s rated 20A and I have a 10A fuse at the switch so as long as it’s less than 10A shouldn’t heat up that much.

Cheers!

1 Like

I like that one because it is so self contained. No AC wires exposed.

You mean you can’t 3d print a case :smile:

I know myself too well. I wire it up in a hacky way, just to “make sure it works” and then when it works, I don’t go back and make it safe.

2 Likes

You really need to work on your OCD.

1 Like

Don’t forget SSRs fail closed(on).

So, I wired up the ss relay to my power bar (tapped the existing switch), I tossed 5V on the inputs, it turned on a usb charger I had plugged into it, and the signal drew hardly any current, maybe 10 mA. Just need to find some free pins on the mini rambo to set m3/m5, (I will be using the LCD). Safety wise, it is screwed in under the table with some electrical tape around the recessed AC poles.

Cheers!

EDIT:

This looks like a safe candidate (lowrider 2, mini-rambo context)

#define Z_MIN_PIN 10

to

#define Z_MIN_PIN -1 // 10

and

#define SPINDLE_LASER_PWM_PIN 9 // Hardware PWM
#define SPINDLE_LASER_ENA_PIN 18 // Pullup!
#define SPINDLE_DIR_PIN 19

to

#define SPINDLE_LASER_ENA_PIN 10 //18

My only question would be what where the values doing as they are, leftovers or something functional? Shouldn’t they be -1 if the LCD is plugged in perhaps in a #else?

EDIT2:

I couldn’t get that to work, probably have to enable spindles / lasers or something, I do have it working with m106 /m107, fan1.

EDIT3:

Got it to work with M3 / M5 by simply using the FAN1 and mapping that to be the spindle enable pin. It’s two pin already, no 5V nearby, easy to access, and non critical.

configuration_adv.h

#define SPINDLE_FEATURE
//#define LASER_FEATURE
#if EITHER(SPINDLE_FEATURE, LASER_FEATURE)
#define SPINDLE_LASER_ACTIVE_HIGH true // Set to “true” if the on/off function is active HIGH
#define SPINDLE_LASER_PWM false // Set to “true” if your controller supports setting the speed/power
#define SPINDLE_LASER_PWM_INVERT false // Set to “true” if the speed/power goes up when you want it to go slower

//#define SPINDLE_LASER_FREQUENCY 2500 // (Hz) Spindle/laser frequency (only on supported HALs: AVR and LPC)

There is a bug IMO where the check is done against SPINDLE_LASER_FREQUENCY and not SPINDLE_LASER_PWM, so un-defining this is required.

/**

  • Speed / Power can be set (‘M3 S’) and displayed in terms of:
    • PWM (S0 - S255)
    • PERCENT (S0 - S100)
    • RPM (S0 - S50000) Best for use with a spindle
      */
      #define CUTTER_POWER_DISPLAY RPM

Meaningless, for completeness.

pins_minirambo.h

#ifndef FAN_PIN
#define FAN_PIN -1 // 8
#endif
#define FAN1_PIN 6

//
// M3/M4/M5 - Spindle/Laser Control
//
// use P1 connector for spindle pins
#define SPINDLE_LASER_PWM_PIN -1 //9 // Hardware PWM
#define SPINDLE_LASER_ENA_PIN 8 // 18 // Pullup!
#define SPINDLE_DIR_PIN -1 //19

I had to go out of my way to avoid pwm, so the same kind change can work for speed control. I tested it against m106 and m107 and nothing happened, so good to go.

1 Like