Bench rig, CPU 1214C DC/DC/DC, TIA V17. Incremental encoder, 100 pulses per rev, A on I0.0 and B on I0.1, HSC1 as an A/B counter, 4x. A small DC motor spins it at about 20 rev per second, so 2 kHz a channel.
Turn the shaft by hand and the count is right, 400 per turn. Run the motor and it counts about half what it should over ten seconds. Not noise, pulses are simply missing. I tried 1x instead of 4x and swapped A and B, same ratio missing, and the scope on I0.0 shows a clean 24V square, 250 us high, 250 us low.
Why does it count right slowly and wrong fast? The datasheet says HSC1 goes to 100 kHz and I'm nowhere near that. So is something eating the pulses before the counter ever sees them, I guess something I've not set on the input?
Encoder output type, push-pull or open collector, and the pull-up value if it's open collector? And is that pulse width measured at the input terminal, not at the encoder?
Push-pull, 24V output, measured right at I0.0 and I0.1 on the CPU terminals. 250 us high, 250 us low, clean edges. Screenshots of both channels attached. Stuck after that, the signal looks perfect to me.
Then the counter's fine and the input filter is eating your pulses. Device configuration, CPU properties, DI 14/DQ 10, Digital inputs, Channel 0 and Channel 1, Input filters. Default is 6.4 ms, which is a debounce for pushbuttons, and a 250 us pulse never gets through it. The HSC only sees what the filter passes.
Set the filter on I0.0 and I0.1 below your pulse width, 0.2 ms or one of the microsecond options, and download. Same on every brand, the fast counter is only as fast as the input stage in front of it. By hand the pulses are milliseconds wide and the filter lets those through, which is why it looked right slowly.
Set the input filter on channels 0 and 1 to 12.8 us, downloaded, and the count is 400 per turn at full speed now, checked over a minute against the scope.
So the 6.4 ms default filter was swallowing my 250 us pulses and the counter only ever saw what got past it. Lowering the filter on the two HSC inputs was the whole fix, the wiring and the mode were fine all along.
Why is the default 6.4 ms on inputs the HSC can use? I'd have expected TIA to change it when I set the HSC up, though maybe that would catch someone else out the other way. Thanks carav9 and hkraus.
The HSC dialog and the filter dialog never talk to each other.