Programming AS-i Valves on S7-300: CP 343-2 Master with ifm AC1411 Slaves
1. Overview
AS-Interface (Actuator Sensor Interface, AS-International) is a single-cable digital fieldbus standardized in EN 50295 and IEC 62026-2. It carries both 24 VDC power and a Manchester-coded digital signal on the same 2-wire yellow profile cable, making it the lowest-cost way to wire binary valves, sensors, and small actuators back to a Siemens S7-300 CPU.
This guide addresses the canonical field problem:
- CPU: SIMATIC S7-300, CPU 317-2 DP (or any S7-300 with a free rack slot, slots 4–11)
- Master: CP 343-2 (order number 6GK7 343-2AH01-0XA0, AS-i V2.0, 31 slaves) or CP 343-2 P (6GK7 343-2AH11-0XA0, V2.1, 62 slaves)
- Slaves: ifm AC1411 (AirBox 4-valve manifold, AS-i profile S-7.F for valve modules with 4 input bits / 4 output bits)
- Goal: command four on/off solenoid valves from a STEP 7 (Classic) program, with one bit per valve, using the digital I/O mapping of the CP 343-2
2. Prerequisites
| Item | Specification | Notes |
|---|---|---|
| STEP 7 (Classic) | V5.5 SP4 or later, with HSP for CP 343-2 | Use SIMATIC Manager; TIA Portal is covered in a separate guide |
| S7-300 rack | 1 free slot, slots 4–11 | CP 343-2 cannot sit in slot 0/1/2/3 (CPU slots) |
| AS-i power supply | 30 VDC, ≥ 2.4 A (e.g. Siemens 3RX9 502-0BA00, Phoenix QUINT) | Standard 24 VDC supply will NOT work; the bus needs the 6 VDC offset to superimpose data |
| AS-i cable | Yellow, profiled, 2 × 1.5 mm² | Use AS-International certified cable only; the profile is what makes vampire (piercing) connections reliable |
| ifm AC1411 | AS-i V2.0, profile S-7.F | Pre-addressed out of the box, address = 0. Use ifm AC1154 handheld to set 1–31 |
| Addressing unit (optional) | ifm AC1154 or Siemens 3RK1 904-2AB01 | Needed only if auto-addressing is disabled or you must change slave addresses |
3. AS-i System Architecture
The topology is a single trunk with drops. The yellow cable is both power and data; the master injects 30 VDC and demodulates the data, the slaves draw 24 VDC and modulate the data using Alternating Pulse Modulation (APM).
4. AS-i Cable and Power Specification
The AS-i specification (EN 50295) defines:
| Parameter | Value |
|---|---|
| Nominal bus voltage | 30.0 VDC ±5% (asymmetric, data on top of power) |
| Voltage available at slave | 24.0 VDC ±10% (after internal decoupling diode) |
| Maximum trunk length | 100 m (extend to 200 m with one repeater, 300 m with two) |
| Maximum current per slave | Typically 100 mA, master-limited to 8 A total |
| Cycle time, 31 slaves | 5 ms |
| Cycle time, 62 slaves (V2.1) | 10 ms |
| Number of I/O bits per master | 248 in / 248 out (V2.0); 4 bits per slave |
5. Slave Addressing Theory (4-bit Nibble Map)
The CP 343-2 reserves 16 bytes of I/O area in the S7-300 process image. The structure is fixed by the AS-i specification:
| Byte / Nibble | Content | Length | Purpose |
|---|---|---|---|
| Byte 0, low nibble | Bus diagnostics flags | 4 bits | Earth fault, overload, duplicate address, etc. |
| Byte 0, high nibble | Reserved | 4 bits | — |
| Nibbles 1 – 31 | Slave data | 4 bits per slave | 1 bit in / 3 bits status per slave (V2.0 standard profile) |
| Nibbles 32 – 62 | Extended slave data | 4 bits per slave | V2.1 only (CP 343-2 P) |
For a single ifm AC1411, the slave's 4 data bits are mapped into one nibble. In digital I/O mode (also called "standard mode" in STEP 7), each slave's 4 bits appear as 4 contiguous input bits and 4 contiguous output bits in the process image of the CPU — exactly like a regular digital I/O module. This is the mode you want for simple on/off valves.
In analog I/O mode (the default after some firmware updates and the ifm default), the slaves are packed into process words (PIW / PQW) and you must shift bits manually. This is intended for slaves that expose 4-bit analog values, not for solenoid control.
6. CP 343-2 Hardware Installation
- Insert the CP 343-2 into a free S7-300 slot (slots 4–11 only). Mechanical keying on the bus connector prevents incorrect backplane insertion.
- Connect the yellow AS-i cable to the front terminals AS-i+ and AS-i- (removable screw connector, 4-pole). The polarity of the cable does not matter at the master.
- Connect the AS-i power supply to the same two terminals AS-i+ and AS-i- of the master; the master has a built-in decoupling circuit so the power supply does not see the data signal.
- If the CP sits at the end of the bus, leave the terminating jumper open; the CP has no internal termination. Termination is on the power supply.
- Power up. The CM LED (green) should light within 2 s. The APF LED (red) is normal OFF when the bus is healthy.
7. STEP 7 Configuration
Open SIMATIC Manager, open your S7 project, double-click Hardware to launch HW Config. Drag the CP 343-2 from the catalog (path: SIMATIC 300 / CP-300 / AS-Interface / CP 343-2) onto the rack. The default configuration in the hardware catalog uses digital I/O addressing for AS-i V2.0 — this is the configuration you want for AC1411.
7.1 I/O Addresses (digital mode default)
The default address window for a CP 343-2 in slot 4 is:
- Inputs:
IB 0–IB 15(16 bytes → 128 bits, 4 bits per slave × 31 slaves + 8 bits diagnostics) - Outputs:
QB 0–QB 15
You may change the start address if it conflicts. The diagnostics nibble in the low 4 bits of IB 0 contains:
| Bit | Meaning (active = 1) |
|---|---|
| I0.0 | Earth fault on AS-i cable |
| I0.1 | Overvoltage / undervoltage on AS-i |
| I0.2 | Duplicate slave address detected |
| I0.3 | Configuration error / slave failed |
7.2 Mapping a Slave to its Bits
With digital I/O, slave N (1 ≤ N ≤ 31) occupies bits:
Inputs: I ( (N-1) × 4 + 8 ) .. I ( (N-1) × 4 + 11 )
Outputs: Q ( (N-1) × 4 + 8 ) .. Q ( (N-1) × 4 + 11 )
The "+ 8" offset skips the 8 diagnostic/flag bits in IB 0. So:
| Slave # | Output bits | Input bits |
|---|---|---|
| 1 | Q8.0 – Q8.3 | I8.0 – I8.3 |
| 2 | Q8.4 – Q8.7 | I8.4 – I8.7 |
| 3 | Q9.0 – Q9.3 | I9.0 – I9.3 |
| ... | ... | ... |
| 31 | Q19.0 – Q19.3 | I19.0 – I19.3 |
For the ifm AC1411 (AirBox 4-valve manifold), each of the 4 output bits drives one solenoid: bit 0 → valve 1, bit 1 → valve 2, bit 2 → valve 3, bit 3 → valve 4. The 4 input bits are valve position feedback (or empty, depending on the connected valve heads).
8. ifm AC1411 Wiring and Address Setup
The AC1411 has an M12 connector (port 1) for AS-i + power, and 4 M12 sockets for the valve heads. The ifm-supplied ifm AC141x configuration over STEP 7 manual walks through the wiring. Key steps:
- Mount the AC1411 on the DIN rail or via the manifold mounting holes.
- Wire the yellow AS-i cable with an M12 AS-i T-piece (ifm AC1057) or a flat-cable piercing clamp (ifm E73064).
- Connect the valve heads to ports 1–4 of the manifold.
- Default slave address is 0 (not yet activated). Set the address to 1, 2, 3, etc. with the ifm AC1154 handheld: navigate to Address → New = 1 → Write.
9. PLC Program: Writing the Valves
9.1 Ladder (FBD) example — turn valve 1 of slave 1 ON
I0.3 M 10.0
---| |----------------( S )---
"bus OK"
M 10.0 Q 8.0
---| |----------------( )---
"run cmd" "valve_1_on"
9.2 Structured Text (SCL) example — write 4 valves in one block
FUNCTION_BLOCK FB 100 "ASi_Valve_Control"
VAR_INPUT
i_Start : BOOL; // permissive
i_BusOK : BOOL; // I0.3 = config error, invert
i_SlaveAddr : INT; // 1..31
i_ValveCmd : WORD; // bit 0..3 = valve 1..4
END_VAR
VAR_OUTPUT
o_ValveStatus : WORD; // 4-bit feedback, right-justified
o_Fault : BOOL;
END_VAR
VAR_TEMP
t_Offset : INT;
t_Word : WORD;
END_VAR
BEGIN
o_Fault := NOT i_BusOK;
// compute output bit offset: slave N -> bits (N-1)*4 + 8
t_Offset := (i_SlaveAddr - 1) * 4 + 8;
// mask out previous writes, then OR in new command
t_Word := (QW0 AND SHL(WORD#16#000F, t_Offset))
OR SHL(i_ValveCmd AND WORD#16#000F, t_Offset);
QW0 := t_Word;
// read status back: bits (N-1)*4 + 8 .. +11
o_ValveStatus := SHR(WORD#16#000F AND (IW0 SHR t_Offset), 0);
END_FUNCTION_BLOCK
9.3 If the master is in Analog Mode (re-mapping from PQW256)
Some ifm-supplied STEP 7 sample projects ship the CP 343-2 in analog mapping, where slave 1 occupies 4 bits in PQW 256 and slave 2 in PQW 258. To turn ON valve 1 of slave 1 in that mode:
L W#16#0001 // valve 1 = bit 0, slave 1 = bits 0..3
T PQW 256 // output image word for slave 1
To turn ON valve 1 of slave 2 you would write W#16#0100 to PQW 256 (bit 8 = valve 1 of slave 2). The two nibbles of PQW 256 map to slaves 1 (low nibble) and 2 (high nibble). A common debugging pattern is to write a single bit pattern such as W#16#0100 then W#16#0000 with a VAT table and observe which physical valve moves.
10. Diagnostic Library and FCs
Siemens provides a free library for the CP 343-2 / CP 343-2 P on the Siemens Industry Online Support portal. The standard FCs you will use:
| FC | Name | Purpose |
|---|---|---|
| FC 1 | ASI_3422_INIT | Initialize the master on startup (assigns diagnostic, sets mode) |
| FC 2 | ASI_3422_DIAG | Read bus diagnostics into a structured DB |
| FC 3 | ASI_3422_RD_SLAVE | Read a specific slave's input nibble |
| FC 4 | ASI_3422_WR_SLAVE | Write a specific slave's output nibble |
The full manual for the library is at SIOS entry 51678777. The diagnostics can be visualized on an HMI via the blocks in SIOS 50897766 (Diagnostic Block and Visualization via HMI or web browser).
11. Verification Procedures
11.1 Bus health check
- In SIMATIC Manager → Online → Accessible Nodes, browse to the CP 343-2.
- Right-click → AS-i → Diagnostics. The "List of active slaves" should show your AC1411 at the expected address, profile S-7.F, with no Detected / Projected mismatch.
- Open the CP 343-2 front panel LEDs: CM green, APF dark, CER dark = healthy bus.
11.2 Bit mapping verification with VAT
- Open a Variable Table (VAT) in STEP 7.
- Add the outputs for slave 1 (
QB 1as a byte or individualQ 8.0…Q 8.3) and the inputs (IB 1/I 8.0…I 8.3). - Click Monitor / Modify. Force
Q 8.0 = 1. You should hear valve 1 of AC1411 #1 click open and the corresponding input feedback bit transition to 1. - Force all four outputs in sequence and confirm physical motion + feedback.
11.3 Scope timing check
Connect a scope to AS-i+ and AS-i- at the master. Each slave query appears as a ~150 µs Manchester burst. Total cycle is 5 ms for 31 slaves, 10 ms for 62. Cycle time is the upper bound on your valve response latency.
12. Troubleshooting Matrix
| Symptom | Likely Cause | Action |
|---|---|---|
| CM LED dark, APF dark | No 24 V backplane to CP | Check S7-300 power supply and backplane connector |
| CM green, APF red | AS-i power supply failed or earth fault | Measure 30 VDC at the master terminals; check insulation |
| CM green, APF red, CER red | Configuration error: slave in STEP 7 ≠ slave on bus | Re-read AS-i → Configuration from the master |
| Slave detected, but no response | Slave at address 0 (factory default) | Set address 1–31 with handheld |
| Valve moves only when a specific PQW bit is written | Master is in analog mapping, not digital | Open HW Config, change CP 343-2 → "Configuration" → "Standard addressing" |
| Wrong valve moves (e.g. writing bit 0 turns on valve 3) | Bit ordering / endianness mismatch with ifm profile | Test with VAT by writing single-bit patterns 16#0001, 16#0002, 16#0004, 16#0008 to PQW 256 and observe; remap if needed |
| Bus is up, but DI flags show I0.0 = 1 (earth fault) | Shield grounded at two points or moisture in the cable | Check the yellow cable for water ingress; remove extra ground points |
| All valves chatter / bus noise | AS-i cable run parallel to VFD cable | Separate ≥ 30 cm; add a ferrite on the VFD output |
| No LEDs on the AC1411 | Yellow cable reversed at the M12 T (pin 1/3 swapped) | Verify pinout: pin 1 = AS-i+, pin 3 = AS-i- |
13. Field-Proven Tips
- Always keep one spare address in the bus (e.g. address 31) with no slave attached. It is invaluable when swapping a failed AC1411 in the field — you can hot-swap, then renumber later.
- Use the digital mapping for purely on/off valves. The analog mapping was designed for slaves that expose 4-bit analog values; using it for solenoids forces you to write bit patterns by hand and is error-prone.
-
Document the start address of the CP 343-2 in the program header (e.g.
// CP343-2 slot 4, IB0..IB15 / QB0..QB15, slave 1 = I8.0..I8.3 / Q8.0..Q8.3). It saves the next commissioning engineer hours of tracing. - Add the CP 343-2 diagnostics DB (DB 100) and the FC 2 read into OB1. When the bus faults, the DB tells you exactly which slave is missing or which duplicate address exists, instead of a generic SF LED.
- For long cable runs (> 50 m), prefer the yellow cable with the integrated data + power on a single jacket over separate power and signal wires — the AS-i cable's profile and capacitance spec are matched to the master's receiver.
14. Standards and Reference Documents
- SIOS 1171856 — AS-Interface: Introduction and Basic Information
- SIOS 5581657 — Manual CP 343-2 / CP 343-2 P AS-Interface Master (08/2008 + 08/2010 supplements)
- SIOS 51678777 — AS-i interface library for S7 AS-i masters (FC blocks)
- SIOS 50897766 — Diagnostic Block and Visualization via HMI or web browser for AS-Interface
- AS-International official site
How do I change the CP 343-2 from analog to digital I/O mapping?
Open HW Config in STEP 7, double-click the CP 343-2, go to the Configuration tab, and select Standard addressing (digital). Recompile HW Config and download to the CPU. After this, slave 1 occupies Q8.0–Q8.3 / I8.0–I8.3 by default, and you can drive each solenoid with a single bit in your program.
Why is my AC1411 detected at address 0 and not exchanging data?
Address 0 is the factory default and is the "not yet commissioned" state. The CP 343-2 will not exchange process data with a slave at address 0. Use an ifm AC1154 (or Siemens 3RK1 904-2AB01) handheld to set a unique address 1–31; cycle the bus or call FC 1 again from the CPU to bring the slave online.
Can I run the yellow AS-i cable next to a VFD motor cable?
No. Keep at least 30 cm separation, cross at 90° if they must intersect, and place a ferrite on the VFD output. AS-i uses a small 6 VDC swing superimposed on 24 VDC; common-mode noise from a VFD will corrupt the data and produce intermittent slave dropouts that are hard to trace.
What is the maximum number of valves I can control on one CP 343-2?
With CP 343-2 (V2.0) you can address 31 slaves. An ifm AC1411 controls 4 valves, so one master drives up to 31 × 4 = 124 on/off solenoids. With CP 343-2 P (V2.1) you can address 62 slaves (248 valves). Each master adds 5 ms (10 ms for V2.1) to the bus cycle, which is your worst-case valve response latency.
Why does writing W#16#0100 to PQW 256 only change one bit?
W#16#0100 sets bit 8 in the output word. In analog mapping, PQW 256 holds the output nibbles of slaves 1 (low nibble, bits 0–3) and 2 (high nibble, bits 4–7) — so writing W#16#0100 actually writes 0x00 to the low nibble and 0x1 to the high nibble, which commands valve 1 of slave 2. This is the expected behavior in analog mode; if you want one bit per valve in your STEP 7 program, switch the master to digital mapping as shown above.