Monitoring & Control Systems
+ Bit Manipulation
1. Monitoring vs Control System
Q: What is the difference between a monitoring and a control system? (learn these 3 points — they are the mark scheme)
- Monitoring only gathers information, but a control system also performs action.
- Output in a control system can affect the input.
- There is no feedback in a monitoring system, but a control system relies on feedback.
Why automate? Old way: the farmer walked out and checked soil quality & water level himself. Now sensors do it and the system can even act by itself — no human needs to be physically present.
Farm: water-level sensor only tells you the level, you walk over and add water = monitoring. If level < 50 L the sprinkler switches on automatically = control. Dam: level too high → gates open automatically = control; only telling you the level = monitoring.
Matching exercise from class (Control or Monitoring?)
| System | Type | Reason (sir’s words) |
|---|---|---|
| Car speed display | Monitoring | only displays / shows the speed |
| Aeroplane autopilot | Control | an action is being performed (steers) based on readings |
| Roller coaster | Control | speed, weight etc. checked and then acted on (brakes / speed) |
| Recording the rainfall | Monitoring | only recording / measuring — nothing done with it |
| Robot loading | Control | “loading” is an action (a verb) caused by the readings |
2. Sensors & Actuators
Sensors
- A physical quantity (temperature, speed, moisture, oxygen level, pH, pressure…) is measured by sensors.
- Sensor = hardware that measures; the name tells you the job (sound sensor → sound).
- Sensors give analogue data (physical waves / values) and only act like an input — on their own they do nothing.
- They use an ADC = Analogue to Digital Converter.
Actuators
- An actuator is a component of a machine that is responsible for moving and controlling a mechanism.
- It receives a signal from the processor and adjusts a controlling device (switches it on / off, like a motor).
- Sometimes uses a DAC = Digital to Analogue Converter (e.g. to sound an alarm) — not always; a motor can run on the digital signal.
3. Types of Sensors & Their Uses
| Sensor | What it does | Example use |
|---|---|---|
| Temperature | measures & records temperature in a particular surrounding | greenhouse, zoo, storage, homes |
| Pressure | detects pressure and measures it (force on a particular area) | lifts; factories (filling packages) — not pressure cooker! |
| Infra-red | detects motion | alarm / security system, automatic doors |
| Sound | detects sound | hotels — footsteps turn lights on; new-born baby’s room |
| pH | measures the pH value (acidity of soil) | farming / greenhouse |
| Moisture | measures the level of moisture | in soil |
| Humidity | measures the level of moisture in air | greenhouse air, weather |
| Precipitation | measures the amount of rainfall (in mm, not counting drops) | weather station |
Also mentioned: water-level sensor (dam, farm tank), oxygen-level sensor, speed, TV-remote receiver (the little red window = infra-red). Moisture ≠ humidity: moisture → soil, humidity → air.
4. Hardware Devices in a Monitoring / Control System
Question style: “Name and describe the hardware devices used…”. Write the device + its job (+ example).
| Device | Job |
|---|---|
| ADC | to convert analogue signals from a sensor to a digital value that can be recorded / understood (0s and 1s) |
| Actuator | e.g. turns the sprinkler on or off |
| Sensors | measure a physical quantity |
| Processor | processes the value recorded by the sensor — e.g. checks whether the water level has reached the range; also stores values, drives a warning or display |
| Cable | to transfer signals between the devices |
| Visible warning device | (lights, alarm) to give warnings to humans |
Is the processor control or monitoring? Both! It measures, stores, compares, runs warning systems or displays. You may add extra detail with an example (water-level range reached or not) — examiners accept it.
5. “How will a monitoring & control system help achieve …?”
The examiner gives any scenario (soil management, water level, cake / milk factory, swimming pool, lift…) and there is no fixed mark scheme — you must construct your own answer by judging the scenario. Sir gave a template of points; don’t copy it word-for-word or memorise it — adapt it to the scenario, with as much detail as you can.
- Name of sensors used — list all the sensors needed (e.g. lift → pressure sensor).
- What will those sensors do — say what each one measures, for every sensor you listed.
- These sensors will read the value and send it to the ADC (not the processor).
- ADC will convert the analogue signal into digital signals (so the computer understands).
- ADC sends the data to the microprocessor (processor also fine).
- If monitoring system: add one line — readings will be displayed. Done!
- If control system: microprocessor compares the values with the range provided (e.g. water must not go below 50 L).
- Microprocessor sends signal to actuator.
- Purpose of the actuator (e.g. switches on the sprinkler / opens the gate to lower the water level).
- If more tasks needed → send signal to another actuator and give its purpose too (repeat for every actuator).
6. Concept of Feedback
Don’t be confused by the everyday word (a customer review). Feedback is given so you can improve: if I only wanted to be told and never change anything, that isn’t feedback. That’s exactly why there is no feedback in a monitoring system — it only watches; a control system relies on it because its output alters the next input.
Q: What is the importance of feedback?
- To ensure that the system operates within the given criteria (e.g. water level must stay ≤ 50 L — sensor data tells it if it’s OK or an action is needed).
- By enabling system output to affect subsequent system inputs — i.e. the upcoming instructions depend on feedback (sir: if you tell me “don’t use pink”, my next slide changes).
- Thus enabling the system to automatically adjust conditions.
Q: What is the use of feedback?
- Sensor will continually measure ____ (the quantity in the scenario, e.g. temperature).
- Readings are sent to the processor and it compares the reading with the preset value (a value already stored in the processor, e.g. 50 L).
- If readings are out of range then the actuator will do ____ (e.g. switch on the AC / a heater to maintain temperature).
- Feedback will ensure that the readings remain in range.
7. Bytes & Flags — the Museum Question
Paper 3 style question that shows how each bit of a byte can act as a flag. Sir’s warning: make sure data-representation (denary ↔ binary) is solid — then it is easy.
Temperature recorded in 7 rooms. Each recording = two successive bytes:
- Byte 1 = temperature reading as an unsigned integer (do NOT use 2’s complement) — “unsigned” = positive number only.
- Byte 2: room shown by setting one bit to 1 (bits 7→1 ↔ room 7→1; e.g. room 7 = bit 7 set). Bit 0 = flag: starts at 0, becomes 1 when the reading has been processed.
Words: set = make the bit 1; clear = make it 0. A flag has two states (on/off, red/green, true/false). “Processed” isn’t defined (stored? displayed? alarm?) — you only need: flag = 1 ⇒ processed.
Analyse the data in the two bytes. One mark each:
- The temperature reading is 179
- The reading is of room number 5 (only bit 5 is 1)
- and the reading has been processed (flag, bit 0 = 1)
Reading 238 from room 4, not yet processed — fill both bytes.
8. Binary Shifting
Binary = the bits in a byte. Shifting = moving all the bits left or right inside the register (we work on one byte). Three types — all on the syllabus:
① Logical shifting
LOGICAL: bits shifted out of the register are dropped (“bit drop”) and the empty places are replaced by zeros.
Method (fast): shift n places = chop n bits off that side, copy the rest as it is, then add n zeros on the other side.
Assembly language: LSL and LSR
| Opcode | Operand | Explanation |
|---|---|---|
| LSL | #n | Bits in ACC are shifted logically n places to the left (zeros enter on the right). |
| LSR | #n | Bits in ACC are shifted logically n places to the right (zeros enter on the left). |
“Once” → #1, “twice” → #2, “thrice” → #3. e.g. logical shift left once = LSL #1, right twice = LSR #2.
ACC = 00110101. Contents after LSL #2?
Drop the 2 left bits (00), copy 110101, add 00 on the right.
Answer: 1 1 0 1 0 1 0 0
ACC = 00110101. What does LSR #3 do mathematically?
Sir skipped this part (board left blank) and said to learn it: shifting left = multiplication, shifting right = division (values get bigger / smaller).
LSR #3 = integer division by 2³ = 8 (LSL #n = ×2n, LSR #n = ÷2n)
② Cyclic shifting
Cyclic: no bits are lost during a shift. Bits shifted out of one end of the register are inserted at the other end of the register.
Syllabus note: the syllabus doesn’t print the assembly codes, but you must know what cyclic and arithmetic shifts are — so learn them (codes CSL #n, CSR #n, ASL #n, ASR #n).
③ Arithmetic shifting
Arithmetic: the sign bit stays the same and the rest is shifted same as logical shifting (bits dropped, zeros come in). Sign bit = the first (left-most) bit: 1 = negative, 0 = positive (Chapter 1, 2’s complement).
| Shift | Bits shifted out | Empty places | Sign bit |
|---|---|---|---|
| Logical (LSL / LSR) | lost (dropped) | zeros | not special |
| Cyclic (CSL / CSR) | re-inserted at other end | the bits that left | not special |
| Arithmetic (ASL / ASR) | lost (dropped) | zeros | stays as it is |
9. Bit Manipulation in a Monitoring / Control System
In a monitoring and control system, each bit in a register or memory location can be used as a flag and would need to be tested (compared), set (made 1) or cleared (made 0) separately.
| I want to… | use | why (sir’s basic guide — not a rigid rule) |
|---|---|---|
| check / test if a bit has been set | AND | AND with a mask, then compare (CMP) |
| set a bit (make it 1) | OR | OR can only ever push a bit towards 1 |
| clear a bit that has been set (make 0) | XOR | same bits → 0 (also inverts) |
Assembly language notation
- Binary: capital B then the bits — e.g. B10000001
- Denary: hash # — e.g. #32
- Hexadecimal: ampersand & — e.g. &F8 = 1111 1000 (two groups of 4 bits: F = 1111, 8 = 1000)
- No # before a number = it’s an address (memory location), e.g. OR 101 uses the byte stored at address 101.
Bit numbers: 0 1 2 … 7 from the right. Weights: bit 0 = 1, bit 1 = 2, bit 2 = 4, bit 3 = 8, bit 4 = 16, bit 5 = 32, bit 6 = 64, bit 7 = 128. Byte = 8 bits (don’t mix up byte and bit — “byte 2” vs “bit 2”).
10. Bitwise OR — used to SET a bit
| A | B | A OR B |
|---|---|---|
| 0 | 0 | 0 |
| 0 | 1 | 1 |
| 1 | 0 | 1 |
| 1 | 1 | 1 |
logic: any 1 → 1
| Opcode | Operand | Explanation |
|---|---|---|
| OR | n | Bitwise OR operation of the contents of ACC with the operand |
operand n can be B… binary, # denary, & hex, or an address.
How it works: “OR #64” means: change 64 to binary (put 1 under the 64-place, rest 0 → 01000000), then OR it bit by bit with ACC.
Set “alarm 3” without changing other bits
Byte stored at memory location 200: bit 0 = flag, bit 1 = A1 (alarm 1), bit 2 = A2, bit 3 = A3. Question: set Alarm 3 to ON without changing the other bits.
- Write 1 below alarm 3 and the rest should be 0 → new binary value 00001000 = #8 (1,2,4,8).
- OR that new binary value with the byte.
Q: write it in assembly language (load → change → store back):
Both A3 and A2 on? Put 1 under both → 00001100 = OR #12. If one of them is already 1 that’s fine — it simply stays 1. (Careful: bit 4 is #16, not #8 — count 1, 2, 4, 8, 16.)
A hardware device in each tank is on/off depending on a bit in memory location 6753. If bit 4 = 1 the device in fish tank 4 is on. Write assembly instructions to set bit 4 of location 6753 to 1 without changing any other bits.
Bit 4 → 1,2,4,8,16 → mask 00010000. “Set” ⇒ OR (whenever you want to set a bit we use OR).
Reading of −2 from fish tank 4; “complete the bytes to show the values after it has been processed”.
On the board sir only wrote the bit-4 mask 00010000 → OR #16 and left the boxes empty. Working (mine, assuming the same two-byte layout as the museum question): negative number ⇒ 2’s complement (2 = 00000010 → flip 11111101 → +1 → 11111110); tank 4 ⇒ bit 4 = 1; processed ⇒ flag bit 0 = 1 ⇒ Byte 2 = 00010001.
11. Bitwise AND — used to CHECK (test) a bit
| A | B | A AND B |
|---|---|---|
| 0 | 0 | 0 |
| 0 | 1 | 0 |
| 1 | 0 | 0 |
| 1 | 1 | 1 |
logic: any 0 → 0
| Opcode | Operand | Explanation |
|---|---|---|
| AND | n | Bitwise AND operation of the contents of ACC with the operand |
Checking a bit — 3 steps
- Put 1 below the bit you want to check (rest 0) → new binary value.
- AND that new value with the value in ACC.
- Compare (CMP) with the new value you created.
Use of AND in monitoring & control: AND is used to check if the bit was set (1) or 0; if you want to check, the AND is followed by a CMP instruction (usually, not always).
Q: Write this in assembly language code:
Q: “but I can see it’s 1 — why check?” You can, the computer can’t. When the byte is given empty / unknown you test it this way.
(i) ACC holds byte 1 from location 106 (LDD 106). Write the instruction to check whether the reading in byte 2 came from location 4.
Location 4 ⇒ bit 4 ⇒ 16. “Check” ⇒ AND. Only one line was asked so one instruction is enough; if the question gave another line you would also compare (CMP #16). Marks: opcode AND, the #, the number 16, whole instruction correct.
(i) AND #16
(ii) Set the flag (bit 0) of the byte in the accumulator to 1. Bit 0 → 1 (weight 1); “set” ⇒ OR.
(ii) OR #1
Address 300 holds an unsigned binary integer (bits 7→0) = 0 1 1 0 0 1 1 0.
(i) Denary value: add the weights where there is a 1:
(ii) Test if bit number 2 in address 300 is 1 → bit 2 = 4 → AND #4 (then compare for the result).
Set bits 4, 5, 6, 7 to 0, but keep bits 0–3 with their existing values.
Think as if you don’t know any value — your instruction must work whether each bit is 0 or 1.
- OR ✗ — OR can never make a 1 into a 0 (even OR with 0 keeps a 1).
- XOR ✗ — it flips bits: XOR with 1 turns a 0 into a 1; XOR with 0 leaves a 1 as 1. Doesn’t always give 0.
- AND ✓ — AND with 0 always gives 0 (whatever the bit was); AND with 1 leaves a bit unchanged.
Answer: AND #15 (1,1,1,1 under bits 0–3 keeps them; 0,0,0,0 under bits 4–7 clears them; 1+2+4+8 = 15.)
12. Bitwise XOR — used to CLEAR (or invert) bits
| A | B | A XOR B |
|---|---|---|
| 0 | 0 | 0 |
| 0 | 1 | 1 |
| 1 | 0 | 1 |
| 1 | 1 | 0 |
logic: same → 0, different → 1 (not binary addition!)
| Opcode | Operand | Explanation |
|---|---|---|
| XOR | n | Bitwise XOR operation of the contents of ACC with the operand |
Note: used to clear or inverse the values (clear = make 0, set = make 1).
Clearing a bit — “Clear bit 5”
- Put 1 below the bit you want to clear (rest 0) → 00100000 = #32.
- Apply XOR with that new value.
Sir’s guide (OR set · AND check · XOR clear) is a helping rule when you’re stuck — think about each question’s logic.
13. Past-Paper Practice
Instruction set used in these questions (from the paper): LDM #n · LDD addr · STO addr · INC · CMP · JPN · JMP · IN · OUT · END · AND / OR / XOR #n or address · LSL / LSR #n — # = denary number, B = binary, no # = an address.
| Address | Data (main memory) |
|---|---|
| 100 | 00001111 |
| 101 | 11110000 |
| 102 | 01010101 |
| 103 | 11111111 |
| 104 | 00000000 |
Write answers with a capital B (it’s a binary value).
| Current ACC | Instruction | Working | New ACC |
|---|---|---|---|
| 11111111 | OR 101 | 101 is an address (no #): value 11110000; OR → any 1 gives 1 | B11111111 |
| 00000000 | XOR #15 | 15 = 00001111 (8+4+2+1); different → 1, same → 0 | B00001111 |
| 10101010 | LSR #2 | drop last 2 bits (10), add 00 on the left: 00 101010 | B00101010 |
| 01010101 | AND 104 | 104 is an address: all 0s; AND with 0 → 0 | B00000000 |
(Row 3: last digit of ACC is smudged on the board; 10101010 matches the answer.)
Full marks 4/4.
ACC = 01100101. Write the bit-manipulation instruction (opcode + operand) that changes it to:
(a) 11111111 → every bit must become 1 ⇒ use OR with all 1s: OR #255 (also accepted: OR #154 or XOR #154 — 154 = 10011010 fills in exactly the 0-bits)
(b) 10011010 → this is every bit flipped (01100101 → 10011010) ⇒ XOR #255 (XOR with all 1s inverts the byte)
Register before = 01101101 each time. Table of instructions: AND #n, XOR #n, OR #n, LSL #n, LSR #n.
| Instruction | Working | Register after |
|---|---|---|
| AND #2 | 2 = 00000010; only bit 1 can survive and bit 1 of the register is 0 | 00000000 |
| OR #8 | 8 = 00001000; bit 3 is already 1 so nothing changes | 01101101 |
| LSL #4 | drop 0110, keep 1101, add 0000 on the right | 11010000 |
Answers worked by me (not on the board) — please check by doing them yourself first.
14. Quick Recap — Full Chapter Cheat-Sheet
- Monitoring: only gathers/shows info, no action, no feedback. Control: also performs action, output affects input, relies on feedback.
- Alarm / light / display / recording = monitoring. Action that changes the environment (sprinkler, gates, autopilot, robot loading) = control.
- Chain: Sensor → ADC → Processor (compare with range) → (DAC) → Actuator; sensor sends to ADC, not straight to the processor.
- Actuator = the thing that switches the device (motor), not the device. ADC analogue→digital, DAC digital→analogue.
- Sensors: temperature · pressure · infra-red (motion) · sound · pH · moisture (soil) · humidity (air) · precipitation (rainfall). Always give an example.
- Hardware: ADC, actuator, sensors, processor, cable (transfer signals), visible warning device (warn humans).
- Feedback = sensor data analysed / used as input. Importance: operate within criteria · output affects next input (“upcoming instruction”) · auto-adjust. Use: sensor measures ___ → processor compares with preset → actuator does ___ if out of range → readings stay in range.
- Bit numbers 0–7 from the right; weights 1·2·4·8·16·32·64·128. Set = 1, clear = 0. Flag bit = on/off (bit 0 = “processed”). “Unsigned” ⇒ no 2’s complement.
- Shifts: logical (drop, zeros in) · cyclic (nothing lost, wraps round) · arithmetic (sign bit stays, rest like logical). LSL #n = ×2n, LSR #n = ÷2n.
- Notation: B10000001 binary · #32 denary · &F8 hex · no symbol = address.
| Job | Gate | Recipe (one 1 under the bit, rest 0 → mask) | Code example |
|---|---|---|---|
| SET a bit (→1) | OR | OR with mask; other bits untouched | LDD 200 · OR #8 · STO 200 |
| TEST a bit | AND | AND with mask, then CMP with the mask: equal ⇒ bit was 1 | LDD 423 · AND #16 · CMP #16 |
| CLEAR bits (→0) | AND | AND with 0s under bits to clear, 1s elsewhere | AND #15 (clear bits 4–7) |
| CLEAR a set bit / INVERT | XOR | XOR with mask flips that bit; XOR #255 inverts all | XOR #32 · XOR #255 |
| A | B | OR | AND | XOR |
|---|---|---|---|---|
| 0 | 0 | 0 | 0 | 0 |
| 0 | 1 | 1 | 0 | 1 |
| 1 | 0 | 1 | 0 | 1 |
| 1 | 1 | 1 | 1 | 0 |