Lindholm Engineers / Mbed 2 deprecated Ultrasonic_Firmware

Dependencies:   mbed

Embed: (wiki syntax)

« Back to documentation index

TDC1000 Class Reference

TDC1000 Class Reference

TDC1000.h Chip function manifest for the TDC1000 More documentation to come. More...

#include <TDC1000.h>

Public Member Functions

 TDC1000 (PinName ChSel=p22, PinName ERR=p23, PinName EN=p16, PinName RESET=p10, PinName SCLK=p7, PinName CS=p8, PinName MOSI=p5, PinName MISO=p6)
 Create TDC1000 instance.
int readError ()
 readError Function The read error function reads the error register and returns that value.
void errorHandler ()
 errorHandler function The error handler function is not really meant to be called by the user.
bool readToggle (SettingChoice)
 readToggle function The read a toggle setting function reads a toggle setting for the TDC1000.
void setToggle (SettingChoice)
 setToggle function This toggle function is very similar to the readToggle function, except that instead of simply reading the setting value, it changes it.
int readMODE_SELECT ()
 MODE_SELECT is the mode the chip is in.
int readTX_FREQ_DIV ()
 TX_FREQ_DIV is the transmit frequency divisor.
int readNUM_TX ()
 NUM_TX is the number of transmit pulses.
int readNUM_AVG ()
 NUM_AVG is the number of cycles to create averaging.
int readNUM_RX ()
 NUM_RX is the number of expected receive pulses.
int readECHO_QUAL_THLD ()
 ECHO_QUAL_THLD is the voltage that qualifies a receive pulse.
int readTX_PH_SHIFT_POS ()
 TX_PH_SHIFT_POS is the point in the transmit burst that the phase shift occurs.
int readPGA_GAIN ()
 PGA_GAIN is the gain of the Programmable Gain Amplifier.
int readTIMING_REG ()
 TIMING_REG creates the period between transmit and receive.
int readSHORT_TOF_BLANK_PERIOD ()
 SHORT_TOF_BLANK_PERIOD is the blanking period for a short TOF measurement.
int readTOF_TIMEOUT_CTRL ()
 TOF_TIMEOUT_CTRL is the echo listening window timeout.
int readAUTOZERO_PERIOD ()
 AUTOZERO_PERIOD is the receiver auto-zero period.
bool read_EN ()
 Enable the chip.
void resetTDC1000 ()
 Reset the chip, also resetting all settings.
bool readChannelSelect ()
 utilize external channel selection
int readClockFrequencyIn ()
 Functions that read setting values.
void setClockFrequencyIn (int)
 Clock frequency is not set within the chip.

Detailed Description

TDC1000.h Chip function manifest for the TDC1000 More documentation to come.

Unfortunately, there are a lot of pins that need to be determined. This file assumes that a separate stopwatch chip is used, and that the MCU only performs the register access functions plus a few more. If an invalid number is entered for a 'set' function, the setting will be set to the default. Pin Number on TDC1000 Function 11 Channel Select. Use any digital out pin for this. 12 Error pin. Requires an INTERRUPT pin in. 15 Enable pin. Use any digital out pin for this. 17 Reset pin. Use any digital out pin for this. 18 SPI serial clock (SCLK) pin. Tie to an SPI interface. 19 Chip select pin. Tied to SPI signal, but can be any digital out pin. 20 SPI MOSI serial pin. Tie to an SPI interface. 21 SPI MISO serial pin. Tie to an SPI interface.

Definition at line 41 of file TDC1000.h.


Constructor & Destructor Documentation

TDC1000 ( PinName  ChSel = p22,
PinName  ERR = p23,
PinName  EN = p16,
PinName  RESET = p10,
PinName  SCLK = p7,
PinName  CS = p8,
PinName  MOSI = p5,
PinName  MISO = p6 
)

Create TDC1000 instance.

TDC1000 class There are a total of 8 pins to the TDC1000 if you have a separate stopwatch chip.

If you use the MCU as a stopwatch chip, which is not recommended, the number increases to 11. The constructor for this class has 8 pin inputs and initializes a whole bunch of things, including the default values for a few variables. Pin Number on TDC1000 Function 11 Channel Select. Use any digital out pin for this. 12 Error pin. Requires an INTERRUPT pin in. 15 Enable pin. Use any digital out pin for this. 17 Reset pin. Use any digital out pin for this. 18 SPI serial clock (SCLK) pin. Tie to an SPI interface. 19 Chip select pin. Tied to SPI signal, but can be any digital out pin. 20 SPI MOSI serial pin. Tie to an SPI interface. 21 SPI MISO serial pin. Tie to an SPI interface.

