Instrument Control (GPIB, Serial, VISA, IVI)

cancel
Showing results for 
Search instead for 
Did you mean: 

Invalid Baud Values using MsComm and rs-485

I have VB6 app that uses the MsComm activex control. The app is using a rs485 port (com3)at 155200 baud. When I change it to anything higher, say 128000 baud, I get "Could not set comm state, there may be more invalid comm parameters...". I've also tried 230400 baud. What's curious is that if I change the baud value in vb at design-time some of the values are accepted but fail at runtime (all other parameters are unchanged ). In other instances the new baud value is rejected at design-time when the mscomm settings property is changed.

Any insight into this problem would be appreciated. At this point I'm not sure if the problem lies with the MSComm activex control or the NI RS-485/2 card driver. I could switch to the NI activex control but it would be painful.

Regards,

Dan Quinones
0 Kudos
Message 1 of 4
(3,781 Views)
Dan,

What is the baud rate of your serial card set at in Measurement and Automation Explorer (MAX)? Make sure that this matches whatever you are trying to set in your VB application.

For your reference, here is a KB about what baud rates are supported by NI serial boards.

What NI serial board do you have?

This is a duplicate of this post, try to post only one time if it's the same issue!

JenK
0 Kudos
Message 2 of 4
(3,769 Views)
Not sure what MAX is set to but I'm changing the baud rate in my app dynamically. The default rate is 115200 baud. I send a command to the target to switch to 128000 baud and then change the mscomm settings property to 128000. I'm using the NI PCI RS485/2 card.

The code's nothing special:

Private Sub cmdSerSettingsConfig_click()
Dim strSettings As String
Dim blnTest As Boolean

On Error GoTo errorHandler
If MSCommSer.PortOpen Then MSCommSer.PortOpen = False
MSCommSer.CommPort = g_udtSerIf1Cfg.intComPort
MSCommSer.Handshaking = g_udtSerIf1Cfg.intFlowControl
strSettings = CStr(g_udtSerIf1Cfg.lngBitsPerSec) + "," 'add bits per second
strSettings = strSettings + g_udtSerIf1Cfg.strParity + "," 'add parity
strSettings = strSettings + CStr(g_udtSerIf1Cfg.intDataBits) + "," 'add data bits
strSettings = strSettings + CStr(g_udtSerIf1Cfg.sngStopBits) 'add stop bits
MSCommSer.Settings = strSettings
MSCommSer.PortOpen = True



Exit Sub
errorHandler:
Call frmPs.runtimeError("Routine: frmPs.cmdSerSettingsConfig. COM Port error.")
Resume Next
End Sub

dq
0 Kudos
Message 3 of 4
(3,764 Views)
Try using this Serial Instrument Control in Visual Basic example.

JenK
0 Kudos
Message 4 of 4
(3,741 Views)