====== CTUD Box Function ====== **Count Up/Down Counter** Category: [[en-us_products:mpino_studio2:box_functions:counter|Counter Box Functions]] ===== Behavior ===== While the left condition is ON, a rising edge on the up input adds one and a rising edge on the down input subtracts one. If both rise in the same scan, the value does not change. ===== Syntax and Arguments ===== **Syntax:** ''CTUD C11 M0 M1 3'' * Target — counter memory C (16-bit) or DC (32-bit) * up — the bit contact to increment (e.g. P0/M1) * down — the bit contact to decrement (e.g. P1/M2) * preset — count at which the done bit turns ON (an integer, not time) ===== Behavior Example ===== ^ Run condition ^ Before ^ Command entered ^ Expected result ^ | Left condition ON | C11=0 | ''CTUD C11 M0 M1 3'' | M0 ×2, M1 ×1 → C11=1 | {{ :en-us_products:mpino_studio2:counter-ctud-timing.svg?1000 |CTUD input, current value, and done state }} ===== Cautions ===== * A counter changes once per rising edge of the left condition. On MPINO-8A4R(T)-S, C0 through C10 are mapped to board functions, so use C11 or later for a counter. ===== Box Functions in the Same Category ===== * [[en-us_products:mpino_studio2:box_functions:counter:ctu|CTU View details]] — Count Up Counter * [[en-us_products:mpino_studio2:box_functions:counter:ctd|CTD View details]] — Count Down Counter