CQM1 SMS Alarm: Configuring GSM Modem with CX-Supervisor

James Nishida10 min read
OmronSCADA ConfigurationTutorial / How-to
Licensed PE Working through this on a live machine? A Maine-licensed engineer can take it from here — included with IMD hardware, by the hour for everything else. Book an engineer

1. Overview

The Omron CQM1 compact PLC and CX-Supervisor SCADA package form a classic alarm-notification stack that is still common in retrofit and small-machine installations. The engineering pattern in this reference uses the CQM1's built-in RS-232C ports to communicate with CX-Supervisor on COM1, while a separate GSM modem occupies COM2 for SMS dispatch. When the ladder program raises an alarm bit, a CX-Supervisor script sends AT commands to the GSM terminal, and the modem transmits a short text message to a maintenance phone.

Three SMS delivery paths are available, listed here in increasing order of hardware footprint:

  • Serial GSM terminal (e.g., Siemens TC35/TC35i) attached to a PC COM port.
  • Legacy handset with a serial data cable (older Siemens, Ericsson, Nokia products).
  • Conventional landline modem using a GSM-to-PSTN adapter or direct SMS-capable PSTN modem.
  • HTTP SMS gateway (Twilio, Clickatell, BulkSMS, vendor SDK) reached over ordinary Internet.

The first three paths are local to the cabinet and need no Internet service; they only require a SIM card with a voice/SMS tariff from any mobile operator. The fourth path is preferred when the cabinet is moved frequently or the GSM reception is poor at the plant.

2. Prerequisites

Item Minimum Specification Notes
PLC CPU CQM1-CPUxx with two physical serial ports (RS-232C + RS-422 or dual RS-232C option board) Host Link protocol on the port facing the PC
Programming software CX-Programmer 5.x or later (CX-One) Required to author and download the ladder
SCADA software CX-Supervisor 3.x or later (CX-One) VB or Java script host
GSM modem Siemens TC35i or equivalent AT-command terminal Insert SIM before power-on; PIN disabled if possible
SIM card Standard voice/SMS tariff, no data plan required Verify APN is not needed for SMS-only
PC Two free RS-232C ports (USB-to-serial adapters acceptable) One for PLC, one for modem
Serial cabling Null-modem (cross-over) DB9 cables for both legs CQM1 uses standard Host Link pin-out
Important: The CQM1 supports Host Link (SYSWAY) and Toolbus. Host Link is the correct mode for CX-Supervisor polling because it allows unsolicited message reception from the PLC. Toolbus is point-to-point only and is reserved for CX-Programmer.

3. Hardware Topology

The topology separates the deterministic data path (PLC <-> SCADA) from the asynchronous alert path (SCADA <-> GSM modem). Both paths terminate on the same PC, but they never contend because the PLC never talks to the modem and the modem never talks to the PLC.

+-----------+    COM1 (Host Link)    +-------+
| CQM1 CPU  | <--------------------> |  PC   |
+-----------+                        |  CX-  |
                                     | Sup.  |
                                     |       |
                                     |       |   COM2 (AT cmd)
                                     |       | <----------+
                                     +-------+            |
                                                          v
                                                  +----------------+
                                                  |  GSM Modem     |
                                                  | (TC35i + SIM)  |
                                                  +--------+-------+
                                                           |
                                                           | SMS
                                                           v
                                                   +---------------+
                                                   | Maintenance   |
                                                   | Phone         |
                                                   +---------------+

Pin assignment follows Omron's standard Host Link cable (XW2Z-200S-CV or equivalent). The modem leg uses a straight-through cable unless the TC35i documentation specifies otherwise; the module's DCE/DTE jumper is normally set for DCE.

4. CQM1 Port Configuration

Open CX-Programmer and inspect the PC Interface Settings dialog before downloading the project. The PC port here refers to the CX-Programmer download channel, not the runtime SCADA channel. The values below correspond to the CQM1's DIP-switch and DM-parameter settings used at commissioning.

Parameter DM Address Value Meaning
Port 1 protocol DM6645 bits 12-15 0x0 (Host Link, default) Use Host Link for SCADA
Port 1 baud DM6645 bits 00-03 0x9 (19200 bps) Or 0x6 (9600) for legacy COM ports
Port 2 protocol DM6646 bits 12-15 0x0 (Host Link) or 0x1 (RS-232C data) Selecting 0x1 frees the port for free ASCII I/O
Port 2 baud DM6646 bits 00-03 0x6 (9600) for TC35i default Match modem AT+IPR if set
Node address DM6648 (low) / DM6649 (high) 0x00 (master polling) Set SCADA as default unit 0; PLC gets 1
Each 0 in the value column reflects an explicit choice; the CQM1 default for many parameters is 0 already. Always re-flash DM parameters after a battery replacement or a new project download or the ports can revert to Host Link regardless of the new ladder.

