Open zarfld opened 1 month ago
example usage provided by PoLabs can be found here https://bitbucket.org/mbosnak/pokeyslib/src/master/Examples/PulseEngine/PulseEngine.cpp
for developer description: publich inter face of PEv2 in pokeyslib is as follows: see https://bitbucket.org/mbosnak/pokeyslib/raw/c08da06747d56962640fdf03ff954c0675b1f563/PoKeysLib.h
// Pulse engine state
enum ePK_PEState
{
PK_PEState_peSTOPPED = 0, // Pulse engine is stopped
PK_PEState_peINTERNAL = 1, // PEv1: Internal motion controller is in use, PEv2: not used
PK_PEState_peBUFFER = 2, // PEv1: Buffered operation mode is in use, PEv2: not used
PK_PEState_peRUNNING = 3, // Pulse engine is activated
PK_PEState_peJOGGING = 10, // Jogging mode enabled
PK_PEState_peSTOPPING = 11, // Pulse engine is stopping
PK_PEState_peHOME = 20, // All axes are homed
PK_PEState_peHOMING = 21, // Axes homing is in progress
PK_PEState_pePROBECOMPLETE = 30, // All axes are homed
PK_PEState_pePROBE = 31, // Axes probing is in progress
PK_PEState_pePROBEERROR = 32, // Error occured during probing
PK_PEState_peHYBRIDPROBE_STOPPING = 40,
PK_PEState_peHYBRIDPROBE_COMPLETE = 41,
PK_PEState_peSTOP_LIMIT = 100, // Pulse engine stopped due to limit reached
PK_PEState_peSTOP_EMERGENCY = 101 // Pulse engine stopped due to emergency switch
};
// Pulse engine axis state
enum ePK_PEAxisState
{
PK_PEAxisState_axSTOPPED = 0, // Axis is stopped
PK_PEAxisState_axREADY = 1, // Axis ready
PK_PEAxisState_axRUNNING = 2, // Axis is running
PK_PEAxisState_axHOMING_RESETTING = 8, // Stopping the axis to reset the position counters
PK_PEAxisState_axHOMING_BACKING_OFF = 9, // Backing off switch
PK_PEAxisState_axHOME = 10, // Axis is homed
PK_PEAxisState_axHOMINGSTART = 11, // Homing procedure is starting on axis
PK_PEAxisState_axHOMINGSEARCH = 12, // Homing procedure first step - going to home
PK_PEAxisState_axHOMINGBACK = 13, // Homing procedure second step - slow homing
PK_PEAxisState_axPROBED = 14, // Probing completed for this axis
PK_PEAxisState_axPROBESTART = 15, // Probing procedure is starting on axis
PK_PEAxisState_axPROBESEARCH = 16, // Probing procedure - probing
PK_PEAxisState_axERROR = 20, // Axis error
PK_PEAxisState_axLIMIT = 30 // Axis limit tripped
};
enum ePK_PEv2_AxisConfig
{
PK_AC_ENABLED = (1 << 0), // Axis enabled
PK_AC_INVERTED = (1 << 1), // Axis inverted
PK_AC_INTERNAL_PLANNER = (1 << 2), // Axis uses internal motion planner
PK_AC_POSITION_MODE = (1 << 3), // Internal motion planner for this axis is in position mode
PK_AC_INVERTED_HOME = (1 << 4), // Axis homing direction is inverted
PK_AC_SOFT_LIMIT_ENABLED = (1 << 5), // Use soft-limits for this axis
PK_AC_FAST_OUTPUT = (1 << 6), // Fast output mode
PK_AC_ENABLED_MASKED = (1 << 7) // Use output enable pin masking
};
enum ePK_PEv2_AxisSwitchOptions
{
PK_ASO_SWITCH_LIMIT_N = (1 << 0), // Limit- switch
PK_ASO_SWITCH_LIMIT_P = (1 << 1), // Limit+ switch
PK_ASO_SWITCH_HOME = (1 << 2), // Home switch
PK_ASO_SWITCH_COMBINED_LN_H = (1 << 3), // Home switch is shared with Limit- switch
PK_ASO_SWITCH_COMBINED_LP_H = (1 << 4), // Home switch is shared with Limit+ switch
PK_ASO_SWITCH_INVERT_LIMIT_N = (1 << 5), // Invert limit- switch polarity
PK_ASO_SWITCH_INVERT_LIMIT_P = (1 << 6), // Invert limit+ switch polarity
PK_ASO_SWITCH_INVERT_HOME = (1 << 7) // Invert home switch polarity
};
enum ePK_PEv2_AxisSignalOptions
{
PK_ASO_INVERT_STEP = (1 << 0), // Invert step signal (active-low)
PK_ASO_INVERT_DIRECTION = (1 << 1) // Invert direction signal
};
// Pulse engine v2 information
typedef struct
{
uint8_t nrOfAxes;
uint8_t maxPulseFrequency;
uint8_t bufferDepth;
uint8_t slotTiming;
uint8_t reserved[4];
} sPoKeysPEv2info;
// Pulse engine v2 structure...
typedef struct
{
sPoKeysPEv2info info; // Pulse engine info
uint8_t AxesState[8]; // Axis states (bit-mapped) - see ePK_PEAxisState
uint8_t AxesConfig[8]; // Axis configuration - see ePK_PEv2_AxisConfig
uint8_t AxesSwitchConfig[8]; // Axis switch configuration - see ePK_PEv2_AxisSwitchOptions
int32_t CurrentPosition[8]; // Current position
int32_t PositionSetup[8]; // Position to be set as current position
int32_t ReferencePositionSpeed[8]; // Reference position or speed (position or pulses/s)
int8_t InvertAxisEnable[8]; // Invert axis enable signal
int32_t SoftLimitMaximum[8]; // Soft limit maximum position
int32_t SoftLimitMinimum[8]; // Soft limit minimum position
uint8_t HomingSpeed[8]; // Homing speed per axis (in %)
uint8_t HomingReturnSpeed[8]; // Homing return speed per axis (in % of the homing speed)
int32_t HomeOffsets[8]; // Home position offset
uint8_t HomingAlgorithm[8]; // Homing algorithm configuration
uint8_t FilterLimitMSwitch[8]; // Digital filter for limit- switch
uint8_t FilterLimitPSwitch[8]; // Digital filter for limit+ switch
uint8_t FilterHomeSwitch[8]; // Digital filter for home switch
int32_t ProbePosition[8]; // Position where probe detected change
int32_t ProbeMaxPosition[8]; // Maximum position to travel to until stopping and returning error
float MaxSpeed[8]; // Maximum axis speed (in pulses per ms)
float MaxAcceleration[8]; // Maximum axis acceleration (in pulses/ms/ms)
float MaxDecceleration[8]; // Maximum axis deceleration (in pulses/ms/ms)
int32_t MPGjogMultiplier[8]; // MPG jog multiplier value
uint8_t MPGjogEncoder[8]; // MPG jog encoder ID
uint8_t PinHomeSwitch[8]; // Home switch pin (0 for external dedicated input)
uint8_t PinLimitMSwitch[8]; // Limit- switch pin (0 for external dedicated input)
uint8_t PinLimitPSwitch[8]; // Limit+ switch pin (0 for external dedicated input)
uint8_t AxisEnableOutputPins[8]; // Axis enabled output pin (0 for external dedicated output)
uint32_t HomeBackOffDistance[8]; // Back-off distance after homing
uint16_t MPGjogDivider[8]; // Divider for the MPG jogging (enhanced encoder resolution)
uint8_t FilterProbeInput; // Filter for the probe input
uint8_t reserved[7]; // Motion buffer entries - moved further down...
uint8_t AxisSignalOptions[8]; // Axis signal options (invert step or direction)
float ReferenceVelocityPV[8]; // Reference velocity in PV mode (between 0.0 and 1.0) as ratio of max. speed
uint8_t ReservedSafety[8]; // 8-bytes reserved
// ------ 64-bit region boundary ------
uint8_t PulseEngineEnabled; // Pulse engine enabled status, also number of enabled axes
uint8_t PulseGeneratorType; // Pulse engine generator type (0: external, 1: internal 3ch)
uint8_t ChargePumpEnabled; // Charge pump output enabled
uint8_t EmergencySwitchPolarity; // Emergency switch polarity (set to 1 to invert)
uint8_t PulseEngineActivated; // Pulse engine activation status
uint8_t LimitStatusP; // Limit+ status (bit-mapped)
uint8_t LimitStatusN; // Limit- status (bit-mapped)
uint8_t HomeStatus; // Home status (bit-mapped)
uint8_t ErrorInputStatus; // Stepper motor driver error inputs status (bit-mapped)
uint8_t MiscInputStatus; // Miscelenous digital inputs...
uint8_t LimitOverride; // Limit override status
uint8_t LimitOverrideSetup; // Limit override configuration
// State of pulse engine - see ePoKeysPEState
uint8_t PulseEngineState;
uint8_t AxisEnabledMask; // Bit-mapped ouput enabled mask
uint8_t EmergencyInputPin;
uint8_t SyncFastOutputsAxisID; // Enable synced outputs and select pulse engine axis to map the data to (1-based)
uint8_t SyncFastOutputsMapping[8]; // Output mapping for the synced outputs
// ------ 64-bit region boundary ------
uint8_t param1; // Parameter 1 value
uint8_t param2;
uint8_t param3;
uint8_t AxisEnabledStatesMask; // Bit-mapped states, where axis enabled and charge pump signals are active
uint8_t PulseEngineStateSetup; // Pulse engine new state configuration
uint8_t SoftLimitStatus; // Bit-mapped soft-limit statuses per axes
uint8_t ExternalRelayOutputs; // External relay outputs
uint8_t ExternalOCOutputs; // External open-collector outputs
uint8_t PulseEngineBufferSize; // Buffer size information...
uint8_t motionBufferEntriesAccepted;
uint8_t newMotionBufferEntries;
uint8_t HomingStartMaskSetup; // Bit-mapped axes indexes to be homed
uint8_t ProbeStartMaskSetup; // Bit-mapped axis indexes for probing
uint8_t ProbeInput; // Probe input (0:disabled, 1-8:external inputs, 9+ Pin ID-9)
uint8_t ProbeInputPolarity; // Probe input polarity
uint8_t ProbeStatus; // Probe status (probe completion bit-mapped status)
// ------ 64-bit region boundary ------
uint8_t MotionBuffer[448]; // Motion buffer
// ------ 64-bit region boundary ------
float ProbeSpeed; // Probe speed (ratio of the maximum speed)
float reservedf;
uint32_t DebugValues[16];
uint16_t BacklashWidth[8]; // half of real backlash width
int16_t BacklashRegister[8]; // current value of the backlash register
uint8_t BacklashAcceleration[8]; // in pulses per ms^2
uint8_t BacklashCompensationEnabled;
uint8_t BacklashCompensationMaxSpeed;
uint8_t reserved_back[2];
uint8_t TriggerPreparing;
uint8_t TriggerPrepared;
uint8_t TriggerPending;
uint8_t TriggerActive;
int32_t SpindleSpeedEstimate;
int32_t SpindlePositionError;
uint32_t SpindleRPM;
uint32_t spindleIndexCounter;
uint8_t DedicatedLimitNInputs;
uint8_t DedicatedLimitPInputs;
uint8_t DedicatedHomeInputs;
uint8_t TriggerIngnoredAxisMask;
uint32_t EncoderIndexCount;
uint32_t EncoderTicksPerRotation;
uint32_t EncoderVelocity;
uint32_t reservedEnd;
uint8_t InternalDriverStepConfig[4];
uint8_t InternalDriverCurrentConfig[4];
} sPoKeysPEv2;
// Pulse engine v2 commands
// Get status of Pulse engine POKEYSDECL int32_t PK_PEv2_StatusGet(sPoKeysDevice device); // Get additional status data POKEYSDECL int32_t PK_PEv2_Status2Get(sPoKeysDevice device); // Configure (setup) the pulse engine POKEYSDECL int32_t PK_PEv2_PulseEngineSetup(sPoKeysDevice device); // Read additional parameters POKEYSDECL int32_t PK_PEv2_AdditionalParametersGet(sPoKeysDevice device); // Set additional parameters POKEYSDECL int32_t PK_PEv2_AdditionalParametersSet(sPoKeysDevice device); // Retrieve single axis parameters. Axis ID is in param1 POKEYSDECL int32_t PK_PEv2_AxisConfigurationGet(sPoKeysDevice device); // Set single axis parameters. Axis ID is in param1 POKEYSDECL int32_t PK_PEv2_AxisConfigurationSet(sPoKeysDevice device); // Set positions - param2 is used for bit-mapped axis selection POKEYSDECL int32_t PK_PEv2_PositionSet(sPoKeysDevice device); // Set pulse engine state POKEYSDECL int32_t PK_PEv2_PulseEngineStateSet(sPoKeysDevice device); // Execute the move. Position or speed is specified by the ReferencePositionSpeed POKEYSDECL int32_t PK_PEv2_PulseEngineMove(sPoKeysDevice device); // Execute the move in PV (position-velocity) mode. Position is specified by the ReferencePositionSpeed, relative velocity by ReferenceVelocityPV - requires FW 4.4.7 or newer POKEYSDECL int32_t PK_PEv2_PulseEngineMovePV(sPoKeysDevice device); // Read external outputs state - save them to ExternalRelayOutputs and ExternalOCOutputs POKEYSDECL int32_t PK_PEv2_ExternalOutputsGet(sPoKeysDevice device); // Set external outputs state (from ExternalRelayOutputs and ExternalOCOutputs) POKEYSDECL int32_t PK_PEv2_ExternalOutputsSet(sPoKeysDevice device); // Transfer motion buffer to device. The number of new entries (newMotionBufferEntries) must be specified // The number of accepted entries is saved to motionBufferEntriesAccepted. // In addition, pulse engine state is read (PEv2_GetStatus) POKEYSDECL int32_t PK_PEv2_BufferFill(sPoKeysDevice device); POKEYSDECL int32_t PK_PEv2_BufferFill_16(sPoKeysDevice device); POKEYSDECL int32_t PK_PEv2_BufferFillLarge(sPoKeysDevice device); POKEYSDECL int32_t PK_PEv2_BufferFillLarge_16(sPoKeysDevice device); // Clear motion buffer in device POKEYSDECL int32_t PK_PEv2_BufferClear(sPoKeysDevice device); // Reboot pulse engine v2 POKEYSDECL int32_t PK_PEv2_PulseEngineReboot(sPoKeysDevice device); // Start the homing procedure. Home offsets must be provided in the HomeOffsets // Axes to home are selected as bit-mapped HomingStartMaskSetup value POKEYSDECL int32_t PK_PEv2_HomingStart(sPoKeysDevice device); // Finish the homing procedure POKEYSDECL int32_t PK_PEv2_HomingFinish(sPoKeysDevice device); // Star the probing procedure. // ProbeMaxPosition defines the maximum position in position ticks where probing error will be thrown // ProbeSpeed defines the probing speed (1 = max speed) // ProbeInput defines the extenal input (values 1-8) or PoKeys pin (0-based Pin ID + 9) // ProbeInputPolarity defines the polarity of the probe signal POKEYSDECL int32_t PK_PEv2_ProbingStart(sPoKeysDevice device); POKEYSDECL int32_t PK_PEv2_ProbingHybridStart(sPoKeysDevice device); // Finish the probing procedure. Probe position and status are saved to ProbePosition and ProbeStatus POKEYSDECL int32_t PK_PEv2_ProbingFinish(sPoKeysDevice device); // Same as previous command, except for pulse engine states not being reset to 'STOPPED' POKEYSDECL int32_t PK_PEv2_ProbingFinishSimple(sPoKeysDevice device); POKEYSDECL int32_t PK_PEv2_SyncedPWMSetup(sPoKeysDevice device, uint8_t enabled, uint8_t srcAxis, uint8_t dstPWMChannel); POKEYSDECL int32_t PK_PEv2_SyncOutputsSetup(sPoKeysDevice * device);
// Get/Set internal motor drivers parameters POKEYSDECL int32_t PK_PEv2_InternalDriversConfigurationGet(sPoKeysDevice device); POKEYSDECL int32_t PK_PEv2_InternalDriversConfigurationSet(sPoKeysDevice device);
POKEYSDECL int32_t PK_PEv2_ThreadingPrepareForTrigger(sPoKeysDevice device); POKEYSDECL int32_t PK_PEv2_ThreadingForceTriggerReady(sPoKeysDevice device); POKEYSDECL int32_t PK_PEv2_ThreadingTrigger(sPoKeysDevice device); POKEYSDECL int32_t PK_PEv2_ThreadingRelease(sPoKeysDevice device); POKEYSDECL int32_t PK_PEv2_ThreadingStatusGet(sPoKeysDevice device); POKEYSDECL int32_t PK_PEv2_ThreadingCancel(sPoKeysDevice device); POKEYSDECL int32_t PK_PEv2_ThreadingSetup(sPoKeysDevice * device, uint8_t sensorMode, uint16_t ticksPerRevolution, uint16_t tagetSpindleRPM, uint16_t filterGainSpeed, uint16_t filterGainPosition);
POKEYSDECL int32_t PK_PEv2_BacklashCompensationSettings_Get(sPoKeysDevice device); POKEYSDECL int32_t PK_PEv2_BacklashCompensationSettings_Set(sPoKeysDevice device);
for usage and information on how these commands interact with pointers of struct please analyze https://bitbucket.org/mbosnak/pokeyslib/src/master/PoKeysLibPulseEngine_v2.c
ensure pokeys_py and pokeys_rt follow the definition below for halinterface of PEv2 and use the correct enumerations and commands to update and extract information for each axis
ensure that pins for required & enabled axes are created only
ensure that input pins are updated by the corresponding pointers in pokeyslib for outputs ensure that the pointers in pokeyslib are update based on corresponding pins
update documentation accordingly
PEv2 information
Pins
Parameters
PEv2 information - for each axis
Pins
Parameters
update developer description Here’s an analysis of the
PoKeysLibPulseEngine_v2.c
file, outlining the pointers used or updated in each function:1. *`PK_PEv2_StatusGet(sPoKeysDevice device)`**
device->PEv2.AxesState[]
(used/updated)device->PEv2.CurrentPosition[]
(used/updated)device->PEv2.ExternalRelayOutputs
(used/updated)device->PEv2.ExternalOCOutputs
(used/updated)device->PEv2.MotionBuffer[]
(used/updated)device->PEv2.ProbeStatus
(used/updated)device->PEv2.BacklashRegister[]
(used/updated)device->PEv2.TriggerActive
(used/updated)device->PEv2.SpindleSpeedEstimate
(used/updated)device->PEv2.SpindlePositionError
(used/updated)device->PEv2.EncoderIndexCount
(used/updated)device->PEv2.EncoderVelocity
(used/updated)2. *`PK_PEv2_PulseEngineSetup(sPoKeysDevice device)`**
device->PEv2.PulseEngineEnabled
(used/updated)device->PEv2.AxesSwitchConfig[]
(used)device->PEv2.SignalConfig[]
(used)device->PEv2.BacklashCompensationEnabled
(used)3. *`PK_PEv2_AxisConfigurationGet(sPoKeysDevice device)`**
device->PEv2.MaxSpeed[]
(used/updated)device->PEv2.MaxAcceleration[]
(used/updated)device->PEv2.MaxDecceleration[]
(used/updated)device->PEv2.HomingSpeed[]
(used/updated)device->PEv2.HomingReturnSpeed[]
(used/updated)device->PEv2.AxesSwitchConfig[]
(used/updated)device->PEv2.SignalConfig[]
(used/updated)device->PEv2.BacklashWidth[]
(used/updated)device->PEv2.BacklashAcceleration[]
(used/updated)4. *`PK_PEv2_AxisConfigurationSet(sPoKeysDevice device)`**
device->PEv2.MaxSpeed[]
(used)device->PEv2.MaxAcceleration[]
(used)device->PEv2.MaxDecceleration[]
(used)device->PEv2.HomingSpeed[]
(used)device->PEv2.HomingReturnSpeed[]
(used)device->PEv2.AxesSwitchConfig[]
(used)device->PEv2.SignalConfig[]
(used)device->PEv2.BacklashWidth[]
(used)device->PEv2.BacklashAcceleration[]
(used)device->PEv2.BacklashCompensationEnabled
(used)5. *`PK_PEv2_PositionSet(sPoKeysDevice device)`**
device->PEv2.CurrentPosition[]
(updated)6. *`PK_PEv2_PulseEngineStateSet(sPoKeysDevice device)`**
device->PEv2.PulseEngineState
(updated)7. *`PK_PEv2_PulseEngineMove(sPoKeysDevice device)`**
device->PEv2.ReferencePositionSpeed[]
(used/updated)8. *`PK_PEv2_PulseEngineMovePV(sPoKeysDevice device)`**
device->PEv2.ReferencePositionSpeed[]
(used/updated)device->PEv2.ReferenceVelocityPV[]
(used/updated)9. *`PK_PEv2_BufferFill(sPoKeysDevice device)`**
device->PEv2.MotionBuffer[]
(used/updated)device->PEv2.MotionBufferEntriesAccepted
(updated)10. *`PK_PEv2_BufferClear(sPoKeysDevice device)`**
device->PEv2.MotionBuffer[]
(cleared)11. *`PK_PEv2_HomingStart(sPoKeysDevice device)`**
device->PEv2.HomingStartMaskSetup
(used)device->PEv2.HomingOffsets[]
(used)12. *`PK_PEv2_HomingFinish(sPoKeysDevice device)`**
device->PEv2.PulseEngineState
(updated)13. *`PK_PEv2_ProbingStart(sPoKeysDevice device)`**
device->PEv2.ProbeInput
(used)device->PEv2.ProbeSpeed
(used)14. *`PK_PEv2_ProbingFinish(sPoKeysDevice device)`**
device->PEv2.ProbeStatus
(updated)15. *`PK_PEv2_BacklashCompensationSettings_Get(sPoKeysDevice device)`**
device->PEv2.BacklashWidth[]
(used/updated)device->PEv2.BacklashRegister[]
(used/updated)device->PEv2.BacklashAcceleration[]
(used/updated)device->PEv2.BacklashCompensationEnabled
(used/updated)16. *`PK_PEv2_BacklashCompensationSettings_Set(sPoKeysDevice device)`**
device->PEv2.BacklashWidth[]
(used)device->PEv2.BacklashAcceleration[]
(used)device->PEv2.BacklashCompensationEnabled
(used)17. *`PK_PEv2_SyncedPWMSetup(sPoKeysDevice device)`**
device->PEv2.PWMSetup[]
(used)Summary of Key Pointers:
Axis State and Motion:
device->PEv2.AxesState[]
device->PEv2.CurrentPosition[]
device->PEv2.ReferencePositionSpeed[]
device->PEv2.ReferenceVelocityPV[]
Homing and Limits:
device->PEv2.HomingStartMaskSetup
device->PEv2.AxesSwitchConfig[]
device->PEv2.SignalConfig[]
Backlash Compensation:
device->PEv2.BacklashWidth[]
device->PEv2.BacklashAcceleration[]
device->PEv2.BacklashCompensationEnabled
Probing:
device->PEv2.ProbeStatus
device->PEv2.ProbeSpeed
PWM Setup:
device->PEv2.PWMSetup[]
Here is a detailed list of the bitmapped fields in PoKeysLib.h (PEv2) that need to be split for each axis, along with their corresponding enumerations, values, and meanings:
1.
HomingStartMaskSetup
uint32_t
Bit Values:
Description: Controls which axes are starting the homing procedure. Each bit represents an axis (1 = homing started, 0 = not started).
2.
BacklashCompensationEnabled
uint8_t
Bit Values:
Description: Indicates whether backlash compensation is enabled for each axis.
3.
TriggerIngnoredAxisMask
uint8_t
Bit Values:
Description: Defines whether the trigger is ignored for each axis (1 = trigger ignored, 0 = trigger active).
4.
DedicatedLimitNInputs
andDedicatedLimitPInputs
uint8_t
Bit Values:
Description: Bitmapped fields for the limit switch inputs (negative limit for
DedicatedLimitNInputs
and positive limit forDedicatedLimitPInputs
).5.
SignalConfig[]
(Signal inversion flags)ePK_PEv2_AxisSignalOptions
Values:
PK_ASO_INVERT_STEP
=(1 << 0)
– Invert step signal (active-low)PK_ASO_INVERT_DIRECTION
=(1 << 1)
– Invert direction signalDescription: This field stores configuration flags that control signal inversion for each axis (step and direction signals).
6.
AxesSwitchConfig[]
(Switch configuration for each axis)ePK_PEv2_AxisSwitchOptions
Values:
PK_ASO_SWITCH_LIMIT_N
=(1 << 0)
– Limit- switchPK_ASO_SWITCH_LIMIT_P
=(1 << 1)
– Limit+ switchPK_ASO_SWITCH_HOME
=(1 << 2)
– Home switchPK_ASO_SWITCH_COMBINED_LN_H
=(1 << 3)
– Home switch is shared with Limit- switchPK_ASO_SWITCH_COMBINED_LP_H
=(1 << 4)
– Home switch is shared with Limit+ switchPK_ASO_SWITCH_INVERT_LIMIT_N
=(1 << 5)
– Invert limit- switch polarityPK_ASO_SWITCH_INVERT_LIMIT_P
=(1 << 6)
– Invert limit+ switch polarityPK_ASO_SWITCH_INVERT_HOME
=(1 << 7)
– Invert home switch polarityDescription: This field defines the switch configuration for each axis, with individual bits representing limit and home switches and their polarities.
7.
MotionBuffer[]
Bit Values: Axis-specific motion data is bit-mapped into this buffer.
Description: This buffer stores movement data for each axis. It needs to be split based on axis-specific motion commands and feedback.
8.
PWMSetup[]
(PWM output configuration)Values:
Description: Stores PWM output configurations, which can be synchronized with axes. Each channel is treated separately but might need to be mapped to individual axis parameters.
9.
ePK_PEv2_AxisConfig
(Axis configuration flags)ePK_PEv2_AxisConfig
Values:
PK_AC_ENABLED
=(1 << 0)
– Axis enabledPK_AC_INVERTED
=(1 << 1)
– Axis direction invertedPK_AC_INTERNAL_PLANNER
=(1 << 2)
– Internal motion planner enabledPK_AC_POSITION_MODE
=(1 << 3)
– Internal motion planner is in position modePK_AC_INVERTED_HOME
=(1 << 4)
– Homing direction invertedPK_AC_SOFT_LIMIT_ENABLED
=(1 << 5)
– Soft limits enabledPK_AC_FAST_OUTPUT
=(1 << 6)
– Fast output modePK_AC_ENABLED_MASKED
=(1 << 7)
– Output enable pin masking enabledDescription: These are flags that control axis configuration (enable/disable, inversion, motion planning mode, homing direction, etc.) for each axis.
Full List of Enumerations in PEv2 that Affect Axis Behavior
ePK_PEv2_AxisConfig
: Configuration flags for each axis (enable, inversion, position mode, etc.)ePK_PEv2_AxisSwitchOptions
: Switch options for each axis (limit and home switch configuration, inversion)ePK_PEv2_AxisSignalOptions
: Signal inversion options for each axis (step and direction inversion)Conclusion:
Many of these bitmapped fields need to be split into individual HAL pins or parameters to map each axis’s status, configuration, and behavior in LinuxCNC. This ensures that each axis operates independently, and its signals are correctly interpreted by the system. The enumeration-based fields provide a clear method for interpreting and configuring these bitmapped values.
Let's go through the key functions related to PoKeys PEv2 in pokeyslib and describe how the values should be updated from corresponding pointers in PoKeysLib to the LinuxCNC HAL pins. We'll use the pin names and usage as defined in the pokeys.comp file.
General Structure
For each PoKeys PEv2 function, we will:
Example Code for Updating PEv2-Related Pins in LinuxCNC
1. PK_PEv2_StatusGet: Retrieve the status of the pulse engine
This function retrieves the general status of the pulse engine, including the current position, axis states, and other general information. The relevant LinuxCNC HAL pins include position feedback (
joint.N.pos-fb
), axis state, and switch statuses.2. PK_PEv2_PulseEngineMove: Execute a move (either position or velocity-based)
This function executes a move by sending position or velocity commands to the PoKeys device. The LinuxCNC HAL pins that handle velocity and position commands should be updated accordingly.
3. PK_PEv2_AxisConfigurationGet: Retrieve axis configuration (limits, home switch, etc.)
This function retrieves the axis configuration, including the home switch, limit switches, and soft limits. The information is reflected in the HAL pins for limit switches, home switches, and soft limits.
4. PK_PEv2_HomingStart: Start the homing procedure
This function initiates the homing procedure for an axis. The homing switch pin (
joint.N.home-sw-in
) should be updated when homing is in progress or complete.5. PK_PEv2_ProbingStart: Start probing (used for Z-height detection, for example)
If probing is supported by PoKeys, this function initiates probing and updates the HAL pins related to probing (e.g.,
probe-in
).6. PK_PEv2_BacklashCompensationSettings_Get/Set: Manage backlash compensation
If backlash compensation is enabled, this function retrieves or sets the backlash compensation settings for each axis. The backlash-related HAL pins can be updated accordingly.
Summary of Pin-Function Mapping
PK_PEv2_StatusGet
joint.N.pos-fb
,joint.N.home-sw-in
,joint.N.limit-p-sw-in
,joint.N.limit-n-sw-in
,pev2.axis-state
PK_PEv2_PulseEngineMove
joint.N.vel-cmd
PK_PEv2_AxisConfigurationGet
joint.N.home-sw-in
,joint.N.limit-p-sw-in
,joint.N.limit-n-sw-in
,pev2.soft-limit
PK_PEv2_HomingStart
joint.N.home-sw-in
PK_PEv2_ProbingStart
probe-in
PK_PEv2_BacklashCompensationSettings_Get/Set
pev2.backlash-enable
,pev2.backlash-width
,pev2.backlash-accel
Key Points
This approach ensures seamless communication between the PoKeys device and the LinuxCNC HAL, while adhering to the PoKeysLib public interface.