Definition at line 26 of file TDC1000.cpp.


Member Function Documentation

void errorHandler (  )

errorHandler function The error handler function is not really meant to be called by the user.

It details the problem the TDC1000 has claimed, but does very little about it.

Definition at line 57 of file TDC1000.cpp.

bool read_EN (  )

Enable the chip.

Definition at line 360 of file TDC1000.cpp.

int readAUTOZERO_PERIOD (  )

AUTOZERO_PERIOD is the receiver auto-zero period.

Definition at line 339 of file TDC1000.cpp.

bool readChannelSelect (  )

utilize external channel selection

Definition at line 395 of file TDC1000.cpp.

int readClockFrequencyIn (  )

Functions that read setting values.

Definition at line 406 of file TDC1000.cpp.

int readECHO_QUAL_THLD (  )

ECHO_QUAL_THLD is the voltage that qualifies a receive pulse.

the value is a number between 0 and 7 that controls the actual threshold value, which is in negative millivolts.

Definition at line 216 of file TDC1000.cpp.

int readError (  )

readError Function The read error function reads the error register and returns that value.

Definition at line 48 of file TDC1000.cpp.

int readMODE_SELECT (  )

MODE_SELECT is the mode the chip is in.

The mode of the chip selects which transducers transmit and which transducer receives the signal. Mode 0 uses each transducer as both sender and receiver, and maps the transmit1 channel with receive2, and transmit2 with receive1. In this mode, Channel selection is what tells the chip which transducer channel to use: ChSel = 0, transmit1; ChSel = 1, transmit2. In this mode, the chip is used primarily for fluid level measurement. Mode 1 also uses each transducer as both sender and receiver. This mode varies with mode 0 by mapping the transmit1 channel with the receive1 channel, and transmit2 with receive2. Otherwise it works almost exactly like mode 0. Mode 2 is different in that it is for fluid flow measurement. The channels are mapped in the same way as mode 1 (TX1-RX1 & TX2-RX2), but when a signal is transmitted on one channel, the chip will be listening for the echo on the other channel. It can be thought of as sending signals back-and-forth between the two transducers. Mode 2 allows for automatic channel swapping: as soon as the signal goes one way, the chip can automatically send it through the second channel in the other direction. For automatic swapping, EXT_CHSEL needs to be off. There is no mode 3 ... yet.

Definition at line 115 of file TDC1000.cpp.

int readNUM_AVG (  )

NUM_AVG is the number of cycles to create averaging.

Definition at line 177 of file TDC1000.cpp.

int readNUM_RX (  )

NUM_RX is the number of expected receive pulses.

Definition at line 196 of file TDC1000.cpp.

int readNUM_TX (  )

NUM_TX is the number of transmit pulses.

Definition at line 159 of file TDC1000.cpp.

int readPGA_GAIN (  )

PGA_GAIN is the gain of the Programmable Gain Amplifier.

The actual gain is the gain number * 3dB.

Definition at line 257 of file TDC1000.cpp.

int readSHORT_TOF_BLANK_PERIOD (  )

SHORT_TOF_BLANK_PERIOD is the blanking period for a short TOF measurement.

Definition at line 301 of file TDC1000.cpp.

int readTIMING_REG (  )

TIMING_REG creates the period between transmit and receive.

Definition at line 275 of file TDC1000.cpp.

int readTOF_TIMEOUT_CTRL (  )

TOF_TIMEOUT_CTRL is the echo listening window timeout.

Definition at line 321 of file TDC1000.cpp.

bool readToggle ( SettingChoice  choice )

readToggle function The read a toggle setting function reads a toggle setting for the TDC1000.

There are ...a few toggle settings for the TDC1000. NOTICE: a value of true does not always equal enabled...

