I had created an GUI that allow user to control the DAQ easily. With GUI, I created three functions, which are Init, Start and Stop, each of these functions are explained below:
1. Init - Initialize the DAQ with custom configuration
2. Start - Run the DAQ background scan
3. Stop - Stop the DAQ background scan
Below are my function call for each features:
[Init]
DaqDeviceManager.ReleaseDaqDevice(board);
var devices = DaqDeviceManager.GetDaqDeviceInventory(DaqDeviceInterface.Usb);
var board = DaqDeviceManager.CreateDaqDevice(0, devices[0]);
P/S: I could not write out all code as it was too long, so I just return some important part of my code.
Problem:
Whenever I start my program, then I clicked "Init" followed by "Start". The data received normally. I tested to "Stop" button and the scanning really stop. When I clicked back "Start", it resume normally as well.
Here come the problem, I click "Init" button followed by "Start" again, I received the data normally for a few second then suddenly stuck at the same "current_count" value. No matter how much time I clicked "Init", this issue still the same. I check from the ULError State and it indicated "Invalid board number". Till I restart my entire program, then only my program run normally (first Init only).
Can help me to advice is there any mistake I did in my code?
Question
Ricky Ooi
I had created an GUI that allow user to control the DAQ easily. With GUI, I created three functions, which are Init, Start and Stop, each of these functions are explained below:
1. Init - Initialize the DAQ with custom configuration
2. Start - Run the DAQ background scan
3. Stop - Stop the DAQ background scan
Below are my function call for each features:
[Init]
DaqDeviceManager.ReleaseDaqDevice(board);
var devices = DaqDeviceManager.GetDaqDeviceInventory(DaqDeviceInterface.Usb);
var board = DaqDeviceManager.CreateDaqDevice(0, devices[0]);
<Configure DAQ>
[Start]
board.DaqInScan(chanArray, chanTypeArray, rangeArray, NUM_OF_CHANNEL, ref rate, ref PretrigCount, ref Total_Samples, m_MemHandle, SCAN_OPTIONS); // where SCAN_OPTIONS = ScanOptions.Background | ScanOptions.Continuous
m_IsScanning = true;
while(m_IsScanning)
{
Board.GetStatus(out transfer_status, out current_count, out last_index, m_FunctionType);
Console.WriteLine(current_count);
}
[Stop]
m_IsScanning = false;
board.StopBackground(m_FunctionType);
P/S: I could not write out all code as it was too long, so I just return some important part of my code.
Problem:
Edited by Ricky OoiWhenever I start my program, then I clicked "Init" followed by "Start". The data received normally. I tested to "Stop" button and the scanning really stop. When I clicked back "Start", it resume normally as well.
Here come the problem, I click "Init" button followed by "Start" again, I received the data normally for a few second then suddenly stuck at the same "current_count" value. No matter how much time I clicked "Init", this issue still the same. I check from the ULError State and it indicated "Invalid board number". Till I restart my entire program, then only my program run normally (first Init only).
Can help me to advice is there any mistake I did in my code?
Link to comment
Share on other sites
2 answers to this question
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now