Skip to content

Plunger Component Documentation

Path: src/Plunger.cpp

Revision History: Initial documentation

The Plunger component controls a motor-driven plunger mechanism through a Variable Frequency Drive (VFD). It manages various states including homing, plunging, filling operations, and post-flow sequences while allowing both manual and automatic operation modes.

  • VFD-controlled motor connected to plunger mechanism
  • Joystick peripheral for manual control
  • Modbus-485 communication interface
  • Multiple configurable speed settings
  • Operation timing parameters
  • Auto mode hold durations
  • Multiple operation modes:
    • Manual control via joystick
    • Auto mode via joystick hold
    • Replay of recorded plunge sequences
    • Filling sequence with configurable parameters
    • Post-flow sequence for pressure maintenance
  • State machine design with comprehensive state transitions
  • Jam detection and recovery
  • Modbus control interface
  • Configurable timings and speeds
  • Recording and replaying of plunge operations

Plunger

VFD

Joystick

Ticker

ModbusTCP

Arduino

The Plunger component operates as a state machine with the following states:

Joystick UP

Joystick DOWN

Joystick RIGHT + HOLD

Joystick RIGHT + BRIEF

HOLD > autoModeHoldDuration

Joystick release

HOLD > autoModeHoldDuration

Joystick release

Joystick non-center after release

Joystick non-center after release

Joystick non-RIGHT

Joystick non-CENTER

Plunge completed, post-flow disabled

Joystick UP

Joystick non-UP/non-CENTER

Joystick LEFT + HOLD

Plunge completed, post-flow enabled

Joystick non-CENTER after release

Joystick non-CENTER after release

Post-flow completed

IDLE

HOMING_MANUAL

PLUNGING_MANUAL

FILLING

Plunge completed

Plunged wait timeout

Home completed

Homed wait timeout

PLUNGING

PLUNGED

HOMING

HOMED

RECORD

REPLAY

HOMING_AUTO

STOPPING

PLUNGING_AUTO

POST_FLOW

Stopping wait timeout

Duration timeout

Complete wait timeout

POST_FLOW_STOPPING

POST_FLOW_STARTING

POST_FLOW_COMPLETE

JAMMED

RESETTING_JAM

Default state waiting for input

Detected overcurrent condition

Transitional state to IDLE

  • Consider optimizing timer usage to reduce RAM footprint
  • Evaluate performance impact of multiple state transitions during operation
  • Implement configurable acceleration/deceleration profiles for smoother operation
  • Assess VFD command frequency to prevent communication bottlenecks
  • Implement validation of Modbus command sources
  • Add access control to prevent unauthorized command execution
  • Consider adding confirmation requirements for critical operations
  • Log and alert on suspicious command patterns
  • Ensure compliance with relevant machine safety standards
  • Consider implementing additional safety interlocks
  • Document safety requirements and certifications
  • Follow applicable electrical code requirements for industrial equipment
  • Monitor VFD current to detect potential mechanical issues before jam events
  • Implement a maintenance log for plunger operations
  • Consider adding physical position sensing for more precise control
  • Develop UX guidelines for joystick operation to minimize user error
  • Create a calibration routine for optimal performance with different materials

The following example shows how to initialize and mount a Plunger component:

#ifdef PIN_PLUNGER_1_ENABLE
vfd_1 = new VFD(
this, // owner
PIN_PLUNGER_1_ENABLE, // enablePin
PIN_PLUNGER_1_FORWARD, // forwardPin
PIN_PLUNGER_1_COM, // communicationPin
PIN_PLUNGER_1_ALARM, // alarmPin
PLUNGER_1_ID_VFD // id
);
joystick_1 = new Joystick(
this, // owner
PIN_PLUNGER_1_JOYSTICK_X, // pinX
PIN_PLUNGER_1_JOYSTICK_Y, // pinY
PLUNGER_1_ID_JOYSTICK // id
);
if (vfd_1 && joystick_1)
{
plunger_1 = new Plunger(
this, // owner
vfd_1, // vfd
joystick_1, // joystick
PLUNGER_1_ID // id
);
// Configure plunger settings
plunger_1->settings.speedRampHz = PLUNGER_1_SPEED_RAMP_HZ;
plunger_1->settings.speedSlowHz = PLUNGER_1_SPEED_SLOW_HZ;
plunger_1->settings.speedMaxHz = PLUNGER_1_SPEED_MAX_HZ;
plunger_1->settings.autoModeHoldDurationMs = PLUNGER_1_AUTO_MODE_HOLD_DURATION_MS;
plunger_1->settings.defaultMaxOperationDurationMs = PLUNGER_1_MAX_OPERATION_DURATION_MS;
plunger_1->settings.enablePostFlow = PLUNGER_1_ENABLE_POST_FLOW;
// Add to components list
if (plunger_1) {
components.push_back(vfd_1);
components.push_back(joystick_1);
components.push_back(plunger_1);
Log.infoln(F("Plunger_1 initialized with VFD and Joystick"));
}
else {
Log.errorln(F("Plunger_1 initialization failed."));
}
}
else {
Log.errorln(F("VFD_1 or Joystick_1 initialization failed, cannot create Plunger_1."));
}
#endif