Automating PicoVNA 106 in C#

Post your .Net discussions here
Post Reply
jephilli
Newbie
Posts: 0
Joined: Tue May 15, 2018 7:25 pm

Automating PicoVNA 106 in C#

Post by jephilli » Tue May 15, 2018 7:40 pm

Hi,

I'm trying to automate some testing with the PicoVNA 106. I'm installed the software from the thumb drive that came with the VNA. I can control VNA from Pico's software and I'm trying to use the DLL to control the VNA from a C# application.

I've successfully loaded the DLL and I can find the SN of the VNA using the FND() command. Following the flowchart on page 4 of the programmer's guide, I tried using SelectKit() and the other commands to initialize the VNA, but I kept on getting a "Path not found" error.

- What path is the SelectKit() method looking for? And how do I set that path from my C# app?

I tried doing a workaround by using the PicoVNA2 to calibrate the VNA, save that calibration to a file, and then use the LoadCal() method in my C# application to apply the cal file to the VNA. I was able to get it to work successfully once or twice, moved onto developing another part of the application, but now it's not working anymore. The LoadCal() method is just returning "Error."

- Why can I load a cal file into the PicoVNA2 that Pico supplies, but get an error when I try to use the LoadCal() method in my C# app?

Thanks for the help!

-James

Martyn
Site Admin
Site Admin
Posts: 3371
Joined: Fri Jun 10, 2011 8:15 am
Location: St. Neots

Re: Automating PicoVNA 106 in C#

Post by Martyn » Wed May 16, 2018 5:55 am

Have you tried our C# example from GitHub

If that doesn't help then please email your code to support@picotech.com and we can take a look for you.
Martyn
Technical Support Manager

jephilli
Newbie
Posts: 0
Joined: Tue May 15, 2018 7:25 pm

Re: Automating PicoVNA 106 in C#

Post by jephilli » Fri May 18, 2018 5:29 pm

Yes, I can load the example from Github and everything works fine. That's why I'm asking what the differences are.

I noticed that in your Github example, your project has an Interop.PicoControl2 reference that my project doesn't have. I was under the impression that all I needed to do was reference the PicoControl2.dll and I would up and running.

Sorry if that's a dumb question. I'm a hardware engineer trying to code this application and don't have a lot of experience with higher level software languages.

-James

jephilli
Newbie
Posts: 0
Joined: Tue May 15, 2018 7:25 pm

Re: Automating PicoVNA 106 in C#

Post by jephilli » Fri May 18, 2018 9:23 pm

Yeah, I've tried the example code in github and it works just fine. But when I try using the DLL in my own application, I get "Error" as the response whenever trying to apply a calibration file - which was created with the PicoVNA2 software. And I can apply the same calibration file with your example code.

I sent an e-mail to the address you mentioned with my code and the calibration file. It's probably something really simple.

Thanks!

Martyn
Site Admin
Site Admin
Posts: 3371
Joined: Fri Jun 10, 2011 8:15 am
Location: St. Neots

Re: Automating PicoVNA 106 in C#

Post by Martyn » Sat May 19, 2018 6:14 am

Can we see your code ?

Otherwise trying merging your code into our base example.
Martyn
Technical Support Manager

jephilli
Newbie
Posts: 0
Joined: Tue May 15, 2018 7:25 pm

Re: Automating PicoVNA 106 in C#

Post by jephilli » Mon May 21, 2018 4:09 pm

I just tried merging some of my functions in your example code. I removed all your buttons and data plots in order to add the interfaces needed for my application. I called the exact same functions in the same way with the samer variables that you were calling in your button click events and I still got an "Error" response when selecting a calibration file.

Martyn
Site Admin
Site Admin
Posts: 3371
Joined: Fri Jun 10, 2011 8:15 am
Location: St. Neots

Re: Automating PicoVNA 106 in C#

Post by Martyn » Tue May 22, 2018 6:25 am

I can't see an email on the system, did you get a ticket number SUPPORT-xxxx issued in a return email ?

If not then it may have been blocked, particularly if there were dll or exe files in the attachments, so can you try just sending the code.
Martyn
Technical Support Manager

jephilli
Newbie
Posts: 0
Joined: Tue May 15, 2018 7:25 pm

Re: Automating PicoVNA 106 in C#

Post by jephilli » Tue May 22, 2018 3:17 pm

No I didn't see a return e-mail. I attached a zip file. I would have thought that would make it through.

I sent another e-mail to the support e-mail address with just a .cs file - if that's what you mean by "just the code." There's only so many ways to call those functions. I'm not sure just seeing the .cs file will be really helpful.

Martyn
Site Admin
Site Admin
Posts: 3371
Joined: Fri Jun 10, 2011 8:15 am
Location: St. Neots

Re: Automating PicoVNA 106 in C#

Post by Martyn » Wed May 23, 2018 9:52 am

I have asked via email that you send in the code, not just the form initialization.

One other thing to check is that the application you are building needs to be x86 only, which our example is.
Martyn
Technical Support Manager

jephilli
Newbie
Posts: 0
Joined: Tue May 15, 2018 7:25 pm

Re: Automating PicoVNA 106 in C#

Post by jephilli » Wed May 30, 2018 7:20 pm

Martyn,

Sorry I haven't had time to try re-sending the entire project to you. Have you ever tried creating a .zip file but changing the extension to .txt so it slips through the filters?

I've been ignoring the "Error" response from the LoadCal() method and continuing to build up my app. My project in Visual Studio is targeting an x86 platform and using the .NET 4.6.1 framework. I'm using Windows 10 to develop the project, but the app will be running on a 64-bit system using Windows 7.

I did a test run of the .exe on the Windows 7 machine this morning, and the LoadCal() method actually returned an "OK" response. So it looks like it might be a Windows 7 vs. Windows 10 issue.

Martyn
Site Admin
Site Admin
Posts: 3371
Joined: Fri Jun 10, 2011 8:15 am
Location: St. Neots

Re: Automating PicoVNA 106 in C#

Post by Martyn » Fri Jun 01, 2018 8:53 am

Sometimes that can work, otherwise post the code onto a file sharing site.
Martyn
Technical Support Manager

Post Reply