LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Labview Serial data request/read

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

http://zone.ni.com/reference/en-XX/help/371599L-01/lvfpga/fpga_mem_method_request/

 

CG

0 Kudos
Message 1 of 16
(4,967 Views)
SPC connection? What do you mean by that? Is it a USB to Serial (i.e. does it show up as a COM port in Device Manager) connection? If yes, you should use the VISA functions to read/write data to/from the device. Look in the LabVIEW Examples under VISA and you should find something to get you started (Help -> Example Finder).

The link you posted is for when you are communicating with a LabVIEW FPGA device - which probably isn't the case.

You might also want to check with the manufacturer of the device to see if they have LabVIEW drivers / instrument drivers available. At the very least, you will want to have the manual for the device handy as it will give you the connection properties (e.g. baud rate) and detail the protocol for what commands to send / responses the device supports.

LabVIEW Champion, CLA, CLED, CTD
(blog)
0 Kudos
Message 2 of 16
(4,936 Views)

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?

Jim
You're entirely bonkers. But I'll tell you a secret. All the best people are. ~ Alice
For he does not know what will happen; So who can tell him when it will occur? Eccl. 8:7

0 Kudos
Message 3 of 16
(4,931 Views)

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?

========================
=== Engineer Ambiguously ===
========================
0 Kudos
Message 4 of 16
(4,930 Views)

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 

0 Kudos
Message 5 of 16
(4,912 Views)

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?

========================
=== Engineer Ambiguously ===
========================
0 Kudos
Message 6 of 16
(4,900 Views)

it has a carriage return, looks like a musical note 

0 Kudos
Message 7 of 16
(4,877 Views)

@cgarlow wrote:

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.

SerialCapture.PNG

The VISA Read will read data until it receives a Termination Character or times out.

========================
=== Engineer Ambiguously ===
========================
Message 8 of 16
(4,873 Views)

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.


GCentral
There are only two ways to tell somebody thanks: Kudos and Marked Solutions
Unofficial Forum Rules and Guidelines
"Not that we are sufficient in ourselves to claim anything as coming from us, but our sufficiency is from God" - 2 Corinthians 3:5
Message 9 of 16
(4,870 Views)

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.

0 Kudos
Message 10 of 16
(4,866 Views)