Please enable JavaScript to view this site.

DAQFactory User's Guide

Navigation: 17 Devices > 17.7 LabJack UE9 / U6 / U3 > 17.7.6 Counters and Timers > 17.7.6.5 Setting up Specific Timer Modes

17.7.6.5.5 Firmware Counter In w/ Debounce

Scroll Prev Top Next More

This Timer mode works the same as Firmware Counter In, but introduces a debounce circuit for mechanical switch counting.  It is really designed for frequencies less than 10hz, mostly push-button and reed-switch detection.  Setting it up is similar to the regular Firmware Counter In, but has some extra steps to set the debounce settings:

1) Enable a Timer:

 

AddRequest(ID, LJ_ioPUT_CONFIG, LJ_chNUMBER_TIMERS_ENABLED, 1, 0, 0)

2) Set the mode:

 

AddRequest(ID, LJ_ioPUT_TIMER_MODE, 0, LJ_tmFIRMCOUNTERDEBOUNCE, 0, 0)

3) Set the clock frequency and divisor:

 
// use system clock so works on U3 and UE9:

AddRequest(ID, LJ_ioPUT_CONFIG, LJ_chTIMER_CLOCK_BASE, LJ_tcSYS, 0, 0)
AddRequest(ID, LJ_ioPUT_CONFIG, LJ_chTIMER_CLOCK_DIVISOR, 48, 0, 0)

4) Set the debounce settings to a single 87ms period, positive edges counted:

 

AddRequest(ID, LJ_ioPUT_TIMER_VALUE, 0, 257, 0, 0)

5) GoOne() to actually execute the commands:

 

GoOne(ID)

6) Create a channel to read the Timer.  I/O Type is Timer, Channel # is the timer #, in this case 0.

You can reset the timer to 0 by using LJ_ioPUT_TIMER_VALUE, put please read the section on resetting counters and how to get around it.

 

AddRequest(ID, LJ_ioPUT_TIMER_VALUE, 0, 0, 0, 0)