LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Inputs

Solved!
Go to solution

RossGE wrote:
I have my hardware working in Hyperterminal now and have pulled up the basic serial example but Im having trouble understanding how it works. 

What are you having problems understanding? In your case you do not need to write anything out, so the Write toggle switch would be set to False (down). When you run the VI (after setting the correct serial port parameters) it should read whatever is on the serial port.

 


Do i need to just copy the example into my program to get the numbers inputted into my code?

Not entirely. I don't know what you've got set up as code is concerned, so without knowing anything else you'd have some sort of loop. You initialize the serial port before the loop, read from the device inside the loop, and do whatever you need, and then close outside the loop (see the "Advanced Serial Write and Read" example for this basic structure). You still need to determine whether the device ends its response with a specific character. This is so you can configure the serial port read to either terminate once it sees a specific character (as the "Advanced Serial Write and Read" example does), or whether you need to use the Number of Bytes at Serial Port inside your loop(as the "Basic Serial Write and Read" example does). Do you know whether the device uses a termination character? When you see the data streaming across in HyperTerminal is it all on one line, or is it one measurement per line? If it's one measurement per line then a termination character is being used. You need to find out what this is. You can find out by saving the transmission to file and then open the file with a hex editor, or you can use PortMon.

 

0 Kudos
Message 11 of 21
(1,223 Views)

I got the input to send into labview and I believe it is inputing in an acceptable way.  However, I'm not sure if it is the best way to input the data and when i try to convert the strings into numerical data no data is outputted out of the converter. Could you look at this and tell me where i am going wrong?

 

 

0 Kudos
Message 12 of 21
(1,208 Views)

Don't put your Serial port configuration in the while loop.  Put it ahead of the while loop.  Reconfiguring the port every iteration is probably wiping out your buffer.

 

Are you sure 100 msec is enough of a delay to be getting data back?  Put an indicator on the output of bytes at port so you can see how many bytes you are actually receiving.

0 Kudos
Message 13 of 21
(1,205 Views)

Ravens Fan wrote:

Don't put your Serial port configuration in the while loop.  Put it ahead of the while loop. 


Well, I'm glad to see that he's paying attention to what I'm saying.

 


RossGE wrote:

I got the input to send into labview and I believe it is inputing in an acceptable way.  However, I'm not sure if it is the best way to input the data and when i try to convert the strings into numerical data no data is outputted out of the converter. Could you look at this and tell me where i am going wrong?


I have no idea if the Decimal String to Number is even correct because you have not given us any example of what you actually get on the serial port, and as I've already mentioned twice now you need to perform your read based on how the device sends the data. If the device adds a termination character then that's how you should be performing the read. If it does, but you use the Number of Bytes at Serial Port then you could be reading part of one measurement and part of the next. The conversion in this case will be gibberish.

0 Kudos
Message 14 of 21
(1,196 Views)
Alright after carefully reading all your messages I pulled the input out of the loop and changed the code to include a termination character as best i could.  As of now the program is outputing the string, I provided a copy of the hyperterminal test.  But, the decimal string to numeric function is outputing only in integers, 0 if less than1 and 1 if anything greater.  I tried to change the offset and the function with no success.
Download All
0 Kudos
Message 15 of 21
(1,160 Views)

It's pretty clear you have not read the help on the Decimal String to Number function. It clearly states that the conversion is to integers. You want Fract/Exp String to Number.

 

Go to the help menu and turn on Context Help. Move your mouse over a function and read the help. Click on the Detailed Help.

0 Kudos
Message 16 of 21
(1,153 Views)
Yes I had the help menu up i had tried both the two converters I had to change the number of digits in the properties.  I have completed the program but sometimes my progam loses the decimal, the negative sign  or just puts out zeros and when i run it highlighted it the converter gets over run i think that i have my termination character settings off how do i go about finding the correct setting.
0 Kudos
Message 17 of 21
(1,137 Views)

In your Untitled3 VI:

  • Delete all of the code between the serial port configuration and the while loop. It is either redundant or not necessary for what you're doing. For example, you are not writing to the serial port, so there is no need to configure VISA to append a linefeed when you want to write. You are also not using flow control, so it's pointless to set XON/XOFF values. And unless you have a good reason to, there's little need to configure the buffer size. I know you copied that code from the "Advanced Serial Write and Read", but my point wasn't to copy the code verbatim.
  • Delete the case structure around the Read. You're always reading.


RossGE wrote:
Yes I had the help menu up i had tried both the two converters I had to change the number of digits in the properties. 

The number of digits of what? Are you referring to the precision/significant digits? You can, of course, change that to whatever you want, depending on how you want the number displayed in the indicator. You must use the Fract/Exp String to Number, however, since that's the string you're getting.

 


I have completed the program but sometimes my progam loses the decimal, the negative sign  or just puts out zeros and when i run it highlighted it the converter gets over run i think that i have my termination character settings off how do i go about finding the correct setting.

There are many ways to find out what the termination character is:

  • The documentation. Corollary: the manufacturer.
  • PortMon - this will display the raw bytes that are coming across (as well as the text).
  • Saving the HyperTerminal session to file (NOT copying and pasting, but actually using the capture to file), and then opening the file with a hex editor or a text editor that has a Hex Viewer plug-in (like NotePad++).
  • (I think) Using Instrument I/O Assistant. In the first step if you set the termination character to <none>, and then add a "Read and Parse" step you should be able to read over the serial port and see the bytes. Not sure about this method, though.
0 Kudos
Message 18 of 21
(1,129 Views)
One additional piece of information: The value that you've wired for the "bytes to read" input of VISA Read should be set to a value large enough to guarantee that you get the entire measurement. When using a termination character VISA Read will stop reading once it sees the termination character. I don't know if you used 12 since that's what you're expecting the measurement reading to be. If so, I'd use something like 20.
0 Kudos
Message 19 of 21
(1,118 Views)

Thanks changing the byte count on the string converter is allowing me to output the proper size.  However, when i deleted all the information between the serial port and the while loop the converter begin to get over run with data.

0 Kudos
Message 20 of 21
(1,098 Views)