I have created a nice python scrip to make an SPC chart with data from a T7 using command response based off of time and it works well. Now I would like to add an encoder in to the mix and take a reading every so many encoder pulses. I have the externaly clocked stream working with the clock devisor but it throws an exception if i lett it sit too long without spinning the encoder. I am sure it has to do with LJM_STREAM_SCANS_RETURN and LJM_STREAM_RECEIVE_TIMEOUT_MS but am unsure how to set those in python.
https://labjack.com/support/software/api/ljm/function-reference/ljmestre...
We somewhat recently made an externally clocked stream example in Python. It is available on our ljm-python GitHub (not on the main branch yet) and demonstrates how to set the LJM configurations:
https://github.com/labjack/labjack-ljm-python/blob/stream_external_clock...
Thanks. i added the falowing to my code.
# Configure LJM for unpredictable stream timing
ljm.writeLibraryConfigS(ljm.constants.STREAM_SCANS_RETURN,
ljm.constants.STREAM_SCANS_RETURN_ALL_OR_NONE)
ljm.writeLibraryConfigS(ljm.constants.STREAM_RECEIVE_TIMEOUT_MODE,
ljm.constants.STREAM_RECEIVE_TIMEOUT_MODE_MANUAL)
ljm.writeLibraryConfigS(ljm.constants.STREAM_RECEIVE_TIMEOUT_MS, 0)
i get a LJM library error code 1309 LJME_NO_SCANS_RETURNED but it goes away if i comment out
ljm.writeLibraryConfigS(ljm.constants.STREAM_SCANS_RETURN,
ljm.constants.STREAM_SCANS_RETURN_ALL_OR_NONE)
it appears to be working as intended without it but i will need to do more testing
Thanks that helped.
You may notice that our example just catches and ignores that specific exception; the LJME_NO_SCANS_RETURNED error is expected with the STREAM_SCANS_RETURN_ALL_OR_NONE configuration if you call eStreamRead before scansPerRead scans have been acquired.
I found that after I replied and have that working but thanks for your continued support.
I have another question now. Is there a way to stop the stream without filling the buffer in the labjack. On FI01 I have the line run signal which starts stream in a while loop. When I remove the signal on FI01 i have to spin the encoder to fill the buffer to get out of the while loop