Use the name that is in the TI documentation, with capital letters, of that setting. Or, you can refer to this big chart. VCOM_SEL | Common-mode voltage reference control (default internal) MEAS_MODE | AFE measurement type (default time-of-flight) DAMPING | Transmit burst damping (default disabled) CH_SWP | Turns on or off automatic channel swapping in mode 2 (default disabled) EXT_CHSEL | Allows for external channel selection (default disabled) CH_SEL | Selects the active transmit/receive pair (default channel 1) TEMP_MODE | Select which temperature measurement channels are used (default Reference, RTD1 and RTD2) TEMP_RTD_SEL | Change which type of RTD is currently connected (default PT1000) TEMP_CLK_DIV | Modify the clock divider for the temperature mode (default divide by 8) BLANKING | Adds power blanking in the standard TOF measurements (default disabled) RECEIVE_MODE | Changes receive echo mode (default: single echo) TRIG_EDGE_POLARITY | Change what the trigger edge polarity should be (default rising edge) PGA_CTRL | Turns on or off the Programmable Gain Amplifier (default active) LNA_CTRL | Turns on or off the Low-Noise Amplifier (default active) LNA_FB | Modifies the LNA feedback mode (default capacitive feedback) FORCE_SHORT_TOF | Forces the chip to use a short TOF mode even with a large timing register (default disabled) ECHO_TIMEOUT | Turns on or off the timeout function, which means the chip will stay in receiving mode until | it receives all of the necessary echoes (default enabled) CLOCKIN_DIV | The divisor for generating the standard waiting period (default 1)

Parameters:
choiceChoice indicates which setting you want to read.

There are ...a few toggle settings for the TDC1000. NOTICE: a value of true does not always equal enabled...

Parameters:
choiceChoice indicates which setting you want to toggle.

Use the name that is in the TI documentation, with capital letters, of that setting. Or, you can refer to this big chart. VCOM_SEL | Common-mode voltage reference control (default internal) MEAS_MODE | AFE measurement type (default time-of-flight) DAMPING | Transmit burst damping (default disabled) CH_SWP | Turns on or off automatic channel swapping in mode 2 (default disabled) EXT_CHSEL | Allows for external channel selection (default disabled) CH_SEL | Selects the active transmit/receive pair (default channel 1) TEMP_MODE | Select which temperature measurement channels are used (default Reference, RTD1 and RTD2) TEMP_RTD_SEL | Change which type of RTD is currently connected (default PT1000) TEMP_CLK_DIV | Modify the clock divider for the temperature mode (default divide by 8) BLANKING | Adds power blanking in the standard TOF measurements (default disabled) RECEIVE_MODE | Changes receive echo mode (default: single echo) TRIG_EDGE_POLARITY | Change what the trigger edge polarity should be (default rising edge) PGA_CTRL | Turns on or off the Programmable Gain Amplifier (default active) LNA_CTRL | Turns on or off the Low-Noise Amplifier (default active) LNA_FB | Modifies the LNA feedback mode (default capacitive feedback) FORCE_SHORT_TOF | Forces the chip to use a short TOF mode even with a large timing register (default disabled) ECHO_TIMEOUT | Turns on or off the timeout function, which means the chip will stay in receiving mode until | it receives all of the necessary echoes (default enabled) CLOCKIN_DIV | The divisor for generating the standard waiting period (default 1)

Definition at line 98 of file TDC1000.cpp.

int readTX_FREQ_DIV (  )

TX_FREQ_DIV is the transmit frequency divisor.

Transmit Frequency = (Frequency_in)/(2^(TX_FREQ_DIV+1))

Definition at line 136 of file TDC1000.cpp.

int readTX_PH_SHIFT_POS (  )

TX_PH_SHIFT_POS is the point in the transmit burst that the phase shift occurs.

Definition at line 237 of file TDC1000.cpp.

void resetTDC1000 (  )

Reset the chip, also resetting all settings.

Definition at line 371 of file TDC1000.cpp.

void setClockFrequencyIn ( int  newfreq )

Clock frequency is not set within the chip.

Parameters:
newfreqis the frequency of the system clock in Hz.

Definition at line 438 of file TDC1000.cpp.

void setToggle ( SettingChoice  choice )

setToggle function This toggle function is very similar to the readToggle function, except that instead of simply reading the setting value, it changes it.

setToggle function Used for toggling a toggle setting for the TDC1000 on or off.

If the value was on, this function turns it off, and if it was off, this function turns it on. Just like how toggles should work.

Parameters:
choiceChoice indicates which setting you want to toggle.

Definition at line 107 of file TDC1000.cpp.