Overview: Building a Reporting Pipeline Around the CJ1M
The Omron CJ-series CJ1M is a compact modular PLC that frequently appears as the controller of record on packaging, material-handling, and OEM machine cells. It supports an HMC-EF CompactFlash memory card, an Ethernet option board or dedicated module (CJ1W-ETN21), and the Controller Link module (CJ1W-CLK21), all of which can be combined to build a self-contained reporting pipeline that ends in a relational database on the office side of the network.
The canonical workflow is:
- The CJ1M writes production, alarm, and process values to a CSV file on the CompactFlash card using the File Memory operations built into the CPU.
- An automation computer or SCADA station connects to the PLC's Ethernet module and pulls the CSV over FTP.
- CX-Supervisor (or an in-house application) parses the CSV and inserts records into a Microsoft Access (.accdb / .mdb) database using ODBC.
This article covers the hardware prerequisites, the on-PLC file format, the FTP transfer setup, the CX-Programmer project storage convention, and the CX-Supervisor to Access linkage that the original author asked about.
Hardware Prerequisites
| Item | Catalog Number | Notes |
|---|---|---|
| CJ1M CPU Unit | CJ1M-CPU11/12/13/21/22/23 (basic) or CJ1M-CPU31-43 (built-in I/O) | CPU12 and above recommended for memory-card file operations. |
| CompactFlash Memory Card | HMC-EF172 (16 MB), HMC-EF372 (32 MB), HMC-EF672 (64 MB) | Use Omron-supplied HMC-EF cards; consumer CF cards are not qualified for industrial file memory. |
| Ethernet Module | CJ1W-ETN21 (100Base-TX) | Required for FTP access to the memory card; ETN11 supports FINS only. |
| Controller Link Module (alt.) | CJ1W-CLK21 or CLK21-V1 | Use when the supervising computer is on a token-ring plant network instead of Ethernet. |
| CX-Programmer | WS02-CXPC1-EV4 (v9.x or later) | Used for ladder/ST edit, project save (.cxp/.cxt), and memory-card transfer. |
| CX-Supervisor | WS02-SUPC1-EV3 | SCADA runtime with native ODBC binding to MS Access. |
MEMORY_CARD_WRITE_PROTECT errors.CompactFlash Memory Card Architecture on the CJ1M
The CJ1M CPU recognizes an HMC-EF CompactFlash card as "File Memory". Three system files are written to the card automatically when a project is downloaded from CX-Programmer to the CPU:
| Filename | Generated By | Contents |
|---|---|---|
AUTOEXEC.OBJ |
CX-Programmer transfer | Compiled object code that the CPU auto-executes on power-up when the card is the active file-memory bank. |
SYMBOLS.SYM |
CX-Programmer transfer | Symbol table for online debugging, tag resolution, and variable name publication. |
COMMENTS.CMT |
CX-Programmer transfer | Comment / rung annotation data; useful for documentation export. |
The card is shared between these system files and any user CSV file the application program creates. The File Memory is addressed as a sequential byte stream; CP1H/CJ1M CPUs expose it through the special I/O area and through ladder instructions FREAD, FWRITE, and CMND.
Generating CSV Files on the PLC
CSV is the lowest-common-denominator exchange format between an embedded controller and a PC database. Two approaches are field-proven on the CJ1M:
Approach 1 - STL string build + FWRITE
The application constructs an ASCII row in a word-mapped DM/EM buffer, terminates it with 0D0A (CR + LF), and writes the row to the card using FWRITE. A typical record of 64 bytes (32 words) per line is a good compromise between throughput and parse complexity.
;--- Build one CSV line in D20000..D20031 (ST-style STX blocks) ---
; Tag , Value , Unit , Timestamp , Status
; string constants come from EM bank (e.g. E0_20000 contains 'TEMPERATURE')
;
; Using CX-Programmer MOVE/MOV$ ladder:
; D20000 = $5445 ; 'TE'
; D20001 = $4D50 ; 'MP'
; ... etc
;
; Write to file "REPORT.CSV" on the memory card:
; FWRITE 0 D20000 32 "REPORT.CSV" &0
;
; Trigger every minute with a clock-pulse bit (P_1min):
Strings are written using the instruction variant FWRITE$ when CX-Programmer is configured to treat the source words as ASCII. The third operand is the word count, and the last operand is the file mode flag (0 = create/append, 1 = overwrite, 2 = create-or-error).
Approach 2 - Sequential file log via ladder task
For high-volume logging, partition the EM area into 32 KB data blocks, write a full block at a time using FWRITE, and rotate the file name on a daily basis: REPORT20240315.CSV. CX-Programmer's date/time variables (_Y, _M, _D) feed the filename so the file system stays self-organized.
Storing the CX-Programmer Project (.CXT) on the Flash Card
The CX-Programmer project can be exported to the CompactFlash card as a .cxt file using File > Save As with File of type set to CX-Programmer project (.cxt), then selecting the memory-card drive letter in CX-Programmer's PC Card Explorer. The .cxt format is the ladder-visible binary representation of the project and is the canonical way to ship a project alongside the controller to a remote site.
Worked steps in CX-Programmer v9.x:
- Connect online to the CJ1M and execute PLC > Transfer > From PLC to retrieve the running project.
- Select File > Save As and choose the CX-Programmer Project Files (.cxt) filter.
- In the save dialog, navigate to the memory card (the HMC-EF shows as a removable drive on the engineering PC via a USB CF adapter, or via FTP when the Ethernet module is online).
- Save with a descriptive name such as
MACHINE01_LINE3.CXT.
To reload the project at commissioning: copy the .CXT back to the engineering laptop, open it in CX-Programmer, and transfer to the new CPU. Symbol files (SYMBOLS.SYM) and rung comments (COMMENTS.CMT) bundled inside the .CXT are preserved.
Ethernet Module CJ1W-ETN21 Configuration for FTP
The CJ1W-ETN21 is the only CJ-series Ethernet unit that exposes an FTP server capable of browsing the CompactFlash card. The ETN11 supports FINS/UDP and FINS/TCP only. Refer to the Omron CJ1W-ETN21 product page and the Ethernet Units Operation Manual (W463) for the parameter set.
| Parameter (CX-Integrator / ETN21 Console) | Typical Value | Purpose |
|---|---|---|
| IP Address | 192.168.10.21 | Static address recommended for FTP. |
| Subnet Mask | 255.255.255.0 | Match plant subnet. |
| FINS Node Address | 21 | Must equal last octet of IP for default FINS routing. |
| FINS/UDP Port | 9600 | Default. |
| FINS/TCP Port | 9600 | Default. |
| FTP Server | Enabled | Required for CSV pull. |
| FTP User / Password | omron / ******** | Set in ETN21's "FTP login account" field. |
| Auto Clock Adjustment | Enabled | Keeps file timestamps correct. |
The FTP root path on the CJ1W-ETN21 corresponds to the file-memory bank that is currently mounted. After the memory card is inserted and recognized, the files appear at the FTP root:
/
/REPORT.CSV
/REPORT20240315.CSV
/AUTOEXEC.OBJ
/SYMBOLS.SYM
/COMMENTS.CMT
/MACHINE01_LINE3.CXT
Pulling CSV Files by FTP from the Automation Computer
A Windows scheduled task or a small Python script can pull the CSV at any interval. The simplest scripted pull is:
# pull_reports.py - sample FTP retrieval
import ftplib, datetime, os
HOST = "192.168.10.21"
USER = "omron"
PWD = "<set in ETN21>"
OUT = r"C:\Reports\Inbox"
with ftplib.FTP(HOST) as ftp:
ftp.login(USER, PWD)
files = ftp.nlst("*.CSV")
for f in files:
local = os.path.join(OUT, f)
with open(local, "wb") as fp:
ftp.retrbinary(f"RETR {f}", fp.write)
print("Pulled", f, os.path.getsize(local), "bytes")
Run this script every 5 minutes via Windows Task Scheduler. After each successful pull, append a row to an Access log table recording the file name, file size, pull timestamp, and source IP - this provides audit traceability that is often required for ISO 9001 environments.
Controller Link as an Alternative Network Path
If the supervising computer is already on a Controller Link token-ring network (typical in older Sysmac installations), the CJ1W-CLK21 module is preferred over Ethernet. Controller Link carries FINS messages at up to 2 Mbps on twisted pair, but does not provide FTP. CSV retrieval over Controller Link is implemented by ladder code that reads the file and broadcasts its contents in a FINS file-memory read (FREAD served via a host-link computer). Refer to the Controller Link product page and the Controller Link Units Operation Manual (W309).
For plants with both networks, install both modules in the same rack and configure CX-Integrator routing tables so that the FINS source/destination tables forward file-memory reads transparently.
CX-Supervisor and MS Access Integration
CX-Supervisor (SCADA runtime from Omron) is the path of least resistance to MS Access because it binds data points directly to ODBC data sources. Steps to connect:
- Open the CX-Supervisor project for the machine cell.
- On the engineering PC, configure a 32-bit ODBC System DSN named, for example,
REPORTS_ACCESS, pointing to the Access database file (e.g.,C:\Reports\Reports.accdb). - In CX-Supervisor, open Database > Database Connection and link the DSN.
- For each CJ1M tag, set the Database tab properties: Save Changes = On Change or Periodic (10 s), Table = ProcessLog, Field = TagValue.
- Build an Access table with at least the columns:
TagName,TagValue,Timestamp,Quality,SourceFile. - Run the runtime and verify rows appear in Access using a linked table or a small Access query.
If a SCADA layer is undesirable, an alternative is to import the CSV directly into Access through a VBA macro bound to an Access form button:
' Access VBA - import the latest CSV from the FTP inbox
Sub ImportLatestCSV()
Dim fso As Object, f As Object, folder As Object
Set fso = CreateObject("Scripting.FileSystemObject")
Set folder = fso.GetFolder("C:\Reports\Inbox")
For Each f In folder.Files
If LCase(Right(f.Name, 4)) = ".csv" Then
DoCmd.TransferText acImportDelim, , "RawCSV", f.Path, True
End If
Next f
End Sub
Run ImportLatestCSV() on a timer event or on the After Update of a "Pull Now" button.
Access Database Design for PLC Reports
A well-normalized Access schema keeps queries fast and reduces duplicate storage. Suggested tables:
| Table | Key Fields | Purpose |
|---|---|---|
| Machine | MachineID (PK), MachineName, PLCModel, IPAddress, CFSize | Catalog of machines and their connection parameters. |
| Tag | TagID (PK), MachineID (FK), Symbol, Description, Unit | Maps CJ1M symbol names to human-readable fields. |
| ProcessLog | LogID (Auto PK), TagID (FK), TagValue, Timestamp, Quality | Time-series values. |
| AlarmLog | AlarmID (PK), MachineID (FK), AlarmCode, SetTime, ResetTime, AckUser | Discreet alarm history. |
| FilePullAudit | PullID (PK), FileName, FileSize, PullTimestamp, SourceIP | FTP receipt trail. |
Indexes on ProcessLog.Timestamp and ProcessLog.TagID will keep Access responsive above 1 million rows. Compact the database monthly (Database Tools > Compact and Repair) - Access tends to bloat when CSV imports happen frequently.
End-to-End Commissioning Procedure
- Insert an HMC-EF card into the CPU and verify the MEM indicator turns steady green.
- Download the application program from CX-Programmer; confirm
AUTOEXEC.OBJ,SYMBOLS.SYM, andCOMMENTS.CMTappear at the FTP root. - Run the ladder for two minutes; download
REPORT.CSVfrom FTP and verify the header row matches the configured tag list. - Install and configure the CJ1W-ETN21 module. Test
pingfrom the automation computer to the PLC's IP. - Open the FTP client and login with the configured user; browse the file memory and confirm all expected CSV files appear.
- Install CX-Supervisor or the standalone Python puller on the automation computer.
- Configure the ODBC DSN to the Access database and bind each PLC tag to the appropriate field.
- Run for 24 hours. Compare row counts in
ProcessLogagainst the number of CSV writes performed by the PLC.
Verification Checklist
| Check | Expected Result |
|---|---|
| Memory card LED on CPU | Solid green (no error). |
| FTP login | Returns 230 User logged in, proceed. |
| FTP directory listing | Contains REPORT*.CSV plus the three system files. |
| CSV header row | Matches the configured tag order, comma-delimited, terminated by CR+LF. |
Access ProcessLog row count |
Grows monotonically while the PLC runs. |
| CX-Supervisor online state | All bound tags show Good quality in the database inspector. |
Troubleshooting Matrix
| Symptom | Likely Cause | Resolution |
|---|---|---|
| FTP returns 530 Login failed | Wrong user/password, or FTP server disabled on ETN21. | Re-enter credentials in ETN21 Console; ensure FTP Server = Enabled. |
| FTP directory is empty | CF card not recognized; wrong DIP switch setting. | Verify DIP switch pin 7 = OFF, card seated, MEM LED solid green. |
FWRITE fault flag = ON |
Card full, write-protected, or filename invalid. | Check free space via FTP; confirm filename is 8.3 ASCII. |
| CSV rows garbled in Access | Region settings changing decimal separator. | Force decimal point in PLC string; lock regional settings on engineering PC. |
| Access table grows but values are zero | Tag binding pointed at wrong DB field or wrong symbol name. | Re-check CX-Supervisor Database tab; verify SYMBOLS.SYM matches the running build. |
| Old data overwritten unexpectedly | File mode = 1 (overwrite) instead of 0 (append). | Change FWRITE mode operand to 0 or use daily rotating filenames. |
| CF card removed mid-write | Power loss or operator error. | Reinsert card, power cycle; rerun FWRITE; consider an industrial-rated card. |
Frequently Asked Questions
Can the CJ1M write a CSV directly, or does it need CX-Programmer running?
Yes. The CJ1M CPU writes CSV files using the ladder instructions FWRITE and FWRITE$. CX-Programmer is only required to author and download the program; the PLC continues to write CSV files autonomously once the card is mounted and the program is running.
Which Ethernet module supports FTP access to the memory card?
The CJ1W-ETN21. The older CJ1W-ETN11 supports FINS messaging only and cannot expose the CompactFlash file system to an FTP client. Refer to the Ethernet Units Operation Manual (W463) for the parameter set.
Can CX-Supervisor write directly to an MS Access database without an intermediate CSV step?
Yes. Configure a 32-bit ODBC System DSN pointing to the Access file, then bind CX-Supervisor tag values directly to Access table fields using the Database tab in the tag editor. The CSV step is optional and is used mainly as an audit trail.
How do I store a CX-Programmer project (.cxt) on the CompactFlash card?
Use File > Save As in CX-Programmer, select CX-Programmer Project Files (.cxt), and navigate to the HMC-EF card (either via a USB CF adapter on the engineering PC or via FTP if the Ethernet module is online). The .cxt bundles ladder, symbols, and comments.
Is Controller Link a viable alternative to Ethernet for this reporting task?
Controller Link (CJ1W-CLK21) carries FINS messages but does not support FTP. CSV retrieval over Controller Link requires ladder code that reads the file and broadcasts its contents to the supervisor through FINS file-memory read commands. Use Ethernet (CJ1W-ETN21) whenever FTP-style retrieval is desired.