DLMS/COSEM 蓝皮书解读三十七S-FSK PhyMAC set-upclass_id 50—— 电力线窄带载波 S-FSK 的物理层 MAC 层参数建模系列说明本系列基于 DLMS UA《Blue Book蓝皮书第 16 版 · 第 2 部分》一个接口类一篇。第 36 篇讲了IPv6 setupclass_id 48那是 IP 网络层。本篇把视角切到电力线载波PLC的最底层——S-FSKSpread Frequency Shift KeyingIEC 61334-5-1 定义的慢速、高可靠窄带 PLC技术它的物理层与 MAC 层参数怎么在 DLMS 里建模。上篇回顾第 36 篇是 IPv6 网络层配置本篇是 PLC 物理层/MAC 层配置属于完全不同的通信栈分层。两者通过DL_reference这类引用串起来IP 对象指链路层链路层指物理层——S-FSK 这类 PLC 技术就是链路层之下的介质相关部分。0. 为什么需要这个类 —— 电力线不是以太网物理层要单独配电表挂在电力线上通信介质极其恶劣噪声、衰落、频率选择性衰减。S-FSK 是 IEC 61334 定义的一种窄带 PLC 技术靠mark/space 两个频率传数据速度慢但极可靠适合抄表。它的物理层频率、增益和 MAC 层MAC 地址、中继、同步、信用都需要可配置、可读取于是有了这个接口类。蓝皮书原文S-FSK PhyMAC set-up, Overview“An instance of the ‘S-FSK PhyMAC set-up’ class stores the data necessary to set up and manage the physical and the MAC layer of the PLC S-FSK lower layer profile.”蓝皮书原文version 0 Overview 的 NOTE“The use of version 0 of this interface class is deprecated.”/ 以及 version 1 Overview 同样标注“The use of version 0 … is deprecated.”——新项目直接用 version 1。1. 类蓝图S-FSK PhyMAC setup 0…n class_id 50, version 1属性静态/动态数据类型MinMaxDefShort namelogical_namestaticoctet-string———xinitiator_electrical_phasestaticenum03—x 0x08delta_electrical_phasedyn.enum06—x 0x10max_receiving_gainstaticunsigned———x 0x18max_transmitting_gainstaticunsigned———x 0x20search_initiator_thresholdstaticunsigned——98x 0x28frequenciesstaticfrequencies_type———x 0x30mac_addressdyn.long-unsigned——FFEx 0x38mac_group_addressesstaticarray———x 0x40repeaterstaticenum———x 0x48repeater_statusdyn.boolean———x 0x50min_delta_creditdyn.unsigned———x 0x58initiator_mac_addressdyn.long-unsigned———x 0x60synchronization_lockeddyn.boolean———x 0x68transmission_speedstaticenum063x 0x70version 0 ↔ version 1 差异关键写代码必须分支v0 在 x0x28 是search_initiator_gainunsignedv1 改为search_initiator_thresholdunsigned缺省 98v1新增transmission_speedx0x70enum 0–6缺省 3v0 没有v0repeater缺省为 1且repeater_status TRUEv1repeater缺省由项目配套规范指定v0 的initiator_mac_address描述里多一句若写 NO-BODY则mac_address须置 NEW——v1 去掉了该句仅保留值取决于synchronization_locked的通用说明。Specific methodsv0 与 v1均无方法m/o 表为空。MAC 地址空间12 位原文 TableS-FSK 的 MAC 地址是12 位范围 000–FFF预定义值如下地址值NO-BODY000Local MAC001 – FIMA-1InitiatorFIMA – LIMAMAC group addressLIMA 1 – FFBAll configuredFFCNEWFFEAll PhysicalFFF蓝皮书原文“FIMA : First Initiator MAC address; C00. LIMA : Last Initiator MAC address; DFF.”—— 即发起方 MAC 范围是 C00–DFF组地址从 LIMA1DFF1E00 起到 FFB 止。2. 属性逐条解读2.1 initiator_electrical_phasestatic, enum蓝皮书原文Holds the MIB variable initiator-electrical-phase (variable 18)... It is written by the client system to indicate the phase to which it is connected.enum: (0) Not defined (default), (1) Phase 1, (2) Phase 2, (3) Phase 3蓝皮书原文NOTE“This enumeration is different from that of [IEC 61334-5-1].”—— 别拿底层标准的相位枚举照搬。2.2 delta_electrical_phasedyn, enum蓝皮书原文Holds the MIB variable delta-electrical-phase (variable 1)... It indicates the phase difference between the clients connecting phase and the servers connecting phase.enum: (0) Not defined, (1) 同相, (2) 60°, (3) 120°, (4) 180°, (5) -120°, (6) -60°(0) 表示服务器暂时无法确定相位差。2.3 max_receiving_gain / max_transmitting_gainstatic, unsigned蓝皮书原文Corresponds to the maximum allowed gain bound to be used by the server system in the receiving mode. The default unit is dB./ 发送侧是“maximum attenuation bound… in the transmitting mode. The default unit is dB.”蓝皮书原文重要“The possible values of the gain may depend on the hardware. Therefore, after writing a value to this attribute, the value should be read back to know the actual value.”——写了要读回硬件可能量化/钳位。2.4 search_initiator_thresholdv1, static, unsigned缺省 98蓝皮书原文This attribute is used in the intelligent search initiator process. If the value of the initiator signal is above the value of this attribute, a fast synchronization process is possible. The default value is 98 dBµV.⚠️v0 逻辑相反v0 的属性叫search_initiator_gain原文“If the value of the max_receiving_gain is below the value of this attribute, a fast synchronization process is possible.”—— 一个是信号高于阈值→快同步v1阈值一个是接收增益低于某值→快同步v0增益。两版判断方向不同解析/配置务必按版本分支。2.5 frequenciesstatic, frequencies_type蓝皮书原文Contains frequencies required for S-FSK modulation.frequencies_type :: structure { mark_frequency: double-long-unsigned, space_frequency: double-long-unsigned }单位 Hz。即 S-FSK 的两个载频。2.6 mac_addressdyn, long-unsigned缺省 FFENEW蓝皮书原文Contains the value of the address of the physical attachment (MAC address) associated to the local system. In the unconfigured state, the MAC address is ‘NEW-address’./“MAC addresses are expressed on 12 bits.”蓝皮书原文重置触发“This attribute is set to NEW: by the MAC sub-layer, once the time-out-not-addressed delay is exceeded; when a client system ‘resets’ the server system.”蓝皮书原文置 NEW 的连锁反应“When this attribute is set to NEW: the system loses its synchronization; the mac_group_address attribute is reset (array of 0 elements); the system automatically releases all AAs which can be released.”—— 即mac_address FFE(NEW)是一个强状态重置信号会顺带丢同步、清组地址、释放会话。2.7 mac_group_addressesstatic, array of long-unsigned蓝皮书原文Contains a set of MAC group addresses used for broadcast purposes./“The ALL-configured-address, ALL-physical-address and NO-BODY addresses are not included in this list. These ones are internal predefined values.”2.8 repeater / repeater_statusstatic enum / dyn booleanrepeater enum: (0) never repeater, (1) always repeater, (2) dynamic repeater repeater_status boolean: FALSE无中继, TRUE中继蓝皮书原文(0) never... should never repeat; (1) ... is a repeater: it has to repeat all frames received without error and with a current credit greater than zero; (2) ... the repeater status can be dynamically changed by the server itself.蓝皮书原文v0“The default value is 2, and the server system is a repeater (repeater_status TRUE).”注意 v1 未给缺省由项目规范定。2.9 min_delta_creditdyn, unsigned蓝皮书原文The Delta Credit (DC) is the subtraction of the Initial Credit (IC) and Current Credit (CC) fields of a correct received MAC frame. The delta-credit minimum value... is held by this variable./“Only the three least significant bits are used.”repeater1时只有当前信用 0的帧才被中继——这个信用机制就是靠 IC/CC/DC 实现的。2.10 initiator_mac_addressdyn, long-unsigned蓝皮书原文Its value is either the MAC address of the active-initiator or the NO-BODY address, depending on the value of the synchronization_locked attribute.—— 详见下条synchronization_locked。2.11 synchronization_lockeddyn, boolean蓝皮书原文If the value of this attribute is equal to TRUE, the system is in the synchronization-locked state. In this state, the initiator-mac-address is always equal to the MAC address field of the active-initiator MIB object./“If FALSE… the initiator_mac_address attribute is always set to the NO-BODY value… In the synchronization-unlocked state, the server synchronizes on any valid frame.”2.12 transmission_speedv1 only, static, enum 0–6缺省 3蓝皮书原文The transmission speed supported by the physical device.enum50 Hz 电网60 Hz 电网(0)300 baud360 baud(1)600 baud720 baud(2)1 200 baud1 440 baud(3)2 400 baud缺省2 880 baud(4)4 800 baud5 760 baud(5)7 200 baud8 640 baud(6)9 600 baud11 520 baud注意S-FSK 速率跟电网频率绑定——同一 enum 值在 50 Hz 和 60 Hz 地区波特率不同因为符号周期按半周计时。3. 方法该类无方法v0/v1 的 Specific methods 表均为空。所有配置通过SET属性完成所有状态由 MAC 子层/CIASE 内部写Register服务、time-out-not-addressed等。需要重置服务器请用第 38 篇S-FSK Active initiator的reset_NEW_not_synchronized方法。4. 【实战举例】示例 1frequencies 的 mark/space 频率示例值欧洲 CENELEC 频段常见的 S-FSK 一对载频示例非蓝皮书原文实际以设备/项目配套规范为准frequencies_type { mark_frequency: double-long-unsigned 132500, // 132.5 kHz space_frequency: double-long-unsigned 143500 // 143.5 kHz }A-XDR 编码每个double-long-unsigned是 4 字节大端如132500 00 02 06 94。示例 2mac_address 的 12 位编码MAC 地址是 12 位在 DLMS 里用long-unsigned2 字节承载NEW FFE →long-unsigned 0x0FFENO-BODY 000 →0x0000All Physical FFF →0x0FFF。写mac_address 0x0FFE即把设备打回未配置态触发示例 1 里的连锁重置。示例 3repeater 与 synchronization_locked 的协作一个做中继的集中器子节点repeater 1alwayssynchronization_locked TRUE锁定到某个 DC 的发起方。此时它只中继信用 0且来自/去往该发起方的帧若synchronization_locked变 FALSE它改去同步任意合法帧initiator_mac_address落回 NO-BODY。示例 4transmission_speed 选型v1中国/欧洲 50 Hz 电网、想要最稳健的低速 →transmission_speed 32400 baud带宽紧张想提速 →69600 baud。美国 60 Hz 电网同 enum 对应 2880 / 11520 baud。示例 5v0 与 v1 的 search 属性对比v0: search_initiator_gain 30 // 接收增益低于 30 → 可快同步收得弱才需快同步 v1: search_initiator_threshold 98 // 发起方信号高于 98 dBµV → 可快同步信号强才快同步两版判断方向相反迁移时不能直接照搬字段值必须读版本号分支。示例 6mac_address 置 NEW 的连锁反应时序主站调 Active initiator.reset_NEW_not_synchronized(某MAC) → S-FSK PhyMAC setup.mac_address 写 FFE (NEW) ├─ 系统丢失同步MAC 子层动作 ├─ mac_group_addresses 重置为空数组 └─ 所有可释放的 AA 被释放已建会话断开这就是为什么重置一台表会让它短暂离线、并重新走搜索/注册流程。示例 712 位 MAC 地址空间全景结合原文 Table000 NO-BODY 保留未指定/重置值 001–C00-1 Local MAC 本机本地地址段 C00–DFF Initiator (FIMA–LIMA) 发起方/集中器地址段 E00–FFB MAC group address 组播/组地址段LIMA1 起 FFC All configured 保留所有已配置 FFE NEW 保留未配置态 FFF All Physical 保留所有物理地址说明区间划分来自原文 TableFIMAC00, LIMADFF。写mac_group_addresses只能用 E00–FFB 段写其它段会冲突预定义值。示例 8delta_electrical_phase 的相位差怎么读一台表接在 A 相Phase 1它的 DC 接在 C 相Phase 3则delta_electrical_phase (4) 180 degrees相差 180°。这个值由服务器自行测定(0) 表示暂时测不出。主站读到 (4) 就能知道表和我不在同一相跨相耦合信号会弱——是 PLC 部署的重要提示。示例 9repeater1 时的信用门控中继逻辑收到一帧当前信用 CC 0 且帧无误 → 若 repeater 1always → 中继转发该帧 → 转发时 CC 递减从 4 到 0 → repetitions_counter 在一个中继阶段开始 1被转 5 次也只 1min_delta_credit记录收到正确帧时 DC 的最小值是评估链路余量的指标值长期很小说明信用常快耗尽中继容易断。5. 工程上容易踩的坑v0 已弃用新项目用 v1但老设备可能还在 v0读对象前先确认version否则search_initiator_*和transmission_speed字段会错位。v0/v1 的 search 属性逻辑相反增益 vs 阈值见示例 5迁移时务必分支。MAC 地址是 12 位存成long-unsigned但有效范围只有 000–FFF写 FFF(F) 之外的全 F要当心语义FFFAll PhysicalFFENEW。预定义 MAC 值别乱写NO-BODY000 / NEWFFE / All-configuredFFC / All-physicalFFF 是内部保留值组地址从 E00 起——写错会破坏广播/发现逻辑。gain 写了必须读回硬件可能量化SET 的值 ≠ 实际生效值。synchronization_locked决定initiator_mac_address语义TRUE 时它等于 active-initiator 的 MACFALSE 时恒为 NO-BODY——解析前先读锁状态。repeater2时repeater_status由设备自决别以为repeater2就一定中继看repeater_status实际值。写mac_addressNEW是核弹级重置会丢同步、清组地址、释放 AA生产环境慎用。transmission_speed跟电网频率绑定同一 enum 在 50/60 Hz 波特率不同跨地区设备别套用同一数值。该类无方法想重置要走S-FSK Active initiator.reset_NEW_not_synchronized别在本类找 action。6. 小结 下期预告本篇要点S-FSK PhyMAC setup(50) 管 S-FSK PLC 的物理层频率/增益与 MAC 层MAC 地址/中继/同步/信用MAC 地址 12 位预定义值 NEWFFE / NO-BODY000 / All-physicalFFF 等synchronization_locked是 MAC 状态机的核心开关mac_addressNEW触发强重置v1 相对 v0 多了transmission_speed、把search_initiator_gain改成search_initiator_threshold该类无方法配置全靠SET属性。下一篇第 38 篇S-FSK Active initiatorclass_id 51—— 紧接本篇的发起方概念到底是谁哪个客户端系统最后用 Register 请求注册了这台服务器它的active_initiator三元组和reset_NEW_not_synchronized方法正是本篇mac_address重置的源头。参考资料DLMS UA《Blue Book Ed.16 Part 2 – COSEM interface classes》S-FSK PhyMAC set-up(class_id 50, version 0 与 1) 章节文中属性、数据类型、Short name 偏移、MAC 地址表、枚举与引文均与原文一致示例中的频率/波特率/字节为帮助理解而构造标注示例/非蓝皮书原文实际以设备对象列表及项目配套规范为准。