MaslowCNC / Firmware

Maslow Firmware
GNU General Public License v3.0
261 stars 136 forks source link

Add support for configuring spindle control signal high/low. #436

Closed CptanPanic closed 6 years ago

CptanPanic commented 6 years ago

Currently I am setting up my spindle control logic to connect to a super-pid spindle controller. It uses an active low to trigger it, and I notice in code that there is almost support to have option to have active low or high but it is hardcoded to be boolean activeHigh = true; Enhancement would be to add ability to pull this value from sysSettings , and a '$' command to set it.

Thanks.

BarbourSmith commented 6 years ago

I support this!

CptanPanic commented 6 years ago

I am going to make this and submit a PR.

blurfl commented 6 years ago

Instead of adding another setting, how about changing the existing setting for 'Spindle Automation' to a pick list with ['None', ''Relay - Active High', 'Relay - Active Low', 'Servo Operated Switch'] and implementing the logic in Spindle.cpp for all those options. That way non-spindlers won't have to wait for a function they don't have... Also, make 'none' the default. Also, don't configure the gpio as an output until an M-code that actually turns the spindle on is executed. This will aid to prevent turning on the spindle on Arduino reset. Any other precautions to prevent inadvertent activation would be a very good idea. Make it safe.

CptanPanic commented 6 years ago

Yeah that sounds good

blurfl commented 6 years ago

Make 'none' the default. Don't configure the gpio as an output until an M-code that actually turns the spindle on is executed. This will aid to prevent turning on the spindle on Arduino reset. Any other precautions to prevent inadvertent activation would be a very good idea. Make it safe.

davidelang commented 6 years ago

On Mon, 23 Apr 2018, Scott Smith wrote:

Instead of adding another setting, how about changing the existing setting for 'Spindle Automation' to a pick list with ['None', ''Relay - Active High', 'Relay - Active Low', 'Servo Operated Switch'] and implementing the logic in Spindle.cpp for all those options. That way non-spindlers won't have to wait for a function they don't have...

add warnings for what happens when the arduno looses power or reboots, if that's going to cause the router to start spinning, people should know before they set it to do so.

blurfl commented 6 years ago
what happens when the arduno looses power or reboots, if that's
going to cause the router to start spinning

Unfortunately, I don't think we can't know that. There are many ways to use a gpio pin to cause a change in an external circuit. Few people consider failure modes when lashing up a control like this.

davidelang commented 6 years ago

On Wed, 25 Apr 2018, Scott Smith wrote:

what happens when the arduno looses power or reboots, if that's
going to cause the router to start spinning

Unfortunately, I don't think we can't know that. There are many ways to use a gpio pin to cause a change in an external circuit. Few people consider failure modes when lashing up a control like this.

But we aren't needing to figure out all the ways to use a GPIO pin, we just need to look at the arduino.

when it powers off, the pin will go low, if low causes the motor to spin, that's a hazard

when the arduino boots, does the pin go low while it's initializing? if so, that would cause the motor to spin (again a hazard)

if the pin goes high as the arduino boots, then the motor control circuit needs to be smarter, because a simple gpio controlled relay isn't safe in either mode.

So what happens to the pin as the arduino boots?

CptanPanic commented 6 years ago

Since pin isn't written to until M3 is sent, it seems that the internal resistor is activated by default on boot so the active low isn't triggered, at least for my device.