[etherlab-users] Pdos and bit positions

Florian Pose fp at igh-essen.com
Thu Jul 10 13:58:21 CEST 2008


Hi,

On Thu, Jul 10, 2008 at 12:23:29PM +0200, Erwin Burgstaller wrote:
> const static ec_pdo_entry_reg_t domain1_pdo_regs[] = {
>    {0, 9,  Beckhoff_EL2004, Beckhoff_EL2004_PDO_Output1, &r_dig_out[0], &bit_pos[0]},
>    {0, 9,  Beckhoff_EL2004, Beckhoff_EL2004_PDO_Output2, &r_dig_out[1], &bit_pos[1]},
>    {0, 9,  Beckhoff_EL2004, Beckhoff_EL2004_PDO_Output3, &r_dig_out[2], &bit_pos[2]},
>    {0, 9,  Beckhoff_EL2004, Beckhoff_EL2004_PDO_Output4, &r_dig_out[3], &bit_pos[3]},
>    {}
> };
> 
> $ ethercat pdos -s 9
> SM0: PhysAddr 0x0f00, DefaultSize    0, ControlRegister 0x44, Enable 9
>   RxPdo 0x1600 "Channel 1"
>     Pdo entry 0x7000:01, 1 bit, "Output"
>   RxPdo 0x1601 "Channel 2"
>     Pdo entry 0x7010:01, 1 bit, "Output"
>   RxPdo 0x1602 "Channel 3"
>     Pdo entry 0x7020:01, 1 bit, "Output"
>   RxPdo 0x1603 "Channel 4"
>     Pdo entry 0x7030:01, 1 bit, "Output"

there are four Pdos that have a single entry with 1 bit each. These four
bits are mapped right after another (in the same byte).

That's why the byte offsets r_dig_out[0..3] will all contain the same
byte offset, but the bit_pos[0..3] will be 0..3.

The correct way of setting the bits would be:

EC_WRITE_BIT(domain1_pd + r_dig_out[i], bit_pos[i], blink ? 0x01 : 0x00);

> Btw., what are the RxPdo entries for?

Pd entries are the actual process data variables. Pdos are just
"containers" to group the entries.

> Something differnt: When I write all 4 bits at once with EC_WRITE_U8,
> will there be something overwritten?

No, that will work as expected and is perfectly valid. But keep in mind,
that this is an assumption about the Pdo layout of the slave.

> The other way round: What do I read, if I call EC_READ_U8 on a 4-bit
> digital in?

One byte with the 4 output bits in it.

-- 
Best regards,
Florian Pose

http://etherlab.org



More information about the Etherlab-users mailing list