LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

COM port question

Solved!
Go to solution

Good to see the problem has been solved.

In any case, for future reference:

I'm using Eltima Serial Port Monitor, that lets you monitor a serial port used by an other application.

If I'm not mistaken there is a free version downloadable.

 

Regards,

Marco

0 Kudos
Message 11 of 25
(1,245 Views)

I'm having a difficult time figuring out how to correctly send commands to the instrument.

 

It should be very simple. According to the manual, I just send a single carriage return and it will reply with:
" Hello. Press ? for Help. "

 

Then I send the string "X" and it returns an array of data like so:
"LC1123101742,2012,243,1233,15,3.16,24.66,-5511.213,-999999.0,-999999.0,-999999.0,-999999.0,-999999.0,-999999.0,-999999.0,-999999.0,-999999.0,-999999.0,-999999.0,-999999.0,-999999.0,-999999.0,-999999.0,23.3,-99.0,-99.0,-99.0,-99.0,-99.0,-99.0,-99.0,-99.0,-99.0,-99.0,-99.0,-99.0,-99.0,-99.0,-99.0"

 

When I do this in Hyperterminal, it works perfectly.

port.PNG

 

I tried the same thing in LabVIEW using the Serial Write function, but I must be doing something incorrectly.

When I send the correct command in Hyperterminal, I can audibly hear the instrument making a clicking noise so I know it is working.

Then moments later I get the data array in Hyperterminal.

 

When I send the command in LabVIEW, I do not hear anything from the instrument, and I do not get any data back from it.

 

Example.PNG

 

I attached a simple version of the code I threw together in LabVIEW. Would someone mind taking a look at how I am sending the commands.
Perhaps I am missing some termination characters or something like that. 

Cory K
0 Kudos
Message 12 of 25
(1,234 Views)

You need to append the carriage return to your string before sending it out.  Hyperterminal does this automatically.


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
0 Kudos
Message 13 of 25
(1,229 Views)

When I append a carriage return to the string, I am just getting blank lines returned back every iteration.

 

Here's a really weird behavior. When I run the code in "Highlight Execution" mode, it works intermittently. But not normally. Smiley Frustrated

What could be causing that?

Cory K
0 Kudos
Message 14 of 25
(1,222 Views)

I would guess that you need a wait after you write the command.  You need to wait for the instrument to take its measurements and then send them back to you afterall.


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
0 Kudos
Message 15 of 25
(1,209 Views)

Can you save the vi for 2010?  I'm a little behind on versions.

0 Kudos
Message 16 of 25
(1,202 Views)

Here is the most up to date version of the VI in 2010.

 

Basically, here's what I think I am doing (or would like to be doing).

 

1) Configure the port

2) Write a carriage return to get the introduction line

3) Write the command "X"

4) Wait 15 seconds for it to take and send measurements

5) Read whatever is in the buffer

6) Append this data to an array for later use

7) Repeat 3-6 until "Stop" is pressed

😎 Housekeeping

 

Step 3 must not be working correctly because I very rarely hear any clicking noise. If I run the VI maybe 20 times, I will hear the clicking once or twice, even if I let the while loop run for 10 minutes or so.

Cory K
0 Kudos
Message 17 of 25
(1,195 Views)

I thought manual said to send 2 carriage returns to wake it up?

0 Kudos
Message 18 of 25
(1,188 Views)

Check that the default configuration of the VISA Configure are compatible with the current configuration of your device.

--
Tim Elsey
Certified LabVIEW Architect
0 Kudos
Message 19 of 25
(1,179 Views)

I think I figured out what the issue was. The instrument needs a bit of time between commands, as Crossrulz said.

This was more apparent manually typing commands using Hyperterminal.

Between the first carriage return and the first X, I had to put a 5 second wait.

 

This was the case for all of my Serial Writes, they cannot be back-to-back, they needed waits between them.

Cory K
0 Kudos
Message 20 of 25
(1,176 Views)