Tool Enable - M15 - IOT Relay - & Breakout board (auto turn off/on router)

I modified my IOT relay when I first got it so that the one outlet that is NORMALLY ON but switches off when control voltage is applied is now an ALWAYS ON outlet.

1 Like

Okay that’s sketchy. I don’t think I’ll be using the PWM spindle (tool enable). If you happen to click on either Z zero or the XY zero in the jog commands area to the upper left of the screen it for some reason enables the tool which would turn on your router.

That is dangerous, went out to my machine and jogged all around and didn’t have that. Then I tested the M3S1 via the MDI to make sure it would turn on and it did. Just went out again to power it down and jogged and the router did turn on. Wonder if somehow the MDI is getting replayed as I sent a M5 command to shut it down and then jogged again and it didn’t happen. I use the controller mostly, only using the touch screen to probe xyz/z and start the job, probably why I haven’t seen it sooner.

2 Likes

Just did another simple test and that seems to be what is happening. If you previously sent a M3S1 command through the MDI and used the stop button instead of sending a M5 to stop the router, subsequent jogging seems to be replaying the M3S1 starting the router. Far from an exhaustive test but seems to be what is happening. @OnefinityCNC, if this is the case, this is one for the bug list to be resolved quickly as it could cause injury. @MindOfMcClure, this might be a solution to your issue as well.

1 Like

I’ll give that a shot tomorrow. To your point though… That should be a top priority to fix, when I hit the jog it’s fortunate that I did not have the wrench on my router yet. Someone’s I do job the machine a little closer went I’m in the middle is a bit change.

Won’t be doing that until it’s fixed. I’m still waiting on controller #3, so it’s the screen buttons or bust until I get that 3rd and hopefully last one.

Thanks,
-Alex

There are two aspects to controlling an external relay highlighted in this excellent thread. I will break them down separately below.

Electrical Connections/PWM Settings

The tool output (PWM spindle) can be used to control an external relay with a few caveats:

  • The output will provide a PWM waveform with a duty cycle set by the M3SXXX command.
  • The duty cycle of the output is controlled by the XXX number in the M3SXXX command and the “Min/Max Spin” settings under the “Tool” settings. For example, if we assume the following:

Min Spin = 0 RPM
Max Spin = 255 RPM
PWM Min Duty = 1%
PWM Max Duty = 99.99%
PWM Frequency = 1000Hz

This means that M3S127 will set the output signal to a 50% duty cycle (127/255 = 0.5). The output signal will have a 1kHz frequency and it will be high (3.3V) for 0.5ms and low (0V) for 0.5ms.

If we send M3S1 we are asking for a 1/255 = 0.4% duty cycle. Since this is below the PWM Min Duty setting, the controller will output a 1% duty cycle and we will get a 1kHz signal that his high for 0.01ms and low for 0.99ms.

  • The PWM signal cannot be reliably measured with a multimeter, especially at high frequencies. A multimeter will read close to 0V for low duty cycles and close to 3.3V for high duty cycles but it will not give an accurate reading in between because of its relatively low sampling rates. If you have access to an oscilloscope, that is the best way to view/check PWM signals.
  • For anyone reading this thread in the future, as noted above, the PWM output can only supply a few milliamps of current at 3.3V so it cannot be used to directly drive a relay coil. In this case, the IoT device has internal logic and circuitry to drive the relay.
  • The IoT relay probably has some high impedance input circuitry that feeds the logic circuitry which controls the SPDT relay inside the unit. I would be a bit concerned with feeding it a PWM signal instead of a straight DC signal as it could lead to a situation where the relay is being switched on and off at high frequency. This may not be observable in a highly inductive load like a spindle or vacuum motor but it would wear out the relay in fairly short order.
  • All that being said, the load 1 and 2 outputs should also work to control the relay. The Amazon listing says it will take control voltages up to 48VDC. The 36VDC load outputs should do the trick as they are straight DC output but please confirm the input voltage rating with the manufacturer first!

