eDAC()
//Write to 1 analog output.
eDI()
//Read 1 digital input.
eDO()
//Write to 1 digital output.
eTCConfig()
//Configure all timers and counters.
eTCValues()
//Update/reset and read all timers and counters.
In addition to the basic operations, these functions also automatically handle configuration as needed. For example, eDO() sets
the specified line to output if previously configured as input.
The first 4 functions should not be used when speed is critical with multi-channel reads. These functions use one low-level function
per operation, whereas using the normal Add/Go/Get method with IOTypes, many operations can be combined into a single low-
level call. With single channel operations, however, there will be little difference between using an easy function or Add/Go/Get.
The last two functions handle almost all functionality related to timers and counters, and will usually be as efficient as any other
method. These easy functions are recommended for most timer/counter applications.
Following is example pseudocode:
//Take a measurement from AIN3 using 0-5 volt range and 12-bit resolution.
//eAIN (Handle, ChannelP, ChannelN, *Voltage, Range, Resolution,
// Settling, Binary,
Reserved1, Reserved2)
//
eAIN(lngHandle, 3, 0, &dblVoltage, LJ_rgUNI5V, 12, 0, 0, 0, 0);
printf("AIN3 value = %.3f\n",dblVoltage);
//Set DAC0 to 3.1 volts.
//eDAC (Handle, Channel, Voltage, Binary, Reserved1, Reserved2)
//
eDAC(lngHandle, 0, 3.1, 0, 0, 0);
//Read state of FIO2.
//eDI (Handle, Channel, *State)
//
eDI(lngHandle, 2, &lngState);
printf("FIO2 state = %.0f\n",lngState);
//Set FIO3 to output-high.
//eDO (Handle, Channel, State)
//
eDO(lngHandle, 3, 1);
//Enable and configure 1 output timer and 1 input timer, and enable Counter0.
//Fill the arrays with the desired values, then make the call.
alngEnableTimers = {1,1,0,0,0,0}; //Enable Timer0-Timer1
alngTimerModes = {LJ_tmPWM8,LJ_tmRISINGEDGES32,0,0,0,0}; //Set timer modes
adblTimerValues = {16384,0,0,0,0,0}; //Set PWM8 duty-cycle to 75%.
alngEnableCounters = {1,0}; //Enable Counter0
//
//eTCConfig (Handle, *aEnableTimers, *aEnableCounters, TCPinOffset,
//
TimerClockBaseIndex, TimerClockDivisor, *aTimerModes,
//
*aTimerValues, Reserved1, Reserved2);
//
eTCConfig(lngHandle, alngEnableTimers, alngEnableCounters, 0, LJ_tc750KHZ, 3, alngTimerModes, adblTimerValues, 0, 0);
//Read and reset the input timer (Timer1), read and reset Counter0, and update
//the value (duty-cycle) of the output timer (Timer0).
//Fill the arrays with the desired values, then make the call.
alngReadTimers = {0,1,0,0,0,0}; //Read Timer1
alngUpdateResetTimers = {1,1,0,0,0,0}; //Update Timer0 and reset Timer1
alngReadCounters = {1,0}; //Read Counter0
alngResetCounters = {1,0}; //Reset Counter0
adblTimerValues = {32768,0,0,0,0,0}; //Change Timer0 duty-cycle to 50%
//
//eTCValues (Handle, *aReadTimers, *aUpdateResetTimers, *aReadCounters,
//
*aResetCounters, *aTimerValues, *aCounterValues, Reserved1,
//
Reserved2);
//
eTCValues(lngHandle, alngReadTimers, alngUpdateResetTimers, alngReadCounters, alngResetCounters, adblTimerValues, adblCounterValues, 0, 0);
printf("Timer1 value = %.0f\n",adblTimerValues[1]);
printf("Counter0 value = %.0f\n",adblCounterValues[0]);
4.3.10 - SPI Serial Communication
The UE9 supports Serial Peripheral Interface (SPI) communication as the master only. SPI is a synchronous serial protocol
typically used to communicate with chips that support SPI as slave devices.
This serial link is not an alternative to the USB connection. Rather, the host application will write/read data to/from the UE9 over
USB, and the UE9 communicates with some other device using the serial protocol. Using this serial protocol is considered an
advanced topic. A good knowledge of the protocol is recommended, and a logic analyzer or oscilloscope might be needed for
troubleshooting.
There is one IOType used to write/read data over the SPI bus:
LJ_ioSPI_COMMUNICATION
// Value= number of bytes (1-240). x1= array.
The following are special channels, used with the get/put config IOTypes, to configure various parameters related to the SPI bus.
See the low-level function description in Section 5.3.16 for more information about these parameters:
LJ_chSPI_AUTO_CS
LJ_chSPI_DISABLE_DIR_CONFIG
LJ_chSPI_MODE
47
Need help?
Do you have a question about the UE9 and is the answer not in the manual?