c# setup | LabJack
 

c# setup

5 posts / 0 new
Last post
DSpen
DSpen's picture
c# setup

First of all, the new site looks great! I'm having issues getting the labjack namespace set up. I've downloaded the latest from https://labjack.com/support/software/installers but I'm still unable to run my program or the examples. I have .net 4 and am using visual studio 2013. "The type or namespace name 'LabJack' could not be found"

LabJack Support
labjack support's picture
Thanks about the website.

Thanks about the website.

Regarding your Visual Studios (VS) project, make sure to add the LJUDDotNet.dll assembly to your project's examples. I don't have VS2013 on hand at the moment, but in VS2012 in the Solutions explorer you can right-mouse click References, select Add Reference and then under Assemblies->Extensions you can check LabJackUD .NET to add the assembly to your project. Next make sure you are "using LabJack.LabJackUD;" in your code like in the examples, and call functions like ePut in .NET like "LJUD.ePut".

DSpen
DSpen's picture
Sorry for the late reply,

Sorry for the late reply, figured it out a bit after I posted. 

I already had checked and made sure the dll was in the correct location. I removed labjack from my VS's extensions, added it back in. didn't work. repeated 2 more times, and  then it started to work. I must have done something wrong during my VS setup.

DSpen
DSpen's picture
In Python I was using u3

In Python I was using u3.readRegister(5000) to read the value from dac0. I'm having trouble finding the c# version of this.

The same goes for reading FIO, u3.getAIN(6), instead i'm using 

                    LJUD.eDI(d.ljhandle, 6, ref intValue);

                    ain6 = intValue;

Is there a better/more efficient way to do this?

Thank you

LabJack Support
labjack support's picture
In the UD driver there is no

In the UD driver there is no equivalent Modbus function for u3.readRegister(5000). The UD driver is built around using the low-level functions and doesn't offer high-level Modbus functionality. You would need to build the Modbus packet and parse its response for Modbus functionality using the raw I/O functions. An alternative to using Modbus to read the DAC would be to connect your DAC to an AIN, and read that AIN for the DAC voltage.

As for reading a single analog input, use the eAIN function as demonstrated in the U3_EFunctions example. For example:

//ChannelN = 31 or 199 is a single ended reading.
LJUD.eAIN( d.ljhandle, 6, 31, ref dblValue, 0, 0, 0, 0);
ain6 = dblValue;

Use eDI if you want to read a digital input from a FIO line. For reading multiple analog inputs at the same time effiiciently, refer to the U3_Simple and U3_AllIO examples. The C# examples can be found here:

https://labjack.com/support/software/examples/ud/dotnet