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

Reading float values #17

Closed
orkhands opened this issue Sep 2, 2021 · 1 comment · Fixed by #18
Closed

Reading float values #17

orkhands opened this issue Sep 2, 2021 · 1 comment · Fixed by #18
Assignees
Labels

Comments

@orkhands
Copy link

orkhands commented Sep 2, 2021

Hi @drunsinn,

I can confirm that the lib works with iTNC530, 606420 02 SP3 quite nicely!

I am able to retrieve correct sensor values from the PLC memory as indicated by the addresses provided by the inventcom article (e.g. 322 milling head speed in revolutions/minute). Yet, so far I am only able to query Integer values. The machine does provide more sensor data, e.g. the milling head torque in Nm as decimals (at least I can see this from the TNCscope tool).

I do not know the specific PLC memory addresses for these values. So I tried reading all the adresses and interpreting them as float, yet this didn't bring up meaningful values anywhere. Doe you have an idea how I can convert the readouts correctly? So far, I am reading the DWORDs and convert them to floats using

value = con.read_plc_memory(address=x, mem_type=pyLSV2.MemoryType.DWORD,count=1)
flval = struct.unpack('f',value[0:4]) 

To do so, I had to change read_plc_memory() to directly return the payload, otherwise, I wasn't able to dissect plc_values further so that I could extract the raw byte data.

I hope I haven't overlooked something here. Thanks!

@drunsinn
Copy link
Owner

drunsinn commented Sep 2, 2021

Hello @orkhands,

thanks for the feedback! I will add your software version to my list :-)

I am sorry to say that as far as i know TNCscope is using the DNC library instead of LSV2. I have done quite a bit of searching and analysis with Wireshark but DNC is quite a bit harder to decode than LSV2 which is for the most part just plain text without any encoding.

On the upside it seems that there is indeed a problem in pyLSV2 in reading from the memory address. Currently it is using the telegram R_MB to read values from memory, on a TNC 640 this has worked just fine and i assumed it would also work on an iTNC as i got good values for everything i checked. This seems to not be the case! After checking again with TNCcmd again I found the command GETVALUE which i always ignored as it has some strict limitations:
Availability: iTNC 530 as of 34049x 03 and 60642x 01 or TNC 640 as of 34059x 01 (only with TNCcmdPlus)
This command uses the telegram R_DP to read values by using some kind of special path like \PLC\memory\M\100.

I created a new branch to try reading via R_DP and it seems to work at least for one value :-) check it out here: data_path
It adds the new function read_data_path(path) which takes a string like TNCcmd. This is not ready yet as i have not been able to figure out the meaning of all the byte values sent and revived. If i have time i will take a look next weekend on what i can figure out. If you are interested you can take a look yourself, Pull requests are always welcome!

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

Successfully merging a pull request may close this issue.

2 participants