Experimental Physics and
Andrew just reminded me that some people have run into problems with binary records
and BOOL tags when using the 'EtherIP' driver for AllenBradley ControlLogix PLCs.
Looks like we finally figured it out.
Thanks to Andrew for sending the detailed debug output of the driver for one such instance!
So here's some rather long sermon, which hopefully will help in the future when
people search tech-talk for similar issues...
Symptom: A BO record can write a '1' to turn something on the PLC 'on', but when later writing a '0' to turn it 'off' again, that seems to have no effect.
Reason/explanation/underlying problem: The EtherIP support for binary records addresses bits: 1 bit for the BO/BI, NOBT for the MBBO/MBBI, ..., because that seemed like a reasonable idea at the time.
The underlying network protocol doesn't fully distinguish between writing bits
in a BOOL array and bits of a DINT (array).
When writing BOOL, that's actually the same as writing DINT.2,
meaning: third BOOL array element, couting from 0,
is the same as the third bit in a DINT.
A single DINT is the same as a DINT array with only one element.
When writing to BOOL, that's actually the same as writing DINT.0.
Both refer to the 33rd bit (counting from 0) in some memory structure.
So complcation #1 arises when your BO record writes to 'fred',
and you think that's DINT array 'fred', third element,
but the driver will actually deal with the third bit of the first element.
--> Use BOOL for binary records, or read the driver's readme about the "B"
flag for accessing bits in non-BOOL tags.
Problem 2: When we write a '1' to a bit in a BOOL array, that bit will read back as '1' (assuming that nothing else on the PLC changes it). The driver is specifically written to handle that case: The BO records will only touch bits.
However, write '1' to a scalar BOOL tag, it reads back as '255'. Which is OK, both values are considered 'on' by PLC logic. But if you now write a '0' to that tag, the driver will only write a zero bit, using the last readback. Meaning: it ends up writing 254 = 255 - bit 0, and the PLC will still consider that 'on'. --> Use binary records with BOOL _arrays_. That works, and is more efficient than single BOOL tags anyway. If you have to deal with a single BOOL tag, remember that this functions more like an SINT with possible values 0 and 255, and use an AI or AO record for it. Maybe an AO record linked to a BO record.
|ANJ, 02 Sep 2010||
· Search · EPICS V4 · IRMIS · Talk · Bugs · Documents · Links · Licensing ·