예제 #1
0
        private void TestLibrary()
        {
            IPwmManager manager = PwmManagerFactory.Instance;

            int[] controllers = manager.GetPwmControllers();

            if (controllers == null)
            {
                Log.Error(TAG, "Error getting controllers");
                return;
            }

            foreach (int controller in controllers)
            {
                Log.Info(TAG, "Found PWM controller " + controller);
            }

            int[] controllerchannels = manager.GetPwmChannels(1);

            Log.Info(TAG, "Controller 1 has " + controllerchannels.Length + " channels");

            IPwm pwm = manager.Open(1, 0);


            Log.Info(TAG, "pwm 1:0 is " + pwm.Enabled);

            pwm.FrequencyHz = 120;

            Log.Info(TAG, "pwm 1:0 frequency: " + pwm.FrequencyHz + " HZ");

            pwm.Enabled = true;

            Log.Info(TAG, "pwm 1:0 is " + pwm.Enabled);

            pwm.DutyCycle = 50;

            Log.Info(TAG, "pwm 1:0 duty cycle: " + pwm.DutyCycle + "%");

            pwm.Polarity = PwmPolarity.PolarityNormal;

            Log.Info(TAG, "pwm 1:0 polarity is " + pwm.Polarity);
        }
예제 #2
0
        public HBridgeMotor (IPwm pwm = null)
        {
            CalibrationInput = AddInput ("CalibrationInput", Units.Ratio, 1);
            SpeedInput = AddInput ("SpeedInput", Units.Ratio, 0);
            IsNeutralInput = AddInput ("IsNeutralInput", Units.Boolean, 0);

            A1Output = AddOutput ("A1Output", Units.Digital, 0);
            A2Output = AddOutput ("A2Output", Units.Digital, 0);

            PwmFrequencyOutput = AddOutput ("PwmFrequencyOutput", Units.Frequency, DefaultFrequency);
            PwmDutyCycleOutput = AddOutput ("PwmDutyCycleOutput", Units.Ratio, SpeedInput.Value);

            // This is a direct connection.
            SpeedInput.ValueChanged += (s, e) => Update ();
            IsNeutralInput.ValueChanged += (s, e) => Update ();

            if (pwm != null) {
                PwmFrequencyOutput.ConnectTo (pwm.FrequencyInput);
                PwmDutyCycleOutput.ConnectTo (pwm.DutyCycleInput);                
            }
        }
예제 #3
0
        public HBridgeMotor(IPwm pwm = null)
        {
            CalibrationInput = AddInput("CalibrationInput", Units.Ratio, 1);
            SpeedInput       = AddInput("SpeedInput", Units.Ratio, 0);
            IsNeutralInput   = AddInput("IsNeutralInput", Units.Boolean, 0);

            A1Output = AddOutput("A1Output", Units.Digital, 0);
            A2Output = AddOutput("A2Output", Units.Digital, 0);

            PwmFrequencyOutput = AddOutput("PwmFrequencyOutput", Units.Frequency, DefaultFrequency);
            PwmDutyCycleOutput = AddOutput("PwmDutyCycleOutput", Units.Ratio, SpeedInput.Value);

            // This is a direct connection.
            SpeedInput.ValueChanged     += (s, e) => Update();
            IsNeutralInput.ValueChanged += (s, e) => Update();

            if (pwm != null)
            {
                PwmFrequencyOutput.ConnectTo(pwm.FrequencyInput);
                PwmDutyCycleOutput.ConnectTo(pwm.DutyCycleInput);
            }
        }
예제 #4
0
 public ServoController(IPwm pwmPin)
 {
     Pin = pwmPin;
 }
예제 #5
0
 public ServoController(IPwm pwmPin)
 {
     Pin = pwmPin;
 }