Question of a newbie | LabJack
 

Question of a newbie

4 posts / 0 new
Last post
Alaska
Alaska's picture
Question of a newbie

Greetings,

I want to know:  

- where can i find information about Global_Constants and variables like scanrate or delay. i cant find it in the documentation or in the LJUD Source Code of the Java Wrapper

- what does ScanRate mean? Does it mean that it will collect  for example 1000 scans in 1 sek if the delay is also set to 1000?

- how can i configure my stream in a way that AIN0,AIN1,AIN2,AIN3 will be scanned

- what is the difference between LJUD.Constants.ioADD_STREAM_CHANNEL and LJUD.Constants.ioADD_STREAM_CHANNEL_DIFF

This is what i do: 

//Define the scan list as AIN0 then AIN1.
LJUD.addRequest(modelU3.intHandle, LJUD.Constants.ioCLEAR_STREAM_CHANNELS, 0, 0, 0, 0);
LJUD.addRequest(modelU3.intHandle, LJUD.Constants.ioADD_STREAM_CHANNEL, 0, 0, 0, 0); // first method for single ended reading - AIN0
LJUD.addRequest(modelU3.intHandle, LJUD.Constants.ioADD_STREAM_CHANNEL_DIFF, 1, 0, 32, 0); // second method for single ended reading - AIN1

Thank you for help.

LabJack Support
LabJack Support's picture
> - where can i find

> - where can i find information about Global_Constants and variables like scanrate or delay

The following is going to be your primary information:

https://labjack.com/support/datasheets/u3/high-level-driver/example-pseudocode/stream-mode

... and the following are also going to be useful to know:

https://labjack.com/support/datasheets/u3/hardware-description/ain
https://labjack.com/support/datasheets/u3/hardware-description/ain/channel_numbers
https://labjack.com/support/datasheets/u3/operation
https://labjack.com/support/datasheets/u3/operation/stream-mode
https://labjack.com/support/datasheets/u3/high-level-driver/overview
https://labjack.com/support/datasheets/u3/high-level-driver/example-pseudocode/analog-inputs


Scan rate will be talked about in those links, but delay is likely
just a software delay in the example, and not a function of the UD
library or the U3 hardware.


> - what does ScanRate mean? Does it mean that it will collect
>  for example 1000 scans in 1 sek if the delay is also set to 1000?

If ScanRate is 500, that means the U3 will acquire a new scan (1
sample from every channel in the scan list) every 2 milliseconds.

Delay has no impact on the ScanRate.  If you still need help
understanding delay, let us know and someone else here who is familiar
with the Java example will have to help.


> - how can i configure my stream in a way that AIN0,AIN1,AIN2,AIN3 will be scanned

//Define the scan list as singled ended AIN0 through AIN3.
AddRequest (lngHandle, LJ_ioCLEAR_STREAM_CHANNELS, 0, 0, 0, 0);
AddRequest (lngHandle, LJ_ioADD_STREAM_CHANNEL, 0, 0, 0, 0);
AddRequest (lngHandle, LJ_ioADD_STREAM_CHANNEL, 1, 0, 0, 0);
AddRequest (lngHandle, LJ_ioADD_STREAM_CHANNEL, 2, 0, 0, 0);
AddRequest (lngHandle, LJ_ioADD_STREAM_CHANNEL, 3, 0, 0, 0);


> - what is the difference between LJUD.Constants.ioADD_STREAM_CHANNEL
> and LJUD.Constants.ioADD_STREAM_CHANNEL_DIFF

The first is for adding a single-ended channel to the scan list.  The
second is for adding a differential channel to the scan list (and you
pass the negative channel in x1).

Alaska
Alaska's picture
Hello,

Hello,

thanks for your answers. 

Just to be clear if i understood the proportions. if i wanted to have a scan every 20ms i have to set the scanrate to 50?

I also have a problem with the configuration of the 4 Stream Channels. If i intend to scan four channels in my java programm or your example "SimpleStream". The application ends after one scan with a crash of java SE. In your example application i added the configuration parameter like you postet. Can you help me with the problem please? 


LabJack Support
LabJack Support's picture
Yes, if you want a scan every

Yes, if you want a scan every 20 ms you set the scan rate to 50. Scan rate is in scans per second.

As for the crash, make sure you adjust the size of you stream read array (adblData in our example) when you change your numScans and the number of channels in your scan, so numScans*#Channels. The example only accounts for a 2 channel stream and I am guessing the crash is due to your stream read array being too small. So in the example code the changes needed for 4 channels would be:

            double[] adblData = new double[4*(int)numScans];

            //...

            //Give the driver a 5 second buffer (scanRate * 4 channels * 5 seconds).
            LJUD.addRequest(intHandle, LJUD.Constants.ioPUT_CONFIG,
                    LJUD.Constants.chSTREAM_BUFFER_SIZE, scanRate * 4 * 5, 0, 0);

            //...

            System.out.println("Actual Sample Rate = " + formatter.format(4 * refValue.getValue()));

            //...

                //This displays just the first scan.
                System.out.println("First scan = " + formatter.format(adblData[0])
                        + ", " + formatter.format(adblData[1]) + formatter.format(adblData[2]
                        + formatter.format(adblData[3]);