Connecting to Device via VDT2

I am trying to establish a connection to a Piezo controller using VDT2. The connection can be established and the port opened. However the device does not seem to react on any of my commands. It expects them to be in ASCII (CRLF).

Printing of V_VDT after VDTWrite2 returns 1, so seems to be successful.

Below is the source code.

Function cmdAg(pp) 
        String pp
    String command = pp +"\n\r"
       
        // initialize port
    VDT2/P=COM5 baud=57600, stopbits=1, databits=8, parity=0
    VDTOperationsPort2 COM5

    VDTWrite2 command
End


I am invoking the function with cmdAg("MR"), where "MR" is an ASCII command which should change the mode of the controller.

Using supplied software I am able to control and steer the controller using these commands, so the syntax of them should be fine. I am a bit lost, because I don't really have any ideas how to debug this.

Any help would be much appreciated.
I don't see anything wrong with what you are doing assuming that the parameters (COM5, baud, stopbits, databits, parity) are correct.

Double-check the parameters against the documentation for the piezo controller.

What OS are you running on?

Does your machine have built-in serial ports or if not, what serial adapter are you using?

Make sure no other software is using the serial port. For example, reboot and start Igor before running any other software.

If you are running on VISTA or Window 7, try launching Igor by right-clicking the Igor.exe icon and choosing Run as Administrator.
lin wrote:

Function cmdAg(pp) 
        String pp
    String command = pp +"\n\r"
       
        // initialize port
    VDT2/P=COM5 baud=57600, stopbits=1, databits=8, parity=0
    VDTOperationsPort2 COM5

    VDTWrite2 command
End



CRLF is represented by "\r\n", which is not what you have in your code.
Quote:
CRLF is represented by "\r\n", which is not what you have in your code.


Good catch, 741!
Thanks for the replies :).

I fixed the error pointed out by 741, and rechecked all the parameters (data bits: 8, parity: none, stop bits: 1, flow control: none, termination character: CR/LF). Unfortunately, it still does not work.

I have to mention that the specified baud rate is 921600. However, Igor throws an 'Invalid baud rate error' if I try to set this baud rate. So I tried to run it at a lower baud rate and adjusted the settings of the COM port accordingly. Could this be the problem?
lin wrote:
I have to mention that the specified baud rate is 921600. However, Igor throws an 'Invalid baud rate error' if I try to set this baud rate. So I tried to run it at a lower baud rate and adjusted the settings of the COM port accordingly. Could this be the problem?


VDT2 supports only a limited number of hardcoded baud rates. If my version is still up to date then the fastest rate that it currently supports is 256000 baud. Adapting this to your baud rate (which is pretty high) will require an updated version of the XOP. I'm sure hrodstein will have some thoughts on this later.
Quote:
I have to mention that the specified baud rate is 921600. However, Igor throws an 'Invalid baud rate error' if I try to set this baud rate. So I tried to run it at a lower baud rate and adjusted the settings of the COM port accordingly. Could this be the problem?


That's a very unusual baud rate.

VDT2 supports only the baud rates shown in the VDT2 Settings dialog.

You need to set the piezo controller to use the same baud rate as you set in VDT2. If this is not possible then you will not be able to control the device from Igor.