Siemens S7コネクタ
Siemens S7コネクタは、OPC UAや他のミドルウェアなしでSiemens S7シリーズPLCとの直接通信を可能にします。
コネクタタイプ:
S7Reader- S7 PLCからデータを読み取るS7Writer- S7 PLCにデータを書き込む
サポートされているPLC:
- S7-300
- S7-400
- S7-1200
- S7-1500
S7 Reader
Section titled “S7 Reader”{ "type": "S7Reader", "config": { "endpoint": "192.168.0.1:102", "pollingRate": 1000, "rack": 0, "slot": 2 }, "variables": [ { "key": "temperature", "dataType": "Real", "memoryArea": "DB", "blockNumber": 1, "startIdx": 0, "size": 4, "bitOrder": "BigEndian" }, { "key": "counter", "dataType": "Dint", "memoryArea": "DB", "blockNumber": 1, "startIdx": 4, "size": 4, "bitOrder": "BigEndian" } ]}S7 Writer
Section titled “S7 Writer”{ "type": "S7Writer", "config": { "endpoint": "192.168.0.1:102", "rack": 0, "slot": 2 }, "variables": [ { "key": "setpoint", "dataType": "Real", "memoryArea": "DB", "blockNumber": 1, "startIdx": 100, "size": 4, "bitOrder": "BigEndian" } ]}設定パラメータ
Section titled “設定パラメータ”エンドポイント
Section titled “エンドポイント”PLC IPアドレスとポート(デフォルトポートは102):
{ "endpoint": "192.168.0.1:102"}ラックとスロット
Section titled “ラックとスロット”CPUモジュールの物理位置:
{ "rack": 0, "slot": 2}一般的な設定:
- S7-300: rack=0、slot=2
- S7-400: rack=0、slot=2または3
- S7-1200: rack=0、slot=1
- S7-1500: rack=0、slot=1
ポーリングレート
Section titled “ポーリングレート”リーダーのミリ秒単位の間隔:
{ "pollingRate": 1000}メモリエリア
Section titled “メモリエリア”DB(データブロック)
Section titled “DB(データブロック)”構造化データの最も一般的なエリア:
{ "key": "temperature", "dataType": "Real", "memoryArea": "DB", "blockNumber": 1, "startIdx": 0, "size": 4}どのDBかを指定するにはblockNumberが必要です。
M(メルカー/フラグ)
Section titled “M(メルカー/フラグ)”汎用メモリ:
{ "key": "flag_value", "dataType": "Word", "memoryArea": "M", "startIdx": 0, "size": 2}物理入力信号(読み取り専用):
{ "key": "sensor_input", "dataType": "Bool", "memoryArea": "I", "startIdx": 0, "size": 1}物理出力信号(読み取り/書き込み):
{ "key": "motor_output", "dataType": "Bool", "memoryArea": "Q", "startIdx": 0, "size": 1}C(カウンタ)
Section titled “C(カウンタ)”カウンタ値:
{ "key": "production_count", "dataType": "Word", "memoryArea": "C", "startIdx": 0, "size": 2}Bool(1ビット)
Section titled “Bool(1ビット)”ブール値:
{ "dataType": "Bool", "size": 1}Byte(8ビット)
Section titled “Byte(8ビット)”8ビット符号なし整数(0-255):
{ "dataType": "Byte", "size": 1}Word(16ビット)
Section titled “Word(16ビット)”16ビット符号なし整数(0-65535):
{ "dataType": "Word", "size": 2}Dword(32ビット)
Section titled “Dword(32ビット)”32ビット符号なし整数:
{ "dataType": "Dword", "size": 4}Int(16ビット符号付き)
Section titled “Int(16ビット符号付き)”16ビット符号付き整数(-32768から32767):
{ "dataType": "Int", "size": 2}Dint(32ビット符号付き)
Section titled “Dint(32ビット符号付き)”32ビット符号付き整数:
{ "dataType": "Dint", "size": 4}Real(32ビットfloat)
Section titled “Real(32ビットfloat)”32ビット浮動小数点:
{ "dataType": "Real", "size": 4}Char(8ビットASCII)
Section titled “Char(8ビットASCII)”ASCII文字:
{ "dataType": "Char", "size": 1}S7 PLCはデフォルトでBig Endianバイト順序を使用します:
{ "bitOrder": "BigEndian"}完全な変数定義:
{ "key": "temperature", // Meddleペイロードキー "dataType": "Real", // S7データ型 "memoryArea": "DB", // メモリエリア "blockNumber": 1, // DB番号(DBエリアの場合) "startIdx": 0, // 開始バイトオフセット "size": 4, // バイト単位のサイズ "bitOrder": "BigEndian" // バイト順序}一般的なユースケース
Section titled “一般的なユースケース”1. 生産監視
Section titled “1. 生産監視”{ "type": "S7Reader", "config": { "endpoint": "192.168.1.10:102", "pollingRate": 1000, "rack": 0, "slot": 2 }, "variables": [ { "key": "machine_status", "dataType": "Word", "memoryArea": "DB", "blockNumber": 10, "startIdx": 0, "size": 2, "bitOrder": "BigEndian" }, { "key": "production_count", "dataType": "Dint", "memoryArea": "DB", "blockNumber": 10, "startIdx": 2, "size": 4, "bitOrder": "BigEndian" }, { "key": "cycle_time", "dataType": "Real", "memoryArea": "DB", "blockNumber": 10, "startIdx": 6, "size": 4, "bitOrder": "BigEndian" } ]}2. プロセス制御
Section titled “2. プロセス制御”{ "type": "S7Writer", "config": { "endpoint": "192.168.1.10:102", "rack": 0, "slot": 2 }, "variables": [ { "key": "temperature_setpoint", "dataType": "Real", "memoryArea": "DB", "blockNumber": 20, "startIdx": 0, "size": 4, "bitOrder": "BigEndian" }, { "key": "enable_process", "dataType": "Bool", "memoryArea": "M", "startIdx": 0, "size": 1, "bitOrder": "BigEndian" } ]}3. デジタルI/O監視
Section titled “3. デジタルI/O監視”{ "type": "S7Reader", "config": { "endpoint": "192.168.1.10:102", "pollingRate": 500, "rack": 0, "slot": 2 }, "variables": [ { "key": "emergency_stop", "dataType": "Bool", "memoryArea": "I", "startIdx": 0, "size": 1, "bitOrder": "BigEndian" }, { "key": "motor_running", "dataType": "Bool", "memoryArea": "Q", "startIdx": 0, "size": 1, "bitOrder": "BigEndian" } ]}トラブルシューティング
Section titled “トラブルシューティング”解決策:
- PLC IPアドレスとポートを確認
- ネットワーク接続を確認:
ping [plc-ip] - PLCが外部接続を許可していることを確認(PLC設定を確認)
- ラックとスロット番号がPLC設定と一致することを確認
- ファイアウォールルールを確認(ポート102)
アクセス拒否
Section titled “アクセス拒否”解決策:
- PLC保護設定を確認
- PLCでPUT/GET通信が有効になっていることを確認
- PLCにパスワード保護がないことを確認
- PLCがRUNモードであることを確認(一部の操作にはSTOPモードが必要)
誤ったデータ値
Section titled “誤ったデータ値”解決策:
startIdx(バイトオフセット)を確認sizeがデータ型と一致することを確認- DBエリアの
blockNumberを確認 bitOrderを確認(S7の場合はBigEndianである必要があります)- TIA PortalまたはSTEP 7を使用してメモリレイアウトを確認
低速パフォーマンス
Section titled “低速パフォーマンス”解決策:
- 頻度を減らすために
pollingRateを増やす - 連続したメモリアドレスをグループ化
- 変数の数を減らす
- ネットワークレイテンシを確認
ベストプラクティス
Section titled “ベストプラクティス”- データブロックを使用: より良い構造のためにDB内のデータを整理
- メモリレイアウトを文書化: DBの構造のマップを保持
- 連続アドレス: 散在した読み取りよりも効率的
- STOPモード: 最初のテストにはより安全
- データ型: PLC プログラムタイプと正確に一致
関連コネクタ
Section titled “関連コネクタ”- OPC UA - より広範なサポートを持つ代替
- Modbus - 代替産業プロトコル
- Filter - S7データをフィルタリング
- InfluxDB Writer - S7データを保存