[etherlab-users] Beckhoff EL6001/EL6021 Issues

Graeme Foot Graeme.Foot at touchcut.com
Fri May 23 01:39:52 CEST 2014


Hi,

We use the EL6021 module using RS422 mode.

The PDO structures below look the same as what we've got.  Other configuration (for RS422 mode) we set is:
0x8000:02 --> 0    (= disable XON/XOFF support for tx)
0x8000:03 --> 0    (= disable XON/XOFF support for rx)
0x8000:06 --> 0    (= full duplex)
0x8000:07 --> 1    (= RS422)

You can also connect wires between the RX and TX channels on the module to loop back to the module itself.


On Startup:
- do the usual ecrt_master_slave_config(), ecrt_slave_config_pdos() calls
- use ecrt_slave_config_reg_pdo_entry() to connect to each of the Control word, Write data, Status word & Read data
- I also use a couple of SDO state machines for 0x8000:11 (baud rate) and 0x8000:15 (data frame) so that these can be set by the user at runtime


I have 3 state machines that control the reading/writing of the port data Main, Read & Write

Main State Machine

0 - STANDBY
  reset m_connected
  wait for m_connect = true --> 1
1 - SET CONFIG
  set baud rate and data frame via SDO's
  wait for Status.InitAccepted (SW.2) = false --> 2
2 - APPLY CONFIG
  set Control.InitRequest (CW.2)
  wait for Status.InitAccepted (SW.2) = true --> 3
3 - CONFIGURED
  clear Control.InitRequest (CW.2)
  clear Control.TransmitRequest (CW.0)
  clear Control.ReceiveAccepted (CW.1)
  reset m_transmitAccepted
  reset m_receiveRequest
  wait for Status.InitAccepted (SW.2) = false --> 4
4 - READY
  set m_connected
  wait for m_connect = false --> 0


Read State Machine

0 - STANDBY
  wait for m_connected = true --> 1
1 - READY
  wait for
  {
    if m_connected = false --> 0
    if m_receiveRequest != Status.ReceiveRequest (SW.1)
    {
      set m_receiveRequest = Status.ReceiveRequest (SW.1)
      --> 2
    }
    if Status.ReceiveBufferFull (SW.3) --> 2
  }
2 - READ DATA
  cnt = Status.ReceiveCount (SW.8..SW.15)
  for (i = 0; i < cnt; i++)
  {
    if (m_readCnt >= COMM_PORT_BUFF_SIZE)
    {
      m_readErrors++
      break;
    }
    idx = (m_readIdx + m_readCnt) % COMM_PORT_BUFF_SIZE
    m_readData[idx] = ReceiveChar[i]
    m_readCnt++
  }
  set Control.ReceiveAccepted (CW.1) = ! Control.ReceiveAccepted (CW.1)
  --> 1


Write State Machine

0 - STANDBY
  wait for m_connected = true -->1
1 - READY
  wait for
  {
    if m_connected = false --> 0
    if m_writeCnt > 0 --> 2
  }
2 - WRITE DATA
  cnt = min(m_writeCnt, 22)
  set Control.TransmitCount (CW.8..CW..15) = cnt
  for (i = 0; i < cnt; i++)
  {
    TransmitChar[i] = m_writeData[m_writeIdx]
    m_writeIdx = (m_writeIdx + 1) % COMM_PORT_BUFF_SIZE
    m_writeCnt--
  }
  set Control.TransmitRequest (CW.0) = ! Control.TransmitRequest (CW.0)
  wait for
  {
    if (TIME_IN_STEP > 1 second)
    {
      set Control.TransmitRequest (CW.0) = ! Control.TransmitRequest (CW.0)
      reset TIME_IN_STEP
    }
    if m_connect = false --> 0
    if m_transmitAccepted != Status.TransmitAccepted (SW.0)
    {
      m_transmitAccepted != m_transmitAccepted
      --> 1
    }
  }


Variables:
bool m_connect
bool m_connected
bool m_transmitAccepted
bool m_receiveRequest

int m_readCnt
int m_readErrors
int m_readIdx
int m_readCnt
char m_readData[COMM_PORT_BUFF_SIZE]

int m_writeIdx
int m_writeCnt
char m_writeData[COMM_PORT_BUFF_SIZE]

COMM_PORT_BUFF_SIZE is the size of your buffers that you are reading the data into and writing from.


So in summary:

Open the connection:
- initialise the parameters by setting Control.InitRequest (CW.2) and waiting for Status.InitAccepted (SW.2)
- reset Control.InitRequest (CW.2) and waiting for Status.InitAccepted (SW.2) to be reset then your good to go

To write data:
- set Control.TransmitCount (CW.8..CW..15) with the number of bytes you are going to write
- set the characters (up to max of 22 chars)
- toggle Control.TransmitRequest (CW.0)
- wait for Status.TransmitAccepted (SW.0) to be toggled

