Hello,
I am developing a simple POC that involves, setting a digital output on the LabJack U6 using C# as the platform.
As soon as I set the ouput, I would like to see the status of the IO.
This is the code :
//Read digital input FIO1. LJUD.AddRequest (u6.ljhandle, LJUD.IO.GET_DIGITAL_BIT_STATE, 1, 0, 0, 0); //Set digital output FIO1 to output-high. LJUD.AddRequest (u6.ljhandle, LJUD.IO.PUT_DIGITAL_BIT, 1, 1, 0, 0); //Read digital input FIO1. LJUD.AddRequest(u6.ljhandle, LJUD.IO.GET_DIGITAL_BIT_STATE, 1, 0, 0, 0);Problem:
Not able to read the updated digital ouput.
Can some one throw some light on how this could be done?
Best Regards,
Abhi
Are you executing the requests and getting the result?
//Set digital output FIO1 to output-high.
LJUD.AddRequest (u6.ljhandle, LJUD.IO.PUT_DIGITAL_BIT, 1, 1, 0, 0);
//Execute the request.
LJUD.GoOne (u6.ljhandle);
//Read digital input FIO1.
LJUD.AddRequest(u6.ljhandle, LJUD.IO.GET_DIGITAL_BIT_STATE, 1, 0, 0, 0);
//Execute the request.
LJUD.GoOne(u6.ljhandle);
//Get the reading.
double state = 0;
LJUD.GetResult(u6.ljhandle, LJUD.IO.GET_DIGITAL_BIT_STATE, 1, ref state);
Hello, Yes I am executing the request but getting the wrong result.
An observation, when I set the ouput as false and try to read, I get it as true.
At the moment, my best guess is that the read is occurring to quickly to see the change. We see the opposite of what we expect because that was the previous state. Try placing a sleep for 10-50 ms before the read operation.
Also, if there is anything attached to the IO, it may be holding the line low. We should disconnect any other devices while testing the LabJack and host program.