There are two timer / counter modes for pulse width modulation (PWM), one is 16 bit, the other 8 bit. These, and the available timer clocks are described in your LabJack User's manual and vary depending on the device. The setup, however, is largely the same. Here's some sample script for setting up and starting a PWM8 on FIO4. As always, we assume you've done using() and include() someplace else and defined ID appropriately:
//Set the timer/counter pin offset to 4, which will put the first timer/counter on FIO4.
AddRequest (ID, LJ_ioPUT_CONFIG, LJ_chTIMER_COUNTER_PIN_OFFSET, 4, 0, 0)
// use system clock so works on U3 and UE9:
AddRequest(ID, LJ_ioPUT_CONFIG, LJ_chTIMER_CLOCK_BASE, LJ_tcSYS, 0, 0)
//Enable 1 timer. It will use FIO0.
AddRequest(ID, LJ_ioPUT_CONFIG, LJ_chNUMBER_TIMERS_ENABLED, 1, 0, 0)
//Configure Timer0 as 8-bit PWM. Frequency will be 1M/256 = 3906 Hz.
AddRequest(ID, LJ_ioPUT_TIMER_MODE, 0, LJ_tmPWM8, 0, 0)
//Set the PWM duty cycle to 50%.
AddRequest(ID, LJ_ioPUT_TIMER_VALUE, 0, 32768, 0, 0)
//Execute the requests.
GoOne(ID)
We've explained most of these commands already. The only one new is the LJ_ioPUT_TIMER_VALUE. This sets the PWM duty cycle. Even though we are using an 8 bit PWM, this takes a 16 bit number. 32768 is half way into a 16 bit unsigned integer, so this results in a 50% duty cycle PWM. The general form of this command is:
LabJack ID, LJ_ioPUT_TIMER_VALUE, Timer #, Value, 0, 0
The two modes are:
LJ_tmPWM8
LJ_tmPWM16