Overview
Wireless serial communication between PLCs and operator interfaces opens new possibilities for retrofits, hard-to-reach installations, and mobile HMIs. This technical reference covers integrating Digi XBee radio modules with the Parallax Stamp PLC (#30064) and the Omron CPM2A series PLC, using point-to-point and point-to-multipoint RS-232 replacement topologies. Engineers will find serial electrical specs, AT command parameters, Host Link framing, PBASIC code, latency budgets, antenna selection, power budgeting, and field troubleshooting guidance.
The reference assumes the engineer is comfortable with RS-232 voltage levels, the concept of UART framing (start, data, parity, stop bits), and has access to a terminal emulator such as Parallax Serial Terminal, Tera Term, or PuTTY for AT-mode configuration of the XBee modules. Where API mode or firmware updates are required, Digi's XCTU utility is the recommended configuration tool.
Hardware Architecture
Parallax Stamp PLC (#30064)
The Parallax Stamp PLC is a BASIC Stamp 2 (BS2-IC) based programmable logic controller that exposes PBASIC to industrial control. The BS2-IC runs PBASIC 2.5 and provides two built-in serial instructions:
SEROUT pin, baudmode, [data]
SERIN pin, baudmode, [data]
These instructions drive the on-board RS-232 transceiver that appears on serial port 1. The port can be reconfigured for baud rates from 300 to 50,000 bps by selecting the appropriate baudmode constant in PBASIC.
| Parameter | Spec |
|---|---|
| Processor | BS2-IC @ 20 MHz |
| I/O | 16 I/O pins (P0-P15) |
| Program memory | 2 KB EEPROM (~500 PBASIC lines typical) |
| Data EEPROM | 2 KB |
| Serial port 1 | RS-232, DB9 male, DCE-style |
| Programming connection | Same DB9 port, 9600 bps default inverted |
| Operating voltage | 9 VDC adapter or 7.5 VDC battery pack |
| Current draw | 40 mA typical, 60 mA peak |
Reference: Parallax Stamp PLC product page; Stamp PLC datasheet (PDF).
Omron CPM2A
The Omron CPM2A is a compact micro-PLC widely used in discrete automation. Its serial capabilities are critical for any wireless bridging design:
| Port | Type | Protocol | Default Settings |
|---|---|---|---|
| Port 1 (RS-232C) | RS-232C, D-sub 9-pin | Host Link / NT Link / no-protocol | 9600, 7,E,2 (Host Link) |
| Port 2 (RS-422/485) | RS-422A / RS-485 | Host Link / NT Link / no-protocol / peripheral bus | Configurable via DM |
For wireless Host Link bridging, Port 1 in Host Link mode is the most common target because most HMI/SCADA packages already speak Host Link and the CPM2A is widely deployed as a peer on the plant floor. Host Link frame format is the standard @-delimited ASCII protocol used across the Omron CP/CJ/CS family.
Reference: Omron CPM2A product family; CPM2A Datasheet (PDF).
Digi XBee Radio Modules
The XBee family provides drop-in wireless serial replacement. The most relevant families for PLC work:
| Model | Protocol | Frequency | RF Data Rate | UART Max | Range (LOS) |
|---|---|---|---|---|---|
| XBee S1 (XB24) | IEEE 802.15.4 | 2.4 GHz | 250 kbps | 115.2 kbps | 100 ft / 300 ft (Pro) |
| XBee S2C | ZigBee 3.0 | 2.4 GHz | 250 kbps | 115.2 kbps | 200 ft / 4000 ft (Pro) |
| XBee SX 900 | DigiMesh | 900 MHz | 250 kbps | 115.2 kbps | Up to 65 miles (Pro) |
| XBee 3 | ZigBee 3.0 / DigiMesh | 2.4 GHz | 250 kbps | 115.2 kbps | 200 ft / 4000 ft (Pro) |
For PLC retrofit work inside a plant, the XBee S2C or SX 900 is typical. The XBee S1 remains common for legacy point-to-point links and is the cheapest option for a simple cable replacement. The XBee 3 adds MicroPython programmability and Bluetooth Low Energy for commissioning via phone, which can simplify initial setup on a tall ladder or a remote control panel.
Reference: Digi XBee product family; XBee S2C user guide.
RS-232 Electrical Interface
XBee modules expose a UART at CMOS/TTL levels (0-3.3 V). The Stamp PLC and CPM2A both expose true RS-232 (+/-3 V to +/-15 V on the line). A level translator is required between any XBee and a true RS-232 port.
| Translator | Source | Notes |
|---|---|---|
| MAX3232 breakout board | SparkFun, Adafruit | 3.3 V logic in, +/-5 V RS-232 out |
| Parallax USB-to-RS232 (28030) | Parallax | Industrial-grade DB9 male/female |
| XBee Explorer USB (WRL-08687) | SparkFun | Includes FT232RL + 3.3 V regulator |
| XBee Explorer Serial (WRL-09132) | SparkFun | DB9 through-hole, 3.3 V logic only |
For a non-USB host, the SparkFun XBee Explorer Serial with an external MAX3232 is the lowest-cost field solution. The XBee is 3.3 V only; tying any XBee pin to 5 V damages the radio permanently.
Wiring Topologies
Topology A: Stamp PLC to PC/HMI Wireless Pair
[PC running HMI software]
|
| USB-to-RS232 (or USB XStick)
v
[XBee Coordinator, 115200,N,8,1]
<-- 2.4 GHz link, 100-300 ft -->
[XBee End Device on plant side]
| MAX3232 level translator
v
[CPM2A Port 1 DB9 OR Stamp PLC P0/P1 UART]
Topology B: Stamp PLC as Wireless Bridge for CPM2A
For retrofits where the CPM2A cannot be moved and a wired Host Link run is impractical, the Stamp PLC can sit in-line between the CPM2A and the XBee radio:
[HMI / SCADA PC]
|
v
[XBee Coordinator]
<-- RF link -->
[XBee Router]
|
v
[Stamp PLC P0/P1]
|
v
[CPM2A Port 1 (Host Link)]
In this topology the Stamp PLC runs a transparent Host Link pass-through. Its two UARTs (one via P0/P1 to the XBee, one via the DB9 to the CPM2A) operate at the same baud and parity; the Stamp simply moves bytes between them with a small FIFO.
XBee Point-to-Point Configuration
For a simple cable replacement between a Stamp PLC or CPM2A and a remote HMI/PC, two XBees configured as a transparent serial pair is sufficient. All commands below assume XBee S2C firmware 802.15.4 mode (ATAP 0).
Coordinator (Host Side)
+++ (enter AT command mode; guard time 1 s default)
AT (verify module responds OK)
ATRE (factory reset - wipes PAN ID, channel, DH/DL)
ATBD 7 (set UART to 115200 bps; 0=1200..7=115200)
ATD7 1 (set DIO7 as CTS - flow control)
ATD6 1 (set DIO6 as RTS)
ATAP 0 (transparent mode, not API)
ATDH 0 (destination address high = 0)
ATDL 0x1234 (destination address low = your remote's 64-bit SH+SL)
ATMY 0x5678 (this module's 64-bit address)
ATID 0x1A2B (PAN ID)
ATCH 0x0C (802.15.4 channel 12)
ATCN (exit AT command mode; applies settings)
ATWR (write to non-volatile memory)
End Device (Stamp PLC / CPM2A Side)
+++
ATRE
ATBD 7
ATAP 0
ATDH 0
ATDL 0x5678 (mirror the coordinator's MY)
ATMY 0x1234
ATID 0x1A2B
ATCH 0x0C
ATCN
ATWR
The two modules must share PAN ID and channel. They do not need to share MY/DL if you only want broadcast or any-coordinator behavior, but explicit addressing is the only way to ensure deterministic latency and avoid airtime collisions with other 2.4 GHz networks on the same channel.
Reading Back the Configuration
+++ (1 second guard before and after)
ATMY (returns MY value)
ATDL (returns DL value)
ATBD (returns UART baud index)
ATVR (returns firmware version)
ATCN (exit)
Always document the BD, CH, ID, MY, DL, VR of every deployed XBee on the network diagram. Half of all field service calls end up being an undocumented module whose address was forgotten.
PBASIC Code on the Stamp PLC
The Stamp PLC's SERIN/SEROUT can read from the XBee-attached pin and forward data to other I/O. Sample PBASIC fragment for an operator-interface-style polling loop:
' {$STAMP BS2}
' {$PBASIC 2.5}
XBeeRX PIN 0 ' XBee DOUT -> Stamp P0 (through MAX3232 if RS-232)
XBeeTX PIN 1 ' XBee DIN <- Stamp P1
Led PIN 8 ' Status LED
Baud CON 16468 ' 9600 baud, inverted (RS-232)
idx VAR Byte
ch VAR Byte
Main:
SEROUT XBeeTX, Baud, ["PING", CR]
FOR idx = 1 TO 5
SERIN XBeeRX, Baud, 1000, Timeout, [ch]
DEBUG ch
NEXT
HIGH Led
PAUSE 200
LOW Led
GOTO Main
Timeout:
DEBUG "RX timeout", CR
RETURN
If the XBee side is at 3.3 V CMOS and the Stamp PLC serial port 1 already includes an RS-232 transceiver, the cleanest path is to wire a dedicated second serial pin pair (P0/P1) for XBee communication, leaving the DB9 for programming/debugging. This eliminates mode switching every time the firmware is downloaded.
The Stamp's PBASIC SERIN with timeout is the right primitive for polling; without a timeout the program will hang indefinitely if the XBee drops the link. Always pair every wireless SERIN with a timeout branch.
Omron CPM2A Host Link Bridging
Host Link is Omron's master/slave serial protocol on the CPM2A. Frame format:
| Field | Bytes | Notes |
|---|---|---|
| @ | 1 | Header |
| Unit No. | 2 | "00" typically |
| Header code | 2 | e.g., "RD" for read, "WR" for write |
| Text | variable | Command-specific |
| FCS | 2 | 1-byte XOR + ASCII hex |
| *CR | 2 | Terminator |
A wireless bridge running on the Stamp PLC can read/write DM area words:
' Read DM0000 from CPM2A unit 00
' Host Link command: @00RD0000000158*
' Expected response: @00RD00xxxxFCS*CR
SEROUT XBeeTX, Baud, ["@00RD00000001", CR]
SERIN XBeeRX, Baud, 2000, Timeout, [STR buf\17]
For new deployments, configure CPM2A Port 1 for Host Link via the PLC Setup area:
| Setup word | Address | Value | Meaning |
|---|---|---|---|
| Port 1 settings | DM6650 | 0000 | Standard Host Link, 9600, 7,E,2 |
| Port 1 baud etc. | DM6651 | 0604 | Standard Host Link default |
| Unit number | DM6653 | 0000 | Slave address 00 |
Reference: CP Series Programming Manual (PDF).
Worked Example: Read DM0000 Every Second
This Stamp PLC sketch forwards a Host Link poll to the CPM2A and returns the response verbatim over the XBee link:
' {$STAMP BS2}
' {$PBASIC 2.5}
XBeeRX PIN 0
XBeeTX PIN 1
Cpm2aTX PIN 2
Cpm2aRX PIN 3
Led PIN 8
Baud CON 16468 ' 9600 baud, inverted
PollStr CON "@00RD0000000158*", CR
idx VAR Byte
ch VAR Byte
Main:
SEROUT Cpm2aTX, Baud, [PollStr]
FOR idx = 1 TO 17
SERIN Cpm2aRX, Baud, 1500, Timeout, [ch]
SEROUT XBeeTX, Baud, [ch]
NEXT
HIGH Led : PAUSE 50 : LOW Led
PAUSE 1000
GOTO Main
Timeout:
SEROUT XBeeTX, Baud, ["TIMEOUT", CR]
RETURN
The two SEROUT operations at the end of each byte must not exceed the XBee buffer (256 bytes). With 17 bytes per Host Link read this is fine; for high-bandwidth DT reads, switch the XBee to API mode and use explicit frames.
XCTU-Based Configuration
While the AT command set works for two-radio setups, the Digi XCTU utility is recommended for anything more complex. XCTU provides:
- GUI display of all XBee parameters (config, addressing, I/O, sleep).
- Live RSSI versus time plots for site surveys.
- Firmware update across the entire S2C family.
- Frame generator for API mode testing.
- Console window with full hex view of API frames.
For a wireless PLC link, run a 5-minute range test in XCTU (Tools -> Range Test) at the install location before commissioning. If the link drops below -90 dBm or shows more than 5 percent packet loss, swap to a higher-gain antenna or step up to XBee PRO SX 900 MHz for better wall penetration.
Antenna Selection and Site Survey
Antenna choice is often the difference between a 100-foot link and a 300-foot link. The XBee ships with a 1/4-wave whip (2.5 dBi). Options:
| Antenna | Gain | Use Case |
|---|---|---|
| Whip (included) | 2.5 dBi | Line-of-sight, short range, prototyping |
| Dipole external | 5-6 dBi | Outdoor fixed installations |
| Patch / panel | 8-10 dBi | Point-to-point with clear Fresnel zone |
| Yagi | 12-15 dBi | Long-range directional, requires alignment |
Site survey steps:
- Mount both radios at their final locations with the planned antenna.
- Run XCTU Range Test for at least 5 minutes, capturing RSSI distribution.
- Verify median RSSI > -80 dBm and 95th percentile packet loss < 1 percent.
- If thresholds fail, reposition antennas or swap to higher gain.
- Re-test with plant machinery running; motors, VFDs, and welding inverters raise the noise floor on 2.4 GHz.
Power and Enclosure for Remote PLCs
If the remote node is a Stamp PLC tethered only to the CPM2A, you can power it directly from the CPM2A's 24 VDC supply via a buck regulator. The Stamp draws 40-60 mA at 9 V; a 24-to-9 VDC switching regulator (e.g., Recom R-78E9.0-0.5) is sufficient.
For a fully wireless retro-fit where no AC is available:
- Solar: 10 W panel + 7 Ah SLA battery + 24 VDC bus runs a Stamp + XBee pair for 5-7 days without sun.
- PoE: Inject 48 V at the wired side; the remote XBee end uses a 5 W PoE splitter to 5 VDC for the radio and a boost converter for the Stamp.
- Battery: 4x AA alkaline cells at 6 V feed the Stamp's onboard regulator for ~30 hours of polling at 1 Hz.
Enclosure selection matters: ABS plastic is RF-transparent. Steel NEMA 4 enclosures attenuate 2.4 GHz by 15-25 dB and must use an external bulkhead-mount SMA antenna. Aluminum attenuates less than steel but still warrants an external antenna for any reliable link beyond a few meters.
Wireless Latency and Online Editing
Online edits on the CPM2A require round-trip Host Link acks that take roughly 50 ms per packet over a wired port. Over an XBee S2C in transparent mode, expect:
- Single-packet latency: 30-80 ms typical, up to 250 ms on retransmit.
- Throughput: ~38 kbps effective for 115.2 kbps UART.
- Online-edit-induced download: 2-10 seconds depending on program size.
The source conversation noted that the $69 PLC class devices take the controller offline for "several seconds" during download. Even with a wired link, the operator must accept this. With an XBee in transparent mode and a 0x1000-byte program, total download time grows from ~2 s wired to ~6-10 s wireless, which is tolerable for non-critical reconfiguration work.
If wireless online editing must be deterministic, switch the XBees to API mode (ATAP 1) and use explicit TX Request frames with acknowledged delivery. This guarantees packet-level retries and exposes RSSI/last-hop status to the host PC.
Safety and Operational Notes
- Do not deploy XBee radios in Class I Div 1 hazardous locations without an additional intrinsic-safety barrier.
- The XBee 3 RF module has FCC, IC, ETSI, and Telec certifications when used with the certified Digi antenna. Use of non-approved antennas or RF power modifications voids certification.
- Wireless links are not suitable for SIL-rated emergency-stop signaling, machine guarding, or safety interlock circuits.
- The Stamp PLC lacks a hardware watchdog by default; add external brown-out and WDT supervision if the wireless link is part of a safety-critical control loop.
- Use shielded cabling between the MAX3232 and the XBee in noisy plant environments to avoid EMI-induced FCS errors on Host Link.
Troubleshooting Matrix
| Symptom | Probable Cause | Verification | Fix |
|---|---|---|---|
| Garbled RX (junk characters) | Baud mismatch between XBee UART and host | Verify ATBD on both XBees; match PC COM port | Set matching baud on all three nodes |
| One-way only | CTS/RTS flow control disabled or wrong direction | Check ATD6/D7 settings; loopback test | Match DIO6/DIO7 pin directions; tie CTS to GND if not used |
| No link light, no data | PAN ID or channel mismatch | ATID/ATCH on both sides; use XCTU range test | Force matching PAN ID and channel |
| High latency bursts | RF noise / retransmits on 2.4 GHz | Run ATAI (association indicator) and ATDB (RSSI) | Switch to DigiMesh 900 MHz (XBee SX) for noisy sites |
| CPM2A "RS-232C Error" on comm port | Voltage level mismatch (3.3 V to RS-232C port) | Scope DI line at DB9 | Insert MAX3232 translator |
| XBee unresponsive in AT mode | Guard time violated | Pause 1+ second before/after +++ | Add 1 s delays; do not send +++ within 1 s of last char |
| Frame Check Sequence errors | Half-duplex collision | ATRR for retries; check DIO7 high | Enable HW flow control; lower baud rate |
| Stamp SERIN hangs | Missing timeout parameter | Review SERIN signature | Always include timeout label and fallback branch |
| Online edit fails halfway | Retransmit timeout too short | Check ATRO packetization options | Switch to API mode with explicit acks |
Field Commissioning Checklist
- Flash ATRE on both XBees to start clean.
- Apply matching PAN ID and channel to both modules.
- Confirm matching baud and parity between XBee, host, and PLC.
- Verify RSSI > -90 dBm at the operating location using XCTU Range Test.
- Issue a Host Link "MS" (status read) command and confirm FCS-correct response.
- Cycle power on XBee and PLC; re-verify link.
- Document the BD, CH, ID, MY, DL of every deployed XBee on the network diagram.
- Mark every DB9 cable as "wireless-side" vs. "wired-side" to avoid human cross-connects during service.
- Validate plant equipment behavior in all modes (RUN, PROGRAM, MONITOR) over the wireless link.
- Record peak observed latency; compare against Host Link polling requirements.
Can a Parallax Stamp PLC be programmed wirelessly over an XBee link?
Yes. Connect the XBee to the Stamp PLC's P0/P1 UART (or through an external RS-232 transceiver to the DB9). Program downloads take the Stamp offline for several seconds; expect 6-10 seconds for typical 1 KB programs at 9600 bps. Configure both XBees for transparent mode, matching PAN ID, channel, and baud (ATBD on both sides).
What serial settings does the Omron CPM2A default to for Host Link on Port 1?
Port 1 ships at 9600 bps, 7 data bits, even parity, 2 stop bits, Host Link mode, unit number 00. These are controlled via PLC Setup area words DM6650 (Host Link mode), DM6651 (comm parameters), and DM6653 (unit number 00-31).
Why am I receiving random ASCII garbage from one XBee when the other is fine?
Three common causes: baud rate mismatch (verify ATBD on both units), missing MAX3232 translator tying TTL to RS-232, or insufficient CTS/RTS handling. Set ATBD to the same value on both radios and confirm the host is at the same baud. Use XCTU's Console to view the raw bytes for diagnosis.
How do I extend the range of an XBee pair between the PLC and HMI?
Use XBee PRO modules (PRO S2C or PRO SX 900), add a high-gain 5-8 dBi external antenna, or switch to XBee SX 900 MHz for better wall penetration through concrete and steel. Line-of-sight range scales roughly with antenna gain and power output; specify a certified Digi antenna to maintain regulatory compliance.
Is wireless online editing of a CPM2A reliable enough for production?
For non-emergency parameter tuning, yes, with XBee API mode and acknowledged delivery. For routine program uploads and STOP/RUN transitions, prefer a wired Host Link cable. Wireless links introduce 30-250 ms of variable latency that can break tooling expecting deterministic timing and will trip the CPM2A's comm timeout if set below 1 second.