Hello,
My ongoing RPI based project needs some help. Since 2015 my robot has been running on RPI2 and Maestro Servo Controller via Windows 10 IoT Core based program written in C#. I have recently upgraded to RPI 3, Visual Studio 2019 and the latest IoT Core build. As a result the servo control has stopped working. Last week I purchased a brand new Maestro - identical to my original - but that didn’t help. Here is what I have:
Visual Studio 2019, version 16.6.4
Windows 10 SDK (10.0.19041.0)
.NET Core 2.2 Runtime
Target - Windows 10, version 1809
Raspberry Pi 3 Model B
Windows 10 IoT Core, build #17763 - the latest official build installed via Windows 10 IoT Core Dashboard
Maestro 6 Channel Micro controller
Maestro Firmware version 1.04
6 Volt Rechargeable NiMH Battery
What works:
- Servo is running fine from the Maestro Control Center, serial mode: dual port or fixed baud rate
- My UWP app sample code below is driving servo as expected when running from the desktop with Maestro plugged into its USB
- On the RPI 3, another USB serial device - RoboClaw motor controller - is still working flawlessly
What doesn’t work:
- When deployed to RPI on ARM platform the below code is running fine but fails to rotate the servo.
- The green light blinks as if a command has been received but nothing happens, no rotation.
I am testing by setting a breakpoint at the maestroSetTarget, and on desktop the servo rotates while on RPI it does not. No exceptions are being thrown. The controller behaves as if it doesn’t recognize the command.
From the app manifest:
<Capabilities>
<Capability Name="internetClient" />
<DeviceCapability Name="serialcommunication">
<Device Id="any">
<Function Type="name:serialPort" />
</Device>
</DeviceCapability>
<DeviceCapability Name="lowLevel"/>
</Capabilities>
Am I missing a setting somewhere?
Is there a known issue with the 17763 build that might affect some serial devices?
Pololu - have you tested the Maestro 6 with RPI running 17763?
Any help would be highly appreciated
Thanks
Victor
public sealed partial class MainPage : Page
{
Windows.Storage.Streams.DataWriter dataWriter = null;
SerialDevice serialDevice = null;
public MainPage()
{
this.InitializeComponent();
Task t = Task.Factory.StartNew(() => TestMaestro());
Task.WaitAll(t);
}
public async Task TestMaestro()
{
var selector = SerialDevice.GetDeviceSelector();
DeviceInformationCollection devices = await DeviceInformation.FindAllAsync(selector);
var deviceInfo = devices.Where(p => p.Name.IndexOf("Maestro", StringComparison.OrdinalIgnoreCase) >= 0).Last();
serialDevice = await SerialDevice.FromIdAsync(deviceInfo.Id);
serialDevice.BaudRate = 9600;
serialDevice.DataBits = 8;
serialDevice.Parity = SerialParity.None;
serialDevice.StopBits = SerialStopBitCount.One;
serialDevice.Handshake = SerialHandshake.None;
dataWriter = new Windows.Storage.Streams.DataWriter(serialDevice.OutputStream);
dataWriter.UnicodeEncoding = Windows.Storage.Streams.UnicodeEncoding.Utf8;
await maestroSetTarget(dataWriter, 0, 20);
await maestroSetTarget(dataWriter, 0, 70);
}
public async Task maestroSetTarget(Windows.Storage.Streams.DataWriter dataWriter, byte channel, int target)
{
byte[] command = new byte[] { 0xAA, 0x0C, 0x04, channel, 0x70, (byte)target };
dataWriter.WriteBytes(command);
await dataWriter.StoreAsync();
}
}