Configuring and Reading Counters [U3/U6/UE9] | LabJack
 
« Close

Datasheets and User Guides

App Notes

Software & Driver

 

Configuring and Reading Counters [U3/U6/UE9]

Counter features on UD devices can easily be configured and read without custom software by using our LJControlPanel and LJLogUD/LJStreamUD software on Windows.

Configuring Counters in LJControlPanel

  1. Open the device in LJControlPanel.

    Follow steps 1-6 in our U3/U6/UE9 Quickstart Tutorials.
     
  2. Click the "Config" button in the Timer/Counter section of the Test panel.

    Once pressed, a new window should appear with more timer and counter settings.


     
  3. Enable your counters.

    For this tutorial we will enable one counter on FIO4.

    Ensure "# Timers Enabled" is 0 and click the "Enable" box for Counter 0.


     
  4. Set the "Pin Offset".

    Set the "Pin Offset" entry to 4 to put Counter0 on FIO4. This is most convenient for U3 users; U6 or UE9 users could apply a pin offset of 0 to put Counter0 on FIO0. Note that the minimum pin offset for the U3 is 4. See the timer/counter datasheet page of the U3 for more information.

    If any timers were enabled they would appear on the DIO before the counters. For example, if two timers and Counter0 are enabled with a pin offset of 4, the timers would appear on FIO4 and FIO5 and Counter0 would appear on FIO6.


     
  5. Click "OK".

    The smaller timer/counter window will close and you should now see your counter value incrementing if you have a good pulse input attached to the counter0 DIO pin. If you are unsure if you have a good pulse input, a jumper wire clamped in a GND terminal should produce increments when you tap the other end of the wire to the inside-back of the timer/counter DIO pin terminal[1]. Clicking inside the Counter0 reset box will reset the counter back to 0. 


     
  6. Troubleshooting an input.

    With a typical counter signal, you would connect signal+ to the counter DIO (FIO4 in this tutorial) and connect signal- to a GND terminal on the LabJack.

    The necessary connections for your signal could depend on the details of your signal. Some further resources that may be useful for troubleshooting a digital signal are the Driven Signals and Open-Collector Signals app notes.

    Always ensure you have a good electrical connection from your signal to the LabJack. Touching a conductor to the top of the screw head of an un-clamped screw terminal is rarely a valid electrical connection. The screw head is usually a valid connection point when the terminal is clamped, but the only guaranteed valid connection is to securely clamp a conductor/ signal wire inside the screw terminal.

    If your signal is not giving you counts, use a DMM or oscilloscope to confirm you have valid voltages on the DIO line. The counter/digital input in this example is looking for a rising edge, which means that the state of the digital input changes from low to high. On UD devices a low is less than 0.8V and a high is greater than 2.00V. See the specifications in your device datasheet for further details U3/U6/UE9.

    If too many edges are being detected: If the signal is very noisy it can cause multiple fast edges rather than a single edge. A simple low pass RC filter (e.g. R=1k and C=0.01uF gives a cutoff frequency of 16kHz) is a possible solution, but the problem suggests the signal is very noisy and could be a symptom of improper connection. Mechanical switch signals can be susceptible to switch bounce, which can result in additional edges; see our Switch Signal app note.
     
  7. [Optional] Save your timers and counters in your startup configuration.

    This is suggested if using LJLogUD, LJStreamUD, or other simple polling programs, but not needed if your software will do the configuration. Also note that U3 hardware revisions 1.20 and 1.21 do not support timer/counter startup configurations.The U3-LV and U3-HV are hardware revision 1.30.

    To save your timers and counters for startup you must set up the timers/counters in the Config  Defaults panel of LJControlPanel rather than the Test panel.

    First, close the Test panel and click "Config Defaults".


    Set up all of your timer/counter settings.


    Click "Write Values". A new window will pop up; Click "Yes" to save your configuration.


    Close LJCP and power cycle the device to apply your changes. Note that the Test panel will not load your configurations, so we recommend you test the feature in LJLogUD.  You can also return to the Config Defaults panel in LJCP to see if it shows the power up defaults you set.

[1] LabJack digital inputs have an internal 100k pull-up that weakly holds them high, so when you connect a GND wire to a digital input it will pull the line low and create a falling edge. When you pull out the wire you get a rising edge.  You are not likely to make a perfectly clean single contact, so a counter will typically increment many counts each time you tap the wire.  Also note that you should touch the ground wire to the inside-back of the counter terminal.

Next Step:

The following forum topic describes how to do frequency measurement with a counter. You can also move on to Configuring a Timer or subsequently Logging Timers/Counters.