Hi,
I have problem when I try to read AIN channel 1 from LabJack
initialization for AIN input, channel number 1
private void StartStreamWithEkstenziometar()
{
try
{
//Configure the stream:
//Configure all analog inputs for 16-bit resolution
LJUD.AddRequest(lngHandle, LJUD.IO.PUT_CONFIG, LJUD.CHANNEL.AIN_RESOLUTION, 9, 0, 0);
//Configure the analog input range on channel 2 for bipolar 10 volts (extensometer)
//LJUD.AddRequest(lngHandle, LJUD.IO.PUT_AIN_RANGE, 2, LJUD.RANGES.BIP10V, 0, 0);
LJUD.AddRequest(lngHandle, LJUD.IO.PUT_AIN_RANGE, 1, 2, 0, 0);
//LJUD.AddRequest(lngHandle, LJUD.IO.GET_AIN, (LJUD.CHANNEL)1, 0, 0, 0);
if (onHeader.ConditionsOfTesting.rbtnYes.IsChecked == true)
{
//Execute the list of requests.
LJUD.GoOne(lngHandle);
LJUD.ePut(lngHandle, LJUD.IO.PUT_CONFIG, LJUD.CHANNEL.TDAC_SCL_PIN_NUM, 2, 0);
LJUD.ePut(lngHandle, LJUD.IO.TDAC_COMMUNICATION, LJUD.CHANNEL.TDAC_UPDATE_DACA, 10.0, 0);
numScansRequested = NUM_SCANS;
_LabJackWorking.Start();
}
}
catch (Exception ex){}
}
The program broke down at the code line LJUD.ePut(lngHandle, LJUD.IO.TDAC_COMMUNICATION, LJUD.CHANNEL.TDAC_UPDATE_DACA, 10.0, 0);
After that I commented that line of code and I have initialization without that line
now my initialization function is
private void StartStreamWithEkstenziometar()
{
try
{
//Configure the stream:
//Configure all analog inputs for 16-bit resolution
LJUD.AddRequest(lngHandle, LJUD.IO.PUT_CONFIG, LJUD.CHANNEL.AIN_RESOLUTION, 9, 0, 0);
//Configure the analog input range on channel 2 for bipolar 10 volts (extensometer)
//LJUD.AddRequest(lngHandle, LJUD.IO.PUT_AIN_RANGE, 2, LJUD.RANGES.BIP10V, 0, 0);
LJUD.AddRequest(lngHandle, LJUD.IO.PUT_AIN_RANGE, 1, 2, 0, 0);
//LJUD.AddRequest(lngHandle, LJUD.IO.GET_AIN, (LJUD.CHANNEL)1, 0, 0, 0);
if (onHeader.ConditionsOfTesting.rbtnYes.IsChecked == true)
{
//Execute the list of requests.
LJUD.GoOne(lngHandle);
LJUD.ePut(lngHandle, LJUD.IO.PUT_CONFIG, LJUD.CHANNEL.TDAC_SCL_PIN_NUM, 2, 0);
//this line code now is commented
//LJUD.ePut(lngHandle, LJUD.IO.TDAC_COMMUNICATION, LJUD.CHANNEL.TDAC_UPDATE_DACA, 10.0, 0);
numScansRequested = NUM_SCANS;
_LabJackWorking.Start();
}
}
catch (Exception ex){}
}
Then this initialzation function is OK, but when I try to get value from AIN channel 1 my program broke down again
The brogram broke down at the line code LJUD.eGet(lngHandle, LJUD.IO.GET_AIN, 1, ref adblDataIL, 0);
Can you please help with this,
Many thanks in advance
First, for your TDAC_UPDATE_DACA call make sure you LJTick-DAC is connected to FIO2 and FIO3, and that the screw terminals are screwed down on the connectors. That call will fail if a LJTick-DAC is not connected.
Second, what exceptions are you getting when you program "breaks down"? The exception will describe the error which will be helpful. Your analog input eGet call looks fine. Make sure you have opened your U6 and have a valid handle to it (lngHandle) before you make calls to your U6.
Exception is Error in Application
and I still have problem with this code
private void StartStreamWithEkstenziometar()
{
try
{
//Configure the stream:
//Configure all analog inputs for 16-bit resolution
LJUD.AddRequest(lngHandle, LJUD.IO.PUT_CONFIG, LJUD.CHANNEL.AIN_RESOLUTION, 9, 0, 0);
//Configure the analog input range on channel 2 for bipolar 10 volts (extensometer)
//LJUD.AddRequest(lngHandle, LJUD.IO.PUT_AIN_RANGE, 2, LJUD.RANGES.BIP10V, 0, 0);
LJUD.AddRequest(lngHandle, LJUD.IO.PUT_AIN_RANGE, 1, 2, 0, 0);
//LJUD.AddRequest(lngHandle, LJUD.IO.GET_AIN, (LJUD.CHANNEL)1, 0, 0, 0);
if (onHeader.ConditionsOfTesting.rbtnYes.IsChecked == true)
{
//Execute the list of requests.
LJUD.GoOne(lngHandle);
LJUD.ePut(lngHandle, LJUD.IO.PUT_CONFIG, LJUD.CHANNEL.TDAC_SCL_PIN_NUM, 2, 0);
//this line code now is commented
//LJUD.ePut(lngHandle, LJUD.IO.TDAC_COMMUNICATION, LJUD.CHANNEL.TDAC_UPDATE_DACA, 10.0, 0);
numScansRequested = NUM_SCANS;
_LabJackWorking.Start();
}
}
catch (Exception ex){}
}
Then this initialzation function is OK, but when I try to get value from AIN channel 1 my program broke down again
The program broke down at the line code LJUD.eGet(lngHandle, LJUD.IO.GET_AIN, 1, ref adblDataIL, 0);
Can you please help with this,
Many thanks in advance
What exception message are you getting? Catching the exception like so, and displaying the error message and stack trace will give a better understanding of what the error is and where it is occurring (your eGet call which isn't in the code you provided?):
catch (LabJackUDException ljex)
{
Console.Out.WriteLine("Exception message: " + ljex.ToString());
Console.Out.WriteLine(ljex.StackTrace);
}