From Friday, April 19th (11:00 PM CDT) through Saturday, April 20th (2:00 PM CDT), 2024, ni.com will undergo system upgrades that may result in temporary service interruption.
We appreciate your patience as we improve our online experience.
From Friday, April 19th (11:00 PM CDT) through Saturday, April 20th (2:00 PM CDT), 2024, ni.com will undergo system upgrades that may result in temporary service interruption.
We appreciate your patience as we improve our online experience.
10-29-2020 07:49 PM - edited 10-29-2020 08:07 PM
Hi
I have problem in rs-232c communication.
I'm using nl-42 sound meter.
I read serial manual but I can't understand command.
I add string with \n\r too in manual ,but nothing respond.
In my opinion I don't understand command exactly.
I add serial manual too. please somebody help me~!~!
10-29-2020 10:24 PM
I think a few hints about how to configure and use VISA will solve most of your problems.
Now, your code will work (probably), assuming you've set up the other parameters such as the Baud Rate and the other numeric specifications (the N-8-1 configuration is probably the most common, and is, I think, the default, so you probably don't need to wire any of the parameters (except Baud Rate) to Configure Serial Port.
So you send your Instrument a serial Command, ending in <CR><LF>. You then do a VISA Read of (say) 1024 Bytes. Your Instruments sends you a response ("Hello, Human, What is your name? <CR><LF>") (that is probably not what it will send, but it will end in the <CR><LF>). Because you've enabled Termination Character and asked for more Bytes than it is sending, you'll get the entire Response String, and nothing else. Now all you have to do is to do some String parsing to figure out what the command response was, and if it has numeric data, how to "extract" it.
Here's a hint -- look at "Scan from String" (on the String Palette). For example, the Clock command gives you three numbers separated by "/", a space, then three number separated by Colons. You can probably parse this with "%d/%d/%d %d:%d:%d" and get it to give you back 6 integer values ...
Bob Schor
10-29-2020 10:39 PM
DO NOT USE BYTES AT PORT! It is the wrong thing to use 99% of the time.
You check the bytes at port immediately after you sent the message. You gave the device zero time to receive the message, act on it, and return any data. Even the LabVIEW examples which use bytes at port (and they are poor examples) show to put a wait in there.
Read Crossrulz's recent VI Week presentation for tips on how to do serial communication properly in LabVIEW.
10-29-2020 11:03 PM - edited 10-29-2020 11:21 PM
Very thanks for your response.
I try like this but I have a timeout error ...
10-29-2020 11:33 PM
Thanks for your help.
I did like this but I got a timeout error...
I intall usb driver but doesn't response...
Please fix my code.
Thank you again.
10-30-2020 03:03 AM - edited 10-30-2020 03:06 AM
Hi odoria,
@odoria wrote:
I did like this but I got a timeout error...
I intall usb driver but doesn't response...
Which driver did you install?
Does the COM port appear in Windows device manager and in MAX?
Does that serial device come with software from the manufacturer?
Can you communicate with that device using either some "terminal" software (like HyperTerm or similar) or VISA test panel in MAX?
@odoria wrote:
Please fix my code.
You did not attach any code so far: we cannot debug or edit images using LabVIEW!
A simple "fix" would be to use AutoCleanup…
10-30-2020 05:38 AM
So are you using the RS-232 or the USB? Notice that they are different connectors on the device and you have to set up the device to choose which one to use. At the moment I suspect the device is not set up correctly and/or you are using the wrong connector.
10-30-2020 09:17 PM
Yes im using rs232 and in NI MAX I can see
it's connected.
And I setting all same as manual.
Thanks for your help.
10-30-2020 09:20 PM
Im using rs-232 cable and I set up too
device setring as rs-232 communication.
Setting same baudrate...etc .. in
communication manual.
Thanks for your help.
10-31-2020 08:33 AM
I wonder if there is problem with the language settings on your PC. In your first message it shows you are concatenating the carriage return and line feed characters onto your string to write by way of the string constants. So that seems good.
But the screen show show and indicator for that result set for \code display mode. It should look like $Echo,On\r\n however you have other character in place of the \. It looks like a W with a line through it. It is like it is some other character up in the high end of the ASCII table.
Right after the concatenation, add a String to Byte Array function and put an indicator on that. Expand it so we can see all the bytes. Run your code and give us a screenshot. I want to see what the byte values are for the string being sent and see if they are correct. Those last two should be 13 and 10.