0

I would like to request your help in writing the following variables(strings) from a Raspberry Pi(python program) to CPU S7-1200 . I have compiled and installed Snap7 python.What are the changes I need to do for writing the variables (pc, prob,Xi, Yi,, Xx, Yx, Xmi,Ymi)

The Python code is as follows:

import snap7
import struct

from time import sleep
from snap7.util import *

plc=snap7.client.Client()

pc= "Narayan"
prob="90%"
Xi = "0"
Yi = "10"
Xx = "20"
Yx = "30"
Xmi=10
Ymi=15

plc.connect (’10.10.54.2’,0,1)

These variables (pc, prob,Xi, Yi,, Xx, Yx, Xmi,Ymi) are updated continuously from my actual program .

ZF007
  • 3,318
  • 8
  • 26
  • 39
  • Have you read the docs: [python-snap7](https://python-snap7.readthedocs.io/en/latest/client.html). Are you aware of this: [example.py](https://github.com/gijzelaerr/python-snap7/blob/master/example/example.py) – stovfl Sep 07 '18 at 12:18
  • I have tried it .But is it necessary to do block read fro writing to a block. Also I got error for : from db_layouts import rc_if_db_1_layout ::: File "", line 1, in ModuleNotFoundError: No module named 'db_layouts' – Aravind Sep 10 '18 at 07:21
  • Read: [SO:how-can-i-communicate-between-a-siemens-s7-1200-and-python](https://stackoverflow.com/questions/10355953/how-can-i-communicate-between-a-siemens-s7-1200-and-python/24056273#24056273), and [python-snap7-s7-1200-simple-example](http://simplyautomationized.blogspot.com/2016/02/python-snap7-s7-1200-simple-example.html) – stovfl Sep 10 '18 at 12:24
  • Is python a requirement. I use node-red that is included with the Raspberry Pi to get data from the PLC and send it to the PLC. Here is an example of the PI reading and writing to a WAGO PLC. [link](https://stackoverflow.com/questions/58209686/where-should-i-start-with-my-opc-ua-client/58211410#58211410) – CTGControls Jun 23 '20 at 18:04

0 Answers0