If the application needs the PLC to originate SMS messages without the SCADA PC, configure Port 2 with the RS-232C free-data mode (DM6646 = 0x1006) and use TXD(48) instructions in the ladder to send ASCII frames directly to the modem. This bypasses CX-Supervisor entirely and is the recommended path when the PC is optional.

5. Ladder Logic for Alarm Generation

A minimal alarm-detection rung uses a comparator against a threshold and a SET instruction on a dedicated alarm word. CX-Supervisor polls this word cyclically through Host Link; the SCADA script reacts to the rising edge.

-- Rung 1: Threshold alarm
|--[ LD 200.00 ]--[ > D200 D201 ]--[ SET 100.01 ]--|
|   (process    | (analog value   | (alarm bit     |
|    running)   |  vs setpoint)   |  for SCADA)    |

-- Rung 2: Latch reset on operator acknowledge
|--[ 250.00 ]--[ RSET 100.01 ]--|
|   (ack from HMI)

-- DM201 holds the alarm setpoint in BCD

Word W100 can be assembled into a 16-bit alarm map so a single Host Link read retrieves all 16 alarm sources. CX-Supervisor maps each bit to a discrete point tag.

6. CX-Supervisor Script Configuration

CX-Supervisor supports Microsoft VBScript and, in newer builds, Java-based extensions. Either scripting engine can open the second COM port, write AT frames, and read the modem's response.

6.1 Create the Alarm Point

  1. Open the CX-Supervisor project and select Project > Points > Add.
  2. Define point ALM_HIGH_PRESSURE with PLC address 100.01 and update on Change.
  3. Add an action in the point's Events tab: select the On True event, choose Run Script, and call SendSMS(ALM_HIGH_PRESSURE.Value).

6.2 Open the GSM Port

The following VBScript snippet, placed in the project script section, opens COM2 at 9600 8N1 and verifies that the modem responds to a basic AT command before any alarm is allowed to fire.

' Project_Scripts.bas
Dim g_modem
Sub Project_Start()
    Set g_modem = CreateObject("MSCOMMLib.MSComm")
    g_modem.CommPort = 2            ' COM2
    g_modem.Settings = "9600,N,8,1"
    g_modem.InputLen = 0
    g_modem.RThreshold = 1
    g_modem.PortOpen = True
    AT_Query "AT"                   ' expect "OK"
    AT_Query "AT+CMGF=1"            ' switch to text mode
    AT_Query "AT+CSMP=17,167,0,0"   ' set SMSC and validity
    g_modem.PortOpen = False
End Sub

Sub AT_Query(cmd)
    g_modem.Output = cmd & vbCr
    Wait 0.2
    Debug.Print g_modem.Input        ' echoes back to CX-Supervisor log
End Sub

Sub SendSMS(reason)
    Dim number, body
    number = "+15551234567"         ' operator on-call
    body   = "Plant alarm: " & reason & " at " & Now
    g_modem.PortOpen = True
    g_modem.Output = "AT+CMGS="" & number & """ & vbCr
    Wait 0.2
    g_modem.Output = body & Chr(26) ' Ctrl+Z terminates SMS
    Wait 1.0                        ' SMS submission
    g_modem.PortOpen = False
End Sub

Use Project_Start() as the project's Startup macro so the modem hand-shake occurs once at SCADA boot. Avoid opening COM2 until after CX-Supervisor has finished initialising its Host Link session on COM1; otherwise the OS may allocate both COMs to a single process and collide with the PLC driver.

Tip: If the GSM module is reachable only on a virtual COM port created by a USB driver, verify the COM number in Windows Device Manager. Pinned VCPs disappear when the USB cable is unplugged and reappear on a different number after reboot.

7. AT-Command Reference for SMS

All SMS-related AT commands follow the ETSI GSM 07.05 specification. The subset below is sufficient for alarm text messages.

Command Expected Response Function
AT OK Modem presence check
AT+CMGF=1 OK Switch to text mode (vs PDU mode)
AT+CMGS="+1..." > (prompt) Begin SMS submission to number
message body + Chr(26) +CMGS: nn and OK Submit text and end with Ctrl+Z
AT+CSCA="+1..." OK Program SMS service centre address
AT+CSQ +CSQ: rssi, ber Query signal quality; rssi 0-31, 99 = unknown
AT+CREG? +CREG: n, stat Network registration status; stat 1 or 5 = home/roaming
AT+CMGL="ALL" +CMGL: idx,... lines List stored messages (if AT+CNMI not used)

PDU mode (AT+CMGF=0) is required for binary content, concatenated messages above 160 characters, or Unicode. For a one-line alarm text, PDU mode is unnecessary.

8. SMS Gateway Alternative

When a SIM card and a GSM modem are inconvenient (no cellular coverage, frequent PC moves, or large message volume), an HTTP-based gateway delivers the same outcome over the existing Internet connection. The CX-Supervisor script is rewritten to call the gateway's REST endpoint rather than open a serial port.

