SPLat Logo

Terminal (for serial comms testing)

NOTICE: SPLat Controls has moved. We are now at 1/85 Brunel Rd, Seaford, 3198. map

Terminal (for serial comms testing)

SPLat/PC contains an integrated serial terminal which has been designed to assist in developing arbitrary communications protocols on a SPLat controller.

A little history

All SPLat controllers have a serial port. This is the port you use to connect the controller to SPLat/PC for programming. It is sometimes called the programming port. On early SPLat models we used an RS232 compatible port, and this has been carried through to recent version of the same products. Specific cases are the SL88 through SL100 family, and the MMI88 through MMI202 family (and possible descendants since this was written). On more recent models we have reduced unit costs by using a CMOS/TTL programming port, and converting it to RS232 via a programming cable (model PC232). This applies to products like CC18, MS120, HD8 and a large number of custom SPLat controllers.

However, the same serial port (sometimes called "COM port", a term popularised in the Personal Computer world) can be used for a lot of external communications during running of your application program (SPLatWare). In SPLat, we first did this by making our proprietary protocol (communications language) SPLatLink available to, for instance, allow users to have a SPLat interact with a PC, maybe for data-logging. Later we implemented ModBus, an industry standard protocol, making it possible for SPLat controllers to connect to thousands of specialised devices like variable speed drives. Most recently we have implemented "User programmable protocols". That means that it is now possible to program SPLat to a huge variety of communications protocols. A typical example of this is 3rd party products, like weigh scales, measurement instruments, motion control boards, etc., which all use their own proprietary formats for sending data or receiving commands.

While SPLatLink and ModBus are "pre-canned" protocols, "User programmable protocols" are definitely not. Developing a user protocol can be quite tricky, and some new tools were required to assist in the process.

More on SPLat serial communications and protocols.

SPLat/PC has two related but distinctly different tools for developing serial communications protocols.

Note: You need to distinguish between developing some arbitrary serial protocol and using the SimpleHMI function that is also built into SPLat/PC. In the first case you will be aiming to interact with some 3rd party product, say a weigh scale, using whatever data formats that device employs. With the SimpleHMI much of the protocol stuff is taken care of for you under the hood, and you can concentrate on your application specific requirements.

Invoking the terminal

The terminal is invoked by the button labelled "SIO" (Serial Input/Output) on the Module window (older releases of SPLat/PC called this Trm)

If you don't see that button you need to upgrade SPLat/PC. You cannot use the terminal and SPLatLink at the same time. You can only use the terminal when not in the Connected state, meaning interacting with the controller to download programs or manipulate the controller I/O.

The terminal will use the same serial port on your computer as you use for programming (COM 1 in the above screen shot). That's one of the benefits of using the SPLat/PC terminal rather than a general purpose terminal emulator like HyperTerm or SuperTerm ... there's no need to swap cables and/or ports, or to fiddle to get SPLat/PC to free the port.

When you click SIO, a new window should appear that has 3 tabs along the top, labelled Terminal, SimpleHMI and Settings. Click the Terminal tab.

The terminal looks like this:

The top black window displays serial data transmitted out of the SPLat Controller. You can chose to display in ASCII or hexadecimal. ASCII is best for human readable or "printable" material. Hex is best for binary data.

The bottom half is for data to be sent to the SPLat controller. There is room for four messages.

You can set the communication setting by clicking the Settings tab, which will expose the following setting pane:

The numbers before the colons correspond to the number used in the Communications Control Block (CCB); any combination you select here can be "reached" by a SPLat controller (and visa versa). The defaults are as shown. The current settings are shown at the bottom of the main terminal screen.

Communicating with the terminal (from your SPLat program)

You need to understand the communications (serial input and output) instructions. You also need to understand the Open_Serial hash command and its ramifications.

Viewing data transmitted out of the SPLat

Data transmitted out of the SPLat, and received by the terminal, is displayed in the top half of the terminal ("Rx"). Try running the following program with default comms settings in the terminal:

#       Open_Serial User(38400,8,N) ;Initialise the serial port to User protocol at 38.4 KBaud
        iiPrintText     251,"Hello World",'0D,'0A
        iiPrintText     251,"How are you?",'0D,'0A
A:      GoTo            A
           

This program uses a Hash Command to initialise the serial port. Hash commands exist in SPLat/PC Build 160 or later

When started, this will pause for 10 seconds (a forced delay before the user protocol kicks in), then send a message out of the serial port. If you have switched to the terminal before then, you should see the result in the Rx window. Click on the ASCII button so you can read it.:

You will notice that the two iiPrintText instructions both have '0D,'0A at the end. These are carriage return (CR) and line feed (LF). They force the terminal to a new line, but are otherwise invisible. Now click the HEX button. The display will switch to showing raw character codes, in hexadecimal:

Now the normally readable characters have become somewhat meaningless hex codes (unless you are an übergeek and read War and Peace in hex, for recreation), but the CR and LF have become visible. On the other hand, you could check a Hex/ASCII table and confirm the codes above.

You will discover that the only way you can connect SPLat/PC to your controller is to power cycle the controller and connect in the first 10 seconds. This is because once the "user protocol" kicks in, the controller cannot recognise a SPLat/PC command to stop. If you change the GoTo to a GoSub, you will not have to power cycle the controller to re-gain control from SPLat/PC. Why? That is an exercise for you, Gentle Reader!

Sending to the SPLat

The bottom half of the terminal window has space for four "pre-canned" messages that can be transmitted via the serial port to the SPLat. These messages are remembered between SPLat/PC sessions. Naturally, the SPLat program needs to be looking out for such messages. This is where the ComRx-something instructions come in.

The basic idea it that you enter a message and then click the corresponding Send button. You can send the same message several times.

Messages can be composed of ASCII characters and hex codes preceded by an apostrophe, and can also have comments following a single semicolon. Hence the following will send "Hello SPLat" plus CR and LF, but not ";test message"

Hello SPLat '0D '0A ;test message

If you want to send an apostrophe you can enter its hex code, '27, or two apostrophes, or an apostrophe followed by anything but a hex digit. If you want to send a semicolon you can enter its hex code, '3B, or two semi-colons. At the bottom of the Tx area is a pane that shows you, in hex, exactly what will get sent from the currently selected message box. Experiment! You won't break anything.