Greg,
I think your solution runs the risk of losing track of how many inputs are on when more than one changes on the same scan. If this happens with the PDs, the count will be short. If it happens on the NDs, the count will be too high. It could go negative (I'm not sure what that means when the system doesn't really support negative numbers) or exceed 4095 in your scaled case. There's no easy way to see when that has happened except when they all come on (at some time) and the number is already at the maximum, or all off and already 0.
I'd suggest recomputing the whole value on each pass. I don't do work with mnemonics but I think is would look sort of like this
STR SP1 always on
LD K0 get a zero
OUT V2000 and initialize V2000
LD K25 get the amount to add - change this to change all scaling
OUT V2001 and initialize V2100, the amount to add
STR C0 if C0 is ON then
LD V2001 get the amount to add
ADD V2000 add it to the current total
OUT V2000 and save the new total
STR C1 if C1 is ON then
LD V2001 get the amount to add
ADD V2000 add it to the current total
OUT V2000 and save the new total
STR C2 if C2 is ON then
LD V2001 get the amount to add
ADD V2000 add it to the current total
OUT V2000 and save the new total
STR C3 if C3 is ON then
LD V2001 get the amount to add
ADD V2000 add it to the current total
OUT V2000 and save the new total
At 4 inputs, this is just about the limit for the brute force approach. If there were more, a subroutine might be better.
However, if all the bits are next to each other, then using the SUM instruction in the PLC is easy and fast. It would look something like this.
STR SP1 always on
LD Kf we want the low 4 bits on
AND V40600 This is where C0-C17 are
SUM Add up the bits
MUL K25 will give a 0 to 100% value
OUT V2000 where the result should go
This is easy for up to 16 adjacent bit variables (X, Y, C, S, T, ...).
It's been a week since the last post, so this is probably too late to do any good.

BTW, I really like the way the CODE boxes scroll.

And "Preview" is pretty cool too.

Roger
I updated my code with the AND and Kf, just in case people stop reading before the get to the correction.
