Technological Studies Systems and Control Teacher/Lecturer Notes and Solutions to Assignments Higher 4559 Spring 1999 HIGHER STILL DET: Technological Studies Systems and Control Teacher/Lecturer Notes and Solutions to Assignments Higher Support Materials q rs TECHNOLOGICAL STUDIES HIGHER SYSTEMS AND CONTROL TEACHER/LECTURER NOTES AND SOLUTIONS TO ASSIGNMENTS INTRODUCTION Technological Studies: Systems and Control Teachers Notes (H) Introduction 1 Technological Studies: Systems and Control Teachers Notes (H) Introduction 2 The 'Systems and Control' teaching materials are split into four Outcomes. The performance criteria for each Outcome is covered within the whole unit. Due to the large size of Outcomes 3 and 4 the outcomes have been sub-divided into smaller sections. Outcome 1 - Control Systems The purpose of this unit is to introduce the operation of control systems. When students have completed this unit they should be able to: • recognise and identify common control systems • describe the operation of open and closed loop control systems • make use of systems diagrams and systems technology. Outcome 2 - Analogue Control Systems The purpose of this unit is to introduce the operation of analogue control systems. When students have completed this unit they should be able to: • correctly identify common applications of analogue control • represent analogue control systems using control diagrams and circuit diagrams • select the appropriate configuration of op-amp in the design of analogue closed loop control systems • select appropriate output drive subsystems for control applications. Technological Studies: Systems and Control Teachers Notes (H) Introduction 3 Outcome 3 - Microcontroller Controlled Mechatronic Systems Section 1 - Introduction The purpose of this section is to introduce the microcontroller and it's architecture. When students have completed this unit they should be able to: • describe the operation and architecture of microcontrollers • understand the terms ALU, RAM, ROM, EEPROM, bus • understand how the Basic Stamp system operates. Section 2 - Number Systems The purpose of this section is to introduce the main number systems used within programmable systems for the processing of information. When students have completed this unit they should be able to: • Use the following terms correctly: decimal, binary, hexadecimal. • Describe contexts when it is appropriate to use the three different number systems. • Convert between decimal, binary and hexadecimal number systems. Section 3 - Simple Control Routines The purpose of this section is to introduce the PBASIC commands used in developing control program listings. When students have completed this unit they should be able to: • understand the use of flowcharts • develop flowcharts from a brief • understand the most common PBASIC commands • write PBASIC programs that involve loops, if statements and sub-procedures. Section 4 - Mechatronic System Interfacing Circuits The purpose of this section is to understand the need for interfacing input and output devices when building mechatronic systems that are controlled by a microcontroller. When students have completed this unit they should be able to: • explain why interfacing circuits are required within mechatronic systems • select appropriate interfacing techniques for common output devices • understand the different operation of common switch types • understand how unipolar stepper motors are controlled • understand the need for D-A conversion • understand how push-pull drivers are used to control dc motors • understand pulse-width modulated control of dc motors • understand the term 'soft-start' when applied to dc motors • write PBASIC programs to control stepper motors • write PBASIC programs to control the speed and direction of dc motors. Technological Studies: Systems and Control Teachers Notes (H) Introduction 4 Outcome 4 - Microcontroller Controlled Monitoring Systems Section 1 - Analogue to Digital Conversion The purpose of this section is to introduce the application of A-D converters. The section explains the function and operation of A-D converters in the context of a programmable system. When students have completed this unit they should be able to: • understand the need for A-D conversion • understand the use of an A-D converter with a microcontroller • understand the term multiplexing and appreciate the reasons for it • understand the term signal conditioning • write PBASIC programs that include ADC routines. Section 2 - Data-Logging The purpose of this section is to introduce the concept of data-logging. The section also involves the use of a host computer for analysing data recorded with a spreadsheet application. When students have completed this unit they should be able to: • understand the term data-logging • understand the term sampling frequency • appreciate the use of data-logging in a practical application • understand how data can be analysed with a spread-sheet applications • write PBASIC programs to control data-logging experiments. Technological Studies: Systems and Control Teachers Notes (H) Introduction 5 Assignments and Activities Written Assignments Each Outcome involves a number of written assignments. The first assignments in each section are simpler questions which cover important teaching points, and the latter assignments build up to examination style questions. It is therefore important that students complete all the assignments. Practical Assignments Practical assignments involve the use of electronic circuits (discrete components or modular systems such as EET Connect or Alpha) or microcontroller circuits (using the modular Basic Stamp and MFA boards). Many of the microcontroller circuits also involve interfacing to three dimensional models. Students are expected to complete all practical assignments. Practical Activities Practical activities differ slightly from practical assignments in that there is no assessment requirement for the activity. Practical activities are mainly used as 'tutorials' in Outcomes 3 and 4 to demonstrate different software techniques. It is expected that the student should complete each activity. Students should not be allowed to simply open and download 'pre-saved' files when completing activities. It is through the process of keying in the program that an understanding of the program operation will be gained. Each activity program is kept deliberately short so that this keying in time is not too great. Technological Studies: Systems and Control Teachers Notes (H) Introduction 6 General notes on using the Basic Stamp Hardware • The Stamp controller has 8 input/output pins. Each pin can be configured as an input or output. There are no separate input or output ports. • The Stamp Controller provides digital (logic-level) outputs. To drive high current loads such as motors and interfacing circuit (e.g. the Outputs Driver module) must be used. • The Basic Stamp modules are coloured red. All red boards can be directly connected together. MFA modules are coloured blue. MFA input modules can be directly connected to the Stamp Controller. However most MFA output modules must be connected to the Stamp Controller via the small red adapter, which maps pins 4-7 from the Stamp Controller to pins 0-3 on the MFA module. Software • The student assignments do not explain how to perform software features such as saving programs, downloading, editing etc. This is because these techniques vary according to the computer platform being used. It will therefore be necessary to teach the students how to achieve these functions for your computer platform. These functions are fully explained in the photocopiable prompt sheets provided with the software. • Students are expected to add comments, and correctly use 'white-space', within each of their PBASIC programs. • PBASIC programs use labels (rather than line numbers) for addressing purposes. • The 'Serial ADC' and 'Datalogging' modules use standard sub-procedures, which are provided in the file ‘template.bas’. Students do not need to learn these subprocedures, as they will always be provided with them if required. However they must understand what task the sub-procedures achieve, and must know how to link these sub-procedures into their PBASIC programs. • Schools may distribute the Basic Stamp software to students for home use. There is no charge for the software when distributed in this manner. Technological Studies: Systems and Control Teachers Notes (H) Introduction 7 BASIC Stamp Equipment List Stamp modules required: • BAS-110 Stamp Controller (with output adapter) • BAS-115 Datalogger Module • BAS-117 Serial A to D Converter • BAS-118 Serial LCD Module • BAS-119 Output Driver • BAS-120 Serial Printer Module MFA modules also required: • D540-312 MFA Sensor Module (with digital sensors) • D540-314 MFA Stepper Motor and Driver • D540-306 MFA Power D to A Converter • D540-313 MFA Analogue Multiplexer • D540-341 MFA Analogue Light Probe • D540-340 MFA Analogue Temperature Probe The following MFA modules are NOT required, but may optionally be used if you already possess them: • D540-303 MFA 8-Switch Input • D540-005 MFA Movement Module • D540-342 MFA Analogue Rotary Sensor • D540-325 MFA Pneumatics Interface • D540-310 MFA 4-Relay Unit • D540-308 MFA 2-Digit Display • D540-323 MFA 8-Bit Driver • D540-304 MFA 8-LED Output MFA Modules are produced & distributed by: Unilab, Lynn Lane, Shenstone, Lichfield, Staffordshire, WS14 0EE Tel: (01543) 483064 Fax: (01543) 483056 All other modules are produced by Revolution Education and distributed by: Teaching Resources, Middlesex University, Trent Park, Bramley Road, London, N14 4YZ Tel: (0181) 447 0342 Fax: (0181) 447 0340 Technological Studies: Systems and Control Teachers Notes (H) Introduction 8 Control Assignment Models A very important aspect of Outcome 3 is the control of 'real' mechatronic systems. It is therefore expected that students have access to three dimensional models for control exercises. These models may be fabricated from constructional sets (such as Lego or Fishertechnic) or from discrete materials. Many schools will already possess a number of these types of model. The apparatus listed below provides brief outlines as to how sample models may be constructed and interfaced to the Stamp Controller. Buggy Apparatus This piece of apparatus is a simple buggy that can be used to demonstrate simple programming techniques. Many schools will already possess 'Lego' buggies which are ideal. If building a new buggy Middlesex Teaching Resources stock a low-cost wormdrive gearbox which is very useful (order code TG1-010, wheels CW3-027) This apparatus should consist of a small buggy with two motors driving a wheel on each side. Two microswitches should be mounted to the front of the buggy to act as 'collision bumpers'. Input Connection switch 1 switch 0 Pin 7 6 5 4 3 2 1 0 Output Connection motor B reverse motor B forwards motor A reverse motor A forwards The motors can be controlled from the Output Driver Module or the MFA Movement Module. The microswitches can be directly wired to the screw terminals on the Stamp Controller as explained in the student text. Technological Studies: Systems and Control Teachers Notes (H) Introduction 9 Washing Machine Apparatus This piece of apparatus should represent a washing machine. Many schools will already possess 'Lego' models. Input Connection door microswitch start switch Pin 7 6 5 4 3 2 1 0 Output Connection motor reverse motor forward The motor can be controlled from the Output Driver Module or the MFA Movement Module. The microswitches can be directly wired to the screw terminals on the Stamp Controller as explained in the student text. Lock Apparatus This piece of apparatus should be designed to simulate a simple time-lock. Three input switches are required. The MFA Switch board could be used directly, or three simple push switches could be mounted on a piece of strip-board. Input Connection switch 3 switch 2 switch 1 Pin 7 6 5 4 3 2 1 0 Output Connection solenoid buzzer green LED red LED A 6V solenoid (e.g. Rapid 60-3205) and 6V buzzer (e.g. Rapid 35-0100) can be driven directly from the Output Driver Module, or could be built more permanently on a piece of strip-board. Technological Studies: Systems and Control Teachers Notes (H) Introduction 10 Light Seeker Apparatus This piece of apparatus uses two LDR sensors to detect light level, and a stepper motor to turn the sensors towards the brightest light. Therefore the LDRs should be mounted on a piece of board that is secured on to the stepper motor spindle. Naturally the LDRs need to be at 90 degrees to the spindle, and separated with a piece of card, so that when a light is shone from the side one LDR receives more light than the other. The LDRs are used as digital sensors in this application, and so should be arranged in a potential divider arrangement (with a 100K potentiometer for calibration purposes). Input Connection LDR 2 LDR 1 Pin 7 6 5 4 3 2 1 0 Output Connection stepper coil stepper coil stepper coil stepper coil The LDRs can be connected to the MFA sensor module, or wired directly to the Stamp Controller screw terminals. The stepper motor should be connected directly to the Output Driver Module. Conveyer Belt and/or Lift Apparatus This piece of apparatus should consist of a conveyer belt, which has a microswitch sensor at each end. The apparatus can be configured vertically to represent a lift, or horizontally to represent a conveyer belt. Input Connection switch 2 switch 1 Pin 7 6 5 4 3 2 1 0 Output Connection Motor reverse Motor forward The motor can be controlled from the Output Driver Module or the MFA Movement Module. The microswitches can be directly wired to the screw terminals on the Stamp Controller as explained in the student text. Technological Studies: Systems and Control Teachers Notes (H) Introduction 11 Other Physical Resources Outcome 1 and 2 involve building electronic circuits using op-amps. These can be built using discrete components, or via a modular system such as E&L 'EET Connect' or Unilab 'Alpha'. Due to the physical feedback signals required in these control circuits the circuits cannot be fully simulated using software such as 'Crocodile Clips'. For Outcome 2 a disassembled radio-control style servo is useful for demonstration purposes. This can be reclaimed from a broken radio-controlled toy, or purchased new from a model shop. For assignment 4.14 in Outcome 3 a small DC motor is required to demonstrate PWM control. It is strongly recommended that a solar motor (e.g. Middlesex Teaching Resources EW2-011 or JPR 450-030) is used, as this can be run at much slower speeds than standard 'toy' DC motors. A propeller mounted on the shaft makes the movement much more visible. Technological Studies: Systems and Control Teachers Notes (H) Introduction 12 Software and Minimum Computer Specifications: The Stamp Controller is programmed via a computer. Five versions of the Stamp software are available for different computer platforms / operating system combinations. The following information provides the minimum system requirements to run each version of the software. PC - DOS stamp.exe 8086 or 286 processor, DOS 2.0, printer port PC - 16 Bit Windows winstamp.exe 386, 4MB, Windows 3.x, serial port PC - 32 Bit Windows winstamp32.exe 486, 8MB, Windows 9x or NT 3.51, serial port Note that the DOS application stamp.exe will run on very old PCs including those that are often considered 'obsolete' as they do not run 'Windows'. Many departments have gathered these 'old' computers for dedicated Stamp use. The Windows applications are fully compatible with all network types. Acorn !AStamp RISC-OS 3.0, 1MB, mouse, serial port Note that some older Archimedes machines (e.g. A3000) may require an operating system upgrade and/or serial port upgrade. Chips required for serial port upgrade 65C51 (28 pin) and LT1133 (24 pin). These chips are available from Farnell Electronics. The DOS software (stamp.exe) does NOT operate via the Archimedes PC Emulator !PCEm. Mac stampx.exe 68020, 4MB, System 6.0, SoftPC stampx.exe PowerMac, 16MB, System 7.1, RealPC winstamp.exe PowerMac, 16MB, System 7.1, SoftWindows 3.0 winstamp32.exe PowerMac, 16MB, System 7.1, SoftWindows 95 There is no 'native' Mac version of the software so one of the following PC emulators is required - SoftPC, RealPC, SoftWindows 3.0 or 9x. The emulator 'Virtual PC' cannot be used. Note that if you are using SoftPC or RealPC you must use the special DOS application stampx.exe (supplied on the DOS disk in \mac,) so that downloading is mapped to the Mac modem port rather than the PC printer port. Due to the relatively high purchase cost of the PC emulator software some schools have collected old '286/386' PCs for dedicated Stamp use. This may be a cheaper alternative as second hand computers are available at very low cost as they are now often considered obsolete as they do not run 'Windows'. Upgrading Computer Systems The same Stamp Controller module is used for all computer platforms. The same programming 'language' syntax is also used for all systems. Therefore changing computer systems at a later date simply involves buying new cables (if required) and obtaining the alternative software. This software can be downloaded free of charge via the Internet or can be provided on disk. Technological Studies: Systems and Control Teachers Notes (H) Introduction 13 Stamp Controller Power Supply The Stamp Controller has two power supply options: 2.1mm DC Power Socket This socket is the preferred power option, and is used with the industry standard 2.1mm (tip positive) style DC power plug. This style of plug is supplied with most 'wall-plug' style DC battery eliminators. A 2.1mm to 4mm 'banana' plug power (order code CAB-030) lead is also available for those wishing to use traditional bench-top power supplies. The power supply must be capable of supplying regulated 7.5 - 9V DC at 300mA. The Stamp Controller is protected against reverse polarity and short-circuits conditions when this type of power supply is used. MFA Power Header. This header is provided for users who wish to use traditional MFA battery connectors from 6V lantern batteries or Unilab Beaver DC power supplies. The power supplied via this connection must not exceed 6V. Exceeding this value could permanently damage the integrated circuits on the board. Note that the MFA power socket is 'disabled' by the 2.1mm socket, ensuring that no damage occurs if two power supplies are accidentally connected simultaneously. Important Note - 'Flat' 6V Lantern Batteries. The Stamp Controller operates (runs programs from memory) down to 3V, but DOES NOT download correctly at voltages less than approx. 4.5V. This characteristic is particularly noticeable when using the DOS software via a PC printer port cable. Therefore if you are receiving repeat download errors, but the module otherwise appears to 'run' programs correctly, the most common problem is a flat battery. Test with a new battery before reporting a fault. Technological Studies: Systems and Control Teachers Notes (H) Introduction 14 Customising the Stamp Controller The Stamp Controller is an extremely versatile board, and can be configured in a number of ways. It has been designed to allow for future modifications and 'upgrades' for other courses, and so contains a number of 'unpopulated' pcb holes for additional components. The following suggestions of how the board can be customised may be useful: Perspex Cover A pre-drilled clear perspex cover that mounts above the components on the Stamp Controller is available separately. This covers all the integrated circuits and prevents inquisitive and/or mischievous fingers removing components. Supplied with instructions and a full kit of support posts and nuts/bolts. 2mm Sockets. It is possible to add 2mm input/output sockets by enlarging the hole in the pad beside the LED and soldering in a 2mm socket (as on the serial ADC board). A kit of 2mm sockets (drill-bit included) is available. Self-adhesive feet. The self-adhesive feet on the underside of the board can be super-glued in place rather than use the self-adhesive tape supplied on the feet. I/O Header The i/o pin header is found to be very useful by many for connection of voltmeter or oscilloscope probes for demonstration purposes. However it is not strictly necessary and so, if the perspex cover is not used to protect the components, it could be removed by cutting off the pins with a pair of side cutters. This would prevent the possibility of students deliberately 'shorting' the pins together with metal devices such as scissors. Clock Resonator If the perspex cover is not used, the 4MHz clock resonator on the Controller could be flexed back and forth by inquisitive fingers, which would eventually cause it to shear off. To prevent this we strongly recommend that it is glued in place with epoxy resin (e.g. Araldite). If desired the resonator can also be totally replaced by a surface mount type resonator, mounted on the underside of the board (pads provided). A suitable device is Farnell code 574-605. Technological Studies: Systems and Control Teachers Notes (H) Introduction 15 Contact Addresses: Revolution Education Ltd 81 Cleave Road, Gillingham, Kent, ME7 4AX Tel: (01634) 856712 Fax: (01634) 856712 Middlesex University Teaching Resources Teaching Resources, Middlesex University, Trent Park, Bramley Road, London, N14 4YZ Tel: (0181) 447 0342 Fax: (0181) 447 0340 Higher Still Development Programme PO Box 12754, Ladywell House, Ladywell Road Edinburgh, EH12 7YH Tel: (0171) 314 4620 Fax: (0131) 314 4621 Unilab Unilab, Lynn Lane, Shenstone, Lichfield, Staffordshire, WS14 0EE Tel: (01543) 483064 Fax: (01543) 483056 E & L Instruments Ltd E & L Instruments Ltd , Aerial Road, Wrexham LL12 0TU Tel: (01978) 853920 Fax: (01978) 854564 Rapid Electronics Ltd Rapid Electronics Ltd, Heckworth Close, Colchester, Essex, CO4 4TB Tel: (01206) 751166 Fax: (01206) 751188 Technology Enhancement Programme 4-7 Red Lion Court, London, EC4B 4AB Tel: (0171) 583 0900 Fax: (0171) 583 0909 Technological Studies: Systems and Control Teachers Notes (H) Introduction 16 TECHNOLOGICAL STUDIES HIGHER SYSTEMS AND CONTROL TEACHER/LECTURER NOTES AND SOLUTIONS TO ASSIGNMENTS OUTCOME 1 Technological Studies: Systems and Control Teachers Notes (H) Outcome 1 1 Technological Studies: Systems and Control Teachers Notes (H) Outcome 1 2 Assignment 1. Explain what is meant by the term 'systems diagram'. When applied to control systems, a Systems Diagram is a useful way of visually representing the desired function of the system. The systems diagram is a form of block diagram than contains all the subsystems within a dashed box, called the systems boundary. The systems boundary indicates the extend of the control system. INPUT CONTROL OUTPUT DRIVER OUTPUT The "real world" input and output conditions of the system are shown as arrows entering, and leaving, the systems diagram. Technological Studies: Systems and Control Teachers Notes (H) Outcome 1 3 Assignment 2. Describe the differences between an open loop and closed loop control system. An Open Loop Control system represents the simplest and cheapest form of control, where an input is processed to produce an output. With open loop control systems there is no capability to adjust the output to suit the changing output requirements. Closed loop control systems are capable of making decisions and adjusting their performance to suit changing output conditions. All closed loop control systems include a feedback sensing subsystem within the systems diagram. The control subsystem will process the feedback signal by making a 'decision' on whether the state of the output should change. FEEDBACK SENSING INPUT CONTROL OUTPUT DRIVER Technological Studies: Systems and Control Teachers Notes (H) Outcome 1 OUTPUT 4 Assignment 3. Describe the purpose of the feedback sensing subsystem in a closed loop control system. All closed loop control systems include a feedback sensing subsystem within the systems diagram. The control subsystem will process the feedback signal by making a 'decision' on whether the state of the output should change. Therefore the feedback sensing system feeds the control subsystem with the condition of the output. FEEDBACK SENSING INPUT CONTROL OUTPUT DRIVER Technological Studies: Systems and Control Teachers Notes (H) Outcome 1 OUTPUT 5 Assignment 4. The figures above show two types of electric fire. The second electric fire is a more modern device fitted with a thermostat. a) Name the type of control system used in each type of electric fire Bar heater is an open loop control system. Thermostat controlled heater is a closed loop control system. b) Draw a system diagram for each type of electric fire. Bar heater SWITCH HELD DOWN CONTROL OUTPUT DRIVER FAN & HEATER SWITCHED ON Thermostat controlled heater THERMOSTAT CONTROL c) HEATING SYSTEM Name a type of electronic sensor that may used for measuring temperature. Thermistor (or thermocouple) Technological Studies: Systems and Control Teachers Notes (H) Outcome 1 6 Assignment 5. LIMIT SWITCH SWITCH UNIT INVERTER TRANSDUCER DRIVER LATCH INPUT/OUTPUT UNIT MOTOR/ GEARBOX LIFT PLATFORM The systems diagram for a simple lift control system is shown below. PLATFORM POSITION SENSOR START LIFT CONTROL OUTPUT DRIVER RAISE LIFT PLATFORM A limit switch at the top of the lift detects when the lift platform has reached the top of the run. The block diagram below shows the system diagram sub-systems broken down into smaller blocks. LIMIT SWITCH START LIFT SWITCH UNIT INVERTER LATCH TRANSDUCER DRIVER MOTOR GEARBOX RAISE LIFT PLATFORM Technological Studies: Systems and Control Teachers Notes (H) Outcome 1 7 A circuit diagram of the system is shown below. +V S Q R Q 0V Build the circuit shown, using discrete components, circuit simulation or a modular electronics system. a) Clearly explain how the system operates. When the start switch is momentarily pressed the system is set. The latch keeps the system set even if the start switch is then released. The transducer driver circuit switches the relay on, which powers the motor. The motor drives the lift cage, which moves up until it hits the microswitch. The microswitch resets the system. This switches the transducer driver off, which switches the motor off and hence stops the lift cage moving. Technological Studies: Systems and Control Teachers Notes (H) Outcome 1 8 The 'transducer driver' circuit used in this instance is a relay driver circuit. RELAY b) Explain the purpose of the relay, transistor and diode within the relay driver circuit. The relay is used to switch the motor on and off. The relay isolates the motor from the control circuit, as the motor is a high current load which uses a separate power supply. The transistor is used to switch the relay on and off. The diode protects the transistor from the back EMF generated when the relay switches off. Technological Studies: Systems and Control Teachers Notes (H) Outcome 1 9 Assignment 6 The output condition using this type of control does not have to be limited to on or off but can be applied to any two desired output states. LIMIT SWITCH 1 INPUT/OUTPUT UNIT INVERTER LATCH TRANSDUCER DRIVER INPUT/OUTPUT UNIT LIFT PLATFORM MOTOR/ GEARBOX +V LIMIT SWITCH 2 OV Build the circuit shown, using discrete components or a modular electronics system. a) Draw a system diagram of the control system. LIMIT SWITCH SWITCH UNIT INVERTER LATCH TRANSDUCER DRIVER MOTOR LIMIT SWITCH GEARBOX RAISE/LOWER LIFT PLATFORM Technological Studies: Systems and Control Teachers Notes (H) Outcome 1 10 b) Draw a circuit diagram of the control system. +V S Q R Q 0V c) Explain the operation (function and effect) of the DPDT relay. The DPDT relay contacts are connected to the motor. The normally closed contacts are wired to make the motor turn in one direction, the normally open contacts are wired to make the motor turn in the other direction. Therefore when the relay is not energised the motor turns in one direction. When the relay is energised the motor turns in the other direction. In this example this causes the lift cage to move up and down. Technological Studies: Systems and Control Teachers Notes (H) Outcome 1 11 TECHNOLOGICAL STUDIES HIGHER SYSTEMS AND CONTROL TEACHER/LECTURER NOTES AND SOLUTIONS TO ASSIGNMENTS OUTCOME 2 Technological Studies: Systems and Control Teachers Notes (H) Outcome 2 1 Technological Studies: Systems and Control Teachers Notes (H) Outcome 2 2 Assignment 1. The block diagram below simulates an automatic heating system. When the bulb heats up the temperature rise is detected by the bead thermistor, which sends a feedback signal back to the comparator. BEAD THERMISTOR INPUT/OUTPUT UNIT COMPARATOR TRANSDUCER DRIVER BULB UNIT A circuit diagram of the system is shown below. TEMPERATURE FEEDBACK SIGNAL +VCC R RT RV R RV OV -VCC The variable resistor, RV1 (connecting to the non-inverting input of the op-amp) is used to set the reference level (or threshold). This sets the desired temperature of the bulb. Build the circuit shown, using discrete components or a modular electronics system. Calibrate the system to the following performance criteria: • When the bulb heats above the reference level the thermistor should sense the temperature and send a signal to the comparator which will switch the bulb off. • When the bulb cools below the reference level the bulb should switch on again. • The system should operate continuously. Technological Studies: Systems and Control Teachers Notes (H) Outcome 2 3 a) Describe how the circuit operates. The op-amp is operating as a comparator, which compares two voltage levels. The first reference voltage level is set by the potential divider circuit that contains RV1. If the second voltage level, set by the thermistor potential divider, is less than the reference value the op-amp switches the transistor on, which cause the bulb to light. As the bulb lights it heats the thermistor, so the thermistor resistance decreases. This causes the voltage level at the centre of the thermistor potential divider to increase. When the voltage level increases above the reference voltage the op-amp switches the transistor off, so the bulb goes out. The thermistor then cools, the thermistor potential divider voltage drops below the reference level, and the whole cycle repeats. b) Explain clearly how you calibrated the system. Answer involving adjusting RV2 to calibrate the thermistor potential divider. Technological Studies: Systems and Control Teachers Notes (H) Outcome 2 4 Assignment 2 Explain the following terms when applied to control systems: open loop, closed loop An Open Loop Control system represents the simplest and cheapest form of control, where an input is processed to produce an output. With open loop control systems there is no capability to adjust the output to suit the changing output requirements. Closed loop control systems are capable of making decisions and adjusting their performance to suit changing output conditions. They include a feedback signal from the output back to the control subsystem. negative feedback, positive feedback The purpose of closed loop control is to ensure that the output is maintained, as closely as possible, to the desired output level. To achieve this a feedback signal is fed back from the output to the control subsystem. This enables the system to react to the condition of the output. Negative feedback reduces the output error (e.g. in a central heating system). Positive feedback reinforces the error (e.g. high pitch sound generated when a microphone is held close to a speaker). error detector The error-detection symbol is used within a control diagram to indicate that the control involves two signals. The feedback signal is connected to the negative symbol to indicate the use of negative feedback. TEMPERATURE SENSOR SET TEMPERATURE LEVEL OPERATIONAL AMPLIFIER OUTPUT DRIVER Technological Studies: Systems and Control Teachers Notes (H) Outcome 2 CONSTANT OUTPUT TEMPERATURE 5 Assignment 3 The block diagram below simulates the automatic water heating system within a washing machine. REMOTE INPUT UNIT DIFFERENCE AMPLIFIER NON-INVERTING AMPLIFIER POWER DRIVER INPUT VOLTAGE UNIT 12V HEATER THERMISTOR BEAKER OF WATER A circuit diagram of the system is shown below. +Vcc THERMISTOR 100K 10K 10K POWER DRIVER HEATER 10K 1K 22K 10K 10K 0V -Vcc Build the circuit shown, using discrete components or a modular electronics system. Observe the response of the system when the desired temperature is altered (by adjusting the variable resistor). Use a digital thermometer to measure the temperature of the fluid, and a voltmeter to measure the voltage across the heater. Technological Studies: Systems and Control Teachers Notes (H) Outcome 2 6 a) Describe how the circuit operates. Clearly explain the purpose of the noninverting amplifier after the difference amplifier? The reference voltage signal to the difference amplifier is provided by the variable resistor in the first potential divider. The second voltage signal is provided by the thermistor potential divider. When there is a large difference between these voltages the difference amplifier provides a large signal to the non-inverting amplifier. Although in signal terms this error signal is quite large, it is not directly large enough to drive the high power driver, and so the signal is amplified by the non-inverting amplifier to produce a larger signal. The heater switches on and the temperature of the water rises. This causes the signal from the thermistor potential divider circuit to approach the reference signal, and so the error difference decreases. When the two signals are quite near the amplified error signal is not enough to drive the output driver, and so the heater switches off. Therefore, unlike a comparator based system, the heater switches off before the desired temperature is reached, not after the desired temperature has been passed. b) Explain clearly how the system responds when the desired temperature level is altered. When the reference signal is altered the difference between the two signals is increased and so a large error results. If this is a large negative error the heater switches on to heat the water. If this is a large negative error the system waits for the water to cool in the surrounding air. Technological Studies: Systems and Control Teachers Notes (H) Outcome 2 7 Assignment 4. A proportional control system is used to regulate the flow rate of coal onto a conveyer belt. The system should sense the weight of coal on the conveyer belt and automatically adjust the gate height to ensure that a constant flow of coal is supplied. POWER SUPPLY RACK AND PINION CONTROL UNIT VARIABLE HEIGHT GATE P CONVEYOR FRAME PIVOTED HERE CONSTANT SPEED DRIVE MOTOR LOAD SENSOR Technological Studies: Systems and Control Teachers Notes (H) Outcome 2 8 a) Draw a systems diagram of the flow rate control system. LOAD SENSOR OPERATIONAL AMPLIFIER b) OUTPUT DRIVER RACK & PINION MOTOR Explain the term 'proportional control'. In proportional closed loop control systems the output signal is directly related to the error signal. Therefore if there is a large error there will be a larger output signal than with a small error. This helps reduce 'overshoot' errors within the system. c i) Name the configuration of op-amp used in proportional control systems. Difference amplifier c ii) Draw a circuit diagram of the op-amp. Rf +Vcc R1 R1 V1 -Vcc V2 Rf Technological Studies: Systems and Control Teachers Notes (H) Outcome 2 Vo 9 d i) Name a suitable output driver circuit which could be used with the control system. Push-pull follower analogue driver d ii) Draw a circuit diagram of the driver circuit. +Vcc NPN OP-AMP SIGNAL LOAD PNP 0V -Vcc Technological Studies: Systems and Control Teachers Notes (H) Outcome 2 10 Assignment 5. The figure shows the layout of an audio mixing desk. TACHOGENERATOR AUDIO MIXING HEAD RECORDING REEL DRIVEN BY DC MOTOR The tape is fed through the audio mixing head by being pulled on to a recording reel driven by a dc motor. As the tape builds up on the recording reel, the tape speed through the audio mixing head will increase. To prevent this from happening, the dc motor is fitted to a closed loop control system. A tachogenerator connected to a pulley senses the tape feed rate and sends an error signal to the control system. a) Name the type of closed loop control used in this application. Proportional closed loop control. b) Name the amplifier used in this type of closed loop control. Difference amplifier. Technological Studies: Systems and Control Teachers Notes (H) Outcome 2 11 c) Draw a control diagram of the system. TACHOGENERATOR OUTPUT DRIVER OPERATIONAL AMPLIFIER d) MOTOR SPEED MOTOR Draw a circuit diagram of the control system and explain the function of each part of the circuit. Rf +Vcc R1 R1 V1 -Vcc V2 Rf Technological Studies: Systems and Control Teachers Notes (H) Outcome 2 Vo 12 Assignment 6. The figure illustrates a system for controlling the wing mirrors on a car by adjusting remote dials on the dash. DIALS A control diagram of the system for rotational movement in the X-axis (one mirror) is shown in the figure below. Similar systems are used for the Y-axis and for the other mirror. FEEDBACK SENSOR REMOTE DIAL OPERATIONAL AMPLIFIER OUTPUT DRIVER MOTOR WING MIRROR POSITION a) With reference to the control diagram, explain clearly how the system operates. When the car driver adjusts the dial the op-amp subsystem switches on the output driver, which cause the motor to move. As the motor moves the negative feedback signal from the mirror is fed back to the operational amplifier. When the mirror is in the correct new position the error detection is zero, so the op-amp switches off the output driver (so the motor switches off). b) Name the type of control used in this system. Proportional closed loop control. Technological Studies: Systems and Control Teachers Notes (H) Outcome 2 13 c) Name the configuration of op-amp required. Difference amplifier. d) State two reasons why the op-amp cannot be used to drive the motor directly. Op amp cannot source a high current for the motor. The back EMF of the motor could damage the op-amp. It is necessary to be able to reverse the direction of the motor. e) Name a suitable output driver which could be used with this system. Analogue push-pull follower f) Draw a circuit diagram of the output driver. +Vcc NPN OP-AMP SIGNAL LOAD PNP 0V -Vcc Technological Studies: Systems and Control Teachers Notes (H) Outcome 2 14 TECHNOLOGICAL STUDIES HIGHER SYSTEMS AND CONTROL TEACHER/LECTURER NOTES AND SOLUTIONS TO ASSIGNMENTS OUTCOME 3 Technological Studies: Systems and Control Teachers Notes (H) Outcome 3 1 Technological Studies: Systems and Control Teachers Notes (H) Outcome 3 2 Assignment 1.1 List the advantages of using a microcontroller within a product design. One microcontroller can often replace a number of separate parts, or even a complete electronic circuit. Some of the advantages of using microcontrollers in a product design are: • increased reliability and reduced stock inventory (as one microcontroller replaces several parts) • simplified product assembly and smaller end products • greater product flexibility and adaptability since features are programmed into the microcontroller and not built into the electronic hardware • rapid product changes or development by changing the program and not the electronic hardware Assignment 1.2 Describe the input sensors and output transducers that may be linked to a microcontroller in the following common household appliances: - microwave oven - washing machine - electronic bicycle speedometer Device Microwave Oven Input Sensors Keypad Door Microswitch Temperature Sensor Washing Machine Control Dial Door Microswitch Temperature Sensor Bicycle Speedometer Press Switches Reed Switch or Hall Effect Sensor Output Transducers Seven Segment Display Internal Light Turntable Motor Bell Magnetron Door Lock Solenoid Solenoid Valves Heater Motor LCD Display Technological Studies: Systems and Control Teachers Notes (H) Outcome 3 3 Assignment 1.3 Explain the following microcontroller terms: ALU, bus, clock Arithmetic/Logic Unit (ALU) and Clock The processing unit (full name arithmetic and logic unit (ALU)) is the 'brain' of the microcontroller. It operates by reading instructions from the read only memory ROM (permanent program memory) and then carrying out the mathematical operations for each instruction. The speed at which these operations occur is controlled by the clock circuit. The clock circuit within the microcontroller 'synchronises' all the internal blocks (ALU, ROM, RAM etc.) so that the system remains stable. The clock circuit is built into the microcontroller, but an external crystal or resonator is required to set the clock frequency. A typical clock frequency for use with a microcontroller is 4MHz, but speeds as high as 20MHz can also be achieved. With a clock frequency of 4MHz the microcontroller completes one million instructions a second! Buses Information is carried between the various blocks of the microcontroller along 'groups' of wires called buses. The 'data bus' carries the 8-bit data between the ALU and RAM / Input-Output registers, and the 'program bus' carries the 13-bit program instructions from the ROM. The size of the data bus provides a description for the microcontroller. Therefore an '8 bit microcontroller' has a data bus '8-bits' wide. Microcontrollers with 16-bit and 32-bit data buses are also available. Technological Studies: Systems and Control Teachers Notes (H) Outcome 3 4 Assignment 1.4 Explain the differences between the following types of memory: - RAM, ROM, EEPROM RAM ROM EEPROM - Random Access Memory - Read Only Memory - Electrically Erasable Programmable Read Only Memory The ROM contains the operating instructions (i.e. the 'program') for the microcontroller. The ROM is 'programmed' before the microcontroller is installed in the target system, and the memory retains the information even when the power is removed. Most microcontrollers are one-time-programmable types, which means the ROM can only be programmed once. If you make a mistake, and have to change the program, the chip has to be thrown away and a new chip programmed with the revised program. To overcome this problem some microcontrollers now use FLASH EEPROM memory instead. This type of 'erasable-permanent' memory allows the ROM to be re-programmed if a mistake is made. The RAM is 'temporary' memory used for storing information whilst the program is running. This memory is 'volatile', which means that as soon as the power is disconnected the contents of the memory is lost. Technological Studies: Systems and Control Teachers Notes (H) Outcome 3 5 Assignment 1.5 Describe the similarities and differences between programming, and constructing interfacing circuits for a 'true' microcontroller and the 'Basic Stamp' system. Microcontrollers are normally programmed in assembler code or 'C', while the Basic Stamp is programmed in the 'user friendly' language BASIC (Beginners' All Purpose Symbolic Instruction Code). When using the Basic Stamp the program is stored in an external EEPROM chip, rather than the usual method of embedding the program in the microcontroller itself. Therefore the primary difference between programming standard microcontrollers and programming the Basic Stamp is that, when you 'download' a program to the Basic Stamp, you are actually programming the external EEPROM, rather than the microcontroller ROM. When you build electronic systems you are still connecting directly to the 'microcontroller' input/output pins, and so the electronic connections are identical to those made to standard microcontrollers. Technological Studies: Systems and Control Teachers Notes (H) Outcome 3 6 Assignment (Section 2) Convert each of the following binary numbers into decimal: 2.1) 11110000 240 2.2) 11000011 195 2.3) 01010101 85 2.4) 10101010 170 Convert each of these decimal numbers into binary: 2.5) 17 00010001 2.6) 23 00010111 2.7) 11 00001011 2.8) 38 00100110 2.9) 33 00100001 Convert the following binary numbers to hexadecimal: 2.10) %11011101 &DD 2.11) %11111001 &F9 2.12) %01010101 &55 2.13) %10101010 &AA 2.14) %11001010 &CA Convert the following hexadecimal numbers to binary: 2.15) &4E %01001110 2.16) &0D %00001101 2.17) &FD %11111101 2.18) &5A %01011010 2.19) &B2 %10110010 Technological Studies: Systems and Control Teachers Notes (H) Outcome 3 7 Assignment 3.3 What is the function of the Data Direction Register (DDR)? Each pin can be configured to be an output (to send digital signals) or an input (to receive digital signals). The Data Direction Register (DDR) is used to configure the port, and in the PBASIC language the DDR is allocated the label 'dirs'. If all the bits in the DDR are set high then all the pins will be set as outputs. If all the bits are set low each pin will be set as an input. Assignment 3.4 What is meant by the term "white-space"? Why is it important to use whitespace and comments when writing programs? The term 'white-space' is used by programmers to define tabs, spaces and blank lines, and the correct use of white-space can make the program listing much easier to read and understand. A comment starts after an apostrophe (') and continues to the end of the line. Although the comments are not needed to make the program work, they are an essential part of the program as they explain in 'plain language' what the program is doing. Comments are particularly important if the program is to be studied by someone else at a later date. Technological Studies: Systems and Control Teachers Notes (H) Outcome 3 8 Assignment 3.5 A set of temporary traffic lights are required for a system of road-works. red red and amber green amber 10 sec 2 sec 10 sec 2 sec Draw a flowchart for the lights sequence shown by one set of the traffic lights. Use the times shown in the table for each stage. START RED ON WAIT 10 Sec. AMBER ON WAIT 2 Sec. RED & AMBER OFF GREEN ON WAIT 10 Sec. GREEN OFF AMBER ON WAIT 2 Sec. AMBER OFF Technological Studies: Systems and Control Teachers Notes (H) Outcome 3 9 Write a PBASIC program to achieve this operation. Use the following pin configuration - red (7), amber (6) and green (5). init: let dirs = %11100000 ' set pins 5-7 as outputs main: high 7 pause 10000 high 6 pause 2000 let pins = %00100000 pause 10000 let pins = %01000000 pause 2000 low 6 goto main ' ' ' ' ' ' ' ' ' ' set pin 7 high wait for 10 seconds set pin 6 high wait for 2 seconds set pin 5 high wait for 10 seconds switch pin 6 high wait for 2 second pin 6 low loop forever (Note this example shows a mixture of high / low and let pins = commands for illustration purposes). Technological Studies: Systems and Control Teachers Notes (H) Outcome 3 10 Assignment 3.6 OUTPUT DRIVER MODULE STAMP CONTROLLER Connect a buggy to the output driver module (or MFA movement module) as shown in the diagram. START MOVE FORWARD WAIT 3 SEC. TURN LEFT WAIT 1 SEC. MOVE FORWARD WAIT 3 SEC. STOP Write a high level program in PBASIC to control the movement of the buggy as shown by the flowchart above. init: let dirs = %11110000 ' set pins 4-7 as outputs main: let pins = %01010000 pause 3000 let pins = %10010000 pause 1000 let pins = %01010000 pause 3000 end ' ' ' ' ' ' ' forward wait for 3 seconds left wait for 1 second forward wait for 3 seconds stop Technological Studies: Systems and Control Teachers Notes (H) Outcome 3 11 Assignment 3.8 OUTPUT DRIVER MODULE STAMP CONTROLLER Connect a buggy to the output driver module (or MFA movement module) as shown in the diagram. 3 3 3 3 The buggy should follow the movement path as shown in the diagram above. Technological Studies: Systems and Control Teachers Notes (H) Outcome 3 12 Draw a flowchart for the movement of the buggy, making use of a for...next command structure. START SET COUNTER = 4 MOTORS FORWARD WAIT 3 MOTORS LEFT WAIT 1 LOOPED 4 TIMES ? NO YES STOP Write a high level program in PBASIC to control the movement of the buggy as shown by your flowchart. (It will be necessary to experiment with time delays to establish how quickly your buggy moves and turns). symbol counter = b0 ' define the variable "counter" init: let dirs = %11110000 ' set pins 4-7 as outputs main: for counter = 1 to 4 let pins = %01010000 pause 3000 let pins = %10010000 pause 1000 next counter ' ' ' ' ' ' end start a for...next loop forward wait for 3 seconds left wait for 1 second end of for...next loop ' end program Technological Studies: Systems and Control Teachers Notes (H) Outcome 3 13 Assignment 3.9 As part of a Christmas decoration, a lighting sequence is to be controlled by a microcontroller. The output connections are shown below. Input Connection Pin 7 6 5 4 3 2 1 0 Output Connection Yellow Light Purple Light Blue Light Green Light Red Light The red and green lights should come on together and stay on for 5 seconds. Then they both go off and the yellow and blue lights should come on together for 8 seconds. They then go off and the purple light flashes on and off 6 times (the 'on' and 'off' times being 0.5 seconds each). The sequence then repeats itself. Technological Studies: Systems and Control Teachers Notes (H) Outcome 3 14 Draw a flowchart and write a PBASIC program for this sequence. START RED & GREEN ON WAIT 5 Sec. RED & GREEN OFF YELLOW & BLUE ON WAIT 8 Sec. YELLOW & BLUE OFF SET COUNTER = 6 PURPLE ON WAIT 0.5 Sec. PURPLE OFF WAIT 0.5 Sec. NO LOOPED 6 TIMES ? YES Technological Studies: Systems and Control Teachers Notes (H) Outcome 3 15 symbol counter = b0 ' define the variable "counter" init: let dirs = %11111111 ' set all pins as outputs main: let pins = %00000101 pause 5000 let pins = %01001000 pause 8000 ' ' ' ' red and green on wait 5 seconds yellow and blue on wait 8 seconds for counter = 1 to 6 let pins = %00100000 pause 500 let pins = %00000000 pause 500 next counter ' ' ' ' ' ' start a for...next loop purple on wait 0.5 second purple off wait 0.5 second end of for...next loop goto main ' loop forever Technological Studies: Systems and Control Teachers Notes (H) Outcome 3 16 Assignment 3.11 START SWITCH ALL PINS HIGH WAIT5 SECONDS SWITCH ALL PINS LOW WAIT0.5 SECONDS SWITCH ALL PINS HIGH WAIT0.5 SECONDS HAS THIS BEEN DONE 10 TIMES? N Y SWITCH ALL PINS LOW STOP Technological Studies: Systems and Control Teachers Notes (H) Outcome 3 17 Develop a PBASIC program that will carry out the instructions shown in the flowchart above. symbol counter = b0 ' define the variable "counter" init: let dirs = %11111111 ' set all pins as outputs main: let pins = %11111111 pause 5000 ' all pins high ' wait 5 seconds for counter = 1 to 10 let pins = %00000000 pause 500 let pins = %11111111 pause 500 next counter ' ' ' ' ' ' start a for...next loop all pins low wait 0.5 second all pins high wait 0.5 second end of for...next loop let pins = %00000000 end ' all pins low ' stop the program Technological Studies: Systems and Control Teachers Notes (H) Outcome 3 18 Assignment 3.12 A motor, connected to pin 7, is to run when a 'start' switch (connected to pin 2) is momentarily pressed. The motor continues to run until another 'stop' switch (connected to pin 3) is pressed - at which point the motor switches off. The system should then reset to wait for another 'start' signal. Draw a flowchart and write a PBASIC program for this sequence. START NO IS PIN 2 HIGH ? YES SWITCH MOTOR ON NO IS PIN 3 HIGH ? YES SWITCH MOTOR OFF init: let dirs = %10000000 ' set pin 7 as output main: if pin2 = 1 then mon goto main ' continue when start switch ' else loop mon: ' motor on high 7 loop: if pin3 = 1 then moff goto loop ' continue when stop switch ' else loop moff: low 7 goto main ' motor off ' back to start Technological Studies: Systems and Control Teachers Notes (H) Outcome 3 19 Assignment 3.13 STAMP CONTROLLER OUTPUT DRIVER MODULE Connect a buggy to the output driver module (or MFA movement module) as shown in the diagram. Connect the micro-switch 'bumpers' to pins 0 and 1 on the Stamp Controller via the screw terminals as shown below. V+ 0 1 2 3 0V SHOWS HOW WIRE 2 SWITCHES TO THE SCREW TERMINALS ON THE STAMP CONTROLLER The buggy should continue in a forward direction until either of the two microswitch bumpers is activated. At this point the buggy should reverse for 3 seconds, rotate 90 degrees clockwise, and then continue in a forwards direction. Technological Studies: Systems and Control Teachers Notes (H) Outcome 3 20 Draw a flowchart and write a PBASIC program to control the movement of the buggy as described above. START MOTOR FORWARD YES IS PIN 0 HIGH ? NO YES IS PIN 1 HIGH ? MOTOR REVERSE NO WAIT 3 Sec. MOTOR TURN WAIT 2 Sec.. init: let dirs = %11110000 ' set pins 4-7 as outputs main: let pins = %01010000 ' forward loop: if pin0 = 1 then bump if pin1 = 1 then bump goto loop ' test switch 0 ' test switch 1 ' else loop bump: let pins = %10100000 pause 3000 let pins = %10010000 pause 2000 goto main ' ' ' ' ' reverse wait for 3 seconds left turn for 2 seconds back to start Technological Studies: Systems and Control Teachers Notes (H) Outcome 3 21 Assignment 3.14 START GREEN LED ON SWITCH PUSHED? NO YES GREEN LED OFF AMBER LED ON WAIT 3 sec. AMBER LED OFF RED LED ON WAIT 4 sec. AMBER LED ON WAIT 2 sec.. RED/AMBER LED OFF GREEN LED ON Develop a PBASIC program that will carry out the instructions shown in the flowchart above. Technological Studies: Systems and Control Teachers Notes (H) Outcome 3 22 Use the following pin configuration. Input Connection Start Switch Pin 7 6 5 4 3 2 1 0 Output Connection Red Light Amber Light Green Light init: let dirs = %11110000 ' set pins 4-7 as outputs main: let pins = %00100000 ' green on loop: if pin3 = 1 then lite goto loop ' test start switch ' else loop lite: let pins = %01000000 pause 3000 let pins = %10000000 pause 4000 let pins = %11000000 pause 2000 goto main ' ' ' ' ' ' ' amber on wait for 3 seconds red on turn for 4 seconds red & amber on wait for 2 seconds back to start Technological Studies: Systems and Control Teachers Notes (H) Outcome 3 23 Assignment 3.16 As part of a shop display, a lighting sequence is to be controlled by a microcontroller. The output connections are shown below. Input Connection switch 2 switch 1 Pin 7 6 5 4 3 2 1 0 Output Connection Red Light Yellow Light Green Light Orange Light If switch 1 is pressed, each light should flash on and off 5 times in sequence i.e. orange then green then yellow then red (each 'on' and 'off' time should be 0.5 seconds). the system then resets for the next switch push. If switch 2 is pressed all lights should flash simultaneously 3 times. There should then be a 2 second pause, before all lights should flash simultaneously 6 times (each 'on' and 'off' time should be 0.5 seconds). The system then resets for the next switch push. Technological Studies: Systems and Control Teachers Notes (H) Outcome 3 24 Draw a flowchart and write a PBASIC program for this sequence (use a subprocedure for the flash routines). START SWITCH 1 ON ? YES FLASH 1 NO SWITCH 2 ON ? YES FLASH 2 NO FLASH 1 FLASH 1 LET COUNTER = 5 LET COUNTER = 10 ORANGE & YELLOW ON RED & GREEN ON WAIT 0.5 Sec. WAIT 0.5 Sec. ORANGE & YELLOW OFF RED & GREEN OFF WAIT 0.5 Sec. NO ALL DONE ? WAIT 0.5 Sec. NO ALL DONE ? YES RETURN YES RETURN Technological Studies: Systems and Control Teachers Notes (H) Outcome 3 25 symbol counter = b0 ' define the variable "counter" init: let dirs = %11110000 ' set pins 4-7 as outputs main: if pin1 = 1 then do1 if pin2 = 1 then do2 goto main ' test switch 1 ' test switch 2 ' else loop do1: for counter = let pins = pause 500 let pins = pause 500 let pins = pause 500 let pins = pause 500 next counter goto main do2: let b1 = 3 gosub flash pause 2000 let b1 = 6 gosub flash goto main 1 to 10 ' start a for...next loop %00010000 ' light on ' wait 0.5 second %00100000 ' light on ' wait 0.5 second %01000000 ' light on ' wait 0.5 second %10000000 ' light on ' wait 0.5 second ' end of for...next loop ' loop to start ' sub-procedures flash: for counter = 1 to b1 let pins = %11110000 pause 500 let pins = %00000000 pause 500 next counter return ' ' ' ' ' ' 3 flashes do sub wait 2 seconds 6 flashes do sub loop to start ' ' ' ' ' ' ' start a for...next loop lights on wait 0.5 second lights off wait 0.5 second end of for...next loop return from sub Technological Studies: Systems and Control Teachers Notes (H) Outcome 3 26 Assignment 3.17 Connect the washing machine model to the Stamp Controller. A sequence of events for the operation of the washing machine is given in the table below: Step 1 Step 2 Step 3 Step 4 Step 5 Step 6 Wait until the door switch is closed. Wait until the start switch is pushed. Rotate the drum clockwise for 10 seconds. Rotate the drum anti-clockwise for 10 seconds Repeat steps 3 and 4 10 times Rotate the drum clockwise for 5 seconds. Rotate the drum anti-clockwise for 5 seconds Repeat steps 5 and 6 5 times Technological Studies: Systems and Control Teachers Notes (H) Outcome 3 27 Draw a flowchart for the control sequence described above. START NO DOOR CLOSED ? YES NO START PUSHED? SET COUNTER = 5 YES SET COUNTER = 10 DRUM CLOCKWISE DRUM CLOCKWISE WAIT 5 Sec. WAIT 10 Sec. DRUM ANTICLOCKWISE DRUM ANTICLOCKWISE WAIT 5 Sec. WAIT 10 Sec. NO NO ALL DONE ? ALL DONE ? YES YES STOP Technological Studies: Systems and Control Teachers Notes (H) Outcome 3 28 Write, and test, a PBASIC program for the control sequence described above. symbol counter = b0 symbol time = b1 symbol cycle = b2 ' define the variable "counter" ' define the variable "time" ' define the variable "cycle" init: let dirs = %11000000 ' set pins 6-7 as outputs step1: if pin0 = 1 then step2 goto step1 ' test start switch ' else loop step2: if pin1 = 1 then step3 goto step2 ' test door switch ' else loop step3: let time = 10000 let cycle = 10 gosub wash ' set time to 10 secs ' set cycles to 10 ' do sub let time = 5000 let cycle = 5 gosub wash ' set time to 5 secs ' set cycles to 5 ' do sub end ' sub-procedures wash: for counter = 1 to cycle let pins = %01000000 pause time let pins = %10000000 pause time next counter return ' ' ' ' ' ' ' start a for...next loop clockwise wait time anticlockwise wait time end of for...next loop return from sub Technological Studies: Systems and Control Teachers Notes (H) Outcome 3 29 Assignment 3.18 MAINS WATER INLET VALVE HEAD STORAGETANK AGITATOR MOTOR DUMP PUMP MOTOR CONVEYOR MOTOR The diagram shows the layout of a pulper machine used in a paper mill. A batch of pulp and fillers, i.e. 5 x 20 kg bales of pulp and 2 x 50 kg bags of fillers, is mixed during the pulping process with 1600 litres of water. The operation of the pulping process is controlled by a microcontroller. The microcontroller connections are as follows: Input Connection Start switch Pin 7 6 5 4 3 2 1 0 Event Operator Action 1 Load conveyer with batch 2 Press start button 3 4 5 6 7 Output Connection Agitator motor Dump Pump Conveyer Inlet valve Control Activity Sequence commences. Open inlet valve. Close valve after 10 minutes. 1 minute after inlet valve opens, start agitator motor. run agitator motor for 11 minutes. Start conveyer 2 minutes after inlet valve opens. Run conveyer for 3 minutes. 1 minute after agitator motor stops, start dump pump. run dump pump for 3 minutes. Reset and wait for next start command. Technological Studies: Systems and Control Teachers Notes (H) Outcome 3 30 (a) Based on the instructions given in the table, draw up a flow chart which shows the control sequence for the pulping sequence. START NO START BUTTON ? YES OPEN VALVE CLOSE VALVE WAIT 1 Min WAIT 2 Min START MOTOR STOP MOTOR WAIT 2 Min WAIT 1 Min START CONVEYOR START PUMP WAIT 3 Min WAIT 3 Min STOP CONVEYOR STOP PUMP WAIT 4Min Technological Studies: Systems and Control Teachers Notes (H) Outcome 3 31 (b) With reference to your flow chart, write a high level program in PBASIC to control the operation of the pulper. Assume use of a pre-written time delay sub-procedure called 'delay' which will produce a time delay in multiples of one minute, according to the value set in the variable 'mins' before the sub-procedure is called. Example - To wait five minutes: init: let dirs = %11110000 let mins = 5 call delay ' set pins 4-7 as outputs symbol mins = b0 main: if pin0 = 1 then doit goto main ' test start switch ' else loop doit: high 4 let mins = 1 gosub delay ' open inlet ' set time ' do delay high 7 let mins = 2 gosub delay ' start motor ' set time ' do delay high 5 let mins = 3 gosub delay ' start conveyer ' set time ' do delay low 5 let mins = 4 gosub delay ' stop conveyer ' set time ' do delay low 4 let mins = 2 gosub delay ' close inlet ' set time ' do delay low 7 let mins = 1 gosub delay ' stop motor ' set time ' do delay high 6 let mins = 3 gosub delay ' start pump ' set time ' do delay low 6 goto main ' stop pump Technological Studies: Systems and Control Teachers Notes (H) Outcome 3 32 Assignment 3.21 SWITCH 1 SWITCH 2 SENSOR MODULE STAMP CONTROLLER SERIAL LED Connect two switches to the sensors module, and the serial LCD module, to the Stamp Controller as shown. When the switch connected to pin '0' is pressed the Stamp Controller should add 1 to the current total, and then display the new value on the LCD. When the switch connected to pin '1' is pressed the Stamp Controller should subtract 1 from the current total, and then display the new value on the LCD. Draw a flowchart and write a PBASIC program to control the operation described above. START WAIT 1 Sec. PIN 0 HIGH ? LET b0 = b0 + 1 PIN 1 HIGH / LET b0 = b0 - 1 Technological Studies: Systems and Control Teachers Notes (H) Outcome 3 UPDATE LCD 33 symbol counter = b0 ' define the variable init: let dirs = %10000000 let pins = %10000000 ' make pin 7 an output ' switch pin 7 high pause 5 serout 7,T2400,(254,1) pause 30 ' short pause ' send 'clear LCD' command ' wait 30 ms main: serout 7,T2400,(254,128) serout 7,T2400,("Value = ") serout 7,T2400,(#counter," ") pause 1000 ' ' ' ' send send send wait 'line 1' command message counter value 1 sec loop: if pin0 = 1 then add1 if pin1 = 1 then take1 goto loop ' test switch 0 ' test switch 1 add1: let counter = counter + 1 goto main ' add 1 ' refresh display take1: let counter = counter - 1 goto main ' take 1 ' refresh display Technological Studies: Systems and Control Teachers Notes (H) Outcome 3 34 Assignment 4.1 Draw appropriate interfacing circuit diagrams for the following output devices. Clearly explain your choice of circuit in each case. a) LED 0V b,c) Buzzer, 6V DC Motor (Same circuit - motor shown) Vt Technological Studies: Systems and Control Teachers Notes (H) Outcome 3 35 d,e) 12V DC solenoid, 24V pneumatic solenoid valve (Same circuit - solenoid shown) + 5V + 12V RELAY SOLENOID 0V 0V Technological Studies: Systems and Control Teachers Notes (H) Outcome 3 36 Assignment 4.2 Connect the electronic lock model to the Stamp Controller. START BUZZER OFF RED LED ON BOLT OUT WAIT 2s SWITCH 1 PRESSED? NO BUZZER ON YES SWITCH 2 PRESSED? NO YES SWITCH 3 PRESSED? NO YES RED LED OFF GREEN LED ON BOLT IN WAIT 3s Technological Studies: Systems and Control Teachers Notes (H) Outcome 3 37 Write, and test, a PBASIC program for the control sequence shown in the diagram above. Input Connection Switch 3 Switch 2 Switch 1 Pin 7 6 5 4 3 2 1 0 Output Connection Bolt Buzzer Green LED Red LED init: let dirs = %11110000 ' make pins 4-7 outputs main: let pins = %10010000 ' red LED & bolt if pin1 = 0 then beep if pin2 = 0 then beep if pin3 = 0 then beep ' test switch 1 ' test switch 2 ' test switch 3 open: let pins = %00100000 pause 3000 goto main ' green LED ' wait 3 seconds ' back to start beep: let pins = %11010000 pause 2000 goto main ' red LED, bolt & buzzer ' wait 2 seconds ' back to start Technological Studies: Systems and Control Teachers Notes (H) Outcome 3 38 Assignment 4.4 Describe three products which may contain stepper motors. Describe how the motor is used in each case. Printer XY Plotter Clock One-arm bandit etc. - to move the printing head back and forth - to move the pen back and forth - to move the second hand - to rotate the wheels so they land on particular symbols Assignment 4.5 A toy manufacturer is designing a new programmable robot toy. Describe the advantages and disadvantages of using stepper motors (rather than dc motors) to manoeuvre the robot. Stepper motors will allow the toy to move in an exact straight line, whilst dc motors will tend to veer off course (as one motor spins slightly faster than the other). Stepper motors will turn corners more accurately. Stepper motors will provide more torque than equivalent sized dc motors. Stepper motors are more expensive than dc motors. Stepper motors draw current when stationary and so will drain batteries quickly. DC motors can achieve higher speeds than stepper motors. Technological Studies: Systems and Control Teachers Notes (H) Outcome 3 39 Assignment 4.6 12V DC SUPPLY STAMP CONTROLLER OUTPUT DRIVER STEPPER MOTOR Connect a stepper motor to the output driver module as shown. Develop a PBASIC program that will rotate the stepper motor 48 steps in one direction, and then 48 steps in the other direction. The table below show the four different steps required to make the motor turn Step 1 2 3 4 1 Coil 4 1 1 0 0 1 Coil 3 0 0 1 1 0 Coil 2 1 0 0 1 1 symbol counter = b0 ' define the variable init: let dirs = %11110000 ' make pins 4-7 outputs main: for counter = let pins = pause 50 let pins = pause 50 let pins = pause 50 let pins = pause 50 next counter for counter = let pins = pause 50 let pins = pause 50 let pins = pause 50 let pins = pause 50 next counter end ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' 1 to 12 %10100000 %10010000 %01010000 %01100000 1 to 48 %01100000 %01010000 %10010000 %10100000 Coil 1 0 1 1 0 0 start a for...next loop step 1 wait 0.05 second step 2 wait 0.05 second step 3 wait 0.05 second step 4 wait 0.05 second next loop start a for...next loop step 4 wait 0.05 second step 3 wait 0.05 second step 2 wait 0.05 second step 1 wait 0.05 second next loop Technological Studies: Systems and Control Teachers Notes (H) Outcome 3 40 Assignment 4.7 Connect the stepper motor light seeker apparatus to the Stamp Controller. Input Connection LDR1 LDR0 Pin 7 6 5 4 3 2 1 0 Output Connection Coil 4 Coil 3 Coil 2 Coil 1 The two LDRs are connected to input pins 0 and 1, and the two potentiometers may require adjustment for sensitivity (depending on light conditions). Technological Studies: Systems and Control Teachers Notes (H) Outcome 3 41 Draw a flowchart and write a PBASIC program that will cause the apparatus to 'follow' a light source that is moved around the apparatus. START BOTH INPUTS ON ? YES NO BOTH INPUTS OFF ? YES NO INPUT 1 ON ? YES MOVE I STEP CLOCKWISE YES MOVE 1 STEP ANTICLOCKWISE NO INPUT 2 ON ? NO Technological Studies: Systems and Control Teachers Notes (H) Outcome 3 42 symbol counter = b0 ' define the variable init: let dirs = %11110000 ' make pins 4-7 outputs main: if pin0 = 1 then both if pin1 = 1 then just2 goto main ' test LDR on pin0 ' test LDR on pin1 ' else loop both: if pin1 = 1 then main ' both on so loop just1: let pins = pause 50 let pins = pause 50 let pins = pause 50 let pins = pause 50 goto main ' ' ' ' ' ' ' ' ' move step wait step wait step wait step wait 4 steps left 4 0.05 second 3 0.05 second 2 0.05 second 1 0.05 second ' ' ' ' ' ' ' ' ' move step wait step wait step wait step wait 4 steps right 1 0.05 second 2 0.05 second 3 0.05 second 4 0.05 second just2: let pins = pause 50 let pins = pause 50 let pins = pause 50 let pins = pause 50 goto main %01100000 %01010000 %10010000 %10100000 %10100000 %10010000 %01010000 %01100000 Technological Studies: Systems and Control Teachers Notes (H) Outcome 3 43 Assignment 4. 9 Crystal glassware is decorated by cutting grooves on to the outside surface. The process leaves the untouched parts of the glass clear and reflective, whereas the cut grooves are dull and rough and require to be polished. The diagram shows the layout of a prototype system, developed by a student, to polish crystal glasses with eight parallel grooves cut along the length of the glass. GROOVE SENSOR 4-PHASE STEPPER MOTOR CRYSTAL GLASS GROOVES POLISHING BRUSH DRIVEN BY DC MOTOR PNEUMATIC CYLINDERS MOVE BRUSH MOTOR INTO/OUT FROM THE GLASS The system is to be controlled by a microcontroller. With a glass in place, the start button is pressed to cause the cutting disk to switch on and move into the cutting position. The first groove is cut for five seconds. The cutter is then withdrawn. The stepper motor rotates the glass through 90 degrees into position for the next groove. The process continues until all four grooves have been cut. The stepper motor used by the student has a step angle of 7.5 degrees. It is controlled by means of an SAA1027 driver IC signalled from the microcontroller. Technological Studies: Systems and Control Teachers Notes (H) Outcome 3 44 Input Connection Pin 7 6 5 4 Output Connection Pneumatic Cylinder (1 = instroke, 0 = outstroke) DC Motor (1 = on, 0 = off) Stepper Direction (0 to 1 pulse = 1 step) Stepper Pulse (1 = clockwise, 0 = anticlockwise) 3 2 1 Start button (logic 1 when pressed) 0 (a) Calculate the number of steps the stepper motor must rotate to rotate the glass through 90 degrees. 90 degrees ÷ 7.5 degrees = 12 steps Technological Studies: Systems and Control Teachers Notes (H) Outcome 3 45 (b) Draw up a flow chart which shows the control sequence for the polishing process. START NO START BUTTON ? YES SWITCH MOTOR ON SET COUNTER = 4 CYLINDER IN WAIT 5 Sec. CYLINDER OUT ROTATE 90O NO ALL DONE ? YES Technological Studies: Systems and Control Teachers Notes (H) Outcome 3 46 (c) With reference to your flow chart, write a high level program in PBASIC to control the polishing process. init: let dirs = %11110000 ' make pins 4-7 outputs main: if pin0 = 1 then loop goto main ' test start switch ' else loop loop: high 6 low 5 ' motor on ' stepper direction clockwise for b1 = 1 to 4 high 7 pause 5000 low 7 for b2 = 1 to 12 high 4 low 4 next b2 next b1 ' ' ' ' ' ' start a for...next loop cylinder in wait 5 seconds cylinder out start a for...next loop 12 pulsed steps low 6 goto main ' motor off ' loop to start ' next stepper pulse ' next cut Technological Studies: Systems and Control Teachers Notes (H) Outcome 3 47 Assignment 4.12 Connect the conveyer belt model to the Stamp Controller. A single block is to be moved continuously back and forth along the conveyer belt without falling off either end. Draw a flowchart that will control the movement as described. START MOTOR FORWARD NO SWITCH 1 ON ? YES MOTOR REVERSE NO SWITCH 2 ON ? YES Write, and test, a PBASIC program for the control sequence as drawn in your flowchart. init: let dirs = %11000000 ' make pins 6-7 outputs main: let pins = %01000000 ' forward loop: if pin1 = 1 then loop2 goto loop ' wait for switch ' else loop loop2: let pins = %10000000 ' backward loop3: if pin2 = 1 then main goto loop3 ' wait for switch ' else loop Technological Studies: Systems and Control Teachers Notes (H) Outcome 3 48 Assignment 4.16 Details of a speed control unit for a dc motor are shown below. 10K 10K 2 22K 1 +5V 39K 0 -5V 0V a) Name the configuration of operational amplifier being used. Summing amplifier. b) Name the method of dc motor speed control being used. Digital to analogue conversion c) Explain clearly how the system operates. The summing amplifier adds the total of the three input signals. The three input signals can only be 5V or 0V in this example. As the input resistors are weighted the output voltage is a ratio of the digital inputs.. In this example the output voltage is equal to Vo = -5 (Pin 2 x (10K/10K) + Pin 1 x (10K/22K) + Pin 0 x (10K/39K)) = -5 (Pin 2 + 0.5 (Pin 1) + 0.25 (Pin0)) where the pin value is 0 or 1. Note this example will not operate correctly at high values as the op-amp cannot source an output greater than V+ (5V in this case) d) State what the output voltage supplied to the motor will be when the following values are applied to the input pins. i) 1 Vo = -5(0.25) = -1.25V ii) 3 Vo = -5(0.5+0.25) = -3.75V iii) 4 Vo = -5(1) = -5V Technological Studies: Systems and Control Teachers Notes (H) Outcome 3 49 Assignment 4.17 A small dc motor, which is used to drive a model conveyer belt, is to be controlled by a microcontroller. The microcontroller gives out a 6V signal when an output bit is switched to logic 1. The speed of the motor must be varied according to the loads which are being carried. for convenience, the speed is to be reduced using pulse-width modulated control. Output connections to the microcontroller are as follows. Input Connection Pin 7 6 5 4 3 2 1 0 Output Connection Motor Anticlockwise Motor Clockwise Develop a short PBASIC procedure which could be used to drive the motor is a clockwise direction with a mark-to-space ratio of 2:1. symbol mark = 2 symbol space = 1 ' define mark = 2 ' define space = 1 init: let dirs = %00110000 ' make pins 4-5 outputs main: high 5 pause mark low 5 pause space goto main ' ' ' ' ' motor on wait mark time motor off wait space time loop Explain how you could alter the procedure to make the motor rotate in an anticlockwise direction, with the same mark-to-space ratio. Replace the high/low 4 commands with high/low 5 Technological Studies: Systems and Control Teachers Notes (H) Outcome 3 50 TECHNOLOGICAL STUDIES HIGHER SYSTEMS AND CONTROL TEACHER/LECTURER NOTES AND SOLUTIONS TO ASSIGNMENTS OUTCOME 4 Technological Studies: Systems and Control Teachers Notes (H) Outcome 4 1 Technological Studies: Systems and Control Teachers Notes (H) Outcome 4 2 Assignment 1.1 A microcontroller based monitoring system is used to monitor sound signals over a period of time. It is found that the maximum voltage generated from the sound signals is 6V. However the maximum voltage that may be fed into the microcontroller system is 1.8V. a) Draw a circuit diagram of a suitable signal conditioning system, based on operational amplifiers, which will allow the signals to be monitored without damaging the microcontroller system. Indicate the values of any components used in your circuit. Input Signal = 6V Required output signal = 1.8V Therefore Gain = output / input = 1.8 / 6 = 0.3 R2 6K6 Vout Vin R1 10K 0V b) If the sound signal is fed into the microcontroller through an ADC which has a voltage reference of 1.8V, write down the 8-bit binary pattern you would expect from the ADC when the sound signal generates a voltage of 4.8V. Clearly identify the least significant bit (LSB). 4.8V x 0.3 = 1.44V 1.8V gives a reading of 255 1.44V gives a reading of 1.44/1.8 * 255 = 204 204 = %11001100 (<LSB) Technological Studies: Systems and Control Teachers Notes (H) Outcome 4 3 Assignment 1.2 The signal from a temperature sensing sub-system is processed by an ADC before being read by a microcontroller. The ADC has a voltage reference of 1.8 volts which produces a binary word of %11111111 a) What is an ADC and why is it required before processing by the microcontroller? An Analogue-to-Digital Converter (ADC) is a device which can convert analogue quantities into digital signals. Temperature is an analogue quantity, but the microcontroller only operates with digital signals. Therefore the ADC is require to process the analogue temperature reading into a digital signal. b) Calculate the binary word produced by the ADC at 200ºC, if the voltage signal from the temperature sensing sub-system at this temperature is 1.2V. Clearly identify the least significant bit (LSB). 1.8V gives a reading of 255 1.2V gives a reading of 1.2/1.8 * 255 = 170 204 = %10101010 (<LSB) Technological Studies: Systems and Control Teachers Notes (H) Outcome 4 4 Assignment 1.5 TEMPERATURE PROBE SERIAL ADC MODULE STAMP CONTROLLER DATALOGGER MODULE SERIAL LCD MODULE Build the circuit as shown in the diagram above. a) Write a high level program in PBASIC that will continually monitor and display the temperature of the water on the LCD. main: gosub adcread 'Get the ADC reading serout S_OUT,T2400,(254,128) 'Print on LCD line 1 serout S_OUT,T2400,("Temp = ",#data," ") pause 1000 'Wait 1 second goto main 'Loop b)The temperature of the water should not be allowed to drop below 45 degrees Celsius. Modify your PBASIC program so that the immersion heater (connected to pin3) is automatically switched on when the water cools below the critical temperature. main: gosub adcread 'Get the ADC reading serout S_OUT,T2400,(254,128) 'Print on LCD line 1 serout S_OUT,T2400,("Temp = ",#data," ") if data < 45 then doon low 3 goto main doon: high 3 goto main 'Jump if temp low 'Heater off 'Loop 'Heater on 'Loop Technological Studies: Systems and Control Teachers Notes (H) Outcome 4 5 Assignment 1.6 A local council has issued standard size "wheely bins" to all households so that the dust carts can empty them automatically. The dustman simply clamps the wheely bin onto a platform and then presses a switch. the platform then rotates through 130 degrees as shown in the diagram. The platform stays in the emptying position for 5 seconds and then returns to its original position, where it triggers a micro switch on the rear of the dustcart. Platform movement is controlled by a dc motor and gearbox. 130 0 STARTSWITCH WHEELY BIN PLATFORM MICRO-SWITCH The process is controlled by a microcontroller. the angle of rotation of the platform is sensed by a rotary potentiometer. The potentiometer is capable of rotating 360 degrees from the starting position, and rotation between 0 and 360 degrees sends a proportional reading of between 0 and 255 via an ADC module connected to the microcontroller. Technological Studies: Systems and Control Teachers Notes (H) Outcome 4 6 Input Connection Micro-switch Start switch Pin 7 6 5 4 3 2 1 0 Output Connection Motor anti-clockwise (Lowers bin) Motor clockwise (Raises bin) (a) Calculate the analogue reading when the platform is 130 degrees from the original position. 360 degrees gives a reading of 255 Therefore 130 degrees gives a reading of 130/360 * 255 = 92 Technological Studies: Systems and Control Teachers Notes (H) Outcome 4 7 (b) Draw up a flow chart which shows the control sequence for the emptying of the wheely bin. START NO START SWITCH YES MOTOR CLOCKWISE NO ANGLE O =130 YES MOTOR OFF WAIT 5 Sec. MOTOR ANTICLOCKWISE NO ANGLE =0O YES MOTOR OFF Technological Studies: Systems and Control Teachers Notes (H) Outcome 4 8 (c) With reference to your flow chart, write a high level program in PBASIC to control sequence for the emptying of the wheely bin. Assume use of a pre-written time delay sub-procedure called 'adcread' which will return the analogue reading in a variable called 'data'. main: if pin0 = 1 then loop goto main 'Test start switch 'Else loop loop: high 4 call adread if data > 92 then up goto loop 'Lift 'Read 'Test 'Else up: low 4 wait 4000 high 5 'Motor off 'wait for seconds 'Lower bin lp2: call adread if data = 0 then main goto lp2 'Read analogue value 'Test for down 'Else continue bin analogue value for top continue (Note that the microswitch could also be used to detect the lower position) Technological Studies: Systems and Control Teachers Notes (H) Outcome 4 9 Assignment 2.1 Suggest a suitable sampling frequency for each of the following monitoring systems. In each case clearly explain why your sample frequency is appropriate. a) Monitoring the temperature in a greenhouse. Once every 10 minutes Temperature will not change rapidly in this environment and so a slow sample rate will do. b) Monitoring the speed of an aeroplane. Once every second The speed could change rapidly. but the pilot would not check he instruments any quicker than once per second. c) Monitoring the heart rate of a premature baby in an incubator. Ten times per second A baby’s heart rate can beat up to 200 times per minute and so a high sample rate is required. d) Monitoring the temperature in a restaurant cold store. Once every 10 minutes Temperature will not change rapidly in this environment and so a slow sample rate will do. Technological Studies: Systems and Control Teachers Notes (H) Outcome 4 10 Assignment 2.6 A datalogging system is to be used to record the temperature and light level in a greenhouse over a period of 1 day. TEMPERATURE PROBE MULTIPLEXER SERIAL ADC MODULE STAMP CONTROLLER DATALOGGER MODULE LIGHT SENSOR Build the apparatus as shown in the diagram above. a) Explain why it is necessary to use a multiplexer in this situation. Two analogue sensors are being used, and as there is only one ADC it is necessary to use the multiplexer to 'switch' the ADC between the two analogue sensors. b) Write a 'test' program in PBASIC that will record the temperature and light levels over a 5 minute period. Select a sampling frequency e.g. 5 seconds Therefore number of readings = 5 mins * 12 readings = 60 main: for b10 = 1 to 60 ' Start a for...next loop low ADC_MPX let page = 0 let address = b10 gosub adcread gosub eewrite ' ' ' ' ' select sensor 1 set EEPROM page set EEPROM address get analogue reading write to EEPROM high ADC_MPX let page = 1 let address = b10 gosub adcread gosub eewrite ' ' ' ' ' select sensor 2 set EEPROM page set EEPROM address get analogue reading write to EEPROM pause 5000 next b10 ' wait 5 seconds ' next loop end Technological Studies: Systems and Control Teachers Notes (H) Outcome 4 11 c) Use the datalink program to retrieve the data from the datalogger module. Using a spreadsheet draw a line graph to show the data recorded. Datalogging Experiment 200 Value 150 Series1 100 Series2 50 46 41 36 31 26 21 16 11 6 1 0 Reading Technological Studies: Systems and Control Teachers Notes (H) Outcome 4 12 Assignment 2.7 A pet shop owner requires a data logging system that will allow him to monitor the temperature of one of the large display aquariums in the shop. The datalogger should record the temperature every ten minutes over a 24 hour period. At the end of the period the owner wants to be able to print out a table of results from the datalogger without having to use a host computer to analyse the data. (a) Draw a block diagram of the system. TEMPERATURE PROBE SERIAL ADC MODULE STAMP CONTROLLER DATALOGGER MODULE SERIAL PRINTER MODULE Technological Studies: Systems and Control Teachers Notes (H) Outcome 4 PRINTER 13 (b) Draw up a flow chart which shows the control sequence for the datalogging experiment. START SET COUNTER=144 STORE TEMP. WAIT 10 Min. ALL DONE? NO YES SWITCH PUSHED? NO YES PRINT DATA Technological Studies: Systems and Control Teachers Notes (H) Outcome 4 14 (c) With reference to your flow chart, write a high level program in PBASIC to perform the experiment. 24 hours with 10 minute sample rate = 24 * 6 = 144 readings main: for b10 = 1 to 144 let page = 0 let address = b10 gosub adcread gosub eewrite for b11 = 1 to 10 pause 60000 next b11 next b10 loop: if pin3 = 1 then print goto loop ' ' ' ' ' Start a for...next loop set EEPROM page set EEPROM address get analogue reading write to EEPROM ' 10 loops of 1 minute ' wait 1 minute ' next loop ' next loop ' wait for switch ' else loop print: serout S_OUT,T2400,(STX) ' Start printing command serout S_OUT,T2400,(TAB,"Reading",TAB,TAB,"Temp") serout S_OUT,T2400,(CR,LF,LF) 'Next line. for b10 = 1 to 144 'Start a for..next loop. let page = 0 'Set page let address = b10 'Set address gosub eeread 'Read data from EEPROM. serout S_OUT,T2400,(TAB,#address,TAB,TAB,#data) serout S_OUT,T2400,(CR,LF) 'Next line next b10 'Next loop. serout S_OUT,T2400,(FF) serout S_OUT,T2400,(ETX) goto loop 'Print form-feed 'Send printer module to sleep Technological Studies: Systems and Control Teachers Notes (H) Outcome 4 15 Assignment 2.8 In a maternity hospital premature babies are cared for in incubators. The temperature inside each incubator is continuously monitored. A microcontroller based datalogging system is used to monitor the temperature from four separate incubators by means of a 4-bit multiplexer. a) With the aid of sketches, explain the function of a 4-bit multiplexer and suggest why it is useful in this application. CHANNEL 0 00 CHANNEL 1 01 CHANNEL 2 10 CHANNEL 3 11 ADC A 4-bit multiplexer can be used to switch between 16 analogue sensors. In this situation only four temperature sensors are used, so a 2-bit multiplexer (as shown in the diagram) would be sufficient. However a 4-bit multiplexer allows space in the system to add more sensors at a later date if required. The multiplexer allows all the incubators to be monitored from a single ADC at one central position. b) Suggest a suitable way of presenting the output from the datalogging system for use by the nursing staff. Explain your answer. A suitable method of presenting the output would be on an LCD display. This situation does not to record the temperatures, but does need to set off an alarm if the temperature goes too high or too low in any of the incubators. An LCD would be a simple visual way that the nursing staff could monitor the temperature. Technological Studies: Systems and Control Teachers Notes (H) Outcome 4 16