UE9 with two EI-1050 | LabJack
 

UE9 with two EI-1050

16 posts / 0 new
Last post
jb
JB2NDR's picture
UE9 with two EI-1050

I've modified ue9_ei1050.m from the example scripts to add another EI-1050 (2 total).  The code I added is

 

ljudObj.ePutS(ljhandle, 'LJ_ioPUT_DIGITAL_BIT', 3, 0, 0);
   ljudObj.ePutS(ljhandle, 'LJ_ioPUT_DIGITAL_BIT', 2, 1, 0);
    ljudObj.AddRequestSS(ljhandle, 'LJ_ioSHT_GET_READING', 'LJ_chSHT_TEMP', 0, 0, 0);
    ljudObj.AddRequestSS(ljhandle, 'LJ_ioSHT_GET_READING', 'LJ_chSHT_RH', 0, 0, 0);
    ljudObj.GoOne(ljhandle);
    [ljerror, dblValue] = ljudObj.GetResultSS(ljhandle, 'LJ_ioSHT_GET_READING', 'LJ_chSHT_TEMP', 0);
    disp(['Temp Probe A = ' num2str(dblValue) ' deg K']);
    disp(['Temp Probe A = ' num2str((dblValue-273.15)) ' deg C']);
    disp(['Temp Probe A = ' num2str((((dblValue-273.15)*1.8)+32)) ' deg F']);
    [ljuderror, dblValue] = ljudObj.GetResultSS(ljhandle, 'LJ_ioSHT_GET_READING', 'LJ_chSHT_RH', 0);
    disp(['RH Probe A = ' num2str(dblValue) ' percent']);

 

I get

UD Error: CRC failed for SHT communication                                                                                                                                                                                                                             
Error using ue9_ei1050 (line 68)
Message: Exception of type 'LabJack.LabJackUD.LabJackUDException' was thrown.
Source: LJUDDotNet
HelpLink:

 

