Skip to main content
Skip table of contents

Counter#: IOType=54,55

Counter#, 2 Command Bytes: 

0

IOType=54,55

1

Bit 0: Reset

4 Response Bytes: 

0

Counter LSB

1

Counter

2

Counter

3

Counter MSB

This IOType reads a hardware counter, and optionally can do a reset.

  • Reset: Setting this bit resets the counter to 0 after reading.

  • Counter: Returns the current count from the counter if enabled. This is the value before reset (if reset was done).

Example

PY
# Counter Feedback command

import u3
d = u3.U3()
d.debug = True
d.configIO(EnableCounter0 = True, FIOAnalog = 15)
# Sent:  [0x5f, 0xf8, 0x3, 0xb, 0x58, 0x0, 0x5, 0x0, 0x44, 0x0, 0xf, 0x0]
# Response:  [0x5a, 0xf8, 0x3, 0xb, 0x53, 0x0, 0x0, 0x0, 0x44, 0x0, 0xf, 0x0]
# {'NumberOfTimersEnabled': 0, 'TimerCounterPinOffset': 4, 'DAC1Enable': 0, 'FIOAnalog': 15, 'EIOAnalog': 0, 'TimerCounterConfig': 68, 'EnableCounter1': False, 'EnableCounter0': True}
d.getFeedback(u3.Counter(counter = 0, Reset = False))
# Sent:  [0x31, 0xf8, 0x2, 0x0, 0x36, 0x0, 0x0, 0x36, 0x0, 0x0]
# Response:  [0xfc, 0xf8, 0x4, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0]
# [0]
# Tap a ground wire to counter 0
d.getFeedback(u3.Counter(counter = 0, Reset = False))
# Sent:  [0x31, 0xf8, 0x2, 0x0, 0x36, 0x0, 0x0, 0x36, 0x0, 0x0]
# Response:  [0xe9, 0xf8, 0x4, 0x0, 0xec, 0x0, 0x0, 0x0, 0x0, 0xe8, 0x4, 0x0, 0x0, 0x0]
# [1256]
JavaScript errors detected

Please note, these errors can depend on your browser setup.

If this problem persists, please contact our support.