Application Design:Hardware Design

Hardware Design

The hardware is typically designed before the software, although it may need to be revisited subsequently. It is possible that the initial choice of MCU may need to be changed when the overall design requirements have been finalized.

Block Diagram

In the block diagram, the system inputs and outputs can be identified, and a provisional arrangement of subsystems worked out. The blocks and their connections should be labeled, indicating their function. The direction and type of information flow between the blocks should be described using arrows. Inset diagrams can be used to illustrate the waveform of analogue signals. Parallel data paths will be shown as block arrows, or with suitable signal labeling. The block diagram for MOT1 is seen in Figure 8.2.

The block diagram can be readily created using the drawing tools in Microsoft® Word or a general purpose drawing package, since it needs only basic shapes, arrows and text boxes. In Word, the drawing toolbar may need to be selected via the main menu, ‘View, Toolbars, Drawing’. The drawing can be embedded in a text file, but beware of interaction of drawing objects with the text cursor, which can disrupt the drawing. It is usually a good idea to move the text cursor below the drawing area. A drawing grid can be switched on to help line up the main drawing objects; from the ‘Draw’ menu, select ‘Grid’ and check the ‘Snap to grid’ option. To make fine adjustments to drawing objects, the grid can later be switched off. It may be found that drawing directly onto the text page by switching off the default option of inserting a drawing canvas is more convenient (Tools, Options, General).

The main elements can be drawn using text boxes, and the same object used for labeling with the ‘No line’ and ‘No fill’ options selected. Various line and arrow styles are available, and the ‘Freeform’ line style in the ‘Autoshapes’ menu is useful for multi-segment lines. This menu also provides various standard shapes for block diagrams and flowcharts. When the drawing is

PIC Microcontrollers-1231

finished, select all the drawing elements by looping with the ‘Select objects’ tool and select ‘Draw, group’. This will create a single drawing object, which will no longer be affected by the text cursor, and allows the whole drawing to be repositioned on the page if necessary.

Hardware Implementation

Unless the program is being written for an existing hardware system, the general hardware configuration must be worked out as part of the design exercise. The nature and complexity of the software are important considerations in the selection of a microprocessor or microcontroller, as are the number and type of inputs and outputs, data storage and interfacing.

Various types of control system could be applied here, some of which are described in more detail in Chapter 14. The requirement is for minimal complexity with no special interfacing. A purely hardware solution could be based around the 555 timer, a standard pulse generator chip whose output is controlled by external CR (analogue) networks. However, this would not provide the push-button (digital) continuously variable output required. The microcontroller also provides a more flexible solution, in that the software is easily reconfigured.

A circuit derived from the block diagram is shown in Figure 8.3. The input control uses simple active low push buttons, with the additional feature of connections for remote system control. The motor is controlled by an FET, which acts as a current switch operated by the PIC digital output. An FET is selected whose input gate operates at TTL levels (0 Vor þ5 V with respect to the source terminal), so that it can be connected directly to the PIC output, and can handle the motor current anticipated (about 500 mA for a small motor). The motor forms an inductive

PIC Microcontrollers-1232

PIC Microcontrollers-1233

load, so a diode is connected to protect the FET from the back electromotive force (emf) normally generated by the motor. Additional decoupling is applied across the supplies to prevent the motor switching transients from disrupting the PIC supply.

The microcontroller only needs four input/output (I/O) pins, so a 12XXX series device with six I/O could be considered. However, an external reset is required, so our basic device 16F84A will be used, at least for simulation purposes. The controller I/O allocation can then be specified as shown in Table 8.2.

The PIC thus provides motor speed control with a PWM output at RA0. The !RUN (‘Not Run’, active low) input has been allocated to RA4. This will be programmed to enable the PWM output to run the motor when low. When RA2 (!UP) is low, the MSR at RB0 should increase, and the motor speed up. When RA3 (!DOWN) is low, the MSR should be reduced, slowing the motor down. !MCLR (Master Clear) is the reset input to the PIC, which will restart the program when pulsed low, and hence reset the speed to the default value of 50% MSR.

Leave a comment

Your email address will not be published. Required fields are marked *