I want to use LB to communicate with an HP Digital Volt Meter to take Voltage readings and report values via RS232. I can talk to the DVM to set it up for readings but it never comes back with a value. I can see the DVM getting set up and take a reading with the value on its screen. At that time DSR is not set high by the PC so the DVM will not send the reading.
I can use this same DVM and null modem cable with another program to make readings. In this situation the PC sets DSR high for the DVM to send the value. So I know that the cable and DVM can do what I want.
This is the LB code I am using:
open "com6:9600,n,8,2,rs,cd0,ds0,cs,LF" for random as #1 print #1, ":SYST:REM" ' Configure the multimeter for ac voltage readings, ' 1 V range, 0.0001 V resolution, 1 reading PRINT #1, ":CONF:VOLT:AC 1,0.0001;:SAMP:COUN 1" ' Trigger the readings, and fetch the results PRINT #1, ":READ?" resp$=input$ (#1, lof(#1)) PRINT ":READ? returned: ", resp$ close #1
There must be something I am not setting correctly.
I missed this post. Couple of things, first off use the standard Liberty phrase for opening the port. DSR is I believe the signal from the remote device to say the data is ready. DTR is the signal from the PC to tell the remote device the PC is ready. With the standard phrase liberty ignores all these handshakes and just gets on with job.
Second point is that it will take time to read,process and transmit the data. It will not appear instantly in the buffer. But you may be using the debugger and giving it time to respond.
If we do need to alter DTR etc it can be done. I will post a link and a bit more detail when I get to my pc.
I did try the standard phrase at the start. I had read the help under OPEN "COMn:...". I also have "INPUT a$" in between some lines to allow time for reading and processing. I also have the Carl Gundel book but haven't found anything on OPEN COMn. I am using a null modem cable with DTR and DSR interchanged. The LED indicator I use is on the Volt Meter end. It would be DTR on the PC end. The Volt Meter manual says it uses DSR and DTR for handshaking. The line with the label DSR comes from the PC and is low when the Volt Meter data is ready to send.
I have disconnected the DTR line from the PC and wired the RTS line from the PC to the disconnected DSR line at the Volt Meter to see if that was the reason for the hold up. It worked but I would rather not solve the issue this way.
In the LBPE article, I see "Liberty can set and reset these lines. RTS is on by default, DTR is not. If you have a device that refuses to work with Liberty BASIC, DTR may need set on.". I am studying the section under 'Obtaining the serial port #handle". I will see what I can do with setting the handshake line ON/OFF.