How to set baudrate on TwinCAT3 PLC for EL6002 or EL6001 comport?

1.5k views Asked by At

I cannot find how to set baudrate for the Beckhoff EL6002. I got a hint that I should use CoeWrite block for that but as I am bit new to TwinCAT I cannot find the correct function block. Could someone send a code example (on structured text) how to do that?

2

There are 2 answers

0
Quirzo On BEST ANSWER

Another solution is to change it under the IO configuration and COE-online tab. When you update it there, it will always remember the value.

In code, you can update it through CoE (Can over EtherCAT) too. You can find the index number of the setting variable from documentation. For channel 1, it seems to be 8000:11 so index = 8000 and subindex = 11.

Then by using mailbox writer block (FB_EcCoESdoWriteEx) from Tc2_EtherCAT library it is possible to write a value to that parameter. So when your PLC program starts, first run the code that updates the variable to desired baudrate.

For example, something like this:

TargetValue := 1; //WORD, Check documentation for correct value

//MailBoxWriter = Instance of FB_EcCoESdoWriteEx
MailBoxWriter(
        sNetId:= **AmsNetId of the EtherCAT master**, 
        nSlaveAddr:= **Serial interface terminal port**, 
        nSubIndex:= 11, 
        nIndex:= 8000, 
        pSrcBuf:= ADR(TargetValue), 
        cbBufLen:= SIZEOF(TargetValue), 
        bExecute:= TRUE, 
        tTimeout:= T#500MS, 
        bCompleteAccess:= FALSE, 
        bBusy=> , 
        bError=> , 
        nErrId=> 
    );

The sNetIdis AmsNetId of the EtherCAT bus master. It can be linked from IO configuration, see Master->Infodata->AmsNetId.

The nSlaveAddr is terminal port from EL6002 and it can be linked from IO configuration, see Terminal->InfoData->AdsAddr->port.

0
pboedker On

An alternative to programming it would be to configure it directly via the IO configuration. If you add a Startup value, it will be set every time the IO changes from a specified state to another. In the pic below, PS means when going from Pre-Op to Safety. So it will work, even if you replace the IO.

Setting IO Startup values