MDI/Jog Interaction

I was able to duplicate the same behavior with the spindle turning on when executing a jog from the UI after issuing an M3 command in the MDI command window:

  • Sending the M3S1 command from the MDI window activates the PWM signal which would turn on the relay (and the attached spindle).
  • Hitting the “stop” button will stop executing any active gcode and turn off the outputs but it does not change the machine state. i.e. The PWM output is still commanded to be in the “on” state with respect to the machine state.
  • The jog button saves the machine state using the M70 (Save Modal State) command before executing an incremental move and then restoring the machine state with M72 (Restore Modal State). When this happens the spindle output in the “on” state is saved because it was never switched off in the machine state with the M5 commands. The M72 command restores the saved state, including the spindle in the “on” state.

All that being said, this sequence of events can cause the spindle to come on while jogging if no M5 command is ever issued. Since it is a potential safety issue, we will modify the jog commands to drop the save/restore modal state in the next software release.

Hope that helps! Let me know if you need any additional info.

14 Likes

Thank you very much James, this is a great overview of what is happening at the code level of the machine.

Until the new update is sent I’ll go back to manual control to be safe.

One Question, when you say “next software release” do you mean the next Firmware update from OF?? OR will there be some other update we need to be on the lookout for?

-Alex

It will be the 1.0.5 release from OneFinity.

3 Likes

Excellent write up! When I modified the post processor I used M3[S], which then uses the speed set in the tool database, which doesn’t do anything to the router itself, but will ensure the full voltage is sent to the relay. I might look at wiring to L1/L2 at some point in the future to simplify the setup.

Regards,
Barry

1 Like

Thanks Barry, let me know when you get around to it as I’d love to swap mine over to the L1/L2 as well. As well as when 1.0.5 is updated.

-Alex

2 Likes

@CruversWorkshop: That is a good point. As long as you are using the tool enable output and not the tool PWM output, it should work like a charm.

2 Likes

If the unit is an electronic relay, it might not trigger without a crossing zero on mains (but it depends on the specific design). Some designs will not trigger without a load (e.g., something drawing current).

0.02

1 Like

I take it you are the software engineer for Onefinity. Yeah I was talking to Mark about this safety issue. Awesome to see this change being made. Will there be any changes “we, the user” should make in the settings for “PWM spindle” to ensure at least a constant 3.2~3.3v PWM signal to the IOT relay for reliability?

Yeah using the tool enable would definitely be something I’d be more interested in by having that constant dc voltage which is what…24-36vdc?

The tool enable output (pin 15) is probably the best bet for controlling a relay versus the tool PWM output (pin 17). They both output 3.3V logic levels: 0V for low and ~3.3V for high. The main difference is that the tool PWM output will always be a PWM signal even if it is set to 100% duty cycle; it will still have a short 0V pulse every cycle in the order of a few hundred nanoseconds. This is an artifact of the way the timer module on the ATxmega microcontroller functions.

The good news is that the tool enable, which most people will use to control an external relay, is a straight logic output and should give you a straight 3.3V or 0V output without any glitching.

9 Likes

@Stewie21 - if you are referring to me, nope. But maybe someday when I come to my senses. :wink:

-Tom

1 Like

Lol, no I was referring to James. :joy:

1 Like

In your PDF instructions you specify that the relay should be switching the white neutral lead. Could you please explain the logic of that choice? Normally the black hot lead is the one that is switched in 120VAC circuits for safety.

It really doesn’t matter honestly in a 120v circuit. That black hot leg can’t do anything without that neutral path back to the panel. So you can break either the hot or the neutral and it’ll work either way.

You are correct that the device will not work if the neutral is switched. However, switching the neutral will leave the device connected to 120 volts. There will be 120V between the black wire and the ground wire at the router. The same is not true if you switch the black wire. There will be no voltage between the neutral and the ground. That is why you should switch the black, or load, not the neutral wire.

There is also no problem switching both the black and the white wire, if you have the correct type of relay.

4 Likes