Background and Use of the Book

 

This project was completed during the search for an answer to the following question: How could one design and implement a programmable logic controller (PLC)? The answer to this question was partially discovered about 15 years ago by the author in a freely available PLC project called PICBIT. The file, called picbit. inc of PICBIT, contains the basic PLC macro definitions. The PIC16F648A-based PLC project has been completed by the inspiration of these macros Of course many new features have been included within the PIC16F648A-based PLC project to make it an almost perfect PLC The reader should be aware that this project does not include graphical interface PC software as in PICBIT or in other PLCs for developing PLC programs. Rather, PLC programs are developed by using macros as done in the Instruction List (IL) PLC programming language An interested and skilled reader could well (and is encouraged to) develop graphical interface PC software for easy use of the PIC16F648A-based PLC.

The PIC16F648A-based PLC project was first reported in a series of 22 articles published in Electronics World magazine (http://www.electronicsworld.co.uk/) between the years 2008 and 2010 [1-22]. All details of this project can be viewed at http//www.meliksah.edu.tr/muzam/UZAM_PLC_with_PIC16F648A.htm [23]. This book is based on an improved version of the project reported in Electronics World magazine. The improvements are summarized as follows:

  1. The current hardware has two boards: the CPU board and the I/O extension board In the previous version of the hardware, the main board consisted of the CPU board and eight inputs/eight outputs, while in the current version, the CPU board excludes eight inputs/ eight outputs Thus, the CPU board is smaller than the previous main board In addition, the current I/O extension board is also smaller than in the previous version

  2. The hardware explained in this book consists of one CPU board and two I/O extension boards Therefore, the current version of the software supports 16 inputs and 16 outputs, while the previous one supported 8 inputs and 8 outputs

  3. Clock frequency was 4 MHz in the previous version, but is 20 MHz in the current version

  4. Some of the macros are improved compared with the previous versions.

  5. Flowcharts are provided to help the understanding of all macros (functions)

In order to properly follow the topics explained in this book, it is expected that the reader will construct his or her PIC16F648A-based PLC consisting of the CPU board and two I/O extension boards using the PCB files provided within the CD-ROM attached to this book In this book, as the PIC assembly is used as the programming language within the MPLAB integrated development environment (IDE), the reader is referred to the homepage of Microchip (http://www.microchip.com/) to obtain the latest version of MPLAB IDE. References [24] and [25] may be useful to understand some aspects of the PIC16F648A microcontroller and MPASMâ„¢ assembler, respectively

The contents of the book's 15 chapters are explained briefly, as follows:

  1. Hardware: In this chapter, the hardware structure of the PIC16F648A-based PLC, consisting of 16 discrete inputs and 16 discrete outputs, is explained in detail

  2. Basic software: This chapter explains the basic software structure of the PIC16F648A-based PLC A PLC scan cycle includes the following: obtain the inputs, run the user program, and update the outputs. In addition, it is also necessary to define and initialize all variables used within a PLC. Necessary functions are all described as PIC assembly macros to be used in the PIC16F648A-based PLC The macros described in this chapter can be summarized as follows: HC16 5 (for handling the inputs), HC5 95 (for sending the outputs), dbncr0 and dbncr1 (for debouncing 16 inputs), initialize, get_inputs, and send_outputs.

  3. Contact and relay-based macros: The following contact and relay-based macros are described in this chapter: ld (load), ld_not (load_ not), not, or, or_not, nor, and, and_not, nand, xor, xor_not, xnor, out, out_not, in_out, inv_out, _set, _reset. These macros are defined to operate on 1-bit (Boolean) variables.

  4. Flip-flop macros: The following flip-flop-based macros are described in this chapter: r_edge (rising edge), f_edge (falling edge), latch0, latch1, dff_r (rising edge triggered D flip-flop), dff_f (falling edge triggered D flip-flop), tff_r (rising edge triggered T flip-flop), tff_f (falling edge triggered T flip-flop), j kff_r (rising edge triggered JK flip-flop), and j kff_f (falling edge triggered JK flip-flop).

  5. Timer macros: The following timer macros are described in this chapter: TON_8 (8-bit on-delay timer), TOF_8 (8-bit off-delay timer), TP_8 (8-bit pulse timer), and TOS_8 (8-bit oscillator timer).

  6. Counter macros: The following counter macros are described in this chapter: CTU_8 (8-bit up counter), CTD_8 (8-bit down counter), and CTUD_8 (8-bit up/down counter).

  7. Comparison macros: The comparison macros are described in this chapter The contents of two registers (R1 and R2) are compared according to the following: GT (greater than, >), GE (greater than or equal to, >), EQ (equal to, =), LT (less than, <), LE (less than or equal to, <), and NE (not equal to, *). Similar comparison macros are also described for comparing the contents of an 8-bit register (R) with an 8-bit constant (K).

  8. Arithmetical macros: The arithmetical macros are described in this chapter The following operators are applied to the contents of two registers (R1 and R2): ADD, SUB (subtract), INC (increment), and DEC (decrement). Similar arithmetical macros are also described, to be used with the contents of an 8-bit register (R) and an 8-bit constant (K)

  9. Logical macros: The following logical macros are described in this chapter: inv_R, AND, NAND, OR, NOR, XOR, and XNOR. These macros are applied to an 8-bit register (R1) with another register (R2) or an 8-bit constant (K)

  10. Shift and rotate macros: The following shift and rotate macros are described in this chapter: SHIFT_R (shift right the content of register R), SHIFT_L (shift left the content of register R), ROTATE_R (rotate right the content of register R), ROTATE_L (rotate left the content of register R), and SWAP (swap the nibbles of a register).

  11. Multiplexer macros: The following multiplexer macros are described in this chapter: mux_2_1 (2x1 MUX), mux_2_1_E (2x1 MUX with enable input), mux_4_1 (4x1 MUX), mux_4_1_E (4x1 MUX with enable input), mux_8_1 (8x1 MUX), and mux_8_1_E (8x1 MUX with enable input).

  12. Demultiplexer macros: The following demultiplexer macros are described in this chapter: Dmux_1_2 (1x2 DMUX), Dmux_1_2_E (1x2 DMUX with enable input), Dmux_1_4 (1x4 DMUX), Dmux_1_4_E (1x4 DMUX with enable input), Dmux_1_8 (1x8 DMUX), and Dmux_1_8_E (1x8 DMUX with enable input).

  13. Decoder macros: The following decoder macros are described in this chapter: decod_1_2 (1x2 decoder), decod_1_2_AL (1x2 decoder with active low outputs), decod_1_2_E (1x2 decoder with enable input), decod_1_2_E_AL (1x2 decoder with enable input and active low outputs), decod_2_4 (2x4 decoder), decod_2_4_ AL (2x4 decoder with active low outputs), decod_2_4_E (2x4 decoder with enable input), decod_2_4_E_AL (2x4 decoder with enable input and active low outputs), decod_3_8 (3x8 decoder), decod_3_8_AL (3x8 decoder with active low outputs), decod_3_8_E (3x8 decoder with enable input), and decod_3_8_E_AL (3x8 decoder with enable input and active low outputs)

  14. Priority encoder macros: The following priority encoder macros are described in this chapter: encod_4_2_p (4x2 priority encoder), encod_4_2_p_E (4x2 priority encoder with enable input), encod_8_3_p (8x3 priority encoder), encod_8_3_p_E (8x3 priority encoder with enable input), encod_dec_bcd_p (decimal to binary coded decimal [BCD] priority encoder), and encod_dec_bcd_p_E (decimal to BCD priority encoder with enable input)

  15. Application example: This chapter describes an example remotely controlled model gate system and makes use of the PIC16F648A-based PLC to control it for different control scenarios

Table 1 shows the general characteristics of the PIC16F648A-based PLC.

TABLE 1
General Characteristics of the PIC16F648A-Based PLC

Images

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
18.219.22.107