Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

CNC 840D communication using Python Code #3

Open
abhishekavl opened this issue Nov 7, 2023 · 0 comments
Open

CNC 840D communication using Python Code #3

abhishekavl opened this issue Nov 7, 2023 · 0 comments

Comments

@abhishekavl
Copy link

Hi,

I am trying to connect with Siemens 840D machine using Python S7 connection on Profinet communication.
I am able to connect with system on Profinet and getting data in Python. But not able to take specific data such as Axis current, Axis load, Actual Axis Speed, Axis Motor temp. etc. These parameters are belong to VFD (used for servo) used in CNC Machine.

Can you please share the methodology for the same?

Below are example code of Python, with this I am able to communicate and getting other data but not the above said parameters.
Either there will be some technique I have to use to take above parameters of VFD or I am not able to use correct address of above parameters.
Can anyone suggest inputs that can help me to solve this issue?

Example Python code1 to get Bool Data :
import snap7
import json
import struct
plc = snap7.client.Client()
plc.connect('192.168.0.1', 0, 1)

In this example boolean in DB 31 at byte 120 and bit 5 is changed. = 120.5

reading = plc.db_read(1,8,1 ) # read 1 byte from db 31 staring from byte 120
#data = plc.db_read(1,0,4)

#real_number = struct.unpack('>f', data)[0]

#print(f"Real number read from DB1 at byte offset 0: {real_number}")

a = snap7.util.get_bool(reading, 0, 0) # set a value of fifth bit
a1 = snap7.util.get_bool(reading, 0, 1) # set a value of fifth bit
a2 = snap7.util.get_bool(reading, 0, 2) # set a value of fifth bit
a3 = snap7.util.get_bool(reading, 0, 3) # set a value of fifth bit
a4 = snap7.util.get_bool(reading, 0, 4) # set a value of fifth bit
a5 = snap7.util.get_bool(reading, 0, 5) # set a value of fifth bit
a6 = snap7.util.get_bool(reading, 0, 6) # set a value of fifth bit
a7 = snap7.util.get_bool(reading, 0, 7) # set a value of fifth bit

data = {

"data1":a,
"data2":a1,
"data3":a2,
"data4":a3,
"data5":a4,
"data6":a5,
"data7":a6,
"data8":a7

}
data = json.dumps(data)
print(data)

CNC_Controller Display Screen1
CNC_Controller Display Screen2
CNC_Internal communication Architecture

Regards
Abhishek

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant