How can I manipulate UDINT variables to display bits on HMI? (VC4)

I am facing an issue where I have used a UDINT variable in logic, and now I want to display individual bits on the HMI—for example, variable.0, variable.1, etc., as statuses. However, in the visualization (Visu), there is no option to do this, as the variable is being displayed as an integer.

Do you have any suggestions on how to achieve this?

Hello,

Extract individual bits into boolean variables in the task, and then display these boolean variables in an HMI.

3 Likes

Thank you for your response
I have already implemented this solution for now, it is working, but it doesn’t seem quite right. I’d like to standardize it, so I’m looking for a better approach.

Maybe it should be a solution to try bit shifting to convert your value into bits

some snippet

        alarm_bitarray[0] =  ((yourValue) >> (0))&1;
	alarm_bitarray[1] =   ((yourValue) >> (1))&1;
	alarm_bitarray[2] =  ((yourValue) >> (2))&1;
	alarm_bitarray[3] =   ((yourValue) >>(3))&1;
	alarm_bitarray[4] =   ((yourValue) >> (4))&1;
	alarm_bitarray[5] =  ((yourValue) >> (5))&1;
	 ......

with regards
Sven

1 Like