« Close

Datasheets and User Guides

App Notes

Software & Driver


Configuring a PWM Output

T-series devices have various configurable clock sources as part of the Digital I/O Extended Feature (DIO-EF) system. In this example we will use the Kipling Register Matrix to configure an output for a PWM signal. For this example we use clock 0 with default settings. The clock source is the base for configuring PWM output. In this example we will set the frequency to 10kHz and the duty cycle to 25%.

This example uses FIO0 (aka DIO0) which is handy on the T7. For the T4 use FIO4 (DIO4) instead.


1. Go to the Register Matrix in Kipling and type "dio0" in the search box to narrow the list of registers. Add the enable and config-a registers to the active list as shown.


2. Change the search term to "clock0" and add the clock enable and the clock roll value to the active list. Since the default frequency is 80Mhz, to get 10kHz we need to divide by 800000. Since our divisor is 1 (default), our roll value is 800000.
80 MHz / (1 * 800000) = 100 Hz
To configure the duty cycle: 25% = 100 * Config_A / Roll_Value, so Config_A is 200000.


3. Write the following values:

DIO0_EF_ENABLE = 0 //Cannot change index if enabled
DIO0_EF_CONFIG_A = 200000


4. At this point the LabJack is outputting PWM on FIO0 at 100Hz with 25% duty cycle. To see the output, see Displaying PWM output in LJStreamM

5. To save the configuration, so the PWM will be configured at boot-up, go to the Power-Up Defaults tab and click "Configure Power-up Defaults". Make sure that "Current Device Settings" option is selected. This is suggested if using LJLogM or LJStreamM, or other simple polling programs, but not needed if your software will do the configuration.



Touching a conductor to the top of the screw head of an un-clamped screw terminal is rarely a valid connection.  The screw head is usually valid when the terminal is clamped, but the only guaranteed valid connection is to securely clamp a conductor inside the screw terminal.


Displaying PWM in LJLogM

Once the PWM output is enabled (above), you can read FIO0 using any row in LJLogM. Change the interval to 1ms and the number of displayed results to 500. The graphed result should show a PWM graph with 25% duty cycle. To see the outputted waveform better, use LJStreamM.


Displaying PWM in LJStreamM

Once the PWM is enabled (above), you can read FIO0 using any row in LJStreamM. Set the scan rate to 10000Hz and the graph history to 1000 scans to see the PWM more clearly. Once the stream is started you should see the outputted PWM in the waveform output.


Configuring PWM in DAQFactory

To configure the counter you can use steps 1-5 above or write to the previously mentioned registers in DAQFactory. See "Device Configuration" on the DAQFactory for LJM page.


Configuring PWM in Your Program

A very handy tool that is available is the PWM pseudocode generator on the PWM extended feature page. Otherwise, to configure PWM check the registers above that need to be written to. You can do this with a few calls to eWriteName or a single call to eWriteNames. When using eWriteNames you need to be sure to configure them according to the order specified above.