ExamBank Scot · Higher Engineering Science question bank · All Higher Engineering Science questions

Higher Engineering Science 2019 Question 4

2 marks · Programmable control

An air pressure supply system in a car garage will be operated by programmable control. The system must meet the following specification. • The system is activated when a user presses a start button • The pumping system then switches on • The air pressure is monitored by an analogue sensor • When the air pressure rises above a set level (100), the pump switches off • A light must flash five times to indicate that the air pressure has reached the set level • The system then resets, ready for the next user Input Pin Output 7 Pump 6 Light Start button 1 Pressure sensor 0 Part of the same test program is shown below in PBASIC and ARDUINO code. int Pressure = 0; int Pressuresensor = 0; int Pump = 7; int Light = 6; int Startbutton = 1; let dirs = %11110000 symbol pressure = b4 main: if pin1 = 1 then main void setup(){ pinMode (Pressuresensor, INPUT); pinMode (Startbutton, INPUT); pinMode (Pump, OUTPUT); pinMode (Light, OUTPUT); } high 7 check: readadc 0, pressure if pressure ≤ 200 then check void loop(){ low 7 if (Startbutton == LOW) { digitalWrite(Pump, HIGH); for b3 = 0 to 5 } else { high 6 pause 200 low 6 pause 200 digitalWrite(Pump, LOW); } Pressure = analogRead (Pressuresensor); if (Pressure <= 200){ next b3 digitalWrite (Pump, LOW); } for(int counter=0; counter<=5; goto main counter=counter+1) {digitalWrite(Light, HIGH); delay(200); digitalWrite(Light, LOW); delay(200); } } There are three faults in the program shown opposite. Identify the lines where the faults are and write the corrected code. Complete for either PBASIC or ARDUINO. The first fault is shown below. Correction 1 PBASIC main: if pin1 = 0 then main Correction 1 ARDUINO if (Startbutton == HIGH) { Correction 2 Correction 3

Marking scheme

Correction 2 (PBASIC) check: if pressure ≤ 100 then check (ARDUINO) if (Pressure > 100){ Correction 3 (PBASIC) for b3 = 1 to 5 (ARDUINO) {for(int counter=1; counter<=5; 1 mark for identification of less than or equal to 100. 1 mark for identification of correct number of loops. Number should show a range with a difference of 5, eg 0-4, 8-12 etc. Exact syntax not required. Must be two faults performing different functions but can answer one from arduino and one from PBasic.

Previous question: Higher Engineering Science 2019 Question 3

Next question: Higher Engineering Science 2019 Question 5