Diamond Power Products MM-48-AT user manual Generating AN Analog Output

Page 35

11. GENERATING AN ANALOG OUTPUT

This chapter describes the steps involved in generating an analog output (also called performing a D/A conversion) on a selected output channel using direct programming (not with the driver software).

There are three steps involved in performing a D/A conversion:

1.Compute the D/A code for the desired output voltage

2.Write the value to the selected output channel

3.Update the D/A

11.1Compute the D/A code for the desired output voltage D/A code = desired output voltage in mV

Note: The DAC cannot generate the actual full-scale reference voltage; to do so would require an output code of 4096, which is not possible with a 12-bit number. The maximum output value is 4095. Therefore the maximum possible output voltage is 4.095V, 1mV less than the full-scale voltage of 4.096V.

11.2Write the value to the selected output channel

First use the following formulas to compute the LSB and MSB values:

LSB = D/A Code AND 255 ;keep only the low 8 bits

MSB = int(D/A code / 256) ;strip off low 8 bits, keep 4 high bits

Example: Output code = 1776

LSB = 1776 AND 255 = 240 (F0 Hex); MSB = int(1776 / 256) = int(6.9375) = 6 (In other words, 1776 = 6 * 256 + 240)

Then write these values and the D/A channel no. to the board:

Write LSB to Base + 0

Write MSB to Base + 1

Write the channel no. to Base + 7

11.3 Update the D/A

Write a 1 to the DAUPD bit in Base + 7 to update the D/A.

To update several channels simultaneously, follow steps 1 and 2 for each channel. After all channel data has been written, write a 1 to the DAUPD bit, and all channels with new data will be updated simultaneously.

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

Page 35

Image 35
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 Interrupt Level Selection Board ConfigurationBase Address Base Address Jumper Position Hex DecimalAnalog Input Range Optocoupler PolarityReserved LSB MSB OverviewBase + Write Function Read Function Read operations Register Map Bit AssignmentsWrite operations DA7 DA6 DA5 DA4 DA3 DA2 DA1 DA0Base + Read Register DefinitionsBase + Write DefinitionsHIGH3 HIGH2 HIGH1 HIGH0 LOW3 LOW2 LOW1 LOW0 AD9 AD8Base + Read/Write A/D Channel Register 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 DIO0OEDGE3 OEDGE2 OEDGE1 OEDGE0 OPTO3 OPTO2 OPTO1 OPTO0 Base + Write Channel and Control RegisterDaupdt DACH2 DACH1 DACH0 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 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 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 ScanenAinte Fifoen Scanen Guidelines for Selecting Fifo Use Fifoen and FifothOperation Table 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 1 Counting/Totalizing Functions COUNTER/TIMER OperationCounter 0 A/D Sample Control Counter Command SequencesCounter Outpbase+15,0x01 Outpbase+15,0x81 General SpecificationsAutocalibration