ScanImage 2018 : Coupling Serial Device to Acquisition

I'm interested in coupling a serially driven temperature controller to my SI acquisition.

Unfortunately I have not been able to find a controller that can take analog signal for temperature setting and give me back analog readout on current temperature that can work with thermocouples (and affordable..).

I have a controller that I need to control via serial port. In the past I've used it via a LabView controller but I wonder if I could use it via serial IO in matlab coupled to ScanImage.

This would be extremely handy to minimize time offsets and other issues with having two separate programs going.


My thinking was to have a function triggered on every frame that I would build a matrix with temperature set point and temperature readout.

I would only read every x frames in order to avoid flooding the serial port with requests (this is an issue with this controller).

My strategy was to only read if (s=com port) s.BytesAvailable has bytes available to minimize locking the function.

 

Have you had experience and/or recommendations with serial IO via user function?

What can be passed to a function that runs every frame and what information does it have access to?

Can the use function access frame number, exact time or time since start of acquisition, can I pass the serial port handle, etc?

 

You will be able to read the thermocouple using a ScanImage user function.

 

Please review the section 'User Function' in the ScanImage API documentation page for an example how to set up a user function.

 

It is very important that your user function does not take up too much time. I think the approach of checking s.BytesAvailable is a good start.

 

Alternatively, you could also use the NI DAQ boards during an acquisition to read out thermocouple data.