04-24-2016 08:16 PM
I need to communicate with a BK instrument Model 1823A which has a RS232 port. I’m using a RS232-to-USB converter based on the latest Prolific chip set. When using the software that comes with the 1823A it works fine for reading and writing data. But when I use VBA code to do this via NI Visa, I cannot read or write data. I have tried two different NI Visa drivers for the 1823A but no luck.
When using NI Max to debug, it sees the RS232-to-USB converter but not the instrument. NI Max acts like things are fine, except that reads commands fail. Write commands appear to work in NI Max but the 1823A does not respond so I believe that the 1823A never really receives write commands.
I use the same model RS232-to-USB converter for another instrument and it works fine with NI Visa when using VBA code. The only difference I can see is that 1823A doesn’t support IDN to identify itself. My questions are:
04-25-2016 05:30 AM
VISA does not see the instrument. All it sees is the serial port you told it to use. From here, it sounds like you just are not sending the right commands. Maybe you need to append a termination character of some kind, typically a Line Feed or a Carriage Return or even both.
04-25-2016 10:52 PM
Thanks. I tried different carriage returns in both NI Max and VBA code but no luck. The 1823A instrument manual says that 0D hex is the right carriage return which sometimes goes by \r. I tired the following in VBA with various carriage returns and syntax. I'm trying to send command F3, but the instrument does not react.
instrument.WriteString "F3" + Chr$(&HD)
instrument.WriteString "F3" & Chr$(&HD)
instrument.WriteString "F3" + Chr(&HD)
instrument.WriteString "F3" & Chr(&HD)
instrument.WriteString "F3" + Chr$(&HD)
instrument.WriteString "F3" & Chr$(&HD)
instrument.WriteString "F3" + "\r"
instrument.WriteString "F3" & "\r"
I noticed the following in the manual and I wonder if this might be relavent. But I don't specifically see this option in NI Max for setting the DTR and RTS pins.
Pin2: RXD ( Receive Data )
Pin3: TXD ( Transmit Data )
Pin4: DTR ( Data Terminal Ready) DC power from PC (high 12V)
Pin7: RTS ( Request to Send ) DC power from PC (low -12V)
*Pins 4 (DTR) should be ENABLED and 7 (RTS) should be DISABLED.
04-26-2016 02:38 AM
04-26-2016 05:40 AM
@Dan747 wrote:*Pins 4 (DTR) should be ENABLED and 7 (RTS) should be DISABLED.
That is likely your problem then. If they should always be in that state, then I think you will have to assert the DTR line and unassert the RTS line as part of your setup. There is a property node in LabVIEW to do this. Not sure what the function is in VB. There is a Flow Control Settings tab when in the VISA Test Panel for asserting or unasserting those lines.