Coaxial switch with remote serial RS-232 interface programming example

Summary: this article describes how to control LinkBone Coaxial switch with remote control via serial RS-232 interface. The complete code example in C++ with description is included.
CoaxialBNC switch with Remote access from LinkBone

This article is related with the following products:

The LinkBone Remote Coaxial BNC switch allows to connect different endpoints to the one common point. The device operation can be compared to the analog multiplexer forwarding signals from set of selected inputs/outputs into one signal line. Each link connection is bidirectional. Meaning that the device connected to the common port can be a signal source or receiver. The example of system with one common signal generator and several receivers is shown on figure 1.

LinkBone coaxial switch with remote control in clock 10Mhz distribiuton applicationFigure 1: Coaxial switch with remote used as a clock distributor/switch

The output of signal generator is being multiplexed between receiver systems. Each of line switches is controlled individually. This allows to connect more than one output to the common input port of the Remote Coaxial BNC switch. The LinkBone coaxial switch has very low impact on routed signals. Figure 2 shows the 10Mhz clock signal used in analyzed system example. The yellow waveform plot represents the 10Mhz square wave signal routed from signal generator to device under test. The blue plot shows  signal connected directly from signal generator to the target system. Directly connected signal has 9.8ns edge rise and fall times. The signal routed over LinkBone switch has a 10.2ns edge rise/fall times. The 0.4ns signal edge time difference is the result of limited Coaxial switch bandwidth.

 

Coaxial switch with remote access routing 10Mhz square clock signalFigure 2: Compassion of 10Mhz square signal routed over LinkBone Coaxial switch and direct connection.

The LinkBone Coaxial switch with remote control can be controlled via PC executing a test script.  The device accepts an easy to use set of text commands send over serial RS-232.

Coaxial switch with remote control via serial RS-232 interface

The state of the internal connections in the Coaxial switch with remote control is controlled by serial RS-232 interface. The device offers different baud rate options and handshake control flows. The configuration of the interface is done via a touch screen on the front panel of the device. The serial RS-232 configuration options menu is visible on figure 3. The user can set the baudrate, the parity bit value, number of stop bits and hardware flow of serial RS-232 interface.

 

LinkBone Coaxial switch with remote serial RS-232 interface settings menu

Figure 3: RS-232 interface configuration menu

The Remote Coaxial BNC switch state is controlled by a simple set of text commands. Commands can be executed using a text terminal or automated test program. The figure 4 shows PuTTY terminal connected to the LinkBone Coaxial switch with remote command line interface. The PuTTY terminal can be downloaded from PuTTY Homepage

The list of text commands accepted by LinkBone Switch:

  • help – prints the list of available commands
  • info – prints information about the device
  • mode <mode> – sets the operation mode of the device
  • off <ports> – disconnects selected port from common port P
  • on <ports> – connects selected port to common port P
  • reset – reset/disconnect all ports
  • status – prints information about status of the switch
  • ping – checks if connection to the device is active by replying ‘Pong’
  • quit – closes current session, this command is only available for a Telnet clients

Putty terminal connectd to LinkBone Coaxial Switch

Figure 4: PuTTY terminal connection to LinkBone Coaxial switch with remote control.

Commands accepted by a LinkBone Coaxial switch can be executed by hand or by automated test program. This section includes two example command sequences explaining how does the ‘singe’ and ‘multi’ mode impacts coaxial switch operation.

The first script enables ports A,B,C,D using the ‘single’ mode (device acts as a multiplexer). This means that in the first step A port is being connected to common port. Then B port is enabled and A port is disconnected.

reset
mode single
on A
on B
on C
on D

The LinkBone Remote Coaxial switch can also operate in ‘multi’ switching mode allowing to connect more than one port to common node. The following example enables all four A,B,C,D ports at the same time. Then ‘off’ command disconnects B and C ports.

reset
mode multi
on A B C D
off B C

At the beginning of the two given example scripts there is a ‘reset’ command to disconnect all coaxial switch ports. The second ‘mode’ command sets the port switch to ‘single’ or ‘multi’ mode. The mode command parameter impacts the ‘on’ and ‘off’ command behavior.

Coaxial switch with remote control via Windows command line interface

The Coaxial switches can be also controlled via Windows command line interface or from bath file(*.BAT or *.CMD). The example command outputs are shown on figure 5.

To start the communication with the coaxial switch an serial port connection settings have to be set up. The following command sets the COM5 baudrate to 9600, data word length to 8 bits with one stop bit. The parity bit is disabled.

mode COM5 BAUD=9600 PARITY=n DATA=8 STOP=1

To send the text command to the coaxial switch an echo output needs to be redirected to serial port (COM5) by using “>” sign.

echo reset > COM5
echo mode single > COM5 
echo on A > COM5
echo on B > COM5

Coaxial switch with remote command execution in windows by command line

Figure 5: Windows command line window with Coaxial switch remote command execution.

Coaxial switch with remote control via test program in C++

The LinkBone Coaxial switch can be controlled from C/C++ program level. The following paragraph shortly explains how to setup an serial port and send text commands to the device. This is an basic remote control code example. User should add necessary functions for external instrument control and measurement taking.

First the serial port connection has to be open via the following code:

    //open to serial port connected to LinkBone coaxial switch with remote control
    HANDLE port = connectToSwitch("COM4");
    if (port==INVALID_HANDLE_VALUE) // if error exit the program
        return 0;

After setting the serial port, test commands can be send to the switch by using sendToSwitch(port, command) function. The first function parameter is the serial port handle. The second parameter is the text command to be send to the coaxial switch.

             
    //send control commands to LinkBone coaxial switch with remote control 
    sendToSwitch(port, "reset\n");
    sendToSwitch(port, "mode single\n");    
    
    sendToSwitch(port, "on A\n");
    //doSomething();
 
    sendToSwitch(port, "on B\n");
    //doSomething();

A good practice after main program execution is to close serial port. The following code can be used for closing serial port connection.

    //close the port serial connection to LinkBone coaxial switch with remote control 
    CloseHandle(port);
    printf("Test program completed. Press an key to continue.\n");
    getch();
    return 0;

Full source code can be found here. The code includes sendToSwitch() and connectToSwitch() function implementation.  To compile the example program a wxDev C++ environment is needed.

LinkBone