Skip to Navigation

U6

Everything tagged "U6"

4.3.6 - Timers & Counters

There are eight IOTypes used to write or read timer and counter information:


LJ_ioGET_COUNTER
LJ_ioPUT_COUNTER_ENABLE
LJ_ioGET_COUNTER_ENABLE
LJ_ioPUT_COUNTER_RESET

LJ_ioGET_TIMER
LJ_ioPUT_TIMER_VALUE
LJ_ioPUT_TIMER_MODE
LJ_ioGET_TIMER_MODE

In addition to specifying the channel number, the following mode constants are passed in the value parameter when doing a request with the timer mode IOType:


LJ_tmPWM16                //16-bit PWM output
LJ_tmPWM8                 //8-bit PWM output
LJ_tmRISINGEDGES32        //Period input (32-bit, rising edges)
LJ_tmFALLINGEDGES32       //Period input (32-bit, falling edges)
LJ_tmDUTYCYCLE            //Duty cycle input
LJ_tmFIRMCOUNTER          //Firmware counter input
LJ_tmFIRMCOUNTERDEBOUNCE  //Firmware counter input (with debounce)
LJ_tmFREQOUT              //Frequency output
LJ_tmQUAD                 //Quadrature input
LJ_tmTIMERSTOP            //Timer stop input (odd timers only)
LJ_tmSYSTIMERLOW          //System timer low read
LJ_tmSYSTIMERHIGH         //System timer high read
LJ_tmRISINGEDGES16        //Period input (16-bit, rising edges)
LJ_tmFALLINGEDGES16       //Period input (16-bit, falling edges)

The following are special channels, used with the get/put config IOTypes, to configure a parameter that applies to all timers/counters:


LJ_chNUMBER_TIMERS_ENABLED     //0-4
LJ_chTIMER_CLOCK_BASE          //Value constants below
LJ_chTIMER_CLOCK_DIVISOR       //0-255, where 0=256
LJ_chTIMER_COUNTER_PIN_OFFSET  //0-8

With the clock base special channel above, the following constants are passed in the value parameter to select the frequency:

tags:

Comments

No comments yet. Speak up. We're listening.

4.3.5 - Digital I/O

There are eight IOTypes used to write or read digital I/O information:


LJ_ioGET_DIGITAL_BIT         //Also sets direction to input.
LJ_ioGET_DIGITAL_BIT_DIR
LJ_ioGET_DIGITAL_BIT_STATE
LJ_ioGET_DIGITAL_PORT        //Also sets directions to input.  x1 is number of bits.
LJ_ioGET_DIGITAL_PORT_DIR    //x1 is number of bits.
LJ_ioGET_DIGITAL_PORT_STATE  //x1 is number of bits.

LJ_ioPUT_DIGITAL_BIT         //Also sets direction to output.
LJ_ioPUT_DIGITAL_PORT        //Also sets directions to output.  x1 is number of bits.

DIR is short for direction, and 0 is input. Note that when you use LJ_ioGET_DIGITAL_BIT_STATE or LJ_ioGET_DIGITAL_PORT_STATE on a line set to output, it leaves it set as output, but it is doing an actual state read based on the voltage(s) on the pin(s). So if you set a line to output-high, but then something external is driving it low, it might read low.

When a request is done with one of the port IOTypes, the Channel parameter is used to specify the starting bit number, and the x1 parameter is used to specify the number of applicable bits. The bit numbers corresponding to different I/O are:


0-7    FIO0-FIO7
8-15   EIO0-EIO7
16-19  CIO0-CIO3
20-22  MIO0-MIO2

Note that the GetResult function does not have an x1 parameter. That means that if two (or more) port requests are added with the same IOType and Channel, but different x1, the result retrieved by GetResult would be undefined.

tags:

Comments

No comments yet. Speak up. We're listening.

4.3.4 - Analog Outputs

The IOType to set the voltage on an analog output is:


LJ_ioPUT_DAC

The following is a special channel, used with the get/put config IOTypes, to configure a parameter that applies to all DACs:

LJ_chDAC_BINARY

Following is example pseudocode to set DAC0 to 2.5 volts:


