PCI interface module (PCI6025E) | |
Analog input module (ADC) | |
Analog output module (DAC) | |
Digital lines module (DIO_PPI) | |
General porpuse counters/timers (TIM) |
PCI interface module |
Files
Filename click to view code | Description | Functions |
PCI6025E.H | Contains variables and functions used to interface with PCI bus and some other useful functions like interrupt set-up, PFI management and Internal Timebase and frequency output manager. REGCONST.H contains DAQ-STC and board registers address | BYTE find_NI_Device(void) |
BYTE reMap(void) | ||
void DAQ_STC_Windowed_Mode_Write(WORD address, WORD value) | ||
WORD DAQ_STC_Windowed__Mode_Read(WORD address) | ||
BYTE setIntClock(BYTE tbs, BYTE divBy2, BYTE divider) | ||
void PFIprogramming(WORD pfi) | ||
void INT_personalize(BYTE personal) | ||
void INT_setup(BYTE ga, BYTE gb) | ||
void bitfield(BYTE dim, DWORD value) | ||
void TEST_bitfield(BYTE dim, DWORD value, char *str) | ||
Immediate_Writex(addr, val)[macro] | ||
Immediate_Readx(addr)[macro] |
Function Description
This function scans the PCI bus searching National Instruments® boards and when one is found structure NIDevice_Info[x] is filled with board's data. When more than one NI® is found structure is filled in right way but driver can manage only the first board that is loaded
This function return number of PCI boards found
You haven't to call this function because is called by reMap function
Back to PCI Interface Module section
PCI E Series board are mapped direct to memory. In Shark OS memory are linearly organized so direct access over 1MB is immediate. Otherwise if you want re map board under 1MB memory you can do this through this function. No argument must be passed because into .h file there's two "#define" which define MITE base address and BOARD base address.
This function, like you see watching code, call find_NI_Device and if no boards is found returns 0. Otherwise if function terminates successfully returns 1
Call this function after Shark function pci_init() and before any other board related function
Back to PCI Interface Module section
DAQ-STC has more than 180 16-bit registers. Too memory is requested to map all registers on memory. Thus Windowed Memory is implemented. When you want read or write one DAQ-STC's register you must call this function passing register address and value you want write. It's important to notice that while windowed access uses much time that direct access it's important that during this operation interrupts are disabled to avoid collision, data losing or data modification
I think you don't need to call this function because it is called by function written in this driver. If you call this function pay attention about register you are going to manipulate and the mean of its bits because you can damage both board and external circuit
Parameter | Description |
WORD address | DAQ-STC register address. In file REGCONST.H you can find a symbolic name associated with register address |
WORD value | Value you want write into DAQ-STC register |
Back to PCI Interface Module section
Like the function above this is used through windowed accessing to read a DAQ-STC register's value. Watch above to understand mean of parameter "address".
This function return value stored in register
Back to PCI Interface Module section
This function sets the internal timebase to work with a software selectable frequency from 20MHz to 100 KHz. It's also enable frequency output system (FOUT) which can provide on pin 50 a square wave with base frequency of Internal Timebase also divided by "divider" value
Parameter | Description |
BYTE tbs | This is the timebase divisor by 100. If you put this to 1 internal timebase is 200 KHz otherwise it is 20 MHz |
BYTE divBy2 | Further frequency divisor by 2. If sets to 1 internal timebase is divide by two otherwise it isn't divided |
BYTE divider | This third divider acts only on Frequency output system so on frequency you can get from pin 50. This divider can assume value from 0 to 15. If 0 frequency is divided by 16 otherwise is divided by the number specified into the parameter. |
This function return 0 if there's an error into the parameters, otherwise return 1
Back to PCI Interface Module section
With this function you can configure the PFI lines. PFI can be configured as a generic input line or as a specific output line. You can see in 6025E User Manual the meaning of each PFI line when is configured like output.
Parameter | Description |
pfi | This parameter must be programmed bit by bit. The first ten bit are connected to the PFI lines. If you set a bit related PFI line is configured as an output line otherwise PFI line is configured as an input. Bits from ten to eleven aren't used. Please pay attention when you are configuring the lines because you may damage both board and external circuit |
Back to PCI Interface Module section
Use this function to select the logic level that will indicate an interrupt condition on IRQ_OUT pins and to enable or disable the possibility of duplicate selected interrupt to IRQ_OUT<0..1> pins
Parameter | Description |
personal | This parameter must be programmed bit by bit. If you set bit 0 signal duplication is enabled otherwise is disabled. With bit 1 you can select interrupt polarity: 0 stand for active high, 1 stand for active low (usually PC uses active low). Other bits aren't used |
Back to PCI Interface Module section
Use this function to enable interrupt group and to select onto which line interrupt signal will be driven. Group A manage interrupt connected with AITM, IRQ_IN0 and TIMER 0. Otherwise Group B is connected with AOTM, IRQ_IN1 and TIMER 1.
Parameter | Description |
gA | Both parameters use the first three bits (0..2) to indicate onto which line drives interrupt signal. Fourth bit enable (if set) or disable (if clear) interrupt group |
gB |
Back to PCI Interface Module section
This two function are useful to print (not in graphic mode... I'm sorry) a register value bit by bit. I use this function to check registers value during operations set up. The second function differs from the first only for the little feature that prints the "str" string before prints register value.
Parameter | Description |
dim | Dimension in byte of the second parameter. Example: BYTE has dimension 1; WORD has dimension 2; and so on... |
value | Value which will be printed on screen |
str only for TEST_bitfield | This string will be printed before printing value |
Back to PCI Interface Module section
These two groups macro write or read directly into memory. The final x stand for "b" that means BYTE or for "w" that means WORD. With Immediate_Writex you must pass first address and second value which will be written into memory. Otherwise with Immediate_Readx only address must be passed.
Example: Immediate_Writeb(0x0C, 0xFF) writes at offset 0x0C value 0xFF
In REGCONST.H you must find address of the most useful board's registers.
Back to PCI Interface Module section
Analog Input Module |
Analog Output Module |
With this module you can program the Analog Output Timing Module (AOTM) of the DAQ-STC and the two DACs on board. Into DAQ-STC there are two timing module for output operations. I only program the first module leave the second module for the next snapshot. Timing module is important but could be substituted with SHARK timing functions and using only the function which access directly DACs output registers.
Files
Filename click to view code | Description | Functions |
DAC.H
| Contains variables and functions used to interface with the two 12-bit DACs present on PCI 6025 E. There are both functions used to program the DAQ-STC AOTM and to set up and use the DACs | void DAC_reset(void) |
void DAC_boardInit(BYTE clock, WORD personal) | ||
void DAC_trigger(WORD trigger) | ||
void DAC_numSetup(DWORD n_updates, DWORD n_iter) | ||
void DAC_update(BYTE source, BYTE ui) | ||
void DAC_channel(BYTE multi, BYTE num) | ||
void DAC_LDACSourceUpdate(BYTE pref) | ||
void DAC_stopError(BYTE error) | ||
void DAC_FIFOFlags(BYTE flags) | ||
void DAC_enableInterrupts(WORD itr) | ||
void DAC_arm(void) | ||
void DAC_startOperation(void) | ||
void DAC_Init(void) | ||
void DAC_output(BYTE DAC_ID, WORD value) |
Function Description
Reset two DACs and into DAQ-STC the associated timing system
Call this function before any DAC's operation or set up
With this function the most common options, like source pin or polarity for the AOTM, can be selected.
This function must be called after DAC-reset but before any other operation.
Parameter | Description |
clock | Only the first two bit are used: bit 0 specifies if AI_TIMEBASE must be divided by 2 and bit 1 specifies if OUT_TIMEBASE must be divided by two. Other bits aren't used |
personal | bit 0..1 select the polarity of the UPDATE output signal |
bit 2..4 not used | |
bit 5 specifies the pulse width of output update signal | |
bit 6 is used to select the update signal timebase | |
bit 7 not used | |
bit 8 sets the DMA PIO control | |
bit 9 not used | |
bit 10 if sets enable the TMRDACWR (TiMeR DAC WRite) which control the analog output FIFO | |
bit 11 selects the FIFO flags polarity | |
bit 12 selects the TMRDACWR pulsewidth | |
bit 13 not used | |
bit 14 selects the number of DAC packages | |
bit 15 not used |
With this function it's possible to set which signal trigger the analog output operations
Parameter | Description | ||||||
trigger | bit 0..4 START1 source select bit 5 edge detection | bit 6 synchronization | bit 7..12 NOT USED
| bit 13 START1 signal polarity | bit 14 synchronized with BC source | bit 15 continuos mode | |
With this function you can select the number of iterations that must be performed and the number of update that must be made into each iteration
Parameter | Description |
n_updates | number of updates that must be made in each iteration |
n_iter | number of iterations that must be made |
Use this function to select where get the update and the UI event
Parameter | Description |
source | bit 0..4 update source select |
bit 5 polarity of update signal | |
bit 6..7 not used | |
ui | bit 0..4 ui source select |
bit 5 polarity of ui source signal | |
bit 6..7 not used |
With this function you can select how many DACs you want update every UPDATE pulse
Parameter | Description |
multi | If different from 0 multiple channels update is enabled |
num | Number of channel updated every UPDATE pulse With PCI 6025 E only two DACs are available |
Use this function to set source and update mode for LDAC<0..1> signals
Parameter | Description |
pref | bit 0 LDAC0 source |
bit 1 DAC0 update mode | |
bit 2 same as bit 0 but for LDAC1 | |
bit 3 same as bit 1 but for DAC1 | |
bit 4..7 not used |
With this function you can select under which error conditions AOTM must be stopped
Parameter | Description |
error | bit 0 stop on BC_TC error |
bit 1 stop on BC_TC trigger error | |
bit 2 stop on overrun error | |
bit 3..7 not used |
This function allows to select which FIFO flags can assert an Interrupt or DMA request
Parameter | Description |
flags | bit 0..1 flags choice |
bit 2..7 not used |
Through this function you can enable which signal will de driven onto an Interrupt Request Line.
Parameter | Description |
flags | bit 0 BC_TC interrupt |
bit 1 START1 interrupt | |
bit 2 UPDATE interrupt | |
bit 3 START interrupt | |
bit 4 not used | |
bit 5 error interrupt | |
bit 6 UC_TC interrupt | |
bit 7 not used | |
bit 8 FIFO flags interrupt | |
bit 9..15 not used | |
Sets each bit to enable related interrupt or clear to disable interrupt request generation signal |
Use this function to arm counters into AOTM module of DAQ-STC. When AOTM is armed also the first values is preloaded into DACs
When software trigger is selected with this function analog output operation can be started. Otherwise is hardware trigger is selected call this function has no effects
This function must be called previous any operation and reset the DACs calling DAC_reset prepare the environment to work configuring the two available DACs
This function writes directly into a DAC output register so "value" is immediately got out as analogic value
Parameter | Description |
DAC_ID | bit 0 Identify DAC into write |
value | bit 0..11 value put in DAC register |
bit 12..15 not used |
Digital lines Module |
With this module it's possible to manage the eight (DIO 0..7) digital lines provided by DAQ-STC and the additional 24 digital lines provided by OKI MSM82C55A Programmable Peripheral Interface
Files
Filename click to view code | Description | Functions |
DIO_PPI.H
| Contains variables and functions used to interface with the eight plus twenty four digital lines provided from the board | void DIO_init(void) |
void DIO_resetReg(void) | ||
void DIO_config(BYTE cfg) | ||
BYTE DIO_read(void) | ||
void DIO_write(BYTE out) | ||
| ||
void PPI_init(void) | ||
void PPI_resetReg(void) | ||
void PPI_config(BYTE cfg) | ||
BYTE PPI_read(BYTE port) | ||
void PPI_write(BYTE port, BYTE val) |
Function Description
Initialize the eight digital lines provided by DAQ-STC
Back to DIO_PPI Interface Module
Force all digital lines as output and force their value to 0
Back to DIO_PPI Interface Module
With this function each line of the eight provided by DAQ-STC can configured separately from the others
Parameter | Description |
cfg | Each bit configures a digital line: bit 0 configures DIO 0... bit 7 configures DIO 7. If you set a bit related digital line is configured as input otherwise as output |
Back to DIO_PPI Interface Module
Read DAQ-STC's digital lines configured as input. Where a line is configured as output value read is 0
Back to DIO_PPI Interface Module
Puts on digital lines the "out" value. Only line configured as output can be accessed. Other lines during output operations are forced to 0
Back to DIO_PPI Interface Module
Initialize the 24 digital lines provided by MSM82C55A
Back to DIO_PPI Interface Module
Force all digital lines as output and force their value to 0
Back to DIO_PPI Interface Module
With this function you can configure MSM82C55A to work in one of its three available modes
Parameter | Description | |||
cfg | bit 7 when sets tells chip that configuration words are going to come | |||
bit 5..6 set up port A mode: | Mode | 0 | 1 | 2 |
bit 6 | 0 | 0 | 1 | |
bit 5 | 0 | 1 | X | |
bit 4 Sets direction of port A byte | ||||
bit 3 Sets direction of the higher first four bits of port C | ||||
bit 2 Sets mode for port B | ||||
bit 1 Sets direction of port B byte | ||||
bit 0 Sets direction of the lowest first four bits of port C |
Back to DIO_PPI Interface Module
Reads eight digital lines from MSM82C55A
Parameter | Description |
port | Specifies which port must be read. Possible values are: |
Back to DIO_PPI Interface Module
Writes into a MSM82C55A port the value specified with "val"
Parameter | Description |
port | Specifies which port must be read. Possible values are: |
val | Specifies the value that must be sent out |
Back to DIO_PPI Interface Module
General Purpose Timers/Counters |
This is the module that controls the General purpose 24-bit timers/counters provided by DAQ-STC. Differently from other modules there aren't function which must be combined to obtain that counters count but each function programs a counter to perform a specified action like counting events or measuring time. In this first snapshot Position sensing and pulse generation aren't implemented. I'm sorry but form my Thesis this features aren't useful. I hope I can put them in the next snapshot.
Files
Filename click to view code | Description | Functions |
TIMER.H
| Contains variables and functions used to interface with two general purpose counters/timers provided by DAQ-STC | void TIM_reset(BYTE counter) |
void TIM_arm(BYTE counter) | ||
void TIM_disarm(BYTE counter) | ||
DWORD TIM_readCounter(BYTE counter) | ||
DWORD TIM_readHWSaveReg(BYTE counter) | ||
void TIM_eventCounting(BYTE counter, BYTE source, BYTE gate, BYTE interrupts, DWORD in) | ||
void TIM_bufferedEventCounting(BYTE counter, BYTE source, BYTE gate, BYTE cumulative, DWORD in) | ||
void TIM_timeMeasurement(BYTE counter, BYTE source, BYTE gate, BYTE type, BYTE interrupts, DWORD in) | ||
void TIM_timeMeasurement(BYTE counter, BYTE source, BYTE gate, BYTE type, BYTE type, DWORD in) |
This function must be called before any operation with timers. It resets the specified counter and the related DAQ-STC's registers
Parameter | Description |
counter | Specifies which counter must be resected. Possible values are: |
Back to Timers/Counters Interface Module
This function must be called after all setting operation because making counters begin count. Parameter "counter" has the same meaning of previous function's parameter
Back to Timers/Counters Interface Module
Calling this function make counters stop counting (but counters aren't resected). See above for parameter "counter" meaning
Back to Timers/Counters Interface Module
Use this function to read counters value while they are counting without disturbing them
Parameter | Description |
counter | Specifies which counter must be resected. Possible values are: |
Back to Timers/Counters Interface Module
During buffered operation like buffered event counting or buffered time measurement, counters when an interrupt occurred save their values into Hardware Save Registers. With this function it's possible accessing and reading these registers
Meaning of parameter "counter" is the same of previous function
Back to Timers/Counters Interface Module
This function sets up specified counter to perform a gated (if you want) events count. You must specify source line, gate line, which interrupts must be enabled and an initial value that will be loaded into the counter
Parameter | Description |
counter | Specifies which counter must be resected. Possible values are: |
source | bit 0..4 Source selection |
bit 5 Source polarity | |
bit 6 Polarity of G_OUT output signal | |
bit 7 Counting direction | |
gate | bit 0..4 Gate selection |
bit 5 gate polarity | |
bit 6..7 G_OUT mode | |
interrupts | bit 0 TC Interrupt enable |
bit 1 Gate interrupt enable | |
bit 2..7 not used | |
in | initial value loaded into counter |
Back to Timers/Counters Interface Module
Also this function performs an event counting but when a gate's event occurs DAQ-STC saves counter values into related Hardware Save registers and if counting is cumulative continues counting else restarts counting from 0 (pay attention: count restarts from 0 and not from your initial value "in")
Parameter | Description |
counter | Specifies which counter must be resected. Possible values are: |
source | bit 0..4 Source selection |
bit 5 Source polarity | |
bit 6 Polarity of G_OUT output signal | |
bit 7 Counting direction | |
gate | bit 0..4 Gate selection |
bit 5 gate polarity | |
bit 6..7 G_OUT mode | |
cumulative | Specifies counting types: |
in | initial value loaded into counter |
Back to Timers/Counters Interface Module
With this function you can perform a pulsewidth or a single period measurement. This function can be used only for one shot measurement so you can get only one pulsewidth measure or only one period measure. The next function, like you'll see, performs continue measurements
Parameter | Description |
counter | Specifies which counter must be resected. Possible values are: |
source | bit 0..4 Source selection |
bit 5 Source polarity | |
bit 6 Polarity of G_OUT output signal | |
bit 7 Counting direction | |
gate | bit 0..4 Gate selection |
bit 5 gate polarity | |
bit 6..7 G_OUT mode | |
type | specifies which type of measure must be performed |
interrupts | bit 0 TC Interrupt enable |
bit 1 Gate interrupt enable | |
bit 2..7 not used | |
in | initial value loaded into counter |
Back to Timers/Counters Interface Module
This function measures time continually. It can measure periods, semiperiods, or pulsewidths.
Parameter | Description |
counter | Specifies which counter must be resected. Possible values are: |
source | bit 0..4 Source selection |
bit 5 Source polarity | |
bit 6 Polarity of G_OUT output signal | |
bit 7 Counting direction | |
gate | bit 0..4 Gate selection |
bit 5 gate polarity | |
bit 6..7 G_OUT mode | |
type | specifies which type of measure must be performed |
in | initial value loaded into counter |
Back to Timers/Counters Interface Module
go to next page |