drunsinn / pyLSV2

A pure Python3 implementation of the LSV2 protocol
MIT License
64 stars 24 forks source link

Part Count Function for iTNC Machines #32

Closed SabarinathRajendran closed 1 year ago

SabarinathRajendran commented 2 years ago

Hello @drunsinn ,

is there a way to get the part count of the machine?.

drunsinn commented 2 years ago

Hello @SabarinathRajendran,

not directly, at least not that I am aware of. There might be a way go geht the counter value via PLC memory but I haven't seen anything relating to parts counters in TNCcmd. To be honest, I have never used the parts counter on a iTNC so I don't exactly know how to test this. Can you point me to any documentation?

On the TNC640 I know about FUNCTION COUNT which lets you set a target value and increment the counter in the nc program. I searched the PLC symbol list on a TNC640 programming station and found some memory locations related to this parts counter: STG_Workpice_counter[0].DG_planned_workpices and STG_Workpice_counter[0].DG_produced_workpices. Thier values correspond to the values displayed in the MOD dialog.

SabarinathRajendran commented 2 years ago

@drunsinn

https://www.inventcom.net/support/heidenhain/read-part-counters

Here they are setting the part count to a variable and are reading it from a table. I was wondering if there is any default counter that runs on the machine like for Program Status.

And any idea on reading the values from the table that are set using the method mentioned in the above documentation.

drunsinn commented 2 years ago

I was not aware something like this could be done, haven't heard about this "hidden" plc memory address before. Quite interesting, I will have to try this myself.

From reading this article I would say it should be as simple as reading the PLC address just like counter = lsv2_connection.read_plc_memory(address=20, mem_type=MemoryType.WORD, count=1) Nothing fancy necessary I would think.

The way we solved this problem currently is to read/write the counter values from a table that is saved at a fixed location on the control. Only recently they added a "official" parts counter in the way I mentioned in my first response. Here are some links to different solutions that use either a table or a QR parameter:

SabarinathRajendran commented 2 years ago

Hello @drunsinn ,

Thanks, I was hoping for a default counter and as you have referred to the default counter i will try to look in to it and will share the function if i can take the value from it.

God speed.