To read data:
- wait for Status.ReceiveRequest (SW.1) to be toggled (or buffer full, Status.ReceiveBufferFull (SW.3))
- get Status.ReceiveCount (SW.8..SW.15)
- read the characters (making sure you don't full up your buffer)
- toggle Control.ReceiveAccepted (CW.1)



Hopefully this helps,
Graeme.



________________________________
From: etherlab-users-bounces at etherlab.org [mailto:etherlab-users-bounces at etherlab.org] On Behalf Of Derrill Vezina
Sent: Friday, 23 May 2014 06:43
To: etherlab-users at etherlab.org
Subject: [etherlab-users] Beckhoff EL6001/EL6021 Issues

Has anyone implemented the Beckhoff EL6001 RS232 and EL6021 Modbus interfaces with the etherlab 1.5.2 master? I am having some trouble with both of the devices and I think the same issue is happening with both modules.

I am able to initialize each of the devices using the ctrl and status register bits doing the initialization sequence. Also, I can set 4073, 4074, 4075 SDO registers for configuration on the port with setting the baud rate, data frame, etc..

Where I am failing is to actually send out the data. Using the structure output from the ethercat tool in the ethercat 1.5.2 / tool folder, I get the following for PDO outputs:

// EL6021 PDO entries
ec_pdo_entry_info_t EL60XX_pdo_entries[] = {
    {0x3003, 0x01, 16},
/* Ctrl */
    {0x3003, 0x02, 8},
/* Data Out 0 */
    {0x3003, 0x03, 8},
/* Data Out 1 */
    {0x3003, 0x04, 8},
/* Data Out 2 */
    {0x3003, 0x05, 8},
/* Data Out 3 */
    {0x3003, 0x06, 8},
/* Data Out 4 */
    {0x3003, 0x07, 8},
/* Data Out 5 */
    {0x3003, 0x08, 8},
/* Data Out 6 */
    {0x3003, 0x09, 8},
/* Data Out 7 */
    {0x3003, 0x0a, 8},
/* Data Out 8 */
    {0x3003, 0x0b, 8},
/* Data Out 9 */
    {0x3003, 0x0c, 8},
/* Data Out 10 */
    {0x3003, 0x0d, 8},
/* Data Out 11 */
    {0x3003, 0x0e, 8},
/* Data Out 12 */
    {0x3003, 0x0f, 8},
/* Data Out 13 */
    {0x3003, 0x10, 8},
/* Data Out 14 */
    {0x3003, 0x11, 8},
/* Data Out 15 */
    {0x3003, 0x12, 8},
/* Data Out 16 */
    {0x3003, 0x13, 8},
/* Data Out 17 */
    {0x3003, 0x14, 8},
/* Data Out 18 */
    {0x3003, 0x15, 8},
/* Data Out 19 */
    {0x3003, 0x16, 8},
/* Data Out 20 */
    {0x3003, 0x17, 8},
/* Data Out 21 */
    {0x3103, 0x01, 16},
/* Status */
    {0x3103, 0x02, 8},
/* Data In 0 */
    {0x3103, 0x03, 8},
/* Data In 1 */
    {0x3103, 0x04, 8},
/* Data In 2 */
    {0x3103, 0x05, 8},
/* Data In 3 */
    {0x3103, 0x06, 8},
/* Data In 4 */
    {0x3103, 0x07, 8},
/* Data In 5 */
    {0x3103, 0x08, 8},
/* Data In 6 */
    {0x3103, 0x09, 8},
/* Data In 7 */
    {0x3103, 0x0a, 8},
/* Data In 8 */
    {0x3103, 0x0b, 8},
/* Data In 9 */
    {0x3103, 0x0c, 8},
/* Data In 10 */
    {0x3103, 0x0d, 8},
/* Data In 11 */
    {0x3103, 0x0e, 8},
/* Data In 12 */
    {0x3103, 0x0f, 8},
/* Data In 13 */
    {0x3103, 0x10, 8},
/* Data In 14 */
    {0x3103, 0x11, 8},
/* Data In 15 */
    {0x3103, 0x12, 8},
/* Data In 16 */
    {0x3103, 0x13, 8},
/* Data In 17 */
    {0x3103, 0x14, 8},
/* Data In 18 */
    {0x3103, 0x15, 8},
/* Data In 19 */
    {0x3103, 0x16, 8},
/* Data In 20 */
    {0x3103, 0x17, 8},
/* Data In 21 */
};

// EL6021 PDO information
ec_pdo_info_t EL60XX_pdos[] = {
    {0x1602, 23, EL60XX_pdo_entries + 0},
/* RxPDO-Map Outputs */
    {0x1a02, 23, EL60XX_pdo_entries + 23},
/* TxPDO-Map Inputs */
};

// EL6021 syncs
ec_sync_info_t EL60XX_syncs[] = {
    {0, EC_DIR_OUTPUT, 0, NULL, EC_WD_DISABLE},
    {1, EC_DIR_INPUT, 0, NULL, EC_WD_DISABLE},
    {2, EC_DIR_OUTPUT, 1, EL60XX_pdos + 0, EC_WD_DISABLE},
    {3, EC_DIR_INPUT, 1, EL60XX_pdos + 1, EC_WD_DISABLE},
    {0xff}
};

I am using these as my defaults since I want to use the full 22 bytes (I know you can configure between 3, 5, and 22 bytes, in which I would like to stick with 22).

When I fill the data bytes and set the ctrl bit to transmit data, I get a transmit success status on the status byte in the next process data exchange but no data goes out the port. I have the other side of the RS232 interface hooked up to procomm to verify there is no data coming out of the port. Plus the activity light does not blink.

Has anyone else had any issues with this?

Thank you!
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.etherlab.org/pipermail/etherlab-users/attachments/20140522/a732570e/attachment-0003.htm>


More information about the Etherlab-users mailing list