LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Serial communication (multiple read/write)

Solved!
Go to solution

Hi, I want to operate a pulser/receiver using LabVIEW serial communication.

By referring to the control commands provided by the pulser/receiver equipment company, I confirmed that serial communication was working well.

 

However, when I turn on the pulsar/receiver,
1) I want to apply multiple initial settings that I have set for various conditions (multiple serial communication)
ex) pulse voltage, damping resistors, trigger source,....etc.

 

2) Also, I want to implement a program when if I change the values of Gain/voltage etc., the serial communication will work and the corresponding values (Gain/voltage etc.) will be converted.

 

I have attached the serial communication document for the pulser/receiver and the LabView code.

 

Can you help me?

 

thank you.

Download All
0 Kudos
Message 1 of 6
(1,549 Views)

Hi hurang,

 


@hurang wrote:

I have attached the serial communication document for the pulser/receiver and the LabView code.


There are several problems in your VI:

  • using a timeout event then is configured to NEVER happen
  • using a wait function with BytesAtPort to read the response of your device: please watch this video! Work with the TermChar configured while initializing the serial port!
  • using a string constant of "\r" (in normal display mode) to append a CR char! Change the displaymode to "\-code display" or use the CR string constant (or change the format string of the FormatIntoString function before)!
  • using a control set to DBL representation but converting to I32: why not use a I32 control?
Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
0 Kudos
Message 2 of 6
(1,527 Views)
Solution
Accepted by hurang

A couple more things:

  • The V300 command does not look like it should get a response.  So the read after that makes no sense.  If you are trying to query the voltage, you should use V?
  • You can simplify the creating of the voltage command by putting the entire message in the Format String in the Format Into String.  Use "V%d\r" as the format and it will take care of the entire message.

 

I have attached a simplified and cleaned up version of your code, taking notes from GerdW as well as my own comments.


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
Download All
0 Kudos
Message 3 of 6
(1,486 Views)

Thanks for your reply!

 

When I turn on the pulser/receiver equipment, I want it to have the initial settings I want (V=300, W20, T1, M1, G32...etc.). How can I input it into the VISA function at once?


Also, if a command to change the setting value is entered into the VISA function, I want the value corresponding to the command to be maintained.

0 Kudos
Message 4 of 6
(1,437 Views)
Solution
Accepted by hurang

Hi hurang,

 


@hurang wrote:

When I turn on the pulser/receiver equipment, I want it to have the initial settings I want (V=300, W20, T1, M1, G32...etc.). How can I input it into the VISA function at once?


Does your device even allow you to send multiple commands in one message? If yes then it should be described in the programming manual of that device. Otherwise you need to send each command with its own message…

 


@hurang wrote:

Also, if a command to change the setting value is entered into the VISA function, I want the value corresponding to the command to be maintained.


When you want to store data within your VI then you need to program that.

Usually shift registers store data…

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
0 Kudos
Message 5 of 6
(1,431 Views)
Solution
Accepted by hurang

@hurang wrote:

When I turn on the pulser/receiver equipment, I want it to have the initial settings I want (V=300, W20, T1, M1, G32...etc.). How can I input it into the VISA function at once?


You should be able to send them in a single string with \ Display code enabled and a \r character between each. But!!!!

Your device has likely a limited internal serial port buffer and may overflow if your command string gets to long. How long that internal serial port buffer is, is unfortunately nowhere documented. Considering the short nature of the commands my guess is that it is rather limited.

Rolf Kalbermatter
My Blog
0 Kudos
Message 6 of 6
(1,419 Views)