//Set DAC0 to 2.5 volts.
ePut (lngHandle, LJ_ioPUT_DAC, 0, 2.50, 0);
tags:

4.3.3 - Analog Inputs

The IOTypes to retrieve a command/response analog input reading are:


LJ_ioGET_AIN       //Single-ended.  Negative channel is fixed as 0/15/199.
LJ_ioGET_AIN_DIFF  //Specify negative channel in x1.

Differential channels are adjacent even/odd pairs only, such as AIN2-AIN3. Thus the positive channel must be even and the negative channel must be +1. The Windows UD driver has different IOTypes for single-ended or differential reads, but the differential IOType can always be used as a negative channel (x1 parameter) of 0/15/199 equates to a single-ended reading.

The following are IOTypes used to configure (or read) the input range of a particular analog input channel:


LJ_ioPUT_AIN_RANGE    // Range and Gain are synonymous
LJ_ioGET_AIN_RANGE    // Range and Gain are synonymous

In addition to specifying the channel number, the following range (i.e. gain) constants are passed in the value parameter when doing a request with the AIN range IOType:

LJ_rgBIP10V     // +/- 10V, i.e. Gain=x1
LJ_rgBIP1V      // +/- 1V, i.e. Gain=x10
LJ_rgBIPP1V     // +/- 0.1V, i.e. Gain=x100
LJ_rgBIPP01V    // +/- 0.01V, i.e. Gain=x1000

The following are special channels, used with the get/put config IOTypes, to configure parameters that apply to all analog inputs:

LJ_chAIN_RESOLUTION     //0=default, 1-8=high-speed ADC, 9-12=high-res ADC
LJ_chAIN_SETTLING_TIME  //0-9 where 0=Auto, see Section 5.2.5.2
LJ_chAIN_BINARY

Following is example pseudocode to read analog inputs:


//Configure all analog inputs for max resolution.  
tags:

4.3.2 - Configuration

There are two IOTypes used to write or read general U6 configuration parameters:


LJ_ioPUT_CONFIG
LJ_ioGET_CONFIG

The following constants are then used in the channel parameter of the config function call to specify what is being written or read:


LJ_chLOCALID
LJ_chHARDWARE_VERSION
LJ_chSERIAL_NUMBER
LJ_chFIRMWARE_VERSION
LJ_chBOOTLOADER_VERSION
LJ_chPRODUCTID
LJ_chLED_STATE

Following is example pseudocode to write and read the local ID:


//Set the local ID to 4.
ePut (lngHandle, LJ_ioPUT_CONFIG, LJ_chLOCALID, 4, 0);

//Read the local ID.
eGet (lngHandle, LJ_ioGET_CONFIG, LJ_chLOCALID, &dblValue, 0);
tags:

Comments

No comments yet. Speak up. We're listening.

4.3 - Example Pseudocode

The following pseudocode examples are simplified for clarity, and in particular no error checking is shown. The language used for the pseudocode is C.
tags:

Comments

No comments yet. Speak up. We're listening.

4.2.22 - eTCValues()

An easy function that updates and reads all the timers and counters. This is a simple alternative to the very flexible IOType based method normally used by this driver.

Declaration:

LJ_ERROR _stdcall eTCValues (  LJ_HANDLE Handle,
                               long *aReadTimers,
                               long *aUpdateResetTimers,
                               long *aReadCounters,
                               long *aResetCounters,
                               double *aTimerValues,
                               double *aCounterValues,
                               long Reserved1,
                               long Reserved2)

Parameter Description:
Returns: LabJack errorcodes or 0 for no error.
Inputs:

  • Handle – Handle returned by OpenLabJack().
  • aReadTimers – An array where each element specifies whether to read that timer. A nonzero value for an array element specifies to read that timer.1
  • aUpdateResetTimers – An array where each element specifies whether to update/reset that timer. A nonzero value for an array element specifies to update/reset that timer.1
  • aReadCounters – An array where each element specifies whether to read that counter. A nonzero value for an array element specifies to read that counter.2
  • aResetCounters – An array where each element specifies whether to reset that counter. A nonzero value for an array element specifies to reset that counter.2
  • aTimerValues – An array where each element is the new value for that timer. Each value is only updated if the appropriate element is set in the aUpdateResetTimers array.1
  • Reserved (1&2) – Pass 0.

