Analog Streaming Problems | LabJack
 

Analog Streaming Problems

20 posts / 0 new
Last post
Deep Thought
Deep Thought's picture
Analog Streaming Problems

Dear community,

I'm facing multiple problems using the LabJack T7 eStream function to read from 2 analog input pins at a rate of 1000Hz... Im programming in MATLAB using a Mac with OS High Sierra v 10.12:

1) Sometimes, after restarting the stream, the input channels are exchanged (I read the signal of pin 1 from where I used to read signal 2 and vice versa)

2) After updating the firmware to the newest version, an interference between the two channels emerged. If one channel reads a higher input, the reading from the other channel is also altered. I had this problem before but could solve it by setting the settling time to 200. Now I'm having the same problem despite not having changed the code. After reinstalling the firmware, the first couple of steams are fine, but then the problem arises.

3) Sometimes, LJM_OpenS is stuck, does not return an error but neither a value and appears to be caught in a loop, so that I have to force quit MATLAB. I know that this specification is quite vague, but I don't know which other details are important for this problem.

I would be extremely thankful for any help, concerning one of there three issues.

Kind regards,

Lukas

LabJack Support
labjack support's picture
1.  Let us know if you see

1.  Let us know if you see this happen again after updating to the latest firmware.

2.  Sounds like your signal might have settling issues.  A good basic way to test is by jumpering the first channel in your scan to VS or GND, and then make your signal the second channel in the scan.  Does the reading from your signal change depending on whether the first channel is jumpered to VS or GND?

3.  Leaving this for a Matlab person here.

Deep Thought
Deep Thought's picture
Thank you for your answer

Thank you for your answer

1) I tried to use the latest firmware. But as mentioned above, the problem (settling issues) just arose after updating to a newer version. I solved the problem by subsequently downgrading to earlier software versions. The latest one that does not have this problem is v1.0229!

2) The first channel was jumpered at all times to GND

 

LabJack Support
labjack support's picture
Regarding OpenS, what

Regarding OpenS, what DeviceType, ConnectionType and Identifier are you using? If you use "T7" and "USB" does the function get stuck?

LabJack Support
labjack support's picture
Also, please make sure you're

Also, please make sure you're running the latest software:

https://labjack.com/support/software/installers/ljm

Deep Thought
Deep Thought's picture
I am using the latest

I am using the latest software (LJM Driver 1.17, Modbus Map 2017.11.28.A, Kipling 3.1.11).

Until now I was using as DeviceType and ConnectionType 'ANY', but changing them to 'T7' and 'USB' does not have any effect.

LabJack Support
labjack support's picture
For #3:

For #3:

A) You might as well try the beta version of LJM (LJM 1.1803): https://labjack.com/support/software/installers/ljm.

B) Try using a different USB cable and a different USB port on your computer

C) Try disconnecting everything from your T7 except the USB cable. Does OpenS still hang?

D) As in your other thread, you could try getting a debug log.

LabJack Support
labjack support's picture
I started and stopped the

I started and stopped the "Stream Basic.vi" example for quite a while without seeing any channel swapping. To get to the bottom of the issues you are seeing we will need to reproduce your test and results.

  • You said "The first channel was jumpered at all times to GND" is that AIN0? What is AIN1 connected to?
  • Are you using one of our examples? If not I strongly suggest you start there.
  • Can you send us your code?
Deep Thought
Deep Thought's picture
I am reading from AIN0 and

I am reading from AIN0 and AIN2, while AIN1 and AIN3 are jumpered to the GND. 

In my code:

try for i=1:100 s = LJ_Handle; s.writeConfig('LJM_DEBUG_LOG_MODE',2) s.writeConfig('LJM_DEBUG_LOG_LEVEL',1) s.writeConfig('LJM_DEBUG_LOG_FILE_MAX_SIZE',123456789) s.streamStart; data=s.streamRead; if data(2)==180; disp( i); end s.streamStop; s.writeConfig('LJM_DEBUG_LOG_MODE',1) s.writeConfig('LJM_DEBUG_LOG_LEVEL',6) s.writeConfig('LJM_DEBUG_LOG_FILE_MAX_SIZE',50000) s.close end catch exception warning(exception.message); end

using the functions specified in the attatched LJ_Handle file result in wron readings in run 

i =   6 , 11, 19,  55, 56, 88

of the loop stated above. I attached the log file. Perhaps that could help to find the problem...

 

File Attachment: 
LabJack Support
labjack support's picture
From your debug log, I see

From your debug log, I see that you start and stop stream in a loop, which causes error messages that aren't really problems.

To capture insightful debug log information for your original issue number #3, you need to:

1. Enable the debug log

2. Call LJM_OpenS

3. Exit the program as soon as possible after the issue occurs

4. Send us ljm.log before running any other LJM-based programs.

LabJack Support
labjack support's picture
Nothing stands out as wrong

Nothing stands out as wrong in the LJ_Handle.m file that you sent, but it appears to be just a class. I would need to see the calls and parameters to see what is going on.

 

We need to put together a test that we can perform. Can you tell me about the signals connected to AIN0 and AIN2. Sensor type, any conditioning, source impedance etc.

 

