I'm writing a program to make continuous current measurements using a Keithley 2657a high-voltage source-measure unit, as well as a Stanford Research Systems SR570 current pre-amplifier. I am using the Keithley 26xx driver to control and take measurements from the 2657a, and a DAQ to take measurements from the SR570. I based my code largely on the current measurement example that came with the Keithley 26xx driver.
The problem I'm having is that the program is very slow, it only takes a measurement every ~2-3 seconds. It seems that the Keithley driver functions in the while loop are the culprits, but I'm not sure if there are any alternatives. I need to be able to change the voltage supplied by the 2657a while the program is running, and I need to continuously monitor the measured current, which is why the 'configure source level' functions and the clear and read buffer functions are all in the while loop.
Is there any way to speed up this code to read the measured current faster? Even just twice a second would be a significant improvement.
Any advice is appreciated.
I would recommend reading the 2657 SMU manual to see what high-speed measurement methods are supported.
The way you implemented the code, 1 measurement is made for every loop iteration but the loop iteration will only progress only after both the SMU and DAQ have measured.
You need look into hardware synchronization techniques to synchronize DAQ and SMU using electrical signals instead of tying them together in the same loop and call it a day.
Here is how I would approach,