How do I do assertions on the BIT datatype?

I want to do an assertion on two variables both declared with the BIT-datatype, but I have noticed that a AssertEquals_BIT does not exist. What do I do?

The reason a AssertEquals_BIT does not exist is that TwinCAT does not allow a BIT-datatype as a variable input. If you have data declared with the BIT-type, the easiest way to do an assertion on these is to do a BIT_TO_BOOL conversion and use the AssertEquals_BOOL.


AssertEquals_BOOL(Expected := BIT_TO_BOOL(VariableDeclaredAsBit_A),
                  Actual := BIT_TO_BOOL(VariableDeclaredAsBit_B),
                  Message := 'The variables differ');

  • Share on:

Your email address will not be published. Required fields are marked *


This site uses Akismet to reduce spam. Learn how your comment data is processed.