-
Notifications
You must be signed in to change notification settings - Fork 88
MPG and DRO interfaces
Third party apps can interact with the controller in a number of different ways.
The keypad plugin translates single character commands to actions. It supports two interfaces, one via I2C and one via an UART channel.
See the plugin readme for supported command characters.
The I2C interface uses an active low strobe signal for telling the controller that a command character is available. There are two strobe modes, either a short pulse on each keypress or keeping the strobe signal low as long as a key is pressed. The latter is used for continuous jogging where the jog movement is canceled on key up.
When the app drives the strobe line low the controller will request the character from the I2C device with address 0x49
.
This mode is enabled by commenting in (by removing the leading //
characters)
#define KEYPAD_ENABLE 1
in my_machine.h.
Controller requirements:_
An I2C port and and a strobe input that should be interrupt capable. The strobe input should be pulled high by the controller.
NOTE: The app should use an open drain output for signalling, never drive the controller strobe pin actively high.
The UART interface accept the same command characters as the I2C interface with the addition of the jog cancel real-time command character 0x85
.
Important: To facilitate continuous jogging the jog cancel real-time command should be sent on every key up event.
This mode is enabled by commenting in (by removing the leading //
characters)
#define KEYPAD_ENABLE 1
in my_machine.h and changing it to
#define KEYPAD_ENABLE 2
Controller requirements:_
A free UART port (not USB). The UART port may be RX only if the main communication port can be "listened" to by the app by physically tapping its TX line.
The default connection parameters are 115200 baud, 1 start bit, no parity and 1 stop bit.
This uses an UART channel for sending gcode or system commands and may use the keypad plugin to handle single character commands when in passive mode. It may also use a control line for switching between passive and active mode.
In passive mode output from the controller is listened to, parsed, and typically used to update a display. This depends on an external sender continuously requesting real time reports.
To get started writing an app an event generating Grbl/grblHAL output parser written in C can be found here.
In active mode the app is in full control and act as a sender.
Mode switching is either by signalling via a dedicated input on the controller or via a real-time command character 0x8B
.
If via a dedicated input then the controller pin enabled as output and driven low while it starts up, when startup is completed the pin is switched to input with pullup enabled.
When the pin is driven low an app should wait for it to go high before attempting to claim control. When high the application can claim full control by pulling the pin low.
If a claim is successful a complete real-time report is sent including the element |MPG:1
, if not a normal status report is sent.
The app has to keep the line low as long as it want to be in control, when releasing control it should let the line go high. If denied control it should also let the line go high.
NOTE: The app should use an open drain output for signalling, never drive the controller pin actively high.
Mode switching via the 0x8B
real time command character requires the keypad plugin enabled in mode 2 and works pretty much the same as switching via a dedicated pin,
the only difference is that the app cannot reliably detect that the controller is up and running.
Ideally senders should disable its UI when an app is in full control, it can detect that by checking for the presence of a |MPG:1
real-time report element.
When control is released a |MPG:0
real-time report element is added. When a sender detects regular real-time reports on startup it can assume that an app is control and should postpone its startup until the app releases control.
This mode is enabled by commenting in (by removing the leading //
characters)
#define MPG_ENABLE 1
in my_machine.h. For mode switching via the 0x8B
real time command character
//#define KEYPAD_ENABLE 1
has to be uncommented and changed to
#define KEYPAD_ENABLE 2
Controller requirements:_
A free UART port (not USB) and, if pin based mode switching is used, a pin that can be changed between output and input with pullup. The pin should be interrupt capable.
The UART port may be RX only if the main communication port can be "listened" to by the app by physically tapping its TX line.
The default connection parameters are 115200 baud, 1 start bit, no parity and 1 stop bit.
NOTE: Currently only a few drivers and board maps support the full range of options. More may be added on request, or by pull requests, if the controller/board has the required resources available.
2022-02-14