Diamond Power Products MM-48-AT user manual Counter Outpbase+15,0x01 Outpbase+15,0x81

Page 43

Reading a counter

 

a.

Latch the counter:

 

 

Counter 0

Counter 1

 

outp(base+15,0x40);

outp(base+15,0xC0);

b.

Read the data:

 

The value is returned in 3 bytes, low, middle, and high (2 bytes for counter 1)

Counter 0

Counter 1

low=inp(base+12);

low=inp(base+12);

middle=inp(base+13);

high=inp(base+13);

high=inp(base+14);

 

c.Assemble the bytes into the complete counter value:

Counter 0

Counter 1

val = high * 2^16 + middle * 2^8 + low;

val = high * 2^8 + low;

Enabling the counter gate

 

Counter 0

Counter 1

outp(base+15,0x10);

outp(base+15,0x90);

The counter will run only when the gate input is high.

Disabling the counter gate

 

Counter 0

Counter 1

outp(base+15,0x20);

outp(base+15,0xA0);

The counter will run continuously.

 

Clearing a counter

Clearing a counter is done when you want to restart an operation. Normally you only clear a counter after you have stopped (disabled) and read the counter. If you clear a counter while it is still enabled, it will continue to count incoming pulses, so its value may not stay at zero.

a. Stop (disable) the counter:

 

Counter 0

Counter 1

outp(base+15,0x08);

outp(base+15,0x88);

b.Read the data (optional). See “Reading a counter” above.

c.Clear the counter:

Counter 0

Counter 1

outp(base+15,0x01);

outp(base+15,0x81);

Diamond-MM-48-AT User Manual V1.01

Page 43

Image 43
Contents DIAMOND-MM-48-AT Table of Contents Description DIAMOND-MM-48-AT Board Drawing O Header Pinout and PIN Description Signal Name DefinitionJ3 Analog and Digital I/O J4 Relays and Optocouplers Signal Name Definition Relay output contactsOptoisolated input contacts Interrupt Level Selection Board ConfigurationBase Address Base Address Jumper Position Hex DecimalReserved Optocoupler PolarityAnalog Input Range Base + Write Function Read Function OverviewLSB MSB Read operations Register Map Bit AssignmentsWrite operations DA7 DA6 DA5 DA4 DA3 DA2 DA1 DA0Base + Read Register DefinitionsBase + Write DefinitionsBase + Read/Write A/D Channel Register AD9 AD8HIGH3 HIGH2 HIGH1 HIGH0 LOW3 LOW2 LOW1 LOW0 DIR3 DIR2 DIR1 DIR0 Base + Read/Write Digital I/O Configuration RegisterBase + Read/Write Relay Control Port RELAY7 RELAY6 RELAY5 RELAY4 RELAY3 RELAY2 RELAY1 RELAY0OEN3 OEN2 OEN1 OEN0 POL3 POL2 POL1 POL0 DIO3 DIO2 DIO1 DIO0Base + Read Digital I/O Data and Edge Status DEDGE3 DEDGE2 DEDGE1 DEDGE0 DIO3 DIO2 DIO1 DIO0Daupdt DACH2 DACH1 DACH0 Base + Write Channel and Control RegisterOEDGE3 OEDGE2 OEDGE1 OEDGE0 OPTO3 OPTO2 OPTO1 OPTO0 Dapre Daprld Reset Fiforst Adstart Base + Write Command RegisterPOL ADCH3 ADCH2 ADCH1 ADCH0 Base + Read Status RegisterCKSEL1 CKFRQ1 CKFRQ0 Scnint Clken Clksel Base + Write Configuration RegisterAdbusy Dabusy CKSEL1 CKFRQ1 CKFRQ0 Scnint Clken Clksel Base + Read Configuration & Status RegisterOVF Fifoth Fifoen Scanen Base + Write Fifo Control RegisterFifoth Fifoen Scanen Base + Read Fifo Status RegisterClrt Clrd Clro Clra Tinte Dinte Ointe Ainte Base + Write Interrupt Control RegisterTint Dint Oint Aint Tinte Dinte Ointe Ainte Base + Read Interrupt Status RegisterBase + Read/Write Counter/Timer D15 Base + Read/Write Counter/Timer D7Base + Read/Write Counter/Timer D23 Ctrno Latch Gtdis Gten Ctdis Cten Load CLR Base + Write Counter/Timer Control RegisterCtrno Base + Read/Write Eeprom / TrimDAC Address Register Base + Read/Write Eeprom / TrimDAC Data RegisterBase + Read Fpga Revision Code Base + Write Eeprom Access Key RegisterBase + Write Calibration Control Register Base + Read Calibration Status RegisterSingle Ended and Differential Inputs Analog Input Ranges and ResolutionResolution Input RangesPerforming AN A/D Conversion LSB = readbase MSB = readbase+1 Data = MSB * 256 + LSB Trigger an A/D conversion on the current channelInput voltage = A/D value / 32768 * Full-scale voltage Conversion or Scan D SCAN, FIFO, and Interrupt OperationTrigger Clken ClkselFifoen = Fifo OperationInterrupt Operation Fifoen Fifoth ScanenOperation Table Guidelines for Selecting Fifo Use Fifoen and FifothAinte Fifoen Scanen Analog Output Overview Generating AN Analog Output 12.3 D/A Calibration Autocalibration OperationReference Voltages 12.2 A/D calibrationDigital I/O Operation Optocoupler Operation Procedure for enabling interrupts on selected edgesPolarity and logic readback Edge detection assumes OENn = 1 to enable edge detectionRelay Operation Counter 0 A/D Sample Control COUNTER/TIMER OperationCounter 1 Counting/Totalizing Functions Counter Command SequencesCounter Outpbase+15,0x01 Outpbase+15,0x81 Autocalibration SpecificationsGeneral