Author Topic: Using C# .NET 8 to talk to lab equipment!  (Read 903 times)

0 Members and 1 Guest are viewing this topic.

Offline ZoapTopic starter

  • Newbie
  • Posts: 2
  • Country: se
Using C# .NET 8 to talk to lab equipment!
« on: December 07, 2025, 03:47:27 pm »
I fall into a very particular section of the venn diagram for "Interested in electronics" and "Programs in .NET", I am way to cheap to buy any of the propriatary programs/hardware used to send commands over GPIB.

So here I am, wanting to build programs for my instruments to automate some things, but to cheap to buy whats needed and no suitable way to do it in the langauge of my choosing, what to do?

So I found out about the open source hardware for the raspberry pi using linux-gpib https://github.com/lightside-instruments/gpib4pi, but that still didnt solve me wanting to use .NET, so I did what any programmer would do and built my own wrapper in .NET 8.

https://www.nuget.org/packages/LinuxGPIB.Net/

I tested it on my HP 54600B running linux-gpib 4.3.7 and successfully read frequency and VPP from the test-output on the scope.

gpib4pi shield on pi 3b
2713051-0

Scope connected to raspbery pi 3b with gpib4pi shield
2713015-1

Scope measurements
2713019-2

Program console output running on the pi
2713023-3

So that's my contribution to this little part of the community, I hope it's useful to someone.


Edit: The screenshot of the program running is from the first build where I got it to work (I wrote all the code before having the hardware to test), there was a bug with the DeviceDiscovery method then, so I hardcoded the scope address (10) to test it, but I have since fixed the DeviceDiscovery bug.
« Last Edit: December 08, 2025, 05:47:09 am by Zoap »
 

Offline Tony_G

  • Super Contributor
  • ***
  • Posts: 1081
  • Country: us
  • Checkout my old test gear channel (link in sig)
    • TGSoapbox
Re: Using C# .NET 8 to talk to lab equipment!
« Reply #1 on: December 07, 2025, 11:12:34 pm »
Nice - Congrats on getting it up and running.

I'm not familiar with ni_gpib kernel module (in fact, I'm not a Linux person at all, closest I get is the occasional tool use in WSL) but if you do have an NI adapter and Windows then you could go look at the documentation for the NI .NET Framework libraries to see what else you could add as a wrapper (I don't think they work with core, at least I've never tried them I just use 4.7).

Good luck with future work on this.

BTW I have some code in C# that might be interesting to you up on Github - This stuff is bits and pieces that I put together for my devices here - I'll include a link to a YT video showing the HP 435B stuff in use:





TonyG
« Last Edit: December 07, 2025, 11:20:15 pm by Tony_G »
 

Offline ZoapTopic starter

  • Newbie
  • Posts: 2
  • Country: se
Re: Using C# .NET 8 to talk to lab equipment!
« Reply #2 on: December 08, 2025, 05:46:45 am »
Nice - Congrats on getting it up and running.

...if you do have an NI adapter and Windows then you could go look at the documentation for the NI .NET Framework libraries to see what else you could add as a wrapper (I don't think they work with core, at least I've never tried them I just use 4.7).

Good luck with future work on this.

...


Thanks!

Unfortunately don't have access to NI-hardware for GPIB interfacing, also I only ever looked at the 'NationalInstuments.Visa' (which does supports .NET Core 6.0 or later) C# syntax when I was well into the design of my wrapper, it remains to be seen if I have to tweak the high-level interface to suit the needs that people have.

I will definitely have a look at the code on your github, maybe trying to port any of the modules you have written will answer some of the real world usability questions I have. Any suggestions on a module you think would make a great example?

If you ever get around to it I'd appreciate any feedback, you can check if your hardware is supported by the linux-gpib library here https://linux-gpib.sourceforge.io/doc_html/supported-hardware.html, although I won't blame you if you don't. Linux is a net positive on the world, but to individuals I'm not so sure.

Also, nice touch with the pdf-report in the video, good visuals overall.
 


Share me

Digg  Facebook  SlashDot  Delicious  Technorati  Twitter  Google  Yahoo
Smf