Join us today!

Notifications
Clear all

TwinCAT - using a single input link to read 18 individual bytes from an EtherCAT slave

6 Posts
3 Users
3 Reactions
529 Views
Posts: 15
Topic starter
(@duncan)
Eminent Member
Joined: 2 years ago

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!

Reply
5 Replies
2 Replies
twinControls
Admin
(@twincontrols)
Joined: 2 years ago

Member
Posts: 114

@duncan Have you tried linking your Struct to physical IO automatically in TwinCAT? 

Auto linking in TwinCAT

Reply
(@duncan)
Joined: 2 years ago

Eminent Member
Posts: 15

@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

Reply
rruiter
Posts: 63
(@rruiter)
Estimable Member
Joined: 2 years ago

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.

Reply
Posts: 15
Topic starter
(@duncan)
Eminent Member
Joined: 2 years ago

@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!

Reply
1 Reply
rruiter
(@rruiter)
Joined: 2 years ago

Estimable Member
Posts: 63
Share: