I am working to program a data output caliper (Starrett 798) through usb. I have never tried to request data before so I am not sure where to start. The caliper has an spc connection and I have an spc to usb converter cable going to my computer. I want to record time and the distance measurement, so im thinking the structure should be like use port# with this baud/even parity, 7 data and 2 stop bit' then request data in a time stamped loop. I have found a request data function but don't think its correct. any help is much appreciated
The last time I played with SPC outputs on micrometers/calipers I looked at the VBA macros the vendor provided for use with MS Excel. Does Starret provide anything like this?
Well to start with there is no "query vi"
First you open a VISA session to the serial port with the necessary serial protocol settings.
Then you send a query command using VISA Write and receive the response using VISA Read.
But all that may be a moot point because according to the manual:
Output (798B only)
798B calipers include an output port that allows data
transmission to computers or printers using the appropriate
Starrett cable/adapter or Starrett DataSure® wireless
interface. The output command is controlled by the in/mm
button. 798A models do not include output.
It would appear the instrument does not respond to query, but sends out its current measument data only when the button is pressed?
It does show up in the device manager as a comm port. the manufacturer has some information to connect using visual basic, see the attached picture. does the VISA read/write have any port opening
Judging by the VB code it looks like it does not respond to a query, but sends data when DTR is False.
Do you have any more information on the data sent? Does it have a termination character like a Line Feed or Carriage Return at the end of each data sent?
it has a carriage return, looks like a musical note
Well then lucky for you this is going to be somewhat easy...
Ignore the VISA Write in this example as you don't need it.
The VISA Read will read data until it receives a Termination Character or times out.
Ok, now that I have enough information...
This instrument sends data as ASCII and properly ends the data with a termination character (the Carriage Return). Also from the screen shot, I know all of the serial port settings. And the last important bit of information is that this is what I call an "intermittent transmitter," meaning it sends data at non-periodic rates (in this case, when you push the in/mm button).
So this is what you need. Use the Bytes At Port to see if any data has come in. We are not using that to see how many bytes to read, just to verify that a message has at least started. If there is no data, wait (I used 50ms). If there is data, just use VISA Read to tell it to read more bytes than a message will ever be (I just used the same 50 constant). This works because the VISA Read will stop when it reads the termination character (the Carriage Return). With that string, just use the Fract/Exp String To Number to get your latest reading.
NOTE: The "..0" case has a Wait (ms) using the same 50 constant from outside of the case structure and the VISA Resource and Error wires are just passed through.
Is this a laptop that you are using? If so, ditch it and use a actual desktop with a serial card installed or use the native one if it has it. You'll thank all of us later on.