[?]: Display number of digital inputs
-
- Posts: 1
- Joined: Sat Feb 20, 2021 9:48 am
[?]: Display number of digital inputs
In the step 7 s300 (with fbd or ladder) write a program that display number of true digital inputs of a card with 16 inputs in every moment.
-
- Posts: 62
- Joined: Sat May 17, 2014 1:26 am
Re: [?]: Display number of digital inputs
Henry S. Warren, Jr. - Hacker’s Delight (Second Edition)
Chapter 5. Counting Bits
For 16 bits:
Chapter 5. Counting Bits
For 16 bits:
Code: Select all
x = (x & 0x5555) + ((x>>1) & 0x5555);
x = (x & 0x3333) + ((x>>2) & 0x3333);
x = (x & 0x0F0F) + ((x>>4) & 0x0F0F);
x = (x & 0x00FF) + ((x>>8) & 0x00FF);
return x;
SIMATIC Step 7 (FBD)
Show