Outputs:

  • aTimerValues – An array where each element is the value read from that timer if the appropriate element is set in the aReadTimers array.
  • aCounterValues – An array where each element is the value read from that counter if the appropriate element is set in the aReadCounters array.

1 Array size must be equal to the number of timers available on the device. UE9:6, U6:4, U3:2
2 Array size must be equal to the number of counters available on the device. UE9:2, U6:2, U3:2

tags:

Comments

No comments yet. Speak up. We're listening.

4.2.21 - eTCConfig()

An easy function that configures and initializes all the timers and counters. This is a simple alternative to the very flexible IOType based method normally used by this driver.

When needed, this function automatically configures the needed lines as digital.

Declaration:

LJ_ERROR _stdcall eTCConfig (  LJ_HANDLE Handle,
                               long *aEnableTimers,
                               long *aEnableCounters,
                               long TCPinOffset,
                               long TimerClockBaseIndex,
                               long TimerClockDivisor,
                               long *aTimerModes,
                               double *aTimerValues,
                               long Reserved1,
                               long Reserved2)

Parameter Description:
Returns: LabJack errorcodes or 0 for no error.
Inputs:

  • Handle – Handle returned by OpenLabJack().
  • aEnableTimers – An array where each element specifies whether that timer is enabled. Timers must be enabled in order starting from 0, so for instance, Timer0 and Timer2 cannot be enabled without enabling Timer1 also. A nonzero value for an array element specifies to enable that timer. Array size must be equal to the number of timers available on the device.1
  • aEnableCounters – An array where each element specifies whether that counter is enabled. Counters do not have to be enabled in order starting from 0, so Counter1 can be enabled when Counter0 is disabled. A nonzero value for an array element specifies to enable that counter. Array size must be equal to the number of counters available on the device.2
  • TCPinOffset – Value specifies where to start assigning timers and counters.3
  • TimerClockBaseIndex – Pass a constant to set the timer base clock. The default is device specific.4
  • TimerClockDivisor – Pass a divisor from 0-255 where 0 is a divisor of 256.
  • aTimerModes – An array where each element is a constant specifying the mode for that timer. Array size must be equal to the number of timers available on the device.1
  • aTimerValues – An array where each element is specifies the initial value for that timer. Array size must be equal to the number of timers available on the device.1
  • Reserved (1&2) – Pass 0.

1 Number of timers UE9:6, U6:4, U3:2
2 Number of counters UE9:2, U6:2, U3:2
3 Pin offset UE9:Ignored, U6:0-8, U3:4-8
4 Default constant UE9:LJ_tc750KHZ, U6:LJ_tc48MHZ, U3:LJ_tc48MHZ

tags:

Comments

No comments yet. Speak up. We're listening.

4.2.20 - eDO()

An easy function that writes the state of one digital output. This is a simple alternative to the very flexible IOType based method normally used by this driver.

When needed, this function automatically configures the specified channel as a digital output.

Declaration:

LJ_ERROR _stdcall eDO (  LJ_HANDLE Handle,
                         long Channel,
                         long State)

Parameter Description:
Returns: LabJack errorcodes or 0 for no error.
Inputs:

  • Handle – Handle returned by OpenLabJack().
  • Channel – The channel to write to. 0-19 corresponds to FIO0-CIO3.
  • State – The state to write to the digital output. 0=False=Low and 1=True=High.

tags:

Comments

No comments yet. Speak up. We're listening.

4.2.19 - eDI()

An easy function that reads the state of one digital input. This is a simple alternative to the very flexible IOType based method normally used by this driver.

When needed, this function automatically configures the specified channel as a digital input.

Declaration:

LJ_ERROR _stdcall eDI (  LJ_HANDLE Handle,
                         long Channel,
                         long *State)

Parameter Description:
Returns: LabJack errorcodes or 0 for no error.
Inputs:

  • Handle – Handle returned by OpenLabJack().
  • Channel – The channel to read. 0-19 corresponds to FIO0-CIO3.

Outputs:

  • State – Returns the state of the digital input. 0=False=Low and 1=True=High.

tags:

Comments

No comments yet. Speak up. We're listening.