Пример #1
0
        /// <summary>
        /// Create an instance of the ULN2003 driver (currently only supports 28BYJ step motor)
        /// </summary>
        public ULN2003(int IN1pin, int IN2pin, int IN3pin, int IN4pin, ULN2003Enums motorType = ULN2003Enums.STEP_28BYJ)
        {
            if (motorType == ULN2003Enums.Other)
            {
                IsSupported = false;
            }
            else
            {
                var gpio = GpioController.GetDefault();
                if (gpio != null)
                {
                    IN1 = gpio.OpenPin(IN1pin);
                    IN2 = gpio.OpenPin(IN2pin);
                    IN3 = gpio.OpenPin(IN3pin);
                    IN4 = gpio.OpenPin(IN4pin);

                    IN1.SetDriveMode(GpioPinDriveMode.Output);
                    IN2.SetDriveMode(GpioPinDriveMode.Output);
                    IN3.SetDriveMode(GpioPinDriveMode.Output);
                    IN4.SetDriveMode(GpioPinDriveMode.Output);

                    SetGPIOWrite(0, 0, 0, 0);

                    SetStepSequences(motorType);

                    SafeBreakMe = new SafeBreak();
                    SafeBreakMe.PropertyChanged += SafeBreakMe_PropertyChanged;

                    IsInitialized = true;
                }
            }
        }
Пример #2
0
 private void SetStepSequences(ULN2003Enums motorType)
 {
     if (motorType == ULN2003Enums.STEP_28BYJ)
     {
         // Each sequence is a step for the step motor
         Step_Seqs = new List <int[]>()
         {
             new int[] { 1, 0, 0, 0 },
             new int[] { 1, 1, 0, 0 },
             new int[] { 0, 1, 0, 0 },
             new int[] { 0, 1, 1, 0 },
             new int[] { 0, 0, 1, 0 },
             new int[] { 0, 0, 1, 1 },
             new int[] { 0, 0, 0, 1 },
             new int[] { 1, 0, 0, 1 }
         };
     }
 }
Пример #3
0
 private void SetStepSequences(ULN2003Enums motorType)
 {
     if (motorType == ULN2003Enums.STEP_28BYJ)
     {
         // Each sequence is a step for the step motor
         Step_Seqs = new List <bool[]>()
         {
             new bool[] { true, false, false, false },
             new bool[] { true, true, false, false },
             new bool[] { false, true, false, false },
             new bool[] { false, true, true, false },
             new bool[] { false, false, true, false },
             new bool[] { false, false, true, true },
             new bool[] { false, false, false, true },
             new bool[] { true, false, false, true }
         };
     }
 }
Пример #4
0
        /// <summary>
        /// Create an instance of the ULN2003 driver (currently only supports 28BYJ step motor)
        /// </summary>
        public ULN2003(IOPi bus, byte pin1, byte pin2, byte pin3, byte pin4, ULN2003Enums motorType = ULN2003Enums.STEP_28BYJ)
        {
            if (motorType == ULN2003Enums.Other)
            {
                IsSupported = false;
            }
            else
            {
                Bus    = bus;
                IN1pin = pin1;
                IN2pin = pin2;
                IN3pin = pin3;
                IN4pin = pin4;
                Bus.SetPinDirection(IN1pin, false);
                Bus.SetPinDirection(IN2pin, false);
                Bus.SetPinDirection(IN3pin, false);
                Bus.SetPinDirection(IN4pin, false);
                //IN1 = gpio.OpenPin(IN1pin);
                //IN2 = gpio.OpenPin(IN2pin);
                //IN3 = gpio.OpenPin(IN3pin);
                //IN4 = gpio.OpenPin(IN4pin);

                //IN1.SetDriveMode(GpioPinDriveMode.Output);
                //IN2.SetDriveMode(GpioPinDriveMode.Output);
                //IN3.SetDriveMode(GpioPinDriveMode.Output);
                //IN4.SetDriveMode(GpioPinDriveMode.Output);

                SetGPIOWrite(false, false, false, false);

                SetStepSequences(motorType);

                SafeBreakMe = new SafeBreak();
                SafeBreakMe.PropertyChanged += SafeBreakMe_PropertyChanged;

                IsInitialized = true;
            }
        }