Home

DM602/DM5602 User`s Manual - RTD Embedded Technologies, Inc.

image

Contents

1. i 4 3 BA 3 8255 PPI Control Word Write Only i 4 4 BA 4 D A Converter 1 LSB Write Only cetona e aaa E Ra nono nennen cieco rene iene 4 5 BA 5 D A Converter 1 MSB Write Only i 4 5 BA 6 D A Converter 2 LSB Write Only riirii EE EAEE nono non on RE crei einen 4 5 BA 7 D A Converter 2 MSB Write Only i 4 5 BA 8 D A Converter 3 LSB Write Only ooooonncconononicnnonononnnnnnnononnconcnnnnnconnornno nono tentent nente tenentes eren nenne 4 6 BA 9 D A Converter 3 MSB Write Only re nooo nente tenter ettet entente nene 4 6 BA 10 D A Converter 4 LSB Write Only i 4 6 BA 11 D A Converter 4 MSB Write Only teret enne enne nnne tentent ettet en neee tenere 4 6 BA 12 Update DAC Outputs Write Only nennen netten enne enne ene nennen 4 6 BA 4 13 Reserved sisters seia aurea amete err E auque an E Ee 4 6 BA x I4 IRQ Enable Write Only kenn BR BR sun 4 6 BA 15 Interrupt Status Clear Read Write i 4 6 Programming the 6023 5602 eee eoe pp IHRE Ph SE Op EHE a e aa da eit Rr PE eaea Eta 4 7 Clearing and Setting Bits in a POrt i 4 8 D A EONVersions daros n HD ORE HERR Oc bebe dese dest ORE ERU E pe cic it a eS ns Pt MERE ede opus 4 0 Initializing the 8255 PRI ica na ae Aia UA aaa ote t e ke 4 11 Digital I O Operations nent ete deer e e ep p e editt eec
2. BA 3 8255 PPI Control Word Write Only When bit 7 of this word is set to 1 a write programs the PPI configuration The table below shows the control words for the 16 possible Mode 0 Port I O combinations APTA O ee q en Flag Port C Lower E O output Mode Select 1 input 00 mode 0 01 mode 1 Port B 10 mode 2 0 output 1 input Port A O output Mode Select 1 input I 0 mode 0 1 mode 1 B Pott gper ii cei RB O output Group A 1 input L O Port I O Flow Direction and Control Words Mode 0 Group B Control Word ein NN a pper ower Car AE Ss Berner A oma mu oma ma 1000100 wr 9 mu Ow oma Oma 10010000 me 9 mu wma oma oma 10011009 39 9 mu ma oma ma ooroo ss 9 mu ret meu ren oono es so 4 4 When bit 7 of this word is set to 0 a write can be used to individually program the Port C lines D7 D6 D5 D4 D3 D2 D1 DO Set Reset Bit Set Reset Function Bit Bit Select 0 set bit to 0 0 active 000 PCO 1 setbitto 1 001 PC1 010 PC2 011 PC3 100 PC4 101 PC5 110 PC6 111 PC7 For example if you want to set Port C bit O to 1 you would set up the control word so that bit 7 is 0 bits 1 2 and 3 are O this selects PCO and bit O is 1 this sets PCO to 1 The control word is set up like this 0
3. 4 11 IntertUpts enr eS un an RI er 4 11 Whatds an Interrupt och t ETE pe Ei e pe D Reiser in 4 11 Interrupt Request Lines aa ei oe eu et be e i dh id E RI q Eee e minha Ere eed 4 11 8259 Programmable Interrupt Controller eese enne enne on non nc eee 4 11 Interr pt Mask Register IMR 7e oer tete is 4 12 End ot Interrupt EOD Command ettet aii ab n ee Fer SERE etae hinein FERE UA 4 12 What Exactly Happens When an Interrupt Occurs e nee nene ener 4 12 Using Interrupts in Your Programs 50 ueteres te eter ek son 4 12 Writing an Interrupt Service Routine ISR eese nennen eene nennen trennen 4 12 Saving the Startup Interrupt Mask Register IMR and Interrupt Vector sese 4 14 Restoring the Startup IMR and Interrupt Vector nennen nennen nenne nennen nennen 4 14 Common Interrupt Mistakes nene ee tem PR ere einer Er ERE HH Pee 4 14 Example Programs esos tice v Dar iro ERU ar IEEE OUTRE UR Ra ERE NER iaia nilo duel 4 15 C and Pascal Programs n TET pet tp OPER IRE EE aero ER ears SR 4 15 BASIC Programs sia ers ee eerte en e Aalst 4 15 CHAPTERS CALIBRATION nassen nenne A IE RM UC epo Spree peo E eise 5 1 Required Equipment en NN 5 3 D A Calbrationi sec nih teet e RE HR iet eec deep eed e eis 5 3 INS oett edidit ee t iR e pee ee Eye boit ree 5 3 420 mA Current E00p ote Ee aou te pads ne EUER ERO Reb og 5 5 APPENDI
4. CMOS package The data to be converted is double buffered at the D A input which allows simultaneous updating of all four D A output channels For voltage outputs the AD712 precision operational amplifier provides complete coverage of the output voltage ranges The exceptionally low offset voltage and drift ensure an accurate analog output on each channel For current loop outputs the AD694 current loop transmitter converts the voltage output of the D A converter to a corresponding current between 4 and 20 mA Digital I O Programmable Peripheral Interface The programmable peripheral interface PPI is used for digital I O functions This high performance TTL CMOS compatible chip has 24 digital I O lines divided into two groups of 12 lines each Group A Port A 8 lines and Port C Upper 4 lines Group B Port B 8 lines and Port C Lower 4 lines You can program these ports for one of three modes of operation 3 3 Mode 0 Basic input output Lets you use simple input and output operation for a port Data is written to or read from the specified port Mode 1 Strobed input output Lets you transfer I O data from Port A in conjunction with strobes or hand shaking signals Mode 2 Strobed bidirectional input output Lets you communicate bidirectionally with an external device through Port A Handshaking is similar to Mode 1 These modes are detailed in the 8255 Data Sheet reprinted from Intel in Appendix C
5. IMR and how to send the end of interrupt EOI command to the 8259 Interrupt Mask Register IMR Each bit in the interrupt mask register IMR contains the mask status of an IRQ line bit O is for IRQO bit 1 is for IRQ1 and so on If a bit is set equal to 1 then the corresponding IRQ is masked and it will not generate an interrupt If a bit is clear equal to 0 then the corresponding IRQ is unmasked and can generate interrupts The IMR is programmed through port 21H For all bits 0 IRQ unmasked enabled 1 IRQ masked disabled End of Interrupt EOI Command After an interrupt service routine is complete the 8259 interrupt controller must be notified This is done by writing the value 20H to I O port 20H What Exactly Happens When an Interrupt Occurs Understanding the sequence of events when an interrupt is triggered is necessary to properly write software interrupt handlers When an interrupt request line is driven high by a peripheral device such as the 602 5602 the interrupt controller checks to see if interrupts are enabled for that IRQ and then checks to see if other interrupts are active or requested and determines which interrupt has priority The interrupt controller then interrupts the proces sor The current code segment CS instruction pointer IP and flags are pushed on the stack for storage and a new CS and IP are loaded from a table that exists in the lowest 1024 bytes of memory This table is ref
6. Operation No Loop Power Supply Figure 2 3 shows how to connect the current loop transmitter outputs to a resistive load with no external loop supply The AD694 current loop transmitters used on the 602 5602 are designed to be stable when driving resistive loads For inductive or poorly defined loads it is recom mended that you add a 0 01 uF capacitor in the location provided on the board for each analog output channel The table included in Figure 2 3 lists each channel and its corresponding capacitor number on the module These capacitors are located above the P2 I O connector The capacitor is placed between the output of the AD694 and analog ground as shown in the circled area of Figure 2 3 2 4 Il O CONNECTOR OP AMP T BUFFERS AOUT 1 LOAD PIN 2 ANALOG GND PIN 7 AOUT 4 LOAD PIN 8 ANALOG GND Fig 2 2 Voltage Output Connections Il O CONNECTOR CURRENT LOOP TRANSMITTERS LOAD LOAD PIN 7 AOUT 4 p Fig 2 3 Current Output Connections No Loop Supply 2 5 Current Loop Operation Single Loop Power Supply Figure 2 4 shows how to connect the current loop transmitter outputs to corresponding loads with a single external loop supply not exceeding 24 volts The AD694 current loop transmitters used on the 602 5602 are powered through the module by 12 volts When operated with a 12 volt supply the AD694 can source
7. WARRANTY Real Time Devices Inc warrants the hardware and software products it manufactures and produces to be free from defects in materials and workmanship for one year following the date of shipment from REAL TIME DE VICES This warranty is limited to the original purchaser of product and is not transferable During the one year warranty period REAL TIME DEVICES will repair or replace at its option any defective products or parts at no additional charge provided that the product is returned shipping prepaid to REAL TIME DEVICES All replaced parts and products become the property of REAL TIME DEVICES Before returning any product for repair customers are required to contact the factory for an RMA number THIS LIMITED WARRANTY DOES NOT EXTEND TO ANY PRODUCTS WHICH HAVE BEEN DAM AGED AS A RESULT OF ACCIDENT MISUSE ABUSE such as use of incorrect input voltages improper or insufficient ventilation failure to follow the operating instructions that are provided by REAL TIME DEVICES acts of God or other contingencies beyond the control of REAL TIME DEVICES OR AS A RESULT OF SERVICE OR MODIFICATION BY ANYONE OTHER THAN REAL TIME DEVICES EXCEPT AS EX PRESSLY SET FORTH ABOVE NO OTHER WARRANTIES ARE EXPRESSED OR IMPLIED INCLUDING BUT NOT LIMITED TO ANY IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE AND REAL TIME DEVICES EXPRESSLY DISCLAIMS ALL WARRANTIES NOT STATED HEREIN ALL IMPLIED WARRANTIES INCLU
8. are first trying your module is address contention Some of your computer s I O space is already occupied by internal I O and other peripherals When the 602 5602 attempts to use I O address locations already used by another device contention results and the module does not work To avoid this problem the 602 5602 has an easily accessible DIP switch S1 which lets you select any one of 32 starting addresses in the computer s I O Should the factory setting of 300 hex 768 decimal be unsuitable for your system you can select a different base address simply by setting the switches to any value shown in Table 1 2 The table shows the switch settings and their corresponding decimal and hexadecimal in parentheses values Make sure that you verify the order of the switch numbers on the switch 1 through 5 before setting them When the switches are pulled forward they are OPEN or set to logic 1 as labeled on the DIP switch package When you set the base address for your module record the value in the table inside the back cover Figure 1 6 shows the DIP switch set for a base address of 300 hex 768 decimal Fig 1 6 Base Address Switch S1 Decimal Hex 54321 Decimal Hex 54321 O cosedizopn S O 0 closed 1 open Pull up Pull down Resistors on Digital I O Lines The 8255 programmable peripheral interface provides 24 parallel TTL CMOS compatible digital I O lines which can be interfaced with external devices The lines are di
9. been loaded for all desired channels the channels are simultaneously updated by issuing the update command If a channel s data has not been updated since the last conversion the output of the DAC will not change The digital data is converted to a corresponding voltage or 4 20 mA current loop value which is present at the output until new data is loaded and another update command is issued The output voltage ranges or current loop operation are determined by the settings of the AOUT channel jumpers on P5 P6 P7 and P8 The following tables show key digital inputs and their corresponding outputs for unipolar and bipolar voltage ranges and for 4 20 mA current loop transmission The resolution for O to 5 volts is 1 22 millivolts for O to 10 and 5 volts 2 44 millivolts for 10 volts 4 88 millivolts and for 4 20 mA current loop 0039 mA DIA Bit Weight a eee tesse o ow on 4 9 D A Converter Bipolar Conversion Table Ideal Output Voltage in millivolts in millamperes 4095 Max Output 128 4 10 Initializing the 8255 PPI Before you can use the 24 8255 based digital I O lines on your 602 5602 the 8255 must be initialized This step must be executed every time you start up reset or reboot your computer The 8255 is initialized by writing the appropriate control word to I O port BA 3 The contents of your control word will vary depending on how you want to configure your I O lines Use the control word de
10. board in your system Table 1 1 Factory Settings Switch Factory Settings Jumper Function Controlled Jumpers Installed Selects an interrupt source pulls tri state buffer to E external interrupt amp ground G for multiple interrupt applications G ground for buffer connected Connects the interrupt source selected on P3 to an interrupt channel IRQ2 IRQ7 All channels disabled Configures the output voltage range or current loop Jumpers installed on 5 X1 VE VO settings for DAC1 to set output of 5 to 5 volts Configures the output voltage range or current loop Jumpers installed on 5 X1 VE VO settings for DAC2 to set output of 5 to 5 volts Configures the output voltage range or current loop Jumpers installed on 5 X1 VE VO settings for DAC3 to set output of 5 to 5 volts Configures the output voltage range or current loop Jumpers installed on 5 X1 VE VO settings for DAC4 to set output of 5 to 5 volts os Sets the base address 300 hex 768 decimal TR 000000 mea Em nmi dii HH 44 PIN PLCC cl 44 PIN PLCC SOCKE Lim m LI Fig 1 1 Module Layout Showing Factory Configured Settings P3 Interrupt Source Select Factory Setting EXT amp G Connected This header connector shown in Figure 1 2 lets you connect one of three interrupt sources to an interrupt channel IRQ2 through IRQ7 selected on P4 The available sources are EXT an external interrupt you can route onto the board throug
11. cn nennen trennen 3 3 Module Layout 2 nte n REDE RESP es IR Oe Reine 5 3 4 20 mA Current Loop Calibration Connections eceececeeeeeeeeeeeeseeseecaeesaecaecsaecneceseereeeeereenaes 5 5 iii iv INTRODUCTION The DM602 DM5602 analog output dataModule turns your IBM PC compatible cpuModule or other PC 104 computer into a high performance testing and control system Ultra compact for embedded and portable applications the 602 5602 features Four fast settling 12 bit analog output channels 5 10 0 to 5 or 0 to 10 volt analog output range Industrial 4 20 mA current loop source Simultaneous updating of all output channels 24 TTL CMOS 8255 based programmable digital I O lines Software enabled interrupts IRQ2 IRQ7 Single 5V power supply DM5602 DOS example programs with source code in BASIC Pascal and C diagnostics software The following paragraphs briefly describe the major functions of the module Note that the DM602 and DMS5602 are identical except that the DM602 requires 12 and 5 volt power supplies and the DM5602 requires a single 5 volts power supply for operation More detailed discussions of module functions are included in Chapter 3 Hardware Description and Chapter 4 Module Operation and Programming The module setup is described in Chapter 1 Module Settings Digital to Analog Conversion The digital to analog D A circuitry features two 12 bit converter channels in each AD7237
12. computer manual and the steps below 1 Turn OFF the power to your system 2 Touch a metal rack to discharge any static buildup and then remove the module from its antistatic bag 3 Select the appropriate standoffs for your application to secure the module when you install it in your system two sizes are included with the module 4 Holding the module by its edges orient it so that the P1 bus connector s pin 1 lines up with pin 1 of the expansion connector onto which you are installing the module 5 After carefully positioning the module so that the pins are lined up and resting on the expansion connector gently and evenly press down on the module until it is secured on the connector NOTE Do not force the module onto the connector If the module does not readily press into place remove it and try again Wiggling the module or exerting too much pressure can result in damage to the 602 5602 or to the mating module 6 After the module is installed connect the cable to I O connector P2 on the module When making this connection note that there is no keying to guide you in orientation You must make sure that pin 1 of the cable is connected to pin 1 of the connector pin 1 is marked on the module with a small square For twisted pair cables pin 1 is the dark brown wire for standard single wire cables pin 1 is the red wire 7 Make sure all connections are secure External I O Connections Figure 2 1 shows the 602 5602 s P2 I O co
13. programmed by writing to and reading from the correct I O port locations on the module These I O ports were defined in the previous section Most high level languages such as BASIC Pascal C and C and of course assembly language make it very easy to read write these ports The table below shows you how to read from and write to I O ports using some popular programming languages language Resd wie BASIC Data INP Address OUT Address Data Data inportb Address outportb Address Data Turbo Pascal Data Port Address Port Address Data mov dx Address mov dx Address Assembly in al dx mov al Data out dx al In addition to being able to read write the I O ports on the 602 5602 you must be able to perform a variety of operations that you might not normally use in your programming The table below shows you some of the operators discussed in this section with an example of how each is used with Pascal C and BASIC Note that the modulus operator is used to retrieve the least significant byte LSB of a two byte word and the integer division operator is used to retrieve the most significant byte MSB C 96 amp a b c a b c a b amp c a b c Pascal MOD DIV AND OR a bMODc a bDIVc a b AND c a bORc MOD AND OR BASIC a bMODc a bANDc a bORc Many compilers have functions that can read write either 8 or 16 bits from to an I O port For example Turbo Pascal uses Port for 8 bit port operations and PortW for 16 bits Turbo C u
14. 8 is DAC4 Figure 1 5 shows the five valid configurations for these headers and the table on the next page summarizes the jumper settings for each output mode Four jumpers are installed to activate one of the five output modes The top pair of pins 5 is jumpered when operating in a unipolar voltage range or as a current loop The next pair of pins 5 is jumpered when operating in a bipolar range 5 or 10 volts The X1 and X2 pins set the range multiplier When a jumper is installed across X1 the multiplier is set at times 1 0 to 5V and 5V ranges When a jumper is installed across X2 the multiplier is times 2 0 to 10V and 10V ranges The VE pins enable voltage outputs when a jumper is installed or the IE pins enable 4 20 mA current loop operation when a jumper is installed Finally a jumper must be placed across the VO pins for output voltages or across the IO pins for 4 20 mA current loop operation To configure each header for your application follow the diagrams and table 5 5 5 5 5 5 5 5 5 5 X1 X1 X1 X1 X1 X2 X2 X2 X2 X2 VE VE VE VE VE IE IE IE IE IE VO VO VO VO VO IO IO IO IO IO 5 volts O to 5 volts 10 volts 0 to 10 volts 4 20 mA Factory Setting current loop Fig 1 5 DAC Output Range Jumpers P5 Through P8 Output Range Jumpers opto bottom sv otossv sov otostov 420mA S1 Base Address Factory Setting 300 hex 768 decimal One of the most common causes of failure when you
15. D A converter IC for a total of four output channels The two channels in each AD7237 are internally double buffered and all chan nels are simultaneously updated by issuing a single command Each channel can be jumpered to one of four output voltage ranges 5 10 O to 5 or O to 10 or as a 4 20 mA current loop source The industrial 4 20 mA current loop signals are less susceptible than voltage signals to electrically induced noise Digital I O The 602 5602 has 24 TTL CMOS compatible digital I O lines which can be directly interfaced with external devices or signals to sense switch closures trigger digital events or activate solid state relays These lines are provided by the on board 8255 programmable peripheral interface chip The 8255 can be operated in one of three modes Pads for installing and activating pull up or pull down resistors are included on the module Installation procedures are given at the end of Chapter 1 Module Settings What Comes With Your Module You receive the following items in your 602 5602 package DM602 or DM5602 interface module with stackthrough bus header Mounting hardware Example programs in BASIC Pascal and C with source code and diagnostics software User s manual If any item is missing or damaged please call Real Time Devices Customer Service Department at 814 234 8087 If you require service outside the U S contact your local distributor Module Accessories In addition to the i
16. DING IMPLIED WARRANTIES FOR MECHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE LIMITED TO THE DURATION OF THIS WARRANTY IN THE EVENT THE PRODUCT IS NOT FREE FROM DEFECTS AS WARRANTED ABOVE THE PURCHASER S SOLE REMEDY SHALL BE REPAIR OR REPLACEMENT AS PROVIDED ABOVE UNDER NO CIRCUMSTANCES WILL REAL TIME DEVICES BE LIABLE TO THE PURCHASER OR ANY USER FOR ANY DAMAGES INCLUDING ANY INCIDENTAL OR CONSEQUENTIAL DAM AGES EXPENSES LOST PROFITS LOST SAVINGS OR OTHER DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE PRODUCT SOME STATES DO NOT ALLOW THE EXCLUSION OR LIMITATION OF INCIDENTAL OR CONSE QUENTIAL DAMAGES FOR CONSUMER PRODUCTS AND SOME STATES DO NOT ALLOW LIMITA TIONS ON HOW LONG AN IMPLIED WARRANTY LASTS SO THE ABOVE LIMITATIONS OR EXCLU SIONS MAY NOT APPLY TO YOU THIS WARRANTY GIVES YOU SPECIFIC LEGAL RIGHTS AND YOU MAY ALSO HAVE OTHER RIGHTS WHICH VARY FROM STATE TO STATE D 3 DM602 DM5602 User Selected Settings Base I O Address hex decimal
17. DM602 DM5602 User s Manual Ug Real Time Devices USA Inc ene DD _ Accessing the Analog World Publication No 602 5 18 98 DM602 DM5602 User s Manual UI REAL TIME DEVICES USA INC Post Office Box 906 State College Pennsylvania 16804 Phone 814 234 8087 FAX 814 234 5218 Published by Real Time Devices Inc P O Box 906 State College PA 16804 Copyright O 1995 by Real Time Devices Inc All rights reserved Printed in U S A Table of Contents INTRODUCTION e i 1 Digital to Analog Conversioni iii eiTe e tte tte ae Gases RH e aaa ai i 3 Digital VO into atte i 3 What Comes With Your Module er ter cane ed dad beben i 3 Module Accessories uses silence ginn C AR ER ERES RENE RO EE ERR e pe Ses i 3 Using This Manual i t et ed eim e pne ae h i 4 When You Need Help 5 o arte et e dick ese a RET Ere rH Een coats Sine ER ha A i 4 CHAPTER 1 MODULE SETTINGS 0u2002002002000000200200000020n20020002002002002000200200200000020000 0000000000000 1 1 Factory Configured Switch and Jumper Settings i 1 3 P3 Interrupt Source Select Factory Setting EXT amp G Connected sss 1 4 P4 Interrupt Channel Select Factory Setting Interrupt Channel Disabled 20020 1 5 P5 Through P8 DAC Output Range Select Factory Setting 5 to 5 volts All Channels 1 5 S1 Base Addr
18. Interrupts The 602 5602 has three jumper selectable interrupt sources the external trigger EXT the INTRB PCO interrupt generated by the 8255 PPI in Mode 1 and the INTRB interrupt PC3 generated by the 8255 PPI Chapter 1 tells you how to set the jumpers on the interrupt header connectors P3 and P4 and Chapter 4 describes how to program interrupts 3 4 CHAPTER 4 MODULE OPERATION AND PROGRAMMING This chapter shows you how to program and use your DM602 DMS5602 It provides a complete description of the I O map and a detailed description of programming operations to aid you in programming The example programs included on the disk in your module package are listed at the end of this chapter These programs written in BASIC Pascal and C include source code to simplify your applications programming 4 1 4 2 Defining the I O Map The I O map for the 602 5602 is shown in Table 4 1 below As shown the module occupies 16 consecutive I O port locations The base address designated as BA can be selected using DIP switch S1 as described in Chapter 1 Module Settings This switch can be accessed without removing the module from the stack The following sections describe the register contents of each address used in the I O map _ Register Description Readtuncton wmeruncion ecran Register Description Read Function Decimal poss Pi ona Pesarenacigiampaimes fes pio 8255 PPI Port A Read Port A digital input lines l
19. ONNECTOR CURRENT LOOP E TRANSMITTERS AD694 Fig 2 4 Current Output Connections Single Loop Supply Il O CONNECTOR CURRENT LOOP 4 TRANSMITTERS AD694 LOAD ANALOG GND AD694 LOAD Fig 2 5 Current Output Connections Multiple Loop Supplies 2 8 CHAPTER 3 HARDWARE DESCRIPTION This chapter describes the major features of the DM602 DM5602 This chapter also describes the hardware selectable interrupts 3 1 3 2 The 602 5602 provides four analog output channels with voltage or 4 20 mA current loop outputs and 24 TTL CMOS digital I O lines as shown Figure 3 1 This chapter describes the hardware which makes up the major functions and hardware selectable interrupts 2 CHANNEL SELECT 12 BIT D A CONVERTER VOLTAGE CURRENT SELECT VOLTAGE CURRENT 2 CHANNEL SELECT 12 BIT D A CONVERTER VOLTAGE CURRENT SELECT PULL UP DOWN RESISTORS EXTINT 45 VOLTS BE 12 VOLTS CONVERTER 15 VOLTS DM5602 ONLY 12 VOLTS 5 VOLTS Fig 3 1 DM602 DM5602 Block Diagram PC BUS tc o E o w z z o o o D A Conversion The 602 5602 performs digital to analog conversions on four independent analog output channels The output of each conversion channel is jumper selectable for 5 10 0 to 5 or 0 to 10 volts or as a 4 20 mA current loop source The AD7237 12 bit D A converter contains two independent D A converter channels in a single
20. The following paragraph describes the calibration procedure for the X2 multiplier ranges To calibrate for X2 0 to 10 or 10 volts set the DAC output voltage range to 0 to 10 volts jumpers on 5 X2 VE and VO on the corresponding header connector which configures the DAC output for the channel you are 5 3 calibrating Then program the D A converter of the channel you are calibrating with the digital value 2048 The ideal DAC output for 2048 at X2 0 to 10 volt range is 5 0000 volts Adjust the appropriate trimpot as listed in Table 5 1 until an output of 5 0000 volts is obtained Repeat this procedure as necessary for all channels with the X2 jumper installed Table 5 2 list the ideal output voltages for all bit weights in the unipolar ranges and Table 5 3 lists the ideal output voltages for the bipolar ranges Chama me D A Bit Weight 4095 Max Output 2048 1024 512 256 128 2 ea RO a a ese ese a ooo ooo 5 4 2048 512 7500 0 _s ces 9x09 5000 0 10000 0 4 20 mA Current Loop To calibrate the 4 20 mA current loop first set up the output of the channel you are calibrating as shown in Figure 5 2 Then program the D A converter of the channel you are calibrating with the digital value 2048 The ideal DAC current loop output for 2048 is 12 mA Adjust the appropriate trimpot as listed in Table 5 4 until an output of 12 mA is obtained Repeat this procedure for all chann
21. X A DM602 DM5602 SPECIFICATIONS eere esee entes tn enne tn enata sins tn saeua inan A 1 APPENDIX B P2 CONNECTOR PIN ASSIGNMENTS eese eese e eese tn en asta tns tn sns tn enata B 1 APPENDIX C COMPONENT DATA SHEETS eere eese setenta enses instans tenens tasse enne C 1 APPENDIX D WARRANTY iere isess5vejssuutbtsesbsben sn aeronavale ariani D 1 1 1 1 2 1 3 1 4 1 5 1 6 1 7 2 1 2 2 2 3 2 4 2 5 3 1 5 1 5 2 List of Illustrations Module Layout Showing Factory Configured Settings sse 1 3 Interrupt Source Select Jumper P3 uote ue eR RR ein Denen 1 4 Pulling Down the Interrupt Request Line rr ereeereere acena ceeneraa nen etre nnnen e 1 4 Interrupt Channel Select Jumper PA us ie t nie e te Ts 1 5 DAC Output Range Jumpers PS Through P8 sees ener nennen nnne 1 5 Base Address Switch S Its u A a Essa Ki een enint tia ite 1 6 Adding Pull ups and Pull downs to Some Digital I O Lines rea 1 8 P2 VO Connector Pin Assignments i 2 4 Voltage Output Connections sis oon ERRE a En aaa SHE CH ecce DR BREI 2 5 Current Output Connections No Loop Supply i 2 5 Current Output Connections Single Loop Supply essere enne 2 7 Current Output Connections Multiple Loop Supplies eee 2 7 DM602 DM5602 Block Diagram eene nennen nenne tree concern cn nenne
22. X X X 0 0 0 1 pele ete D7 De D5 D4 D3 D2 Di DO written to BA 3 X don t care Set Reset Set PCO Function Bit Bit Select 000 PCO BA 4 D A Converter 1 LSB Write Only Programs the DAC1 LSB eight bits BA 5 D A Converter 1 MSB Write Only Programs the DAC1 MSB four bits into DO through D3 D4 through D7 are irrelevant pacis s D7 D6 D5 DA D3 D2 D1 DO Bit 7 Bit 6 Bit 5 Bit 4 Bit 3 Bit 2 Bit 1 Bit 0 pacms D7 DG D5 DA D3 D2 D DO X X X X Bit11 Bit10 Bit9 Bit 8 BA 6 D A Converter 2 LSB Write Only Programs the DAC2 LSB eight bits BA 7 D A Converter 2 MSB Write Only Programs the DAC2 MSB four bits into DO through D3 D4 through D7 are irrelevant 45 BA 8 D A Converter 3 LSB Write Only Programs the DAC3 LSB eight bits BA 9 D A Converter 3 MSB Write Only Programs the DAC3 MSB four bits into DO through D3 D4 through D7 are irrelevant BA 10 D A Converter 4 LSB Write Only Programs the DAC4 LSB eight bits BA 11 D A Converter 4 MSB Write Only Programs the DAC4 MSB four bits into DO through D3 D4 through D7 are irrelevant BA 12 Update DAC Outputs Write Only A write simultaneously starts a D A conversion in all four channels data written is irrelevant If the DAC data has not been updated since the last conversion the output of the DAC wil
23. a current to a point as low as 24 volts below common WARNING Be sure to observe the correct polarity when connecting the external loop supply The positive terminal is connected to ANALOG GND and the negative terminal is connected to the load side as shown in the diagram Failure to properly connect the supply can damage the module Current Loop Operation Multiple Loop Power Supplies Figure 2 5 shows how to connect the current loop transmitter outputs to corresponding loads with an external loop supply not exceeding 24 volts in each loop WARNING Be sure to observe the correct polarity when connecting the external loop supplies The positive terminal is connected to ANALOG GND and the negative terminal is connected to the load side as shown in the diagram Failure to properly connect the supply can damage the module Connecting the Digital I O For all of the digital connections the high side of an external signal source or destination device is connected to the appropriate signal pin on the I O connector and the low side is connected to any DIGITAL GND Running the 5602DIAG Diagnostics Program Now that your module is ready to use you will want to try it out An easy to use menu driven diagnostics program 5602DIAG is included with your example software to help you verify your module s operation You can also use this program to make sure that your current base address setting does not contend with another device 2 6 Il O C
24. e Example Clear bits 2 4 and 6 in a port Read in the current value of the port AND it with 171 171 255 2 2 2 and then write the resulting value to the port In C this is programmed as v inportb port address v va 171 outportb port address v To set multiple bits in a port OR the current value of the port with the value b where b the sum of the individual bits to be set Note that the bits to be set do not have to be consecutive Example Set bits 3 5 and 7 in a port Read in the current value of the port OR it with 168 168 2 2 27 and then write the resulting value back to the port In assembly language this is programmed as mov dx PortAddress in al dx or al 168 out dx al Often assigning a range of bits is a mixture of setting and clearing operations You can set or clear each bit individually or use a faster method of first clearing all the bits in the range then setting only those bits that must be set using the method shown above for setting multiple bits in a port The following example shows how this two step operation is done Example Assign bits 3 4 and 5 in a port to 101 bits 3 and 5 set bit 4 cleared First read in the port and clear bits 3 4 and 5 by ANDing them with 199 Then set bits 3 and 5 by ORing them with 40 and finally write the resulting value back to the port In C this is programmed as v inportb port address v v amp 199 v v 40 out
25. e 8255 PPI By using these interrupts you can write software that effectively deals with real world events Interrupt Request Lines To allow different peripheral devices to generate interrupts on the same computer the PC bus has eight different interrupt request IRQ lines A transition from low to high on one of these lines generates an interrupt request which is handled by the PC s interrupt controller The interrupt controller checks to see if interrupts are to be acknowledged from that IRQ and if another interrupt is already in progress it decides if the new request should supersede the one in progress or if it has to wait until the one in progress is done This prioritizing allows an interrupt to be interrupted if the second request has a higher priority The priority level is based on the number of the IRQ IRQO has the highest priority IRQI is second highest and so on through IRQ7 which has the lowest Many of the IRQs are used by the standard system resources IRQO is used by the system timer IRQ is used by the key board IRQ3 by COM2 IRQ4 by COMI and IRQ6 by the disk drives Therefore it is important for you to know which IRQ lines are available in your system for use by the 602 5602 8259 Programmable Interrupt Controller The chip responsible for handling interrupt requests in the PC is the 8259 Programmable Interrupt Controller To use interrupts you will need to know how to read and set the 8259 s interrupt mask register
26. els Table 5 5 list the ideal output currents for all bit weights AOUT ma 250 GND Output to DAC 2048 Adjust Potentiometer 12 mA Fig 5 2 4 20 mA Current Loop Calibration Connections Table 5 4 4 20 mA Adjustment D A Converter 4 20 mA Current Loop Conversion Table am RE D A Bit Weight in millamperes pm mw a ama la w 5 6 APPENDIX A DM602 DM5602 SPECIFICATIONS A 2 DM602 DM5602 Characteristics Typical 25 C Interface Switch selectable base address I O mapped Jumper selectable interrupts D A Converter ui a papa aaae aaa daia aa eaa kuaa daia AD7237 Analog OUTPUTS iia r Besen ser ea a aa 4 channels Resolution o nea t ES antas raai in aim 12 bits Output ranges ie Oto 5 5 O to 10 or 10 volts 4 20 mA 420 MA E AEE EE E sane E E E E EE transmitter Relative accuracY iras aaa 1 LSB max Full scale accu tracy 2 en een ee aller 5 LSB max Nonsline arity sanza d en tH Eater 1 LSB max Setting iMac eterne n iot eo RR ete e 5 usec typ Digital VO 4 nia CMOS 82C55 NuMber of INES use einen 24 Logic compalibility 5 3 5 2 iride irte fete a TTL CMOS Configurable with optional I O pull up pull down resistors High level output voltage i 4 2V min Low level output voltage i 0 45V max High level input voltage 2 2V min 5 5V max Low level input volta
27. erred to as the interrupt vector table and each entry is called an interrupt vector Once the new CS and IP are loaded from the interrupt vector table the processor begins executing the code located at CS IP When the interrupt routine is completed the CS IP and flags that were pushed on the stack when the interrupt occurred are now popped from the stack and execution resumes from the point where it was interrupted Using Interrupts in Your Programs Adding interrupts to your software is not as difficult as it may seem and what they add in terms of performance is often worth the effort Note however that although it is not that hard to use interrupts the smallest mistake will often lead to a system hang that requires a reboot This can be both frustrating and time consuming But after a few tries you ll get the bugs worked out and enjoy the benefits of properly executed interrupts Writing an Interrupt Service Routine ISR The first step in adding interrupts to your software is to write the interrupt service routine ISR This is the routine that will automatically be executed each time an interrupt request occurs on the specified IRQ An ISR is different than standard routines that you write First on entrance the processor registers should be pushed onto the stack BEFORE you do anything else Second just before exiting your ISR you must clear the interrupt status of the 602 5602 and write an end of interrupt command to the 8259 cont
28. ess Factory Setting 300 hex 768 decimal 1 6 Pull up Pull down Resistors on Digital VO Lines i 1 7 CHAPTER 2 MODULE INSTALLATION 2220u200000200000000n20n00000000002002000200000200n00000000 0000 necnecneecne 2 1 Module Install att Ones sii eco rere tere A rss eU aa Peas Lene asi ipe ons 2 3 External I O Connections n pie een Paper peine tenete ius cese Pe cos E unes 2 3 Connecting the Analog Outputs Voltage Outputs innen 2 4 Connecting the Analog Outputs 4 20 mA Current Loop Outputs essere 2 4 Connectng the Digital TO i aaa Rn It i e eerie estet ei tie da 2 6 Running the 5602DIAG Diagnostics Program sese eren entren nennen trennen trennen 2 6 CHAPTER 3 HARDWARE DESCRIPTION eee esee eese testata tn seta nio sts toss tassa rene neenecneecne 3 1 D A Conversion insito EEEE EE E iano 3 3 Digital I O Programmable Peripheral Interface eee ono rn non cra cnn ne nenennennnnn 3 3 Interr pts iie eerte e P n Pede enr arene 3 4 CHAPTER 4 MODULE OPERATION AND PROGRAMMING 4 eese teet en tentes tn atnenae 4 1 Defining the VO Map in torte te th i i A EA ATO c e re ah 4 3 BA 0 PPI Port A Digital I O Read Write onen 4 3 BA 1 PPI Port B Digital I O Read Write re enne enren nennen 4 3 BA 2 PPI Port C Digital YO Read Write
29. ge cnn 0 3V min 0 8V max Input load current i ete rare ahnen 10 pA Input capacitance CUNYOFPFZIMEz n ascen een 10 pF Output capacitance C OUT lt OF IMBZ ite dette aiii 20 pF Current Requirements DM602 194 mA 9 5 12 volts no load DM5602 340 mA 9 5 volts no load Connector 50 pin right angle header Size 3 55 L x 3 775 W x 0 6 H 90mm x 96mm x 15mm A 3 A 4 APPENDIX B P2 CONNECTOR PIN ASSIGNMENTS B 1 B 2 AOUT1 AOUT2 AOUT3 AOUT4 ANALOG GND ANALOG GND ANALOG GND ANALOG GND EXTINT DIGITAL GND DIGITAL GND PA7 PA6 PAS PA4 PA3 PA2 PA1 PAO PB7 PB5 PB3 PB1 12 VOLTS 12 VOLTS ANALOG GN ANALOG GN ANALOG GN ANALOG GN ANALOG GN ANALOG GN ANALOG GN ANALOG GN DIGITAL GND PIN 1 DIGITAL GND DIGITAL GND PC7 PC6 PC5 PC4 PC3 PC2 PC1 PCO PB6 PB4 PB2 PBO VOLT ds NOLS PIN 49 DIGITAL GND D D D D D D D D 0000000000000000000000000O eee ee 9 9 e eee 9 9 9 9 9 9 9 9 GO 9 Note that 12 volts at pin 47 and 12 volts at pin 49 are available only if your computer bus supplies them these voltages are not provided by the module P2 Mating Connector Part Numbers Manufacturer Part Number 1 746094 0 3425 7650 B 3 B 4 C 1 APPENDIX C COMPONENT DATA SHEETS Intel 82C55A Programmable Peripheral Interface Data Sheet Reprint APPENDIX D WARRANTY D 2 LIMITED
30. h the P2 I O connector PCO which is the INTRB signal from the 8255 PPI and PC3 which is the INTRA signal from the 8255 PPI Note that only ONE interrupt source can be activated at a time This module supports an interrupt sharing mode where the top pair of pins on P3 labeled G are provided so that you can install a jumper which connects a 1 kilohm pull down resistor to the output of a high impedance tri state driver which carries the interrupt request signal This pull down resistor pulls the interrupt request line low whenever interrupts are not active So whenever an interrupt request is made the tri state buffer is enabled forcing the output high and causing an interrupt You can monitor the interrupt status through bit O in the status word I O address location BA 15 After the interrupt has been serviced the clear command returns the IRQ line low disabling the tri state buffers and pulling the output low again Figure 1 3 shows this circuit Because the interrupt request line is pulled low only by the pull down resistor you can have two or more modules which share the same IRQ channel You can tell which module issued the interrupt request by monitoring each module s IRQ status bit If you are not planning on sharing interrupts or if you are not sure that your CPU supports interrupt sharing it is best to disable this feature and use the interrupts in the normal mode This will insure compatibility with all CPUs See chapter 4 for details
31. ines BA 0 posserirone Pesatonticiiaipaines fes gay 8255 PPI Port B Read Port B digital input lines lines BA 1 c td 8255 PPI Port C Read Port C digital input lines lines BA 2 Basa Update All DACs an the outputs of all DACs REC 12 Reseved Reserved Resend Bans Enable and disable interrupt IRQ Enable Reserved generation UTER 14 Interrupt Status Clear Read status of interrupt Clear interrupt Basis 15 BA Base Address BA 0 PPI Port A Digital I O Read Write Transfers the 8 bit Port A digital input and digital output data between the module and an external device A read transfers data from the external device through P2 and into PPI Port A a write transfers the written data from Port A through P2 to an external device BA 1 PPI Port B Digital I O Read Write Transfers the 8 bit Port B digital input and digital output data between the module and an external device A read transfers data from the external device through P2 and into PPI Port B a write transfers the written data from Port B through P2 to an external device BA 2 PPI Port C Digital I O Read Write Transfers the two 4 bit Port C digital input and digital output data groups Port C Upper and Port C Lower between the module and an external device A read transfers data from the external device through P2 and into PPI Port C a write transfers the written data from Port C through P2 to an external device 4 3
32. ing an ISR are forgetting to clear the interrupt status of the 602 5602 and forgetting to issue the EOI command to the 8259 interrupt controller before exiting the ISR 4 14 Example Programs Included with the 602 5602 is a set of example programs that demonstrate the use of many of the module s features These examples are in written in C Pascal and BASIC Also included is an easy to use menu driven diagnostics program 5602DIAG which is especially helpful when you are first checking out your module after installation Before using the software included with your module make a backup copy of the disk You may make as many backups as you need C and Pascal Programs These programs are source code files so that you can easily develop your own custom software for your 602 5602 DAC Simple program that shows how to program the D A converters DIGITAL Simple program that shows how to read and write the digital I O lines BASIC Programs These programs are source code files so that you can easily develop your own custom software for your 602 5602 DAC Simple program that shows how to program the D A converters DIGITAL Simple program that shows how to read and write the digital I O lines 4 15 4 16 CHAPTER 5 CALIBRATION This chapter tells you how to calibrate the DM602 DM5602 using the 5602DIAG calibration program included in the example software package and 8 trimpots on the module These trimpots calibrate the D A X2 multi
33. ith pull ups Port C Lower with pull downs and Port C Upper with no resistors PULL UP Fig 1 7 Adding Pull ups and Pull downs to Some Digital I O Lines CHAPTER 2 MODULE INSTALLATION The DM602 DM5602 is easy to install in your cpuModule or other PC 104 based system This chapter tells you step by step how to install and connect the module for voltage outputs and 4 20 mA current loop outputs After you have installed the module and made all of your connections you can turn your system on and run the 5602DIAG board diagnostics program included on your example software disk to verify that your module is working 2 1 2 2 Module Installation Keep the module in its antistatic bag until you are ready to install it in your cpuModule or other PC 104 based system When removing it from the bag hold the module at the edges and do not touch the components or connec tors Before installing the module in your system check the jumper and switch settings Chapter 1 reviews the factory settings and how to change them If you need to change any settings refer to the appropriate instructions in Chapter 1 Note that incompatible jumper settings can result in unpredictable module operation and erratic response The 602 5602 comes with a stackthrough P1 connector The stackthrough connector lets you stack another module on top of your 602 5602 To install the module follow the procedures described in the
34. l not change BA 13 IRQ Sharing Write Only Enables and disables interrupt sharing Writing a 1 disables interrupt sharing writing a 0 enables inter rupt sharing At power up this register is set to 0 D7 D6 D5 DA D3 D2 D1 DO 0 0 0 0 0 0 0 Interrupt Sharing O enabled 1 disabled BA 14 IRQ Enable Write Only Enables and disables interrupt generation Writing a 1 enables interrupt generation writing a 0 disables interrupt generation D7 D6 D5 DA D3 D2 D1 DO 0 0 0 0 0 0 0 Interrupt Enable Disable O interrupt disabled 1 interrupt enabled BA 15 Interrupt Status Clear Read Write A read shows the status of the interrupt bit O only as defined below A write clears the interrupt data written is irrelevant Each time the interrupt status bit goes high a write should follow to clear the bit D7 D6 D5 DA D3 D2 D1 DO X X X X X X X Interrupt Status O no interrupt 1 interrupt has occurred 4 6 Programming the 602 5602 This section gives you some general information about programming and the 602 5602 and then walks you through the major 602 5602 programming functions These descriptions will help you as you use the example programs included with the module All of the program descriptions in this section use decimal values unless otherwise specified The 602 5602 is
35. nnector pinout Refer to this diagram as you make your I O connec tions Note that 12 volts at pin 47 and 12 volts at pin 49 are available only if your computer bus supplies them these voltages are not provided by the module 2 3 AOUT1 ANALOG GND AOUT2 ANALOG GND AOUT3 ANALOG GND AOUT4 ANALOG GND ANALOG GND ANALOG GND ANALOG GND ANALOG GND ANALOG GND ANALOG GND ANALOG GND ANALOG GND EXTINT DIGITAL GND DIGITAL GND DIGITAL GND DIGITAL GND DIGITAL GND 5 VOLTS DIGITAL GND 12 VOLTS 12 VOLTS DO DO OO DE Od DA OY CIO ON DIE ds DIO OS DKA dd 6369 669 Fig 2 1 P2 I O Connector Pin Assignments Connecting the Analog Outputs Voltage Outputs When the analog output is configured as a voltage output the high side of the device receiving the output is connected to an AOUT line and the low side is connected to the corresponding ANALOG GND Figure 2 2 shows how to connect the 602 5602 voltage outputs to a load NOTE Driving highly capacitive loads can cause unwanted oscillations Placing a 100 ohm resistor in series with the capacitive load should eliminate this condition Connecting the Analog Outputs 4 20 mA Current Loop Outputs When the analog output is configured as a 4 20 mA current loop source you can operate the loop using only the 12 volts supplied to the circuit to power the current loop transmitters or you can use external power supplies for dual power supply operation Current Loop
36. on disabling the interrupt sharing circuit NOTE When you use multiple modules that share the same interrupt only one module should have the G ground jumper installed The rest should be disconnected Whenever you operate a single module the G jumper should be installed Whenever you operate the module with interrupt sharing disabled the G jumper should be removed 9d 09d 1X3 P3 Fig 1 2 Interrupt Source Select Jumper P3 INT IRQ STATUS source CLK INTERRUPT REGISTER INTERRUPT CLR Fig 1 3 Pulling Down the Interrupt Request Line P4 Interrupt Channel Select Factory Setting Interrupt Channel Disabled This header connector shown in Figure 1 4 lets you connect an interrupt source to an interrupt channel IRQ2 through IRQ7 The interrupt source is selected by installing a jumper across the appropriate pair of pins on header connector P3 To connect a source to a channel you must install a jumper across the desired channel as shown in Figure 1 4b Noo 5 0o N o0 50 N U U 5 A Fig 1 4a IRQ Disabled Fig 1 4b IRQ3 Enabled Factory Setting Fig 1 4 Interrupt Channel Select Jumper P4 P5 Through P8 DAC Output Range Select Factory Setting 5 to 5 volts All Channels These four identical header connectors individually set the output range for each of the four DAC channels to one of four voltage ranges or as a 4 20 mA current loop P5 is DACI P6 is DAC2 P7 is DAC3 and P
37. overwrite the appropriate entry in the vector table with a direct memory write but this is a bad practice Instead use either DOS function 25H set interrupt vector or if your compiler provides it the library routine for setting an interrupt vector Remember that vector 8 is for IRQO vector 9 is for IRQ1 and so on If you need to program the source of your interrupts do that next For example if you are using the program mable interval timer to generate interrupts you must program it to run in the proper mode and at the proper rate Finally clear the bit in the IMR for the IRQ you are using This enables interrupts on the IRQ Restoring the Startup IMR and Interrupt Vector Before exiting your program you must restore the interrupt mask register and interrupt vectors to the state they were in when your program started To restore the IMR write the value that was saved when your program started to I O port 21H Restore the interrupt vector that was saved at startup with either DOS function 35H get interrupt vector or use the library routine supplied with your compiler Performing these two steps will guarantee that the interrupt status of your computer is the same after running your program as it was before your program started running Common Interrupt Mistakes Remember that hardware interrupts are numbered 8 through 15 even though the corresponding IRQs are numbered O through 7 Two of the most common mistakes when writ
38. plier output and 4 20 mA current loop output 5 1 5 2 This chapter tells you how to calibrate the D A converter X2 voltage multiplier and the 4 20 mA current loop The X1 range does not have to be calibrated All D A ranges are factory calibrated before shipping Any time you suspect inaccurate readings you can check the accuracy of your conversions using the procedure below and make adjustments as necessary Using the 5602DIAG diagnostics program is a convenient way to monitor conversions while you calibrate the module Calibration is done with the board installed in your system You can access the trimpots along the edge of the module Power up the system and let the module circuitry stabilize for 15 minutes before you start calibrating Required Equipment The following equipment is required for calibration Precision Voltage Source 10 to 10 volts Digital Multimeter 5 1 2 digits Small Screwdriver for trimpot adjustment While not required the 5602DIAG diagnostics program included with the example software is helpful when performing calibrations Figure 5 1 shows the module layout with the 8 trimpots located along the top edge of the module TR1 through TR8 left to right mm nummi 44 PIN PLCC OCKE 44 PIN PLCC OCKET ZAH LH Mm COLE Fig 5 1 Module Layout D A Calibration X2 Voltage Multiplier The D A converter requires no calibration for the X1 ranges 0 to 5 and 5 volts
39. portb port address v 4 8 A final note Don t be intimidated by the binary operators AND and OR and try to use operators for which you have a better intuition For instance if you are tempted to use addition and subtraction to set and clear bits in place of the methods shown above DON T Addition and subtraction may seem logical but they will not work if you try to clear a bit that is already clear or set a bit that is already set For example you might think that to set bit 5 of a port you simply need to read in the port add 32 2 to that value and then write the resulting value back to the port This works fine if bit 5 is not already set But what happens when bit 5 is already set Bits O to 4 will be unaffected and we can t say for sure what happens to bits 6 and 7 but we can say for sure that bit 5 ends up cleared instead of being set A similar problem happens when you use subtraction to clear a bit in place of the method shown above Now that you know how to clear and set bits we are ready to look at the programming steps for the 602 5602 functions D A Conversions D A conversions are performed on the four analog output channels AOUTI AOUT2 AOUT3 and AOUTA by writing data to the D A converter registers and then issuing an update command BA 12 which simultaneously updates the outputs of all four channels The 12 bit digital data for each channel is loaded in a two step process LSB followed by MSB After the data has
40. pt vector that you will be using The IMR is located at I O port 21H The interrupt vector you will be using is located in the interrupt vector table which is simply an array of 256 bit 4 byte pointers and is located in the first 1024 bytes of memory Segment 0 Offset 0 You can read this value directly but it is a better practice to use DOS function 35H get interrupt vector Most C and Pascal compilers provide a library routine for reading the value of a vector The vectors for the hardware interrupts are vectors 8 through 15 where IRQO uses vector 8 IRQ1 uses vector 9 and so on Thus if the 602 5602 will be using IRQ3 you should save the value of interrupt vector 11 Before you install your ISR temporarily mask out the IRQ you will be using This prevents the IRQ from requesting an interrupt while you are installing and initializing your ISR To mask the IRQ read in the current IMR at I O port 21H and set the bit that corresponds to your IRQ remember setting a bit disables interrupts on that IRQ while clearing a bit enables them The IMR is arranged so that bit O is for IRQO bit 1 is for IRQ1 and so on See the paragraph entitled Interrupt Mask Register IMR earlier in this chapter for help in determining your IRQ s bit After setting the bit write the new value to I O port 21H With the startup IMR saved and the interrupts on your IRQ temporarily disabled you can assign the interrupt vector to point to your ISR Again you can
41. roller Finally when exiting the ISR in addition to popping all the registers you pushed on entrance you must use the IRET instruction and not a plain RET The IRET automatically pops the flags CS and IP that were pushed when the interrupt was called If you find yourself intimidated by interrupt programming take heart Most Pascal and C compilers allow you to identify a procedure function as an interrupt type and will automatically add these instructions to your ISR with one important exception most compilers do not automatically add the end of interrupt command to the procedure you must do this yourself Other than this and the few exceptions discussed below you can write your ISR just like any other routine It can call other functions and procedures in your program and it can access global data If you are writing your first ISR we recommend that you stick to the basics just something that will convince you that it works such as incrementing a global variable NOTE If you are writing an ISR using assembly language you are responsible for pushing and popping registers and using IRET instead of RET 4 12 There are a few cautions you must consider when writing your ISR The most important is do not use any DOS functions or routines that call DOS functions from within an ISR DOS is not reentrant that is a DOS function cannot call itself In typical programming this will not happen because of the way DOS is written But what about
42. scription in the previous I O map section to help you program the right value In the example below a decimal value of 128 sets up the 8255 so that all 24 lines are Mode 0 outputs 1 0 0 0 0 0 0 0 D7 D6 D5 D4 D3 D2 Di DO Digital I O Operations Once the 8255 is initialized you can use the digital I O line to control or monitor external devices Interrupts What Is an Interrupt An interrupt is an event that causes the processor in your computer to temporarily halt its current process and execute another routine Upon completion of the new routine control is returned to the original routine at the point where its execution was interrupted Interrupts are very handy for dealing with asynchronous events events that occur at less than regular intervals Keyboard activity is a good example your computer cannot predict when you might press a key and it would be a waste of processor time for it to do nothing while waiting for a keystroke to occur Thus the interrupt scheme is used and the processor proceeds with other tasks Then when a keystroke does occur the keyboard interrupts the processor and the processor gets the keyboard data places it in memory and then returns to what it was doing before it was interrupted Other common devices that use interrupts are modems disk drives and mice Your 602 5602 can interrupt the processor when an external interrupt is enabled or through PCO or PC3 from th
43. ses inportb for an 8 bit read of a port and inport for a 16 bit read Be sure to use only 8 bit operations with the 602 5602 4 7 Clearing and Setting Bits in a Port When you clear or set one or more bits in a port you must be careful that you do not change the status of the other bits You can preserve the status of all bits you do not wish to change by proper use of the AND and OR binary operators Using AND and OR single or multiple bits can be easily cleared in one operation To clear a single bit in a port AND the current value of the port with the value b where b 255 2 Example Clear bit 5 in a port Read in the current value of the port AND it with 223 223 255 2 and then write the resulting value to the port In BASIC this is programmed as V INP PortAddress V V AND 223 OUT PortAddress V To set a single bit in a port OR the current value of the port with the value b where b 2 Example Set bit 3 in a port Read in the current value of the port OR it with 8 8 2 and then write the resulting value to the port In Pascal this is programmed as V Port PortAddress V VOR 8 Port PortAddress V Setting or clearing more than one bit at a time is accomplished just as easily To clear multiple bits in a port AND the current value of the port with the value b where b 255 the sum of the values of the bits to be cleared Note that the bits do not have to be consecutiv
44. t our Technical Support Department 814 234 8087 during regular business hours eastern standard time or eastern daylight time or send a FAX requesting assistance to 814 234 5218 When sending a FAX request please include your company s name and address your name your telephone number and a brief description of the problem CHAPTER 1 MODULE SETTINGS The DM602 DM5602 has jumper and switch settings you can change if necessary for your application The module is factory configured as listed in the table and shown on the layout diagram in the beginning of this chapter Should you need to change these settings use these easy to follow instructions before you install the module in your PC 104 system Note that by installing resistor packs at four the RN locations around the 8255 PPI and soldering a jumper between 5V and common or ground and common in the associated pads for each resistor network you can configure groups of digital I O lines to be pulled up or pulled down This procedure is explained at the end of this chapter Factory Configured Switch and Jumper Settings Table 1 1 lists the factory settings of the user configurable jumper and switches on the 602 5602 Figure 1 1 shows the module layout and the locations of the factory set jumpers The following paragraphs explain how to change the factory settings Pay special attention to the setting of S1 the base address switch to avoid address contention when you first use your
45. tems included in your 602 5602 package Real Time Devices offers a full line of application software and drivers and accessories Call your local distributor or our main office for more information about these accessories and for help in choosing the best items to support your module s application Accessories for the 602 5602 include the MR8 MR 16 series 8 or 16 channel mechanical relay boards the OP8 OP16 series 8 or 16 channel optoisolated digital input boards the OR16 mechanical relay optoisolated digital I O board the TB50 terminal board and XB50 prototype terminal board for prototype development and easy signal access the DM 14 extender board for testing your module in a PC compatible computer and the XT50 twisted pair wire flat ribbon cable assembly for external interfacing Using This Manual This manual is intended to help you install your new module and get it running quickly while also providing enough detail about the module and its functions so that you can enjoy maximum use of its features even in the most complex applications We assume that you already have an understanding of data acquisition principles and that you can customize the example software or write your own applications programs When You Need Help This manual and the example programs in the software package included with your module provide enough information to properly use all of the module s features If you have any problems installing or using this board contac
46. terms of execution time Spending long periods of time in your ISR may mean that other important interrupts are being ignored Also if you spend too long in your ISR it may be called again before you have completed handling the first run This often leads to a hang that requires a reboot Your ISR should have this structure Push any processor registers used in your ISR Most C and Pascal interrupt routines automatically do this for you Put the body of your routine here Clear the interrupt bit on the 602 5602 by writing any value to BA 15 Issue the EOI command to the 8259 interrupt controller by writing 20H to port 20H Pop all registers pushed on entrance Most C and Pascal interrupt routines automatically do this for you The following C and Pascal examples show what the shell of your ISR should be like In C void interrupt ISR void Xour code goes here Do not use any DOS functions outportb BaseAddress 15 0 Clear 602 5602 interrupt outportb 0x20 0x20 Send EOI command to 8259 In Pascal Procedure ISR Interrupt begin Your code goes here Do not use any DOS functions Port BaseAddress 15 0 Clear 602 5602 interrupt Port 20 20 Send EOI command to 8259 end 4 13 Saving the Startup Interrupt Mask Register IMR and Interrupt Vector The next step after writing the ISR is to save the startup state of the interrupt mask register and the interru
47. vided into four groups eight Port A lines eight Port B lines four Port C Lower lines and four Port C Upper lines You can install and connect pull up or pull down resistors for any or all of these four groups of lines You may want to pull lines up for connection to switches This will pull the line high when the switch is disconnected Or you may want to pull down lines connected to relays which control turning motors on and off These motors turn on when the digital lines controlling them are high Pulling these lines down keeps them from floating high during the brief period between power up and initialization To use the pull up pull down feature you must first install resistor packs in any or all of the four locations around the 8255 labeled PA PB PCL and PCH PA RN3 and PB RN2 take a 10 pin pack and PCL RN4 and PCH RN5 take 6 pin packs After the resistor packs are installed you must connect them into the circuit as pull ups or pull downs Locate the three hole pads on the board near the resistor packs They are labeled G for ground on one end and V for 5 volts on the other end The middle hole is common PA is for Port A PB for Port B PCL is for Port C Lower and PCH is for Port C Upper To operate as pull ups solder a jumper wire between the common pin middle pin of the three and the V pin For pull downs solder a jumper wire between the common pin middle pin and the G pin For example Figure 1 7 shows Port A lines w
48. when using interrupts Then you could have a situation such as this in your program If DOS function X is being executed when an interrupt occurs and the interrupt routine makes a call to DOS function X then function X is essentially being called while it is already active Such a reentrancy attempt spells disaster because DOS functions are not written to support it This is a complex concept and you do not need to understand it Just make sure that you do not call any DOS functions from within your ISR The one wrinkle is that unfortunately it is not obvious which library routines included with your compiler use DOS functions A rule of thumb is that routines which write to the screen or check the status of or read the keyboard and any disk I O routines use DOS and should be avoided in your ISR The same problem of reentrancy exists for many floating point emulators as well meaning you may have to avoid floating point real math in your ISR Note that the problem of reentrancy exists no matter what programming language you are using Even if you are writing your ISR in assembly language DOS and many floating point emulators are not reentrant Of course there are ways around this problem such as those which involve checking to see if any DOS functions are currently active when your ISR is called but such solutions are well beyond the scope of this discussion The second major concern when writing your ISR is to make it as short as possible in

Download Pdf Manuals

image

Related Search

Related Contents

KIT-RAD-EE    ASUS PU551JH User's Manual  KH21(KH20).KH61 圧力トランスミッタ機種統廃合  Manual de instruções do medidor de energia modelo  Mellanox MLNX-OS® User Manual for IBM 90Y3474  Sharpdesk Mobile V2  atenção - Jacobsen  Curtis Proscan  Clarion VMA573 User's Manual  

Copyright © All rights reserved.
Failed to retrieve file