LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Cannot programmatically change the baudrate of COM port of NI PXI8431/4

Solved!
Go to solution

I have created a program where I need to check the RS485 connection with a modbus device. For this I need to configure the modbus device and then read data out of the device and see if it is working correctly. The RS 485 communication to the modbus device is coming from com port 8 of an NI PXI 8431/4. So currently I have set the com port baudrate to 38400 in NI MAX and I ran the program, the program works fine. I just have to give the same baudrate while configuring the modbus device. But now the thing is the device is capable of working at multiple baudrates and I need to check that. So I have to change the baud rate of com 8 of the NI PXI 8431/4 and everytime I check I cannot go back and forth to NI MAX to change baud rate. So I need to change the baud rate of the com port 8 of PXI 8431/4 programmatically in LabVIEW. I tried using the VISA configure serial port to change the baud rate, but it is not working. How do I change the baudrate of the com port of NI PXI 8431/4 programmatically in LabVIEW. If you want more clarification I have attached the program. Kindly go through the program and see. Is there any NI PXI 8431/4 driver that helps me change its baudrate. Thanking You. 

0 Kudos
Message 1 of 13
(337 Views)

You don't need special drivers to do this setting.

Your VISA configure serial port is pointless, though, since the Plasmionique's Open Serial Session would initialize the port on its own later.

Now the question is; why this vi does not initialize the serial port?

Is there any error going in or out of the Open Serial Session vi?

Paolo
-------------------
LV 7.1, 2011, 2017, 2019
0 Kudos
Message 2 of 13
(321 Views)

It looks like you there is a VI in your library for setting up the port.  So you don't need to configure that beforehand.  Another concern I have is that you have a wait on the top level diagram and no loops.  If you are using the Run Continuously, you need to stop.  That is meant for debugging simple algorithms, not instrument communications.  You should have a loop to continuously read and/or write.  This way you only need to do the initialization once before the loop and close everything once after the loop.


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 3 of 13
(310 Views)

You don't need special drivers to do this setting.

Your VISA configure serial port is pointless, though, since the Plasmionique's Open Serial Session would initialize the port on its own later.

Now the question is; why this vi does not initialize the serial port?

Is there any error going in or out of the Open Serial Session vi?

Paolo
 
Ok, I have checked it, there is no error coming out of open serial session, but there is an error coming out of read holding registers. I have uploaded the pic of the error. Also it was my mistake. I changed the baudrate to 115200 in NI Max and it still didnt work. But the program was working even when the baudrate in NI MAX is 115200 and in the program it is the original that is 38400. Which means the open serial session configures the baudrate accordingly irrespective of the baudrate in NI MAX but the read holding registers will work only if the baud rate is 38400 and not anything else. What is the reason for this? Thank You. 
0 Kudos
Message 4 of 13
(303 Views)

Are you sure you are correctly changing the baud rate on your device? Maybe you are missing a device restart?

Paolo
-------------------
LV 7.1, 2011, 2017, 2019
0 Kudos
Message 5 of 13
(294 Views)

I am not an expert in Modbus. Could you clarify when u said my device needs a restart. 

0 Kudos
Message 6 of 13
(285 Views)

Nothing Modbus-specific. Your program communicates over COM8 with a Modbus device.

To test different baud rates, you need to set those baud rates also on the slave device.

My question is: it's mandatory to restart the slave device to apply the new baud rate settings?

Paolo
-------------------
LV 7.1, 2011, 2017, 2019
Message 7 of 13
(269 Views)

@pincpanter wrote:

Nothing Modbus-specific. Your program communicates over COM8 with a Modbus device.

To test different baud rates, you need to set those baud rates also on the slave device.

My question is: it's mandatory to restart the slave device to apply the new baud rate settings?


I agree this is something to look for.  It is common for devices to need resetting or rebooting to take any new settings.

Bill
CLD
(Mid-Level minion.)
My support system ensures that I don't look totally incompetent.
Proud to say that I've progressed beyond knowing just enough to be dangerous. I now know enough to know that I have no clue about anything at all.
Humble author of the CLAD Nugget.
0 Kudos
Message 8 of 13
(259 Views)

I have uploaded the new program which I did. Here the program is same as before with a small change. After configuring the Modbus using open serial session, i turn off and on the Modbus device by cutting power supply to Modbus. You can see it in the program. Is that what you meant, but still no change. I am only getting output on baud rate 38400 and on different baud rates it is showing error. 

0 Kudos
Message 9 of 13
(209 Views)

I apologize for me insisting on that, but can you let us know what slave device you are using?

How do you change the baudrate on that device? Jumpers? Microswitches? Menu buttons?

Paolo
-------------------
LV 7.1, 2011, 2017, 2019
0 Kudos
Message 10 of 13
(205 Views)