Hello everyone -
I have two Acuity AR200 laser displacement sensors, which interface with my computer via serial port R232. I am using the instrument control toolbox to communicate with the lasers, which is working seamlessly. The lasers continously acquire and send displacement measurements, and a measurement can be obtained using fscanf(). My problem is that the string I am able to obtain is the measurement taken at the time fopen() is executed. When I move an object in front of the laser and attempt to read a new measurement with fscanf(s), it is still the old measurement. To get the new measurement, I must either close and re-open the connection or send the instrument a command to take only one reading rather than continuous readings (based on its sampling rate). My acquisition rate is therefore dependent upon the speed of my Matlab program and the speed of the serial port commands, rather than the very high rate of which the lasers are capable (1500+ Hz).
As I do not have Simulink, is there a way I can keep an "open connection" to the serial device to continuously sample data from the device rather than sending a command for a single reading in one line of code and then asking what the reading was in the next line of code? Thanks,
Any way I see it, you are going to be limited by the speed of the serial port to transfer the measurements back to MATLAB.
If the instrument supports a "batch mode" and has sufficient memory t hold the measurements taken in "batch mode", you could send a command to the instrument to make 'x' measurements, and then after the 'x' measurements are made, transfer it back to MATLAB. You could also set up a callback or other asynchronous communication to get the data in to MATLAB.
Play games and win prizes!Learn more