Пример #1
0
        private bool HomeStepper()
        {
            PE.HomingStartMaskSetup = 0xFF;        // Home all Axis
            poKeysDevice.PEv2_StartHoming(ref PE); // Initiate the HOMING

            //
            // Wait for homing to complete...
            // - This is only for STOP style steppers.  We need to add code for 360 degree Sensor Steppers
            //
            if (!WaitHome(2000))
            {
                return(false);
            }

            poKeysDevice.PEv2_SetState(ref PE);

            //
            // Stop the Pulse Engine so we can set each axis (stepper) postion to zero since we are HOMED
            //
            PE.PulseEngineStateSetup = (byte)ePoKeysPEState.peSTOPPED;
            poKeysDevice.PEv2_SetState(ref PE);

            //
            // Set each stepper position to zero
            //
            for (int i = 0; i < 8; i++)
            {
                PE.param2          |= (byte)(1 << i);
                PE.PositionSetup[i] = 0;        // Set axis (stepper) position to Zero
                poKeysDevice.PEv2_SetPositions(ref PE);
            }

            //
            // Set Pulse Engine back to RUNNING
            PE.PulseEngineStateSetup = (byte)ePoKeysPEState.peRUNNING;
            poKeysDevice.PEv2_SetState(ref PE);

            //
            // Get Pulse Engine Statue and Check to confirm we are RUNNING
            poKeysDevice.PEv2_GetStatus(ref PE);
            StepperRunning = (PE.PulseEngineState == (byte)ePoKeysPEState.peRUNNING);

            PE.param2 = 0;
            PE.HomingStartMaskSetup = 0;
            return(true);
        }