I can change the orignal code to set FIO3 high and it will work (after I close Matlab and unhook the USB and plug it back-in. So I know both EI-1050 are wired right.

Can you help?

Jb

File Attachment: 
LabJack Support
labjack support's picture
Please describe the wiring

Please describe the wiring from both EI-1050s to your UE9?

jb
JB2NDR's picture
Both green to FIO0.

Both green to FIO0.

Both white to FIO1

Both black to GND

(1) EI-1050 red and brown to FIO2

(2) EI-1050 red and brown to FIO3.

Kind regards.

LabJack Support
labjack support's picture
Sorry for the late reply. I

Sorry for the late reply. I was able to reproduce your issue. It seems that using FIO for power and enable is causing some problems with the clock and data lines. Moving power to DAC0 (set to 3.3V output) fixed things for me. Please try this and get back to us if you are still seeing problems.

jb
JB2NDR's picture
I still get the same error at

I still get the same error at the same place wired and coded as in the following code. I am only trying to read one

EI-1050 as a barebones test.

--START CODE-----------------------------------------------------------------------------------------

clc     % Clear the MATLAB command window
clear   % Clear the MATLAB variables
ljasm = NET.addAssembly('LJUDDotNet');
ljudObj = LabJack.LabJackUD.LJUD;
%Both green to FIO0.
%Both white to FIO1
%Both black to GND
%(1) EI-1050 red to DAC0
%(2) EI-1050 red to DAC0
%(1) EI-1050 brown to FIO2
%(2) EI-1050 brown to FIO3
try
    disp(['UD Driver Version = ' num2str(ljudObj.GetDriverVersion())])
    [ljerror, ljhandle] = ljudObj.OpenLabJackS('LJ_dtUE9', 'LJ_ctUSB', '0', true, 0);
    ljudObj.ePutSS(ljhandle, 'LJ_ioPUT_CONFIG', 'LJ_chSHT_DATA_CHANNEL', 0, 0);
    ljudObj.ePutSS(ljhandle, 'LJ_ioPUT_CONFIG', 'LJ_chSHT_CLOCK_CHANNEL', 1, 0);
    ljudObj.eDAC(ljhandle, 0, 3.3, 0, 0, 0);
    ljudObj.AddRequestSS(ljhandle, 'LJ_ioSHT_GET_READING', 'LJ_chSHT_TEMP', 2, 0, 0);
    ljudObj.AddRequestSS(ljhandle, 'LJ_ioSHT_GET_READING', 'LJ_chSHT_RH', 2, 0, 0);
    ljudObj.GoOne(ljhandle);
    %Fails this step:CRC failed for SHT communication.     
    [ljerror, dblValue] = ljudObj.GetResultSS(ljhandle, 'LJ_ioSHT_GET_READING', 'LJ_chSHT_TEMP', 0);
    %
    disp(['Temp Probe A = ' num2str(dblValue) ' deg K']);
    disp(['Temp Probe A = ' num2str((dblValue-273.15)) ' deg C']);
    disp(['Temp Probe A = ' num2str((((dblValue-273.15)*1.8)+32)) ' deg F']);
    [ljuderror, dblValue] = ljudObj.GetResultSS(ljhandle, 'LJ_ioSHT_GET_READING', 'LJ_chSHT_RH', 0);
    disp(['RH Probe A = ' num2str(dblValue) ' percent']);
catch e
    showErrorMessage(e)
end

-------EndCode--------------------------------------------------------------------------------------------------------------

LabJack Support
labjack support's picture
Try setting your enable pin

Try setting your enable pin (FIO2 in your example code) high before your reading. When you add the second sensor back in you will need to toggle your enable pins according to what sensor you are trying to read.

jb
JB2NDR's picture
Same thing. Maybe order of

Same thing. Maybe order of operations?

%%----------------------Begin code ---------------------------------------

clc     % Clear the MATLAB command window
clear   % Clear the MATLAB variables
ljasm = NET.addAssembly('LJUDDotNet');
ljudObj = LabJack.LabJackUD.LJUD;
%Both green to FIO0.
%Both white to FIO1
%Both black to GND
%(1) EI-1050 red to DAC0
%(2) EI-1050 red to DAC0
%(1) EI-1050 brown to FIO2
%(2) EI-1050 brown to FIO3
try
    disp(['UD Driver Version = ' num2str(ljudObj.GetDriverVersion())])
    [ljerror, ljhandle] = ljudObj.OpenLabJackS('LJ_dtUE9', 'LJ_ctUSB', '0', true, 0);
    ljudObj.ePutSS(ljhandle, 'LJ_ioPUT_CONFIG', 'LJ_chSHT_DATA_CHANNEL', 0, 0);
    ljudObj.ePutSS(ljhandle, 'LJ_ioPUT_CONFIG', 'LJ_chSHT_CLOCK_CHANNEL', 1, 0);
    ljudObj.ePutS(ljhandle, 'LJ_ioPUT_DIGITAL_BIT', 2, 1, 0);
    ljudObj.eDAC(ljhandle, 0, 3.3, 0, 0, 0);
    ljudObj.AddRequestSS(ljhandle, 'LJ_ioSHT_GET_READING', 'LJ_chSHT_TEMP', 2, 0, 0);
    ljudObj.AddRequestSS(ljhandle, 'LJ_ioSHT_GET_READING', 'LJ_chSHT_RH', 2, 0, 0);
    ljudObj.GoOne(ljhandle);
    %Fails this step:CRC failed for SHT communication.     
    [ljerror, dblValue] = ljudObj.GetResultSS(ljhandle, 'LJ_ioSHT_GET_READING', 'LJ_chSHT_TEMP', 0);
    %
    disp(['Temp Probe A = ' num2str(dblValue) ' deg K']);
    disp(['Temp Probe A = ' num2str((dblValue-273.15)) ' deg C']);
    disp(['Temp Probe A = ' num2str((((dblValue-273.15)*1.8)+32)) ' deg F']);
    [ljuderror, dblValue] = ljudObj.GetResultSS(ljhandle, 'LJ_ioSHT_GET_READING', 'LJ_chSHT_RH', 0);
    disp(['RH Probe A = ' num2str(dblValue) ' percent']);
catch e
    showErrorMessage(e)
end

%%----------------------End code ---------------------------------------

LabJack Support
labjack support's picture
Your order of operations look

Your order of operations look good to me. Your AddRequestSS calls have a 2 for the fourth parameter (Value passed for output channels) rather than 0, which is the value we set it to in our example. I do not know off the top of my head what changing this parameter does in this situation, but you could try modifying it back to 0 and see if that works.

jb
JB2NDR's picture
That was sloppy. Here is the

That was sloppy. Here is the example code with turning DAC0 on to 3.3V as the only modification. Same problem.

FIO2 is enable (brown) for EI-1050-2?

%
% Demonstrates talking to a EI-1050 probes using MATLAB, .NET and the UD
% driver.
%
% [email protected]
%

clc  % Clear the MATLAB command window
clear  % Clear the MATLAB variables

% Make the UD .NET assembly visible in MATLAB.
ljasm = NET.addAssembly('LJUDDotNet');
ljudObj = LabJack.LabJackUD.LJUD;

try
    % Read and display the UD version.
    disp(['UD Driver Version = ' num2str(ljudObj.GetDriverVersion())])

    % Open the first found LabJack UE9.
    [ljerror, ljhandle] = ljudObj.OpenLabJackS('LJ_dtUE9', 'LJ_ctUSB', '0', true, 0);

    % Set the Data line to FIO0
    ljudObj.ePutSS(ljhandle, 'LJ_ioPUT_CONFIG', 'LJ_chSHT_DATA_CHANNEL', 0, 0);

    % Set the Clock line to FIO1
    ljudObj.ePutSS(ljhandle, 'LJ_ioPUT_CONFIG', 'LJ_chSHT_CLOCK_CHANNEL', 1, 0);

    % Set FIO2 to output-high to provide power to the EI-1050.

%---------------------modification
    %ljudObj.ePutS(ljhandle, 'LJ_ioPUT_DIGITAL_BIT', 2, 1, 0);
    ljudObj.eDAC(ljhandle, 0, 3.3, 0, 0, 0);

%---------------------modification end
    % Connections for probe:
    %     Red (Power)         FIO2
    %     Black (Ground)      GND
    %     Green (Data)        FIO0
    %     White (Clock)       FIO1
    %     Brown (Enable)      FIO2

    % Now, an add/go/get block to get the temp & humidity at the same time.
    % Request a temperature reading from the EI-1050.
    ljudObj.AddRequestSS(ljhandle, 'LJ_ioSHT_GET_READING', 'LJ_chSHT_TEMP', 0, 0, 0);

    % Request a humidity reading from the EI-1050.
    ljudObj.AddRequestSS(ljhandle, 'LJ_ioSHT_GET_READING', 'LJ_chSHT_RH', 0, 0, 0);

    % Execute the requests.  Will take about 0.5 seconds with a USB high-high or
    % Ethernet connection, and about 1.5 seconds with a normal USB connection.
    ljudObj.GoOne(ljhandle);

    % Get the temperature reading.
    [ljerror, dblValue] = ljudObj.GetResultSS(ljhandle, 'LJ_ioSHT_GET_READING', 'LJ_chSHT_TEMP', 0);
    disp(['Temp Probe A = ' num2str(dblValue) ' deg K']);
    disp(['Temp Probe A = ' num2str((dblValue-273.15)) ' deg C']);
    disp(['Temp Probe A = ' num2str((((dblValue-273.15)*1.8)+32)) ' deg F']);

    % Get the humidity reading.
    [ljuderror, dblValue] = ljudObj.GetResultSS(ljhandle, 'LJ_ioSHT_GET_READING', 'LJ_chSHT_RH', 0);
    disp(['RH Probe A = ' num2str(dblValue) ' percent']);
catch e
    showErrorMessage(e)
end

 

LabJack Support
labjack support's picture
For the enable lines it does

For the enable lines it does not matter what DIO line you use, you just need to have one dedicated DIO for each sensor enable line. I would double check all of your connections. In particular, make sure your data line connection is good. If you don't find any issues maybe power cycle the UE9, try running again, then double check that the original example is still working. I will try to look into this problem a bit more.

jb
JB2NDR's picture
Brown is the enable line?I

Brown is the enable line?I have that connected to FIO2/FIO3. Red is going to power 3.3V? I did power cycle and shut down matlab between runs. No such a thing a "close()" function. Do I use matlab close()?

Thanks

LabJack Support
labjack support's picture
Yes, brown is enable and 3.3V

Yes, brown is enable and 3.3V for power is correct. I believe the UD driver does have a close function, Close(). Note that it closes any UD-Series devices you have open. We may try to add some better documentation with that soon. If you are familiar with python I have a script I can send you to verify both of your sensors and the UE9 are working correctly.

jb
JB2NDR's picture
Python would be good to

Python would be good to counter test. A little brush up would not hurt either. But, are you able to run the Matlab script I posted?

regards

LabJack Support
labjack support's picture
Here is my script. You will

Here is my script. You will also need LabJackPython to run it: https://labjack.com/support/software/examples/ud/labjackpython. Throw my script into the LabJackPython-2.0.0/Examples/EI1050 folder.

 

I did not test specifically in MATLAB, I tested in C#, but both languages make the same calls with the UD Library so they are equivalent. Everything ran fine for me.

File Attachment: 
jb
JB2NDR's picture
I can't see any difference.

I can't see any difference. Remember - the way it is wired, it will not do one EI-1050. I think you may need to run it in Matlab. I assume you have it. May be we are missing somthing simple or there is a corrupted parameter being sent down the pipe.

LabJack Support
labjack support's picture
If our original example

If our original example worked at some point for you I am confident adding the code to use a DAC for power is not the issue. Our DAC lines are much more capable of running the sensors than the FIO lines and your call to eDAC is correct for setting the voltage of DAC0.

You could comment out the code for one sensor in the script I sent to test individual sensors. Alternatively, you could use this utility to test the sensors: https://labjack.com/support/software/misc-utility-apps/ei-1050-utility-app. Sorry I did not link this earlier, I forgot we had it. If neither the script or the utility works then it is likely either the UE9 or sensor is broken (most likely the sensor).

If neither tests work but you are not convinced your sensors are broken you could do some testing on the UE9 using LJControlPanel. If you have not used LJControlPanel before, it is installed with the UD-Library, so it should be on your computer: https://labjack.com/support/software/applications/ud-series/ljcontrolpanel. For tests, I would connect a jumper wire from DAC0 to an AIN and set the DAC to 3.3V. The AIN should read the same 3.3V. You could also check your DIO as described here: https://labjack.com/support/app-notes/test-digital-io-channel.

If the utility does work, I would try reinstalling the UD-Library: https://labjack.com/support/software/installers/ud. There is a small chance you are running an old version of the library that is causing issues.