-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
13 changed files
with
338 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
<Project Sdk="Microsoft.NET.Sdk"> | ||
<PropertyGroup> | ||
<OutputType>Exe</OutputType> | ||
<TargetFramework>net8.0</TargetFramework> | ||
<ImplicitUsings>enable</ImplicitUsings> | ||
<Nullable>enable</Nullable> | ||
<LangVersion>10.0</LangVersion> | ||
</PropertyGroup> | ||
|
||
<ItemGroup> | ||
<ProjectReference Include="..\..\..\..\Meadow.Foundation\Source\Meadow.Foundation.Peripherals\Sensors.Environmental.Keller.XLine\Driver\Sensors.Environmental.Keller.XLine.csproj" /> | ||
<ProjectReference Include="..\..\..\..\Meadow.Modbus\src\Meadow.Modbus\Meadow.Modbus.csproj" /> | ||
</ItemGroup> | ||
</Project> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
using Meadow.Foundation.Sensors.Environmental; | ||
using Meadow.Hardware; | ||
using Meadow.Modbus; | ||
|
||
namespace KellerXLine_Sample; | ||
|
||
internal class Program | ||
{ | ||
private static async Task Main(string[] _) | ||
{ | ||
await Test(); | ||
} | ||
|
||
private static async Task Test() | ||
{ | ||
|
||
var serialPort = "COM12"; | ||
|
||
using (var port = new SerialPortShim(serialPort, KellerTransducer.DefaultBaudRate, Parity.None, 8, StopBits.One)) | ||
{ | ||
port.ReadTimeout = TimeSpan.FromSeconds(15); | ||
port.Open(); | ||
|
||
var client = new ModbusRtuClient(port); | ||
var sensor = new KellerTransducer(client, KellerTransducer.DefaultModbusAddress); | ||
|
||
while (true) | ||
{ | ||
var pressure = await sensor.ReadPressure(PressureChannel.P1); | ||
Console.WriteLine($"Pressure: {pressure.Millibar} mbar"); | ||
|
||
await Task.Delay(1000); | ||
} | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
using Meadow.Foundation.MotorControllers.StepperOnline; | ||
using Meadow.Foundation.Motors.StepperOnline; | ||
using Meadow.Hardware; | ||
using Meadow.Modbus; | ||
|
||
namespace StepperMotor_Sample; | ||
|
||
internal class Program | ||
{ | ||
private static async Task Main(string[] _) | ||
{ | ||
var serialPort = "COM12"; | ||
byte controllerAddress = BLD510B.DefaultModbusAddress; | ||
|
||
using (var port = new SerialPortShim(serialPort, BLD510B.DefaultBaudRate, Parity.None, 8, StopBits.One)) | ||
{ | ||
port.ReadTimeout = TimeSpan.FromSeconds(15); | ||
port.Open(); | ||
|
||
var client = new ModbusRtuClient(port); | ||
var controller = new BLD510B(client); | ||
var motor = new F55B150_24GL_30S(controller); | ||
motor.SetSpeed(new Meadow.Units.AngularVelocity(500, Meadow.Units.AngularVelocity.UnitType.RevolutionsPerMinute)); | ||
|
||
while (true) | ||
{ | ||
await motor.RunFor(TimeSpan.FromSeconds(5), Meadow.Peripherals.RotationDirection.Clockwise); | ||
await motor.Stop(); | ||
await Task.Delay(1000); | ||
await motor.RunFor(TimeSpan.FromSeconds(5), Meadow.Peripherals.RotationDirection.CounterClockwise); | ||
await motor.Stop(); | ||
await Task.Delay(1000); | ||
} | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
<Project Sdk="Microsoft.NET.Sdk"> | ||
<PropertyGroup> | ||
<OutputType>Exe</OutputType> | ||
<TargetFramework>net8.0</TargetFramework> | ||
<ImplicitUsings>enable</ImplicitUsings> | ||
<Nullable>enable</Nullable> | ||
<LangVersion>10.0</LangVersion> | ||
</PropertyGroup> | ||
|
||
<ItemGroup> | ||
<ProjectReference Include="..\..\..\..\Meadow.Foundation\Source\Meadow.Foundation.Peripherals\Motors.StepperOnline\Driver\Motors.StepperOnline.csproj" /> | ||
<ProjectReference Include="..\..\..\..\Meadow.Modbus\src\Meadow.Modbus\Meadow.Modbus.csproj" /> | ||
</ItemGroup> | ||
</Project> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
<Project Sdk="Meadow.Sdk/1.1.0"> | ||
<PropertyGroup> | ||
<TargetFramework>netstandard2.1</TargetFramework> | ||
<CopyLocalLockFileAssemblies>true</CopyLocalLockFileAssemblies> | ||
<OutputType>Library</OutputType> | ||
<AssemblyName>App</AssemblyName> | ||
<LangVersion>10.0</LangVersion> | ||
</PropertyGroup> | ||
|
||
<ItemGroup> | ||
<ProjectReference Include="..\..\..\..\Meadow.Foundation\Source\Meadow.Foundation.Peripherals\Sensors.Environmental.Keller.XLine\Driver\Sensors.Environmental.Keller.XLine.csproj" /> | ||
<ProjectReference Include="..\..\..\..\Meadow.ProjectLab\Source\Meadow.ProjectLab\Meadow.ProjectLab.csproj" /> | ||
<ProjectReference Include="..\..\..\..\Meadow.Modbus\src\Meadow.Modbus\Meadow.Modbus.csproj" /> | ||
</ItemGroup> | ||
|
||
<ItemGroup> | ||
<None Update="app.build.yaml"> | ||
<CopyToOutputDirectory>Always</CopyToOutputDirectory> | ||
</None> | ||
<None Update="app.config.yaml"> | ||
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory> | ||
</None> | ||
</ItemGroup> | ||
</Project> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
using Meadow; | ||
using Meadow.Devices; | ||
using Meadow.Foundation.Sensors.Environmental; | ||
using System; | ||
using System.Threading.Tasks; | ||
|
||
namespace KellerXLine_Sample; | ||
|
||
// Change ProjectLabCoreComputeApp to ProjectLabFeatherApp for ProjectLab v2 | ||
public class MeadowApp : ProjectLabCoreComputeApp | ||
{ | ||
private IKellerTransducer sensor; | ||
|
||
public override Task Initialize() | ||
{ | ||
Resolver.Log.Info("Initialize..."); | ||
|
||
Resolver.Log.Info($"Running on ProjectLab Hardware {Hardware.RevisionString}"); | ||
|
||
var client = Hardware.GetModbusRtuClient(KellerTransducer.DefaultBaudRate); | ||
sensor = new KellerTransducer(client, KellerTransducer.DefaultModbusAddress); | ||
|
||
return base.Initialize(); | ||
} | ||
|
||
public override async Task Run() | ||
{ | ||
while (true) | ||
{ | ||
try | ||
{ | ||
var pressure = await sensor.ReadPressure(PressureChannel.P1); | ||
Resolver.Log.Info($"Pressure: {pressure.Millibar} mbar"); | ||
} | ||
catch (Exception ex) | ||
{ | ||
Resolver.Log.Info($"Error: {ex.Message}"); | ||
} | ||
|
||
await Task.Delay(1000); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
Deploy: | ||
NoLink: [ ProjectLab ] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
# Uncomment additional options as needed. | ||
# To learn more about these config options, including custom application configuration settings, check out the Application Settings Configuration documentation. | ||
# http://developer.wildernesslabs.co/Meadow/Meadow.OS/Configuration/Application_Settings_Configuration/ | ||
|
||
# App lifecycle configuration. | ||
Lifecycle: | ||
|
||
# Control whether Meadow will restart when an unhandled app exception occurs. Combine with Lifecycle > AppFailureRestartDelaySeconds to control restart timing. | ||
RestartOnAppFailure: false | ||
|
||
# When app set to restart automatically on app failure, | ||
AppFailureRestartDelaySeconds: 15 | ||
|
||
# Logging configuration. | ||
Logging: | ||
|
||
# Adjust the level of logging detail. | ||
LogLevel: | ||
|
||
# Trace, Debug, Information, Warning, or Error | ||
Default: Trace |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
using Meadow; | ||
using Meadow.Devices; | ||
using Meadow.Foundation.MotorControllers.StepperOnline; | ||
using Meadow.Foundation.Motors.StepperOnline; | ||
using System; | ||
using System.Threading.Tasks; | ||
|
||
namespace StepperMotor_Sample; | ||
|
||
// Change ProjectLabCoreComputeApp to ProjectLabFeatherApp for ProjectLab v2 | ||
public class MeadowApp : ProjectLabCoreComputeApp | ||
{ | ||
private F55B150_24GL_30S motor; | ||
|
||
public override Task Initialize() | ||
{ | ||
Resolver.Log.Info("Initialize..."); | ||
|
||
Resolver.Log.Info($"Running on ProjectLab Hardware {Hardware.RevisionString}"); | ||
|
||
var client = Hardware.GetModbusRtuClient(BLD510B.DefaultBaudRate); | ||
var controller = new BLD510B(client, BLD510B.DefaultModbusAddress); | ||
motor = new F55B150_24GL_30S(controller); | ||
motor.SetSpeed(new Meadow.Units.AngularVelocity(500, Meadow.Units.AngularVelocity.UnitType.RevolutionsPerMinute)); | ||
|
||
return base.Initialize(); | ||
} | ||
|
||
public override async Task Run() | ||
{ | ||
while (true) | ||
{ | ||
await motor.RunFor(TimeSpan.FromSeconds(5), Meadow.Peripherals.RotationDirection.Clockwise); | ||
await motor.Stop(); | ||
await Task.Delay(1000); | ||
await motor.RunFor(TimeSpan.FromSeconds(5), Meadow.Peripherals.RotationDirection.CounterClockwise); | ||
await motor.Stop(); | ||
await Task.Delay(1000); | ||
} | ||
} | ||
} |
24 changes: 24 additions & 0 deletions
24
Source/ProjectLab/ModbusStepperMotor/ModbusStepperMotor_Sample.csproj
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
<Project Sdk="Meadow.Sdk/1.1.0"> | ||
<PropertyGroup> | ||
<TargetFramework>netstandard2.1</TargetFramework> | ||
<CopyLocalLockFileAssemblies>true</CopyLocalLockFileAssemblies> | ||
<OutputType>Library</OutputType> | ||
<AssemblyName>App</AssemblyName> | ||
<LangVersion>10.0</LangVersion> | ||
</PropertyGroup> | ||
|
||
<ItemGroup> | ||
<ProjectReference Include="..\..\..\..\Meadow.ProjectLab\Source\Meadow.ProjectLab\Meadow.ProjectLab.csproj" /> | ||
<ProjectReference Include="..\..\..\..\Meadow.Foundation\Source\Meadow.Foundation.Peripherals\Motors.StepperOnline\Driver\Motors.StepperOnline.csproj" /> | ||
<ProjectReference Include="..\..\..\..\Meadow.Modbus\src\Meadow.Modbus\Meadow.Modbus.csproj" /> | ||
</ItemGroup> | ||
|
||
<ItemGroup> | ||
<None Update="app.build.yaml"> | ||
<CopyToOutputDirectory>Always</CopyToOutputDirectory> | ||
</None> | ||
<None Update="app.config.yaml"> | ||
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory> | ||
</None> | ||
</ItemGroup> | ||
</Project> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
Deploy: | ||
NoLink: [ ProjectLab, Motors.StepperOnline ] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
# Uncomment additional options as needed. | ||
# To learn more about these config options, including custom application configuration settings, check out the Application Settings Configuration documentation. | ||
# http://developer.wildernesslabs.co/Meadow/Meadow.OS/Configuration/Application_Settings_Configuration/ | ||
|
||
# App lifecycle configuration. | ||
Lifecycle: | ||
|
||
# Control whether Meadow will restart when an unhandled app exception occurs. Combine with Lifecycle > AppFailureRestartDelaySeconds to control restart timing. | ||
RestartOnAppFailure: false | ||
|
||
# When app set to restart automatically on app failure, | ||
AppFailureRestartDelaySeconds: 15 | ||
|
||
# Logging configuration. | ||
Logging: | ||
|
||
# Adjust the level of logging detail. | ||
LogLevel: | ||
|
||
# Trace, Debug, Information, Warning, or Error | ||
Default: Trace |