Do you see the same issue when using the T7's DACs as signal sources to AIN0 and AIN2?

Deep Thought
Deep Thought's picture
Please excuse the long

Please excuse the long response time. I had to wait until the equipment was available. 

    for i=1:100

        s = LJ_Handle;

        

        s.writeConfig('LJM_DEBUG_LOG_MODE',2)

        s.writeConfig('LJM_DEBUG_LOG_LEVEL',1)

        s.writeConfig('LJM_DEBUG_LOG_FILE_MAX_SIZE',123456789)

        

        s.streamStart;

        data=s.streamRead;

        if data(2)==180

            disp(['channel switch at run ' num2str(i)])

            %     for ii=10

            %         disp(data)

            %         data=s.streamRead

            %         WaitSecs(1);

            %     end

            break

        end

        s.streamStop;

        

        

        s.writeConfig('LJM_DEBUG_LOG_MODE',1)

        s.writeConfig('LJM_DEBUG_LOG_LEVEL',6)

        s.writeConfig('LJM_DEBUG_LOG_FILE_MAX_SIZE',50000)

        s.close

    end

gives the output: 

channel switch at run 10

So I stoped right after the error occured. I'll upload the debug_log_file again

File Attachment: 
Deep Thought
Deep Thought's picture
When using the DACs as

When using the DACs as sources I also get wrong readings: 

    for i=1:100

        s = LJ_Handle;

        s.writeConfig('LJM_DEBUG_LOG_MODE',2)

        s.writeConfig('LJM_DEBUG_LOG_LEVEL',1)

        WaitSecs(0.1);

        s.writeName('DAC0',1);

        s.writeName('DAC1',4);

        WaitSecs(0.1);

        s.streamStart;

        WaitSecs(0.1);

        data=s.streamRead;

       if data(2)<3

            disp(data)

            break

        end

        s.streamStop;        

        s.writeConfig('LJM_DEBUG_LOG_MODE',1)

        s.writeConfig('LJM_DEBUG_LOG_LEVEL',6)

        s.writeConfig('LJM_DEBUG_LOG_FILE_MAX_SIZE',50000)

        s.close

    end

Output

    1.0014
    1.0005

Apparently AIN2 gets the same signal strength as AIN0. But perhaps I did something wrong? 

 

 

File Attachment: 
LabJack Support
labjack support's picture
I'll look into the log. In

I'll look into the log. In the meantime, to address your AIN0 and AIN2 issue, I recommend running Examples\More\Stream\StreamBasic.m to ensure that AIN0 and AIN2 are reading correctly. I suggest running it as written (with AIN1) then find/replacing AIN1 with AIN2.

Connect GND to AIN0 and VS to AIN2 to make sure AIN0 and AIN2 are reading correctly.

LabJack Support
labjack support's picture
You can also use Kipling with

You can also use Kipling with GND connected to AIN0 and VS connected to AIN2 (or vice versa) to make sure AIN0 and AIN2 are reading correctly (0V and 5V).

LabJack Support
labjack support's picture
I don't see anything in the

I don't see anything in the Mon, 07/09/2018 - 07:59 debug log that indicates that the OpenS is hanging. Is that still happening?

So I stoped right after the error occured.

What error occurred? Is it a new issue? If so, please start a new thread, since this one is already juggling a couple of different topics.

Deep Thought
Deep Thought's picture
So I stoped right after the

So I stoped right after the error occured

That the readings from the channels were exchanged (not the opening of a handle). Sorry, I should have been more specific!

Deep Thought
Deep Thought's picture
I tried it again, this time

I tried it again, this time jumpering VS to AIN2 and GND to AIN0. At the second time starting a stream the first stream read of AIN2 is smaller than 0.001 (instead of 5). I'll attatch the log file.

Running your example code is not that easy, because its not written for mac+matlab. So I would have to rewrite the whole thing ... if there is a way to prevent this I would be grateful 

File Attachment: 
Deep Thought
Deep Thought's picture
I also can now specify the

I also can now specify the problem a little further: 

When expecting 4.5V at AIN2 and 0V at AIN0 the very first reading of the stream is close to 0V for both channels and 0V for AIN2 as well as 4.5V for AIN0 for all further readings when the eror occurs (the channels are exactly exchanged).  Changing the input voltages is also reflected in these exchanged readings...  

LabJack Support
labjack support's picture
There are a couple of options

There are a couple of options:

1. Try to replicate the issue using our LJM stream examples (for example our C examples or Python examples). If you'd like an example that streams AIN0 and AIN1 and for all scans, checks that AIN0 is ~0 and AIN1 is between 4.7 and 5.1, I've attached stream_basic.c. For a binary executable for macOS, I've attached the binary version of it (you just need to unzip it). It works for me and AIN0 and AIN1 don't flip.

2. Write your own matlab wrapper/interface e.g. using calllib (https://www.mathworks.com/help/matlab/ref/calllib.html)

3. Send us your code. We may not be able to run it, but we can look it over. No guarantees that we'll find any bugs, either.

File Attachment: