📘 CodingMarble Learn

Programming and Mathematical Processing of Industrial Data

A program takes data in (input), does maths on it (process) and shows a result (output). An algorithm is the list of steps. In industry, programs also control machines: they read a sensor, compare it with a set value and switch a device ON or OFF, again and again.

🎬 Step-by-step story

  1. Every program has three parts: input, process and output. Look at the three stations.
  2. Input: a sensor measures the temperature five times. Each blue bar is one reading.
  3. Process: add the five readings (115) and divide by 5. The bars level out to 23. This is the average.
  4. Output: the result 23 °C is shown on the screen, with its unit.
  5. Control: if the temperature is below the set value, the heater turns ON. Otherwise it turns OFF. The loop repeats.
  6. Free play: change the set value and the temperature. Guess ON or OFF, then check.

Tip: drag the 3D scene to turn it. Use two fingers to zoom.

🤔 Common doubts, cleared

What are the three parts of a program?

Input (data in), process (maths and decisions) and output (result out). See the three stations.

Where does input data come from?

From keyboards, files and sensors. Here a sensor gives five readings.

Why does averaging make the bars the same height?

The average is the height every bar would have if the total were shared equally.

Why must the unit be shown in the output?

23 alone is unclear. 23 °C tells the user what it means.

Why is the control program a loop?

The temperature keeps changing, so the program must read it again and again. Watch the heater switch.

When does the heater turn ON?

Only when the temperature is below the set value. Move the sliders to see.

Algorithms and programming

An algorithm is a list of clear steps that solves a problem. A program is an algorithm written so that a computer can run it.

Good steps are in order, one idea each, and they end. You can draw them as a flowchart: a box for an action, a diamond for a yes/no question, and arrows between them.

There are only three building blocks. Sequence: do steps one after another. Selection: choose with if / else. Repetition: repeat with a loop. Every industrial program is made from these three.

Example algorithm: average of readings. 1) Set sum to 0. 2) For each reading, add it to the sum. 3) Divide the sum by the number of readings. 4) Show the answer.

Data input and output

Input is data going into the program. It can come from a keyboard, a file, or a sensor (temperature, pressure, speed). Output is what comes out: text on a screen, a printed report, a saved file, or a signal that switches a motor or a lamp.

Always keep the unit with a number (23 °C, not just 23). Always check the input: a temperature of 900 °C in a room is surely a sensor fault. Reject or flag it.

Data is stored in variables. A group of similar readings is stored in a list (also called an array): readings = [20, 26, 22, 28, 19].

Mathematical processing

Processing means doing maths on data to get something useful. Common jobs: sum, average (mean), maximum and minimum, unit conversion and scaling.

Average = sum ÷ number of readings. Unit conversion: °F = °C × 9/5 + 32. Scaling: a sensor gives 0 to 5 V for 0 to 100 °C, so temperature = voltage × 20.

Machines count in tiny steps, so answers may carry small rounding errors. Round only at the end, and show a sensible number of digits.

Control programming

A control program keeps a machine in the state we want. It runs a loop: read the sensor, compare with the set value, act on a device, then repeat. This is feedback: the result of the action is read again.

ON/OFF control: if temperature < set value then heater ON, else heater OFF. Simple and cheap, used in irons, geysers and fridges.

Real systems add safety: a maximum limit that always switches the heater OFF, and a small gap (hysteresis) so the relay does not click ON and OFF every second.

Try it: a thermostat on paper

Write the geyser rule on paper: set value 45 °C. Pick a temperature, say 38 °C, 45 °C and 52 °C. For each, write heater ON or OFF. Then use the slider in the 3D and check your three answers.

Key formulas and definitions

Worked examples

1. Readings are 12, 15, 18 and 15. Find the average.

Sum = 12 + 15 + 18 + 15 = 60. Count = 4. Average = 60 ÷ 4 = 15.

2. A sensor gives 0 to 5 V for 0 to 100 °C. The reading is 2.5 V. Find the temperature.

Each volt is 100 ÷ 5 = 20 °C. Temperature = 2.5 × 20 = 50 °C.

3. Convert 30 °C to °F.

°F = 30 × 9/5 + 32 = 54 + 32 = 86 °F.

4. A furnace has set value 800 °C. It now reads 780 °C. What does the program do? And at 820 °C?

At 780 °C: 780 < 800, so heater ON. At 820 °C: not less than 800, so heater OFF.

5. Write the algorithm to find the highest of 4 readings.

Take the first reading as "max". For each other reading: if it is bigger than max, make it the new max. At the end show max.

Common mistakes

Practice quiz

1. The three parts of a program are:
2. Average of 10, 20 and 30 is:
3. In control programming, "feedback" means:
4. Rule: if temp < set then heater ON. Temp 30, set 40. The heater is:
5. Which is an output?

Practice: answer these yourself

Type or choose your answer, then press Check. Use a hint if you are stuck; the full solution appears after you answer.

Frequently asked questions

What is the difference between an algorithm and a program?

An algorithm is the idea: the steps in plain words. A program is those steps written in a language the computer understands.

Why do we need a loop in a control program?

Conditions keep changing. The loop reads the sensor again and again so the machine can react every time.

Do I need advanced maths for industrial programming?

No. Sum, average, maximum, ratios and unit conversion cover most daily jobs.

Where this is taught

Japan高校(専門学科)1〜3年Industrial Information and Mathematics

Learn first

Learn next

Related lessons

All Computer Science lessons