Shows how to use the nanoFramework WebServer and the System.Device.Pwm to test your servo motors.
This sample is using an ESP32 connected in WiFi but it can work with any other device that does support PWM and networking. You will have to adjust the Ethernet connection instead of WiFi and adjust the PWM initialization and also remove the non needed nugets.
You will also need a servo motor as the core idea is to test the servo motor!
Important
You have to make sure that the servo motor has a proper power of 5V. The driver pin can be used directly from the device.
Please also make sure you adjust your WiFi credentials and the GPIO pin used for the servo motor.
Just connect to the IP Address of your device with a browser. You will have the following experience:
You can update any single element individually. The minimum and maximum pulses are in micro seconds. You can find them in the documentation of the servo motor. If you don't know or want to find out the limits of your servo motor, you can adjust individually. The position goes from 0 to 100 and it's the position from the minimum pulse (Position = 0) to the maximum pulse (Position = 100).
The result of the adjusted element(s) and the associated PWM Duty Cycle is displayed.
- nanoFramework WebServer
- System.Device.Pwm
- This is a modern implementation of this almost 10 years old .NET Microframework implementation.
- Start Microsoft Visual Studio 2022 or Visual Studio 2019 (Visual Studio 2017 should be OK too) and select
File > Open > Project/Solution
. - Starting in the folder where you unzipped the samples/cloned the repository, go to the subfolder for this specific sample. Double-click the Visual Studio Solution (.sln) file.
- Press
Ctrl+Shift+B
, or selectBuild > Build Solution
.
The next steps depend on whether you just want to deploy the sample or you want to both deploy and run it.
- Select
Build > Deploy Solution
.
- To debug the sample and then run it, press F5 or select
Debug > Start Debugging
.
Note
Important: Before deploying or running the sample, please make sure your device is visible in the Device Explorer.
Tip: To display the Device Explorer, go to Visual Studio menus: View > Other Windows > Device Explorer
.