Skip to content

Software mainController

Pascal Roobrouck edited this page Aug 22, 2019 · 1 revision

The mainController is the state machine that has the top-level control :

  • it receives all the inputs.
  • it controls all the other subsystems.

Inputs:

  • it contains an object HostInterface, as a connection to the host computer (the device controlling the CNC or similar)
  • it contains an array of ButtonSwitch objects, which are all limit switches and input buttons

SubSystems:

  • it contains an object gCode to which it delegates gCode parsing
  • it contains an object SDcard to which it delegates storage of settings, gcode, logs and other files

Outputs:

  • it contains an object Motion to which it delegates the calculation and execution of the motion

StateMachine

For versatility and robustness, the mainController is programmed as a Finite State Machine (FSM) (https://en.wikipedia.org/wiki/Finite-state_machine). This means it has a number of possible states, and each event can change the state and/or trigger a certain output. The state of the machine is stored in 'mainState'. In order to simplify things, homing and probing have their own sub-state-machine : homingState, probingState.

Processing Inputs

The inputs from the hostInterface are serviced by polling/calling MainController::handleMessages()

All events which occur in other threads, are being pushed onto an event queue theEventBuffer The inputs from buttons and switches are serviced by polling/calling MainController::handleEvents()

All events which occur in other threads, are being pushed onto an event queue theEventBuffer

Clone this wiki locally