Diamond Power Products MM-48-AT user manual Optocoupler Operation

Page 38

14. OPTOCOUPLER OPERATION

Diamond-MM-48-AT contains 4 optocoupler inputs with programmable polarity, programmable edge detection capability, and interrupt capability on edge detection. These lines accept inputs up to 28VDC. The transition between logic 0 and 1 occurs at approximately 1.5VDC and is guaranteed to be 1 at 3VDC or above.

The POL jumper on jumper block J6 selects the logic polarity of the 4 register bits OPTO3-0. The POL jumper can be read with the POL bit in Base + 8. The POL register bit indicates the value of an open circuit or logic 0 input signal:

 

 

OPTO3-0 readback value

POL jumper

POL bit

Vin < 1.5VDC

Vin > 3VDC

Out

0

0

1

In

1

1

0

To enable edge detection on any optocoupler, set the corresponding OENn bit to 1, and then select the desired edge polarity with POLn. POLn = 0 selects falling edge, and POLn = 1 selects rising edge. NOTE: The edge polarity is determined with respect to the polarity selected with the POL jumper. If the POL jumper is in, an input voltage change from 0V to 3V is considered a falling edge, not a rising edge.

Whenever you read the optocoupler logic level data OPTO3-0 in Base + 7, you also read the edge status data in the upper 4 bits OEDGE3-0. Reading this register clears the OEDGE3-0 data, so successive reads will show a change in the value of these bits to 0. Note that if an input toggles in both directions between reads, you will still see the change because the OEDGEn bit will be 1 even though the logic level remains the same.

The board may also be programmed to generate interrupts when any selected edge occurs. To enable interrupts on edge detection, set the OINTE bit in Base + 11. when OINTE = 1, any edge programmed in the above manner will generate an interrupt and set the OINT bit in Base + 11. The interrupt routine reads the data by reading from Base + 7, and then it clears the interrupt request by writing a 1 to the CLRO bit in Base + 11.

NOTE: Diamond-MM-48-AT has 4 distinct interrupt circuits that may request interrupt service independently of each other. A PC/104 bus interrupt request will occur when any one of the circuits requests service. As long as any circuit is still requesting service, the interrupt request will stay active. This means that writing to the CLRO bit may not clear the bus interrupt request even though it clears the specific optocoupler input interrupt request. The interrupt service routine is responsible for determining which of the three circuits is requesting service and handling all of them as needed.

Procedure for enabling interrupts on selected edges

1.Select the desired input channel(s) by setting OENn = 1 for each one to be detected.

2.Select the desired edge polarity for each enabled channel by setting POLn appropriately. NOTE: Steps 1 and 2 are done together with a single write operation to Base + 6.

3.Enable optocoupler interrupts by setting the OINTE bit in Base + 11.

4.When an interrupt occurs, read the edge and logic level data from Base + 7.

5.After reading the edge and logic data, write a 1 to the CLRO bit in Base + 11 to clear the interrupt request.

6.When interrupt activity is no longer needed, write a 0 to the OINTE bit to disable optocoupler interrupts.

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

Page 38

Image 38
Contents DIAMOND-MM-48-AT Table of Contents Description DIAMOND-MM-48-AT Board Drawing J3 Analog and Digital I/O Signal Name DefinitionO Header Pinout and PIN Description Optoisolated input contacts Signal Name Definition Relay output contactsJ4 Relays and Optocouplers Base Address Jumper Position Hex Decimal Board ConfigurationBase Address Interrupt Level SelectionAnalog Input Range Optocoupler PolarityReserved LSB MSB OverviewBase + Write Function Read Function DA7 DA6 DA5 DA4 DA3 DA2 DA1 DA0 Register Map Bit AssignmentsWrite operations Read operationsDefinitions Register DefinitionsBase + Write Base + ReadHIGH3 HIGH2 HIGH1 HIGH0 LOW3 LOW2 LOW1 LOW0 AD9 AD8Base + Read/Write A/D Channel Register RELAY7 RELAY6 RELAY5 RELAY4 RELAY3 RELAY2 RELAY1 RELAY0 Base + Read/Write Digital I/O Configuration RegisterBase + Read/Write Relay Control Port DIR3 DIR2 DIR1 DIR0DEDGE3 DEDGE2 DEDGE1 DEDGE0 DIO3 DIO2 DIO1 DIO0 DIO3 DIO2 DIO1 DIO0Base + Read Digital I/O Data and Edge Status OEN3 OEN2 OEN1 OEN0 POL3 POL2 POL1 POL0OEDGE3 OEDGE2 OEDGE1 OEDGE0 OPTO3 OPTO2 OPTO1 OPTO0 Base + Write Channel and Control RegisterDaupdt DACH2 DACH1 DACH0 Base + Write Command Register Dapre Daprld Reset Fiforst AdstartBase + Read Status Register POL ADCH3 ADCH2 ADCH1 ADCH0Base + Write Configuration Register CKSEL1 CKFRQ1 CKFRQ0 Scnint Clken ClkselBase + Read Configuration & Status Register Adbusy Dabusy CKSEL1 CKFRQ1 CKFRQ0 Scnint Clken ClkselBase + Read Fifo Status Register Base + Write Fifo Control RegisterFifoth Fifoen Scanen OVF Fifoth Fifoen ScanenBase + Write Interrupt Control Register Clrt Clrd Clro Clra Tinte Dinte Ointe AinteBase + Read Interrupt Status Register Tint Dint Oint Aint Tinte Dinte Ointe AinteBase + Read/Write Counter/Timer D23 Base + Read/Write Counter/Timer D7Base + Read/Write Counter/Timer D15 Ctrno Base + Write Counter/Timer Control RegisterCtrno Latch Gtdis Gten Ctdis Cten Load CLR Base + Read/Write Eeprom / TrimDAC Data Register Base + Read/Write Eeprom / TrimDAC Address RegisterBase + Read Calibration Status Register Base + Write Eeprom Access Key RegisterBase + Write Calibration Control Register Base + Read Fpga Revision CodeInput Ranges Analog Input Ranges and ResolutionResolution Single Ended and Differential InputsPerforming AN A/D Conversion Trigger an A/D conversion on the current channel LSB = readbase MSB = readbase+1 Data = MSB * 256 + LSBInput voltage = A/D value / 32768 * Full-scale voltage Clken Clksel D SCAN, FIFO, and Interrupt OperationTrigger Conversion or ScanFifoen Fifoth Scanen Fifo OperationInterrupt Operation Fifoen =Ainte Fifoen Scanen Guidelines for Selecting Fifo Use Fifoen and FifothOperation Table Analog Output Overview Generating AN Analog Output 12.2 A/D calibration Autocalibration OperationReference Voltages 12.3 D/A CalibrationDigital I/O Operation Procedure for enabling interrupts on selected edges Optocoupler OperationEdge detection assumes OENn = 1 to enable edge detection Polarity and logic readbackRelay Operation Counter 1 Counting/Totalizing Functions COUNTER/TIMER OperationCounter 0 A/D Sample Control Command Sequences CounterCounter Outpbase+15,0x01 Outpbase+15,0x81 General SpecificationsAutocalibration