private static string UID = "XXYYZZ"; // Change XXYYZZ to the UID of your DC Brick #endregion Fields #region Methods static void Main() { IPConnection ipcon = new IPConnection(); // Create IP connection BrickDC dc = new BrickDC(UID, ipcon); // Create device object ipcon.Connect(HOST, PORT); // Connect to brickd // Don't use device before ipcon is connected dc.SetDriveMode(BrickDC.DRIVE_MODE_DRIVE_COAST); dc.SetPWMFrequency(10000); // Use PWM frequency of 10kHz dc.SetAcceleration(5000); // Slow acceleration dc.SetVelocity(32767); // Full speed forward dc.Enable(); // Enable motor power Console.WriteLine("Press enter to exit"); Console.ReadLine(); dc.Disable(); // Disable motor power ipcon.Disconnect(); }
private static string UID = "XYZ"; // Change to your UID static void Main() { IPConnection ipcon = new IPConnection(); // Create IP connection BrickDC dc = new BrickDC(UID, ipcon); // Create device object ipcon.Connect(HOST, PORT); // Connect to brickd // Don't use device before ipcon is connected dc.SetPWMFrequency(10000); // Use PWM frequency of 10kHz dc.SetDriveMode(1); // Use 1 = Drive/Coast instead of 0 = Drive/Brake dc.Enable(); dc.SetAcceleration(5000); // Slow acceleration dc.SetVelocity(32767); // Full speed forward System.Console.WriteLine("Press enter to exit"); System.Console.ReadLine(); dc.Disable(); ipcon.Disconnect(); }
private static string UID = "XYZ"; // Change to your UID #endregion Fields #region Methods static void Main() { IPConnection ipcon = new IPConnection(); // Create IP connection BrickDC dc = new BrickDC(UID, ipcon); // Create device object ipcon.Connect(HOST, PORT); // Connect to brickd // Don't use device before ipcon is connected dc.SetPWMFrequency(10000); // Use PWM frequency of 10kHz dc.SetDriveMode(1); // Use 1 = Drive/Coast instead of 0 = Drive/Brake dc.Enable(); dc.SetAcceleration(5000); // Slow acceleration dc.SetVelocity(32767); // Full speed forward System.Console.WriteLine("Press enter to exit"); System.Console.ReadLine(); dc.Disable(); ipcon.Disconnect(); }
static void Main() { IPConnection ipcon = new IPConnection(); // Create IP connection BrickDC dc = new BrickDC(UID, ipcon); // Create device object ipcon.Connect(HOST, PORT); // Connect to brickd // Don't use device before ipcon is connected // Register "velocity reached callback" to ReachedCB // ReachedCB will be called every time a velocity set with // SetVelocity is reached dc.VelocityReached += ReachedCB; dc.Enable(); // The acceleration has to be smaller or equal to the maximum acceleration // of the DC motor, otherwise ReachedCB will be called too early dc.SetAcceleration(5000); // Slow acceleration dc.SetVelocity(32767); // Full speed forward System.Console.WriteLine("Press enter to exit"); System.Console.ReadLine(); dc.Disable(); ipcon.Disconnect(); }
private static string UID = "XYZ"; // Change to your UID #endregion Fields #region Methods static void Main() { IPConnection ipcon = new IPConnection(); // Create IP connection BrickDC dc = new BrickDC(UID, ipcon); // Create device object ipcon.Connect(HOST, PORT); // Connect to brickd // Don't use device before ipcon is connected // Register "velocity reached callback" to ReachedCB // ReachedCB will be called every time a velocity set with // SetVelocity is reached dc.VelocityReached += ReachedCB; dc.Enable(); // The acceleration has to be smaller or equal to the maximum acceleration // of the DC motor, otherwise ReachedCB will be called too early dc.SetAcceleration(5000); // Slow acceleration dc.SetVelocity(32767); // Full speed forward System.Console.WriteLine("Press enter to exit"); System.Console.ReadLine(); dc.Disable(); ipcon.Disconnect(); }