How can software make physical changes happen?

804 views

I’ve been thinking a lot about software and how it affects hardware. How is it that software, that runs on code, or some computer language, can affect the physical properties of the computer? For example what has to happen for a phone to physically shut down after pressing the shutdown button on a touch screen? Or how can it be that by pressing a button in a software, a physical movement can be made on an object? Going deeper, how can it be that a button press, or a touch can affect the state of the transistors?
This reminds me of the problem of consciousness, where in a computer a software is like the mind and that cannot phisically connect to the body.

In: 3

13 Answers

Anonymous 0 Comments

Oh boy, an ELI5 that sort-of relates to my day job!

> How is it that software, that runs on code, or some computer language, can affect the physical properties of the computer? For example what has to happen for a phone to physically shut down after pressing the shutdown button on a touch screen?

That part’s conceptually easy: You use something called a latching relay (fancy term for “A switch that can be moved by an electric current, but stays in the position you put it when that current is turned off.”).
You, the squishy human, turn it on by pushing a button. The software turns it off by energizing a magnet that pulls it to the off position.

(***Functionally*** we don’t use mechanical relays directly connected to switches or buttons anymore, at least not on something like your cell phone. We use solid state relays that are on when voltage is present at their control gate and off when it’s not. The phone never actually “turns off” the way we normally think of it, instead it turns off most of those relays so the screen, speakers, cellular modem, etc. aren’t powered, sometimes even the main CPU turns off and all that’s left is a small system that quietly waits for the power button to be pressed & turns the power to the other modules back on when that happens.)

> Or how can it be that by pressing a button in a software, a physical movement can be made on an object?

Fucking magnets, my friend. Fucking. Magnets.

Again in the simplest conceptual terms the software just applies a voltage to an output line, changing it from a zero to a 1. That voltage can be sent to a relay that turns lights on or off, or runs a motor in a specified direction, or any number of other things – the relay doesn’t need much current to open or close, so most chips or transistors can provide enough current to make it work. If you have 8 of those relays all wired in parallel through a bank of resistors you can even set the motor’s speed to one of 255 possible values (based on the parallel resistance of the circuits that are energized).

(Again ***functionally*** we don’t do that much anymore: If we need variable speeds we use solid state relays and [pulse width modulation (PWM)](https://en.wikipedia.org/wiki/Pulse-width_modulation) to effectively control how much power is going to a motor or a lamp or something similar rather than sinking the excess power in resistors to limit the current.)

> Going deeper, how can it be that a button press, or a touch can affect the state of the transistors?

Conceptually a transistor is really just a fancy relay with no moving parts ([someone explained that like we’re five over here](https://www.reddit.com/r/explainlikeimfive/comments/pufzjw/eli5_how_do_transistors_work/)). Whether it’s software or hardware we’re just changing voltages across the gates of various transistors to make them open or close a circuit.

Most transistors can’t handle a lot of current, so we either use solid state relays (*extra fancy* transistors that ***can*** handle lots of current) or mechanical relays to actually control a working load like a motor. But the concept doesn’t change.

In The Before Times we had relay logic](https://en.wikipedia.org/wiki/Relay_logic) circuits which simply connected a bunch of latching and non-latching relays to each other to control the state of output lines based on the state of input lines. You can connect transistors together to run the same kind of relay logic (with much lower power requirements), having mechanical switches on the input lines and actual mechanical relays only at the output end of the system where it has to power a working load.

And yet again ***functionally*** we don’t do that much anymore: We use integrated circuits like an Arduino or entire embeddable systems like a Raspberry Pi that provide general purpose input/output (GPIO) pins, which we can program and address in software. The software is looking for things you *could* look for in relay or transistor logic: “Is there voltage here?” and “How much voltage is here?” and reporting that back to the software which makes the actual decisions to turn other pins off or on as needed. The actual hardware helping us out is abstracted away, so we don’t have to worry about comparator circuits and voltage dividers and the behavior of individual transistors on the board. This is convenient because it’s relatively easy to change the behavior of software, while changing relay or transistor logic circuit behavior generally requires rewiring the circuit.
For people who need the level of control rewiring the underlying components of a logic circuit can provide we *do* have chips that can be rewired on the fly: They’re called [Field Programmable Gate Arrays (FPGAs)](https://en.wikipedia.org/wiki/Field-programmable_gate_array) and they come in a wide range of capabilities and complexity.

You are viewing 1 out of 13 answers, click here to view all answers.