Join us today!
TwinCAT - using a single input link to read 18 individual bytes from an EtherCAT slave
I have a weigh scale controller I am connecting to my TwinCAT PLC. The ESI file from the manufacturer maps 18 input bytes individually, but the information read is grouped into 4 byte (DINT) or 2 byte (UINT) chunks.
I'm trying to avoid the need to individually link each of the bytes to the physical IO. Is it possible to map only to byte0, but still read all 18 bytes?
I would then break the 18 bytes out into chunks to generate the tags I need.
At present I am going to have to map each of the 18 input bytes individually then copy them into a UNION struct so I can generate the outputs. Makes the mapping painful, so hoping to find a way to avoid this.
Any advice gratefully received!
@duncan Have you tried linking your Struct to physical IO automatically in TwinCAT?
In case you want to say thank you !)
We'd be very grateful if you could share this community with your colleagues and friends. You can also buy us a coffee to keep us fueled 😊 This is the best way to say thank you to this project and support your community.
twinControls - https://twincontrols.com/
@twincontrols Thanks for this.
I had stumbled across the pragmas, but felt they were bypassing the whole purpose of the symbolic IO linking that exists in TwinCAT.
I'm still getting familiar with it, but didn't want to bypass it completely in case I lost some of the functionality.
Referencing the box name seems much more interesting, so thanks for that!
I think my current issue would be best solved by a different device ESI file which grouped the bytes differently, but these are manufacturer supplied, and look a bit difficult to customize.
So where I am stuck now, is wanting to be able to add a single link for 18 bytes of inputs, and another single link for 8 bytes of outputs, which my custom library can then break up and use to control the weighscale with nice params like weigh1.NetWeight, Weigh1.GrossWeight etc.
In the meantime I'll have a go with the pragmas.
Thanks for taking the time to reply!
Duncan
I think usually it is also possible to create a struct which has the same elements as the one you;re trying to link. Then you should be able to link all of them at once.
My blog: https://cookncode.com/twincat
My code: https://github.com/roald87
@rruiter I'll have a play with this when I get a chance.
Could I map the entire 'Box' if my structure includes WcState and InfoData?
Although even just mapping once for Inputs, and once for Outputs would suit my needs.
Thanks for the feedback!
@duncan not sure about that
My blog: https://cookncode.com/twincat
My code: https://github.com/roald87
-
I cannot add a variable to the TwinCat scope project.
2 months ago
-
Twincat 3 HMI Server Graph display problem
10 months ago
-
Detecting low voltage on PLC bus
2 years ago
-
Passing a structure between PLCs via ADS using symbolic addressing
2 years ago
-
How to create a generic queue which works for every datatype including structs?
2 years ago
- 17 Forums
- 265 Topics
- 932 Posts
- 2 Online
- 688 Members