CNC Router Build #7 - Panel Buttons and Spindle Control Wiring

Connection and configuation of panel buttons and wiring the inverter to the control board.

The Video

View this video on Youtube.

Spindle Control

The MB2 breakout board has a relay which is used to switch the spindle on and off. This is connected to the inverter with two wires to the FOR and common terminal. It is possible to add a second set of wiring for operating the spindle in reverse, however this is not installed as this machine only runs in one direction.

The panel buttons have two parts. The switches are momentary and each one is wired to a separate input.
The button LEDs are connected to outputs, so that they will turn on/off in response to the contoller, and not just the fact that a button has been pressed.

Button Code

For the buttons to work, some program code must be added to both the Signal script and the Screen Load script. Both scripts are accessed from the 'screen editor' within Mach4.

Code for Signal Script

if (SigLib[sig] ~= nil) then
	SigLib[sig](state)
end

This code runs when any signal changes state, and refers to the SigLib table in the screen load script.

Code for Screen Load Script

SigLib = {
	[mc.ISIG_INPUT16] = function (state)
	if (state == 1) then
		CycleStart()
	end
end,
}

The SigLib table contains the inputs and associated commands for each button. This example is for the Cycle Start button which is wired to input 16. When the state of input 16 changes to 1 (i.e. the button is pressed), the command CycleStart() runs.

For other buttons the code is identical, just change the 16 to the appropriate input number, and 'CycleStart()' to the command required when the button is pressed.

This code or a very similar example should already exist in the scripts, typically commented out with -- at the start of each line.

 

wx