Wednesday, January 3, 2018

Using Vectornav VN-200 in Visual Studio .NET



1. First determine the connection parameters for connecting to the VN-100 sensor. You will need to know the following information. 
- COM Port 
- COM Baud Rate (factory default of sensor is 115200)

2. Open Microsoft Visual Studio and create a new project by going to the menu File → New → Project.... Select the Visual C# project template of Console Application and name the project VisualStudioUsage. 

3.Browse to the location C:/Program Files/VectorNav .NET Library (or C:/Program Files (x86)/VectorNav .NET Library if you are on a 64-bit machine) and copy the files VectorNav.dll and VectorNav.xml into the directory where you saved your new Visual Studio project. Then add a reference to the assembly by right-clicking on the project icon in Visual Studio and from the context menu, select Add Reference.... The window Add Reference should now be displayed. Select the Browse tab and then browse and select the VectorNav.dll that you copied into your project folder. 

4. Under the project VisualStudioUsage, open the file Program.cs. You will now need to add a using VectorNav.Devices; statement to make the library's classes easily accessible. Your code should now look like the snippet below. 




5. Now we will add code statements to connect to the sensor, read data values from the sensor and display them on the screen for 10 seconds, and then disconnect from the sensor. The code to perform these steps are listed below and should be what the file Program.cs looks like.


6. Now to run the code, click the Play icon on the Visual Studio toolbar, or go to the menu Debug → Start Debugging. You should now see a console window pop-up and start displaying YawPitchRoll data from the sensor.

No comments:

Post a Comment