PK2100 C-Programmable Controller Users Manual Revision 2.
Z-World, Inc. PK2100 Users Manual Part Number 019-0014-02 Revision 2.0 021-0024-02 Printed in U.S.A. Last Revised by TI October 22, 1998 Copyright © 1998 Z-World, Inc. All rights reserved. Z-World, Inc. reserves the right to make changes and improvements to its products without providing notice. Trademarks Dynamic C is a trademark of Z-World, Inc. Windows is a trademark of Microsoft Corporation.
CONTENTS About This Manual vii PK2100 Overview 1-1 Getting Started 2-1 I/O Configurations 3-1 System Development 4-1 PK2100 Overview ............................................................................. 1-2 PK2100 Features· .......................................................................... 1-3 PK2110 Features ........................................................................... 1-3 PK2120 Features ...........................................................................
Virtual Driver..................................................................................... 4-3 Invoking the Virtual Driver .......................................................... 4-4 Virtual Driver Services ...................................................................... 4-4 Virtual Driver Variables .................................................................... 4-6 Digital Outputs .............................................................................. 4-6 Digital Inputs ......
Appendix B: Specifications B-1 Appendix C: Power Management C-1 Appendix D: I/O Map and Interrupt Vectors D-1 Appendix E: EEPROM E-1 Appendix F: PLCBus F-1 Appendix G: Battery G-1 Hardware Dimensions ....................................................................... B-2 Jumper and Header Specifications .................................................... B-4 Connectors .........................................................................................
vi s Contents PK2100
ABOUT THIS MANUAL This manual provides instructions for installing, testing, configuring, and interconnecting the Z-World PK2100 controller. Instructions are also provided for using Dynamic C functions. Instructions to get started using Dynamic C software programming functions as well as complete C and Dynamic C references and programming resources are referenced when necessary.
Terms and Abbreviations Table 1 lists and defines terms and abbreviations that may be used in this manual. Table 1. Terms and Abbreviations Term / Abbreviation Description PIO Programmable Input / Output Integrated Circuit RAM Random Access Memory RTC Real-Time Clock SIB Serial Interface Board SRAM Static Random Access Memory NMI Non-Maskable Interrupt Conventions Table 2 lists and defines typographical conventions that may be used in this manual. Table 2.
J1 Pin Number 1 A black square indicates pin 1 of all headers and jumpers. Pin 1 Icons Table 3 displays and defines icons that may be used in this manual. Table 3. Icons Icon $ ( Meaning Refer to or see Please contact Caution ! 7LS FD ( PK2100 Note Tip Factory Default For ordering information, call your Z-World Sales Representative at (530) 757-3737.
x s About This Manual PK2100
PK2100 OVERVIEW Chapter 1 provides an overview and brief description of the PK2100 C-Programmable controller features, options, and upgrades.
PK2100 Overview The PK2100 series is Z-Worlds most comprehensive controller that connects directly to many sensors and peripheral devices without needing intermediate signal conditioning. A typical application for the PK2100 is the control of medium-scale production equipment, such as packaging machinery, special-purpose machine tools, or material processing systems. The PK2100 can be used to detect contact closures, count pulses, and measure analog values such as temperature or pressure.
PK2100 Features Seven fixed digital inputs Six universal inputs One high-gain differential analog input Ten high-current outputs capable of driving inductive loads such as solenoids and relays Two SPDT relays Two analog outputs 2 x 20-charcter LCD screen (backlighted display available) and 2 x 6 keypad PLCBus port One RS-232 port and one RS-232 or RS-485/RS-422 port Rugged enclosure Battery-backed RAM up to 512 kbytes EPROM up to 512 kbytes for holding program and dat
Software Development and Evaluation Tools Dynamic C, Z-Worlds Windows-based real-time C language development system, is used to develop software for the PK2100. The host PC downloads the executable code through the PK2100s RS-232 port to one of the following places: battery-backed RAM, ROM written on a separate ROM programmer and then substituted for the standard Z-World ROM, or optional flash EPROM, which may be programmed or reprogrammed without removing it from the controller.
GETTING STARTED Chapter 2 provides instructions for connecting the PK2100 to a host PC and running a sample program.
Initial PK2100 Setup When the PK2100 powers up, it reads its board jumpers, the keypad, if any, and the contents of the EEPROM to determine its mode of operation. The following modes of operation are available: 1. Run a program stored in battery-backed RAM. 2. Program at 19.2 kbaud using the RS-232 port. 3. Program at 38.4 kbaud using the RS-232 port. The keypad (Figure 2-1) may be used to set the mode. Hold down the MENU/setup key and one other key (FIELD/run, UP/pgm 19.2, or DOWN/pgm 38.4) simultaneously.
Connecting the PK2100 to a Host PC 1. Make sure the PK2100 power source is not connected. 2. Connect the PK2100 to the host PCs RS-232 serial COM port. A 9-pin to RS-232 phone plug adapter is included with the developers kit. 3. Connect the red-tagged lead from the 24-volt (or 12-volt) power supply to the +24-volt screw connector. Connect the other power supply lead to the GND screw connector. 4. Plug the power supply into a wall socket.
2. Compile the program by pressing F3 or by choosing Compile from the Compile menu. Dynamic C compiles and downloads the program into the PK2100s flash memory. 3. Run the program by pressing F9 or by choosing Run from the Run menu. 4. Press Ctrl Z to stop execution of the program. 5. If needed, press F9 to restart execution of the program.
I/O CONFIGURATIONS Chapter 3 discusses how to configure the available inputs/outputs in the PK2100 controller.
PK2100 Inputs and Outputs The PK2100 provides these types of inputs/outputs: Universal analog inputs. Protected digital inputs. High-gain differential analog input. SPDT relays. High-current driver outputs capable of driving inductive loads such as solenoids and relays. Analog outputs. 2 × 20-charcter LCD screen (backlighted display available) and 2 × 6 keypad. Serial communication channels: PLCBus port, RS-232 port, and RS-232 or RS-485/RS-422 port.
The connector labeled +10-V ref is nominally 7 volts for the PK2110/ PK2130 12-volt versions of the PK2100. The connector labeled DC in is 12 or 24 volts, depending on the specific PK2100 model. Figure 3-2 shows a PK2100 block diagram. The PK2100s board layout and schematic are included in this manual.
3 One high-sensitivity differential analog input. Normally, the high-sensitivity range is 01 volts, but the input gain can be changed by installing different input resistors on the operational amplifier. When the positive side of the differential input is more than 1 volt, its voltage can be measured by the universal input with which it is coupled. This input is suitable for connection to resistance bridges. 4. Two relay-contact outputs (NO, NC, COM for each relay).
software (see Chapter 4, System Development) provides the two thresholds. The universal inputs are protected against overloads between -48 and +48 volts. The analog resolution is 10 bits, providing approximately 1024 steps over the range 010 volts (07 volts for PK2110/PK2130). Its sensitivity is about 10 millivolts per step. Figure 3-3 shows a schematic of a single universal input channel. +10-V reference +3.3-kΩ excitation +resistor Jumpers (H4, H5, H6) Input 22 kΩ 0.01 µF 4.
Multiple contacts may be connected with external resistors to a single universal input (Figure 3-5). +10-V ref +10-V ref 3.3 kΩ 4 kΩ 1 kΩ (a) Multiple Contacts (closest has priority) 2 kΩ 3.3 kΩ 1 kΩ (b) Muliple Contacts Resolvable Individually Figure 3-5. Use of External Resistors to Connect Multiple Contacts to Single Universal Input Digital Inputs The seven digital inputs accept an input voltage with a digital threshold at approximately 2.5 volts.
Three of the digital inputs also serve as counter inputs. In addition, there is a special differential counter input. The counter inputs are arranged as shown in Figure 3-7. +5 V C1A C1B +5 V +5 V J8: 7-8 J8: 9-10 /DREQ0 Counter 1 /DREQ1 Counter 2 CKA1 C2A C2B+ + C2B C2B U34, RS-485 receiver Figure 3-7. Digital Inputs Used As Counter Inputs The counters count on a negative-going edge.
exact time, within a few microseconds, at which an event occurs by programming the DMA channel to store one byte and then interrupt the count. The interrupt routine can read the most significant part of the PRT counter and any software extension of this counter. In general, the maximum count is 65,536, which can be extended by software to larger counts if the counting speed is not higher than about 10 kHz. The capabilities of the counters are summarized below.
The gain at the plus and minus inputs is 10 when jumper H7 is installed. The gain of the plus input becomes higher (11) when H7 is removed. This has the effect of skewing the output from a nulled bridge circuit to the middle of the measurement range. Such a bridge circuit is shown in Figure 3-9 below. When the bridge is nulled, both inputs are equal to 5 volts. The output voltage of the input amplifier with H7 removed is 5 × (11 - 10) = 5 volts.
If the negative input x2 is tied to ground, the equation becomes y = a1 × (x1 + a0) or, solving for x1, x1 = y - a0 . a1 This equation returns the input voltage, given the output. The function up_higain(1) returns this value (with Jumper H7 removed). If the output of the operational amplifier is out of range (x1 input above 1 volt, y output above 10 volts), the value of a direct measurement of x1 is returned. This is less accurate by a factor equal to the gain ratio.
The gain for a bridge such as +10 V R1 R2 V V0 47 kΩ R11 47 kΩ R5 + 470 kΩ RP5A would be 1 . R5 R5 g = g0 × 1 – + 1+ R2 R1 The change in gain for the input (V V0) is given by the above formula. If R5 is 47 kΩ and R1 and R2 are each 350 Ω, then the gain is reduced by the factor 1 = 0.9962 1− 47,000 47,000 + 1+ 350 350 or about 4 parts in 1000. Relay Outputs The PK2100 has two relays. Each relay (Figure 3-10) is single pole, double throw.
The relay output signals are routed through the U35 high-current driver chip. Digital Outputs The PK2100 has 10 digital outputs (O1O10). Seven of the outputs belong to one high-current driver chip (U26) and three belong to another chip (U35). These outputs can drive inductive loads such as relays, small solenoids, and stepping motors. Outputs O1O7 on U26 use a common bus (K) for the protective diodes.
The diodes on U35 for outputs O8O10 use the PK2100s power supply directly. D.C. in D.C. in Inductive load Digital output channels O8O10 Figure 3-13. Routing PK2100 Power Supply for Digital Outputs O8O10 The drivers used are the Motorola MC1413B or the equivalent Texas Instruments ULN2003. One drives outputs O1O7, and the other drives outputs O8O10, the onboard relays and the beeper. Each driver chip can dissipate a maximum of 1.25 watts when the ambient temperature is 60°C.
lines can also operate at up to 38,400 baud (57,600 with the optional 9.216-MHz clock upgrade). A second RS-232 port can be configured as a substitute for the RS-422/ RS-485 port by changing board jumpers, but it will have no handshaking lines. Pins 3-4 and 5-6 on Header 8 are connected to enable RS-422/ RS-485 communications. Remove these jumpers and connect Pins 1-2 on Header 8 to enable the second RS-232 output. The RS-232 output pin will be TX-, and the input will be RX-. RX+ must be tied to ground.
SYSTEM DEVELOPMENT Chapter 4 describes the programming support for the PK2100.
Programming Z-world supports program development for the PK2100 in a variety of ways. Support for some of these stems from a virtual driver, which monitors the PK2100s ports and provides a set of virtual latches, timers, counters, function keys and two DAC analog outputs. Gate Programming Gate programming is a quick and easy way to program the PK2100s inputs and outputs. The logic elements are summarized in Table 4-1. Table 4-1.
Full C-Language Programming Full C-language programming may access all the features available in Dynamic C and its libraries. Gate programming and costatements use Z-Worlds virtual driver. Full Dynamic C programming, of course, may include any method or combinations of methods. Virtual Driver The virtual driver is a software package activated by a periodic interrupt every 25 milliseconds and provides certain services to the application programmer. The virtual driver provides the following services.
The following preprocessor variables control features of the virtual driver. #define N_WATCHDOG nn Specify the number of virtual watchdog timers. Each virtual watchdog has a counter that has to be reloaded. If the counter for any virtual watchdog counts down to zero, a hardware reset is forced. To reload a virtual watchdog, type up_wdoghit( int watchdog, byte count ) where count is the number of 25-millisecond ticks to countdown.
lcd_printf( long cursor, char *fmt, arg... ) Print on the liquid crystal display screen. The variable cursor determines the position of the cursor before and after the string of characters determined by the format *fmt and the arguments (arg...) is printed according to traditional printf conventions. The cursor variable is a long integer consisting of four bytes, Y1, X1, Y2, X2, where Y1 is in the most significant byte.
Virtual Driver Variables The variables described here are defined in CPLC.LIB. The virtual driver updates the input variables every 25 milliseconds to reflect the state of the hardware inputs and sets the hardware outputs based on the state of its output variables. ! The virtual driver does not change input variables unless the hardware input has the same value for at least two ticks of the virtual driver.
Timers There are 10 virtual timers. Each timer has an input flag, an output flag, and a reload value. T1IN, T2IN ... T10IN // input flags T1O, T2O ... T10O // output flags T1RLD, T2RLD ... T10RLD // reload values When a timer input (for example, T1IN) goes from 0 to 1, the counter starts counting from the reload value (for example, T1RLD) down, one count every virtual driver tick (25 milliseconds). The output flag (T1O) is set to 1 when the count reaches zero.
Downloading Code A program may be downloaded to the PK2100 via a serial or other communications link. A related problem is loading programs to EPROM, RAM, or an external mass storage device for execution. The basic method for downloading starts with writing a monitor program that is burned into EPROM. This monitor program serves as a master controller to load and start execution of the programs and to regain control when the executed program finishes.
For example, to read and write from serial port 0: char ch; ch = inport( RDR0 ); outport( TDR0, ch ); Ports may be polled or interrupt-driven. The interrupt vectors are given in Table D-4, Appendix D. Attainable Baud Rates The serial ports built into the Z180 can generate standard baud rates when the clock frequency is 6.144 MHz or 9.216 MHz or a small multiple, for example, 3.072, 4.608, 6.144, 9.216, or 12.288 MHz. A crystal is stamped with twice the clock frequency.
The serial ports may be polled or interrupt-driven. A polling driver tests the ready flags (TDRE and RDRF) until a ready condition appears (transmitter data register empty or receiver data register full). If an error condition occurs on receive, the routine must clear the error flags and take any appropriate action. If the CTS line is used for flow control, transmission of data is automatically stopped when CTS goes high because the TDRE flag is disabled.
SOFTWARE REFERENCE Chapter 5 presents information on the Dynamic C software drivers and communication software for the PK2100.
Driver Software Drivers in the Dynamic C software library make it easy to communicate with the PK2100 inputs and outputs. Drivers may be direct or indirect. A direct driver immediately reads or writes to the controlled hardware. An indirect driver uses intermediate variables. Z-Worlds virtual driver is a periodically called interrupt service routine that connects the hardware with intermediate variables.
Analog Input The A/D system relies on software calibration, using calibration constants stored in the system EEPROM. Uncalibrated values are in the range 01023, with each count representing approximately 10 millivolts. Calibrated values are kept on a scale 010,000, with each count representing 1 millivolt, or in the case of the single high-gain input, 0.1 millivolt.
int up_adtest( int channel, int testval ) Returns 1 if external voltage is greater than test value expressed as an uncalibrated 01023 value. Use up_uncal routine to compute test value. For example up_adtest(2,up_uncal(2600)) returns 1 if the Channel 2 input is greater than 2.60 volts. int up_uncal( int calval ) Returns uncalibrated value 01023 given calibrated value in millivolts, 010,000.
This relationship is shown in Figure 5-1 for Channel 1. U1HIGH = up_uncal( 8000 ); U1LOW = up_uncal( 7900 ); U1IN = up_adrd (1) > U1LOW; while(1) OUT2=U1IN; // get immediate // value of U1 // output 2 enabled whenever // U1 is greater than 800 mV Note that the thresholds are expressed as raw (uncalibrated) values. This saves computation time in the interrupt routine. Use the routine up_uncal to compute the raw values from the desired calibrated values. OUTPUT 1 0 U1LOW U1HIGH INPUT Figure 5-1.
void up_dac420( int current ) Sends a current value to the DAC output channel. The current is specified such that 1000 = 1 milliamp. The maximum is 20,000 or 20 milliamps. Pins 1-2 on Jumper J7 must be connected for current output. The maximum output is approximately 12 volts. void up_expout ( int rawval ) Sends a raw value to UEXP, the internal D/A converter. Use this function primarily for testing and calibration since, in most cases, UEXP is subject to constant manipulation by interrupt routines.
uint DMASnapShot( byte channel, uint *counter ) This function reads the number of pulses that a DMA channel (0 or 1) has counted. A DMA counter is initialized with one of the two preceding functions. The function returns 0 if a DMA channel is counting too fast to allow for stable reading of the count value. If the function reads a stable count value, it returns 1 and sets the parameter count.
The following routines read and write the clock: int tmc_wr( struct tm *x ); // write the clock int tmc_rd( struct tm *x ); // read the clock The following routines convert the time to and from a long integer. The long-integer format represents the number of seconds that have passed since midnight (00:00:00), January 1, 1980.
void lc_init_timer1( uint count ) Initializes the timer reload register. The term count is expressed as shown below for the 6.144-MHz clock. count Frequency Period 192 1600 Hz 625 µs 384 800 Hz 1.25 ms 6144 50 Hz 20 ms In other words, count = clock speed ¸ (20 × frequency). int lc_kxget( byte mode ) Gets the current entry from the keypad buffer. If mode is 0, the byte pointer is advanced. Otherwise, it remains at the current byte.
void lc_wait() Waits for the LCD to become free (i.e., not busy). EEPROM Read / Write int ee_rd( int address ) Reads EEPROM at specified address and returns result in lower byte. Returns 1 if EEPROM is not functioning. int ee_wr( int address, char data ) Writes character data at address in EEPROM. Returns 1 if EEPROM is not functioning. int eei_rd( int address ) Reads EEPROM integer (2 bytes, least significant byte first) at address specified.
The data are placed in RAM, not ROM, when some form of initialization is not included when the data are declared. The function then will not work. ! It may seem to be contradictory to write to ROM, but this is possible with flash EPROM, where the flash memory is treated as nonvolatile memory. Flash EPROM is rated for 10,000 writes. Z-Worlds experience has been that flash EPROM seems to last for at least 100,000 writes. Nevertheless, there is a limit after which the flash EPROM chip will need replacement.
Support Libraries and Sample Programs Dynamic C provides subdirectories with libraries and software samples. Table 5-1 lists and describes libraries of use to the PK2100 in the LIB subdirectory. Table 5-1. PK2100 Support Libraries Library Description Z0232.LIB RS-232 library for the Z180 port 0. MODEM232.LIB Miscellaneous functions common to the other communication libraries. UART232.LIB RS-232 library for the RS-232 expansion card. NETWORK.
Table 5-2. Sample Programs in SAMPLES\CPLC Program Description 5KEYCODE.C Code-driven sample program for the five-key system. 5KEYDEMO.C Uses a code-driven five-key system and the RTK for I/O monitor and control. 5KEYLAD.C Combines 5KEYCODE.C and LADDERC.C. 5KEYLINK.C Linked-list sample program for the five-key system. 5KEYSCAN.C Combines 5KEYCODE.C and SCANBLK.C. ADCDEMO.C Use keypad to select which ADC channel to monitor. CDEMO_RT.C Demonstrate the use of the real-time kernel. DACDEMO.
Table 5-3 lists and describes sample communication programs in the SAMPLES\NETWORK subdirectory. Table 5-3. Sample Communication Programs in SAMPLES\NETWORK Sample Description RS232.C RS-232 communication with a PC dumb terminal, with or without a modem. Also, master-to-slave communication with another board running RS485.C. RS485.C Slave program to communicate with the master running RS232.C. CZ0REM.C More elaborate sample of RS-232 communication between board and PC dumb terminal.
APPENDIX A: TROUBLESHOOTING Appendix A provides procedures for troubleshooting system hardware and software.
Out of the Box Check the items listed below before starting development. Rechecking may help to solve problems found during development. Verify that the PK2100 runs in stand-alone mode before connecting any expansion boards or I/O devices. Verify that the entire system has good, low-impedance, separate grounds for analog and digital signals. The PK2100 is often connected between the host PC and another device. Any differences in ground potential can cause serious problems that are hard to diagnose.
Dynamic C Will Not Start If Dynamic C will not start, an error message on the Dynamic C screen (for example, Target Not Responding or Communication Error), announces a communication failure: Wrong Baud Rate Either Dynamic Cs baud rate is not set correctly or the PK2100s baud rate is not set correctly. Wrong System Clock Speed in EEPROM The EEPROM contains the system clock speed as a word at location 108H in units of 1200 baud.
Common Programming Errors Values for constants or variables out of range. Table A-1. Ranges of Dynamic C Function Types Type Range int –32,768 (–215) to +32,767 (215 – 1) long int −2,147,483,648 (−231) to +2147483647 (231 – 1) float –6.805646 × 1038 to +6.805646 × 1038 char 0 to 255 Counting up from, or down to, one instead of zero. In the software world, ordinal series often begin or terminate with zero, not one.
APPENDIX B: SPECIFICATIONS Appendix B provides the dimensions and specifications for the PK2100 controller.
Hardware Dimensions menu item field run up down init F2 F3 F4 del add 2.5 setup help 0.2 typ F1 2.02 1.52 4.01 5.5 Figure B-1 illustartes the PK2100s dimensions. 0.31 typ 0.55 0.2 0.75 1.6 C2B– C2B+ Rx+ Rx– Tx+ Tx– GND RS485 / 422 GND D7/C2A D6/C1B D4 D3 D2 D1 GND D5/C1A 0.22 DIGITAL INPUTS U6 U5 U4 U3 U2 U1 GND UNIVERSAL INPUTS +5V +10V ref 7.0 Figure B-1.
Table B-1 presents the specifications for the PK2100 series of controllers. Table B-1. PK2100 Specifications Board Size Enclosure Size Operating Temperature • Controller • LCD Humidity Input Voltage and Current Configurable I/O Digital Inputs Digital Outputs Analog Inputs Analog Outputs Resistance Measurement Input Processor Clock Speed SRAM EPROM Flash EPROM* Counters Serial Ports Serial Rate Watchdog/Supervisor Time/Date Clock Memory Backup Battery Keypad and LCD Display PLCBus Port * 5.5” × 6.
Jumper and Header Specifications Figure B-3 shows the locations of the PK2100 headers and jumpers. H11 1 J7 H7 14 H9 J1 1 J8 1 1 H1 1 2 J3 J9 1 1 1 H5 H6 H4 J4 H8 J11 1 1 2 Figure B-3. Locations of PK2100 Headers and Jumpers The jumper configurations are described in Table B-2, Table B-3, and Table B-4.. Table B-2.
Table B-3. PK2100 Jumper Connections Header Pins J1 1-2 Connect if using 32K RAM or 128K RAM. 2-3 Connect for 256K or 512K RAM. 4-5 Connect if using 32K, 64K, or 128K EPROM. 5-6 Connect for 512K or 256K EPROM or flash EPROM. 7-8 Connect for other than 32K EPROM. 8-9 Connect for 32K EPROM. J3 J8 10, 11 Not connected. 12-13 Connect for 64K, 128K, 256K flash EPROM. 13-14 Connect for 512K (non-flash) EPROM. 1-2 Write-protect EEPROM at addresses 256–511. This is the factory setting.
Table B-4. PK2100 Header Connections Header H5 Pins Description 7-8 Connect to engage 4–20 mA load resistor (430 Ω) from universal input 6 to ground. 1-2 Connect to enable the second RS-232 output (at the expense of RS-485 output). The output pin will be TX–. The RS-232 input will be RX– and RX+ must be tied to ground. H8 3-4, 5-6 Connect 3-4 and 5-6 to enable the termination and bias resistors for RS-485 communications.
Connectors The ideal conductor for a screw clamp terminal is a single, solid conductor. However, bare copper can become oxidized, particularly if it is exposed to air for a long time before installation. The oxide can increase the resistance in the connection by ~20 Ω, especially if the clamping pressure is not sufficient. Use tinned wires or clean, shiny copper wire to avoid this problem.
B-8 s Appendix B: Specifications PK2100
APPENDIX C: POWER MANAGEMENT Appendix C provides detailed information on power systems and sources.
Power Failure Interrupts The following events occur when power fails: 1. The power-failure nonmaskable interrupt (NMI) is triggered when the unregulated D.C. input voltage falls below approximately 15.6 volts, or 7.8 volts for the PK2110/PK2130 (subject to the voltage divider R9/R33). 2. The system reset is triggered when the regulated +5-volt supply falls below 4.5 volts. The reset remains enabled as the voltage falls further. At this point, the chip select for the SRAM is forced high (standby mode).
Do not forget the interaction between the watchdog timer and the powerfailure interrupt. If a brownout causes an extended stay in the powerfailure interrupt routine, the watchdog can time out and cause a system restart. A few milliseconds of computing time remain when the +5-volt supply falls below 4.5 volts, even if power is abruptly cut off from the board. The amount of time depends on the size of the capacitors in the power supply. A standard wall transformer provides about 10 milliseconds.
C-4 s Power Management PK2100
APPENDIX D: I/O MAP AND INTERRUPT VECTORS PK2100 Appendix D: I/O Map and Interrupt Vectors s D-1
I/O Map The internal registers for the input/ouput devices built into to the Z180 processor occupy the first 40 (hex) addresses of the input/output space. Table D-1 lists the addresses of these internal registers. Table D-1.
Table D-1.
Table D-2 and Table D-3 present the I/O addresses that control I/O devices external to the Z180 processor. Table D-2. Write Registers Address Bit(s) Symbol Function 0x80 0 SDA_W EEPROM data, write. 0x81 0 KEYR2 Keypad drive row 2. Open collector, “1” drives low. 0x82 0 ENB485 Enable RS-485 channel. 0x83 0 BEEPH Beeper, high-voltage drive. “1” drives beeper. 0x84 0 SCL EEPROM clock bit. 0x85 0 KEYR3 Keypad drive row 3. Open collector, “1” drives low.
Table D-2. Write Registers (concluded) Address Bit(s) Symbol Function 0x9D 0 DRV5 Digital output 5. “1” drives output. 0x9E 0 DRV6 Digital output 6. “1” drives output. 0x9F 0 DRV7 Digital output 7. “1” drives output. 0xA0 0 UEXPA Additional bit, next to least, internal DAC. 0xA1 0 UEXPB Additional bit, least significant, internal DAC. 0xA2 0 DACA Additional bit, next to least, external DAC. 0xA3 0 DACB Additional bit, least significant, external DAC.
Table D-3. Read Registers Address 0x80 Bits 0-D7 Symbol UINP DREG1 0x81 0-D7 SDA_R Function Bits 0-6 are universal inputs 0–5 and the sensitive input (bit 6). Bit 7 is a user-programmable jumper (J8 pins 11-12) and is low when the jumper is installed. Bit 7 represents signal PR. Bit 0 is EEPROM data bit. Bit 1 is NMI interrupt line (power fail line). Bits 2, 3, 4, 5, 6, and 7 are keypad columns 0, 1, 2, 3, 4, and 5. 0x88 0-D7 DREG2 Bits 0-6 are digital inputs 0-6.
Table D-4. Interrupt Vectors for Z180 Internal Devices Address Name Description 0x00 INT1_VEC Expansion bus attention INT1 vector. 0x02 INT2_VEC INT2 vector, can be jumpered to output of the real-time clock for periodic interrupt.
Interrupt Priorities The interrupt priorities are listed below in descending order. 1. Trap (Illegal Instruction)internal. 2. NMI (nonmaskable interrupt, power failure)external. 3. INT0 (nonmaskable, level 0)external. 4. INT1 (nonmaskable, level 1, expansion bus attention line)external. 5. INT2 (nonmaskable, level 2, T0 output interrupt if jumpered) external. 6. PRT Timer Channel 0internal. 7. PRT Timer Channel 1internal. 8. DMA Channel 0internal. 9. DMA Channel 1internal. 10.
APPENDIX E: EEPROM PK2100 Appendix E: EEPROM s E-1
PK2100/PK2120 24-V Version Calibration Table E-1 presents the calibration constants for the PK2100/PK2120, the standard 24-volt versions. Table E-1. Calibration Constants for PK2100/PK2120 EEPROM Address Definition 0 Startup Mode. If 1, enter program mode. If 8, execute loaded program at startup. 1 Baud rate in units of 1200 baud. 0x100 Unit “serial number.” BCD time and date with the following format: second, minutes, hours, day, month, year. 0x106 Required power voltage.
Table E-1. Calibration Constants for PK2100/PK2120 EEPROM (continued) Address Definition 0x15C For the standard PK2100, this is current in units of 1.0 µA corresponding to voltage output of 2.000V when set for 020 mA output into nominal 392-Ω load resistor. Typically, near 4000. For the 12-volt PK2100, the output range is 015 mA. 0x15E For the standard PK2100, this is current in units of 1.0 µA corresponding to voltage output of 10.000 V when is set for 0-20 mA output into nominal 392-Ω load resistor.
Table E-1. Calibration Constants for PK2100/PK2120 EEPROM (concluded) Address 0x16C Definition Long coefficient relating speed of microprocessor clock relative to speed of real-time clock. Nominal value is 107,374,182, which is 1/40 of a second microprocessor clock time on the scale where 232 is 1.0 s. This requires 4 bytes of EEPROM, stored least byte first.
APPENDIX F: PLCBUS Appendix F provides the pin assignments for the PLCBus, describes the registers, and lists the software drivers.
PLCBus Overview The PLCBus is a general-purpose expansion bus for Z-World controllers. The PLCBus is available on the BL1200, BL1600, BL1700, PK2100, and PK2200 controllers. The BL1000, BL1100, BL1300, BL1400, and BL1500 controllers support the XP8300, XP8400, XP8600, and XP8900 expansion boards using the controllers parallel input/output port. The BL1400 and BL1500 also support the XP8200 and XP8500 expansion boards. The ZB4100s PLCBus supports most expansion boards, except for the XP8700 and the XP8800.
Two independent buses, the LCD bus and the PLCBus, exist on the single connector. The LCD bus consists of the following lines. LCDXpositive-going strobe. /RDXnegative-going strobe for read. /WRXnegative-going strobe for write. A0Xaddress line for LCD register selection. D0X-D7Xbidirectional data lines (shared with expansion bus). The LCD bus is used to connect Z-Worlds OP6000 series interfaces or to drive certain small liquid crystal displays directly.
There are eight registers corresponding to the modes determined by bus lines A1X, A2X, and A3X. The registers are listed in Table F-2. Table F-2.
Place an address on the bus by writing (bytes) to BUSADR0, BUSADR1 and BUSADR2 in succession. Since 4-bit and 8-bit addressing modes must coexist, the lower four bits of the first address byte (written to BUSADR0) identify addressing categories, and distinguish 4-bit and 8-bit modes from each other. There are 16 address categories, as listed in Table F-3. An x indicates that the address bit may be a 1 or a 0. Table F-3.
Z-World provides software drivers that access the PLCBus. To allow access to bus devices in a multiprocessing environment, the expansion register and the address registers are shadowed with memory locations known as shadow registers. The 4-byte shadow registers, which are saved at predefined memory addresses, are as follows.
Digital output devices, such as relay drivers, should be addressed with three 4-bit addresses followed by a 4-bit data write to the control register. The control registers are configured as follows bit 3 A2 bit 2 A1 bit 1 A0 bit 0 D The three address lines determine which output bit is to be written. The output is set as either 1 or 0, according to D. If the device exists on the bus, reading the register drives bit 0 low. Otherwise bit 0 is a 1.
There are 4-bit and 8-bit drivers. The 4-bit drivers employ the following calls. void eioResetPlcBus() Resets all expansion boards on the PLCBus. When using this call, make sure there is sufficient delay between this call and the first access to an expansion board. LIBRARY: EZIOPLC.LIB, EZIOPLC2.LIB, EZIOMGPL.LIB. void eioPlcAdr12( unsigned addr ) Specifies the address to be written to the PLCBus using cycles BUSADR0, BUSADR1, and BUSADR2.
void set4adr( int adr ) Sets the current address for the PLCBus. All read and write operations access this address until a new address is set. A 12-bit address may be passed to this function, but only the last four bits will be set. Call this function only if the first eight bits of the address are the same as the address in the previous call to set12adr. PARAMETER: adr contains the last four bits (bits 811) of the physical address. LIBRARY: DRIVERS.LIB.
char read4data( int adr ) Sets the last four bits of the current PLCBus address using adr bits 8 11, then reads four bits of data from the bus with BUSADR0 cycle. PARAMETER: adr bits 811 specifies the address to read. RETURN VALUE: PLCBus data in the lower four bits; the upper bits are undefined. LIBRARY: DRIVERS.LIB. void _eioWriteWR( char ch) Writes information to the PLCBus during the BUSWR cycle. PARAMETER: ch is the character to be written to the PLCBus. LIBRARY: EZIOPLC.LIB, EZIOPLC2.
void set8adr( long address ) Sets the current address on the PLCBus. All read and write operations will access this address until a new address is set. PARAMETER: address contains the last eight bits of the physical address in bits 1623. A 24-bit address may be passed to this function, but only the last eight bits will be set. Call this function only if the first 16 bits of the address are the same as the address in the previous call to set24adr. LIBRARY: DRIVERS.LIB.
F-12 s Appendix F: PLCBus PK2100
APPENDIX G: BATTERY Appendix G provides information about the onboard lithium battery.
Storage Conditions and Shelf Life The battery on the PK2100 will provide approximately 9,000 hours of backup for the real-time clock and static RAM as long as proper storage procedures are followed. Boards should be kept sealed in the factory packaging at room temperature until field installation. The board should not be exposed to extremes of temperature, humidity or contaminants.
Battery Cautions Caution (English) There is a danger of explosion if battery is incorrectly replaced. Replace only with the same or equivalent type recommended by the manufacturer. Dispose of used batteries according to the manufacturers instructions. Warnung (German) Explosionsgefahr durch falsches Einsetzen oder Behandein der Batterie. Nur durch gleichen Typ oder vom Hersteller empfohlenen Ersatztyp ersetzen. Entsorgung der gebrauchten Batterien gemäb den Anweisungen des Herstellers.
G-4 s Appendix G: Battery PK2100
PK2100 LE JP3 H11 J7 U26 U12 HC Driver U23 U11 REL2 U35 HC Driver U31 Latch LC U27 Op-Amps Latch REL1 H7 Relay Relay H9 U40/ U20 H1 Reg.
This page is intentionally blank.
INDEX Symbols #define ........................... 4-3, 4-4 #INT_VEC ................................ D-6 #JUMP_VEC ..................... C-2, D-7 /AT ............................................ F-3 /CTS0 ....................................... 4-8 /RDX ......................................... F-2 /STBX ....................................... F-3 /WRX ......................................... F-3 = (assignment) ......................... A-4 _DMAFLAG0 ............................... 5-6 _DMAFLAG1 .........
block diagram dimensions ............................ B-2 PK2100 ........................ 3-3, B-2 board jumpers ......... 2-2, 3-4, 3-14 bridge ........... 3-8, 3-9, 3-10, 3-11 resistance .............................. 3-4 brownout .......................... C-2, C-3 buffer receive ................................. 5-11 transmit ............................... 5-11 built-in beeper ................................. 3-12 relays ................................... 3-12 bus control registers ..................
constants calibration ............. 3-9, 5-3, 5-6 contact protection ..................... 3-4 contacts closures detecting ........................... 3-6 multiple ................................. 3-6 protection .............................. 3-4 relay ............................ 3-11, 5-2 control registers ........................ F-6 conversion calibrated and uncalibrated values ........................ 5-3, 5-5 count negative-going edges ............ 3-8 counter DMA ....................................
drivers calibrated .............................. 5-3 direct ..................... 5-2, 5-3, 5-5 expansion bus ....................... F-6 4-bit................................... F-7 8-bit................................... F-7 high-current ........................ 3-12 high-level .............................. 5-2 high-voltage .......................... 4-3 indirect .................................. 5-2 low-level ....................... 5-2, 5-3 relay ...................................... F-6 virtual ..
high-gain input ................. 5-3, 5-4 high-level drivers ...................... 5-2 high-sensitivity analog input ... 3-8 high-speed counters ................................ 3-6 DMA counter ................ 5-6, 5-7 high-voltage drivers .................. 4-3 hooking up the PK2100 ............ 2-3 how to write to flash EPROM 5-10 hysteresis . 3-3, 3-4, 4-6, 5-2, 5-4 I I/O devices ................................. D-2 interfaces ....................... 3-2, 5-2 map ....................................
jumpers J1 ........................................... B-5 J3 ........................................... B-5 J7 ........................ 3-13, 5-5, B-4 J8 ........................................... B-5 J9 ........................................... B-5 J11 ................................ 4-7, B-5 program-readable ......... 2-2, B-6 K K ............................................. 3-13 K terminal ............................... 3-13 kernel real-time ................ 4-3, 4-4, 5-8 keypad .....
N N_WATCHDOG ............................ 4-4 NETWORK.LIB ........................ 5-12 nickel-cadmium battery ............ 1-3 NMI ............... 1-3, C-2, C-3, D-8 NMI_VEC ......................... C-2, D-7 NOLCD ....................................... 4-3 nonlinearity DAC ...................................... 5-3 nonmaskable interrupts .... 1-3, C-2, C-3, D-8 NOTIMERS ................................. 4-3 NOUNIVERSAL .......................... 4-3 O O1O7 ....................................
programming Full C .................................... 4-3 gate ...................... 4-2, 4-3, 5-12 programs downloading ......................... 4-2 uploading .............................. 4-2 protective diodes ..................... 3-12 PRT ........................................... 3-7 Timer Channel 0 .................. D-8 PRT0DEMO.C .......................... 5-12 pulse measurement ................... 3-8 pulse width measurement ......... 3-3 R RAM battery-backed .....
Serial Channel 1 ....................... 4-9 serial communication ....... 1-2, 1-4, 2-2, 2-3, 3-2, 3-4, 4-2, 4-8, 4-9, 4-10, 5-10 serial interrupt ............................... D-8 output ............................ 3-2, 3-4 serial ports ...... 1-4, 4-7, 4-8, 4-10 asynchronous ....................... 4-9 baud rate ............................... 4-9 interrupt-driven ..................... 4-9 low-level utility functions .... 4-8 multiprocessor communications feature ...............................
U V U1HIGH ..................................... 5-5 U1HIGH, U2HIGH, ... U5HIGH, U6HIGH ............ 4-6 U1IN ................................. 5-4, 5-5 U1IN, U2IN, ... U5IN, U6IN virtual driver .... 3-4, 4-2, 4-3, 4-4, 4-5, 4-6, 4-7, 5-2, 5-4, 5-6, 5-9 function library ............. 4-4, 4-6 invoking ........................ 4-3, 4-4 sample programs ................... 4-4 services ......................... 4-3, 4-4 variables ................................ 4-4 virtual timer ......................
Z-World 2900 Spafford Street Davis, California 95616-6800, U.S.A. Telephone: Facsimile: 24-Hour FaxBack: Web Site: E-Mail: (530) 757-3737 (530) 753-5141 (530) 753-0618 http://www.z w orld.c om zworld@zw orld.com Part No. 019-0024-02 Revision 2.0 Printed in U.S.A.
This page is intentionally blank.