' Gateway path - example using BulkSMS-compatible API
Sub SendSMS_Gateway(reason)
    Dim http, url, body
    Set http = CreateObject("MSXML2.XMLHTTP")
    url = "https://api.example.com/sendsms?u=USER&p=TOKEN&to=" & _
          "+15551234567&text=" & Server.URLEncode("Plant alarm: " & reason)
    http.open "GET", url, False
    http.send
    Debug.Print http.status, http.responseText
End Sub

This approach demands outbound HTTPS on TCP 443 and a stable Internet connection. It removes the SIM management burden and the AT-command round-trip and is the recommended path when the SCADA PC is already networked. A hybrid is also valid: keep the local GSM path for primary alerts and the gateway as a redundant secondary channel.

9. Verification Procedure

  1. Download the ladder project and the CX-Supervisor project to their respective targets.
  2. Force-set W100.01 from CX-Programmer's watch window.
  3. Confirm the CX-Supervisor log records the alarm going True and that Project_Start() executed without error.
  4. Within five seconds the operator phone should receive a text beginning with the configured prefix.
  5. Use AT+CMGL="ALL" on the modem to confirm the message was sent and acknowledged.
  6. Reset the alarm bit from the HMI and confirm ALM_HIGH_PRESSURE returns to 0; check that no further SMS is dispatched until the next rising edge.
Check Expected Tool
PLC <-> SCADA polling No host link errors in CX-Supervisor log; point values update each cycle CX-Supervisor "Log" tab
Modem presence OK reply to AT HyperTerminal or PuTTY on COM2
Network registration +CREG: 0,1 or 0,5 AT+CREG?
Signal strength +CSQ returns rssi ≥ 10 AT+CSQ
End-to-end SMS Operator phone receives within 10 s Operator phone

10. Troubleshooting Matrix

Symptom Likely Cause Diagnostic Remediation
SCADA never sees alarm Wrong PLC address or Host Link parity CX-Programmer "Online" watch Verify DM6645/6646; check 7E2 vs 8N1
AT returns no echo Wrong COM port or cable PuTTY 9600 8N1 on COM2 Swap null-modem cable; disable pin 1 echo
+CMS ERROR: 515 SIM PIN still active Insert SIM in phone, disable PIN Reinsert SIM into modem and reboot
SMS arrives but truncated Modem in PDU mode but script sends text AT+CMGF? Force AT+CMGF=1 at startup
First SMS succeeds, subsequent fail Port not closed between sends Inspect PortOpen state Always g_modem.PortOpen = False after write
Duplicate SMS per alarm Script bound to both On True and On Change Point Event list Bind script to a single rising-edge event
Modem loses registration overnight Antenna or power starved AT+CREG? after 8 h Use external antenna; verify 12 V supply > 1 A
Gateway returns HTTP 403 Token expired or IP allowlist Manual curl Refresh API token; whitelist SCADA IP

11. Field-Proven Caveats

  • Set the TC35i to a fixed baud rate with AT+IPR=9600 and store it with AT&W; autobaud can hang on cold start.
  • Always pre-pend the international + and country code; a national-format number silently fails in some operator networks.
  • Long alarm bursts can saturate the SIM. Use a downstream queueing service if the application generates more than one alarm per minute.
  • CX-Supervisor's VBScript host is single-threaded; do not block on a slow modem inside a frequently-called point event. Push the alarm into a queue and drain it from a periodic timer.
  • Disable PIN on the SIM before deployment; if the PIN must remain, store it in the modem with AT+CPIN="1234" and not in the SCADA script.

Which serial port on the CQM1 should host the GSM modem?

Use the CQM1 port that is not already serving the SCADA link. In a typical PC with two COM ports, place the PLC on COM1 and the GSM modem on COM2. If the CQM1 has only one physical RS-232C, the PC-based approach with a USB-to-serial adapter or the HTTP gateway path is preferable.

Do I need Java or just Visual Basic inside CX-Supervisor?

CX-Supervisor supports both VBScript and Java. VBScript is the most common choice for serial-port work because the MSComm ActiveX control is well documented; Java is appropriate when the application already has a Java back-end or when porting code from an embedded target.

Why are my AT commands receiving no response?

Confirm cable type (null-modem for PC-to-modem), baud rate parity (8N1 is the TC35i default), and that the SIM is registered with AT+CREG?. Ensure the COM port is opened before writing and that InputLen is set so the script does not stall waiting for a terminator.

Is the SIM-card SMS service the same as my mobile phone tariff?

Generally yes. A standard voice/SMS tariff from any operator can send messages through a GSM modem. Some M2M-specific tariffs include bundled SMS at a lower per-message price; pick one of those when message volume is high.

Can the PLC itself send the SMS without the PC?

Yes. Configure CQM1 Port 2 for RS-232C free-data mode (DM6646 set to 0x1006 or equivalent) and use TXD(48) instructions in the ladder to transmit the ASCII payload followed by Ctrl+Z. This removes the PC from the alert path but requires the modem to be wired directly to the CQM1.

Back to blog