Esempio n. 1
0
        public void SetPinData(PoKeysStepper stepper, byte pinID, byte pinFunction)
        {
            if ((owner == null) || (!owner.Connected))
            {
                return;
            }

            if (!owner.PokeysDevice.SetPinData((byte)(stepper.PinHomeSwitch - 1), pinFunction))
            {
                stepper.Error = string.Format(Translations.Main.DigitalInputErrorSetIOType, stepper.PinHomeSwitch);
                return;
            }

            owner.PokeysDevice.SaveConfiguration();

            pinFunction = 0;
            if (!owner.PokeysDevice.GetPinData((byte)(stepper.PinHomeSwitch - 1), ref pinFunction))
            {
                stepper.Error = Translations.Main.DigitalInputErrorGetIOType;
                return;
            }

            if (((pinFunction & 0x2) == 0) && ((pinFunction & 0x82) == 0))
            {
                stepper.Error = Translations.Main.DigitalInputErrorBadIOType;
                return;
            }
        }
Esempio n. 2
0
        internal void StartHomingSingle(PoKeysStepper stepper)
        {
            if (_isHoming)
            {
                return;
            }

            if (!stepper.StepperId.HasValue)
            {
                return;
            }

            if ((owner == null) || (!owner.Connected))
            {
                return;
            }

            int i = stepper.StepperId.GetValueOrDefault() - 1;

            _PEconfig.PulseEngineStateSetup = (byte)ePoKeysPEState.peSTOPPED;
            _PEconfig.PulseEngineStateSetup = (byte)ePoKeysPEState.peRUNNING;
            owner.PokeysDevice.PEv2_SetState(ref _PEconfig);

            stepper.Error = null;
            _PEconfig.ReferencePositionSpeed[i] = stepper.ForwardHomingSteps;
            if (!owner.PokeysDevice.PEv2_Move(ref _PEconfig))
            {
                stepper.Error = string.Format(Translations.Main.StepperMoveError, stepper.StepperId);
            }

            if (!string.IsNullOrEmpty(stepper.Error))
            {
                return;
            }

            Thread.Sleep(500);

            _PEconfig.MaxAcceleration[i]  = (float)(stepper.HomingMaxAcceleration / 1000000);
            _PEconfig.MaxDecceleration[i] = (float)(stepper.HomingMaxDecceleration / 1000000);
            _PEconfig.param1 = (byte)i;                                  // Set parameter param1 to the bit mask to indicate what have the above Axis Configs set
            owner.PokeysDevice.PEv2_SetAxisConfiguration(ref _PEconfig); // Configure the axis

            Thread.Sleep(500);

            _homingTimer          = new DispatcherTimer();
            _homingTimer.Tick    += _homingTimer_Tick;
            _homingTimer.Interval = _homingTimerInterval;

            _PEconfig.HomingStartMaskSetup = (byte)(1 << i);  // Select Axis for Homing
            _homingAxis    = i;
            _homingStepper = stepper.StepperId.GetValueOrDefault();

            owner.PokeysDevice.PEv2_StartHoming(ref _PEconfig);  // Initiate the HOMING

            _homingTimeoutTimer = new Stopwatch();
            _isHoming           = true;
            _homingTimeoutTimer.Start();
            _homingTimer.Start();
        }
Esempio n. 3
0
        private bool InitStepperAxis(PoKeysStepper stepper)
        {
            if ((owner == null) || (!owner.Connected))
            {
                return(false);
            }
            //
            // Now configure and Set Axis Configurations for all steppers
            //
            SetAxisParameters(stepper);

            return(true);
        }
Esempio n. 4
0
        private bool MoveInitialHoming(PoKeysStepper stepper, int stepperPos)
        {
            if ((owner == null) || (!owner.Connected))
            {
                return(false);
            }

            int stepperId = stepper.StepperId.GetValueOrDefault() - 1;

            try
            {
                _PEconfig.ReferencePositionSpeed[stepperId] = stepperPos;
                if (!owner.PokeysDevice.PEv2_Move(ref _PEconfig))
                {
                    stepper.Error = string.Format(Translations.Main.StepperMoveError, stepper.StepperId);
                    return(false);
                }

                return(true);
            }
            catch { return(false); }
        }
Esempio n. 5
0
        private void executeAddStepper(object o)
        {
            if (StepperList.Count == 0)
            {
                MessageBoxResult result = MessageBox.Show(
                    Translations.Main.EnablePulseEngineWarning,
                    Translations.Main.EnablePulseEngineWarningCaption,
                    MessageBoxButton.YesNo,
                    MessageBoxImage.Question);
                if (result != MessageBoxResult.Yes)
                {
                    return;
                }

                InitPulseEngine();
            }

            PoKeysStepper poStepper = new PoKeysStepper();

            poStepper.setOwner(this);
            StepperList.Add(poStepper);
            InitStepperAxis(poStepper);
            RaisePropertyChanged("StepperSlotsAvailable");
        }
Esempio n. 6
0
        internal void SetAxisParameters(PoKeysStepper stepper)
        {
            if ((!stepper.StepperId.HasValue) || (stepper.StepperId.GetValueOrDefault() <= 0))
            {
                return;
            }

            stepper.Error = null;

            int i = stepper.StepperId.GetValueOrDefault() - 1;

            _PEconfig.AxisEnabledInvertMask[i] = 1; // Use inverted axis enabled signal for PoStep drivers
            _PEconfig.AxesConfig[i]            = (int)(ePEv2_AxisConfig.aoENABLED |
                                                       ePEv2_AxisConfig.aoINTERNAL_PLANNER |
                                                       ePEv2_AxisConfig.aoPOSITION_MODE); // Use Position mode

            if (stepper.SoftLimitEnabled)
            {
                _PEconfig.AxesConfig[i] |= (int)ePEv2_AxisConfig.aoSOFT_LIMIT_ENABLED;
            }

            if (stepper.Inverted)
            {
                _PEconfig.AxesConfig[i] |= (int)ePEv2_AxisConfig.aoINVERTED;
            }

            if (stepper.HomeInverted)
            {
                _PEconfig.AxesConfig[i] |= (int)ePEv2_AxisConfig.aoINVERTED_HOME;
            }

            _PEconfig.AxesSwitchConfig[i] = 0;

            if (stepper.HasHomeSwitch)
            {
                _PEconfig.AxesSwitchConfig[i] |= (int)ePEv2_AxisSwitchOptions.aoSWITCH_HOME;
            }

            if (stepper.HomePinInverted)
            {
                _PEconfig.AxesSwitchConfig[i] |= (int)ePEv2_AxisSwitchOptions.aoSWITCH_INVERT_HOME;
            }

            if ((stepper.PinHomeSwitch > 0) && stepper.HasHomeSwitch)
            {
                byte pinFunction = 0;
//                if (stepper.HomePinInverted)
//                    pinFunction = 0x82;
//                else
                pinFunction = 0x2;
                SetPinData(stepper, (byte)stepper.PinHomeSwitch, pinFunction);
                _PEconfig.PinHomeSwitch[i] = (byte)(stepper.PinHomeSwitch);
            }

            _PEconfig.HomingSpeed[i]       = (byte)stepper.HomingSpeed;
            _PEconfig.HomingReturnSpeed[i] = (byte)stepper.HomingReturnSpeed;
            _PEconfig.MaxSpeed[i]          = (float)(stepper.MaxSpeed / 1000);
            _PEconfig.MaxAcceleration[i]   = (float)(stepper.MaxAcceleration / 1000000);
            _PEconfig.MaxDecceleration[i]  = (float)(stepper.MaxDecceleration / 1000000);
            _PEconfig.SoftLimitMaximum[i]  = stepper.SoftLimitMaximum;
            _PEconfig.SoftLimitMinimum[i]  = stepper.SoftLimitMinimum;
            _PEconfig.param1 = (byte)i; // Set parameter param1 to the bit mask to indicate what have the above Axis Configs set

            // Write (Set) above Axis Configuration
            //
            owner.PokeysDevice.PEv2_SetAxisConfiguration(ref _PEconfig); // Configure the axis
        }