I am using the U3-HV Timers to produce two PWM signals (on Counter 0 and Counter 1) with different Duty Cycles (DC). I'm using the VEE example program eFunctionsTimerCounter.vee to do this (please see attached image). I have two questions:
1) I'm having no problem generating one or two PWM signals with different DCs. I can get one PWM on Counter 0, or two PWM signals on Counters 0 & 1. But what I've found is that if Counter 0 is disabled, I can't get a PWM signal on Counter 1. I've tried this on both FIO and EIO outputs with the same result. I'd like to be able to operate the two PWMs separately. But I can't seem to get PWM from just Counter 1 and not 0. Does Counter 0 PWM have to be enabled for Counter 1 PWM to operate?
2) According to Sect.s 2.9.1.1 & 2.9.1.2 in the manual:
https://labjack.com/support/datasheets/u3/hardware-description/timers-co...
https://labjack.com/support/datasheets/u3/hardware-description/timers-co...
... the PWM frequency is supposed to be set by the TimerClockBase and the Divisor. In the VEE program shown, there is a TimerClockBaseIndex value passed to the eTCCONFIG function call, implying some kind of array (?). But no matter what value I put in here or the Divisor input to the same function, the output frequency remains the same. Only the values put into aTimerModes affects the frequency, for which 0 gives 732.4Hz and 1 gives 187.5KHz. Maybe I'm missing something. How can I change the PWM frequency? Is this possible using an eFunction?
Thanks for your help on both of these questions!
1. See the pin assignment information in Section 2.9:
https://labjack.com/support/datasheets/u3/hardware-description/timers-co...
PWM is created with timers, and timers are enabled simply by specifying a value for LJ_chNUMBER_TIMERS_ENABLED:
https://labjack.com/support/datasheets/u3/high-level-driver/example-pseu...
So if you enable 1 timer, it is Timer0, and if you enable 2 timers they are Timer0 and Timer1. There are a couple options for you assuming you are starting with 2 timers enabled with pinoffset=4, and thus Timer0 is on FIO4 and Timer1 is on FIO5:
A. Change to 1 timer enabled with pinoffset=5 and you will not have Timer0 on FIO5.
B. Change the mode of either timer to some input mode so it is not outputting anything. Many people use LJ_tmSYSTIMERLOW.
2. The TimerClockBaseIndex parameter is not an array:
https://labjack.com/support/datasheets/u3/high-level-driver/function-ref...
The reason it says "Index" is because you don't pass the actual clock value (e.g. 4000000) but rather you pass an index (e.g. LJ_tc4MHZ_DIV = 24) that specifies the base clock frequency. If you need the constant numbers, which are not shown in Section 4.3.6, you can look at the header file labjackud.h:
const long LJ_tcSYS = 1; // UE9 + U3 + U6: System clock
const long LJ_tc4MHZ = 20; // U3: Hardware Version 1.21 or higher, + U6
const long LJ_tc12MHZ = 21; // U3: Hardware Version 1.21 or higher, + U6
const long LJ_tc48MHZ = 22; // U3: Hardware Version 1.21 or higher, + U6
const long LJ_tc1MHZ_DIV = 23; // U3: Hardware Version 1.21 or higher, + U6
const long LJ_tc4MHZ_DIV = 24; // U3: Hardware Version 1.21 or higher, + U6
const long LJ_tc12MHZ_DIV = 25; // U3: Hardware Version 1.21 or higher, + U6
const long LJ_tc48MHZ_DIV = 26; // U3: Hardware Version 1.21 or higher, + U6
So if you want to use divisor, pass a base index of 23-26 and then use the desired divisor.
Excellent suggestions on both counts (pardon the pun)! Your prompt response is especially appreciated. Thank you!