How can software make physical changes happen?

615 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

Basically, through electromagnetism. The simplest way to visualize it is that there are lots of tiny little electromagnets that can engage or disengage tiny switches. Tiny switches can control bigger switches, so on and so forth.

Anonymous 0 Comments

That’s what [drivers](https://en.wikipedia.org/wiki/Device_driver) do.

Take a mouse. For simplicity let’s say it’s connected with a wire to the computer. There will be some pins that have a voltage, and some pins that don’t. Those voltages will trigger voltages in the processor at certain memory addresses, and those voltages will trigger other voltages. Eventually the patterns of voltages (and not) will trigger voltages in the wire that connects your screen to the computer, and the pixels on your screen will power up (shine) or not based on the patterns of voltages. To the computer, it’s just voltages or not. To you, it’s patterns of black and white dots – letters on a screen that you can understand.

A transistor can trigger other transistors and propagate voltages. Software, ultimately, is just a way to power up certain transistors in the processor, so that the mouse voltages create the right kind of domino effect to fill your screen with “words”.

There are different levels of “software”. The most basic level, is “if this pin is 0, then make this pin a 1. If this pin is a 1, then make this pin also a 1.” Literally transistor by transistor programming.

The higher levels of software are “languages” that organize things in a way that’s meaningful to humans. You type in your programming language “print the screen” and it generates the 150 pages of “if this pin is 0, then make this pin a 1, and if this pin is a 1, then make this other pin a 0” code to flip the transistors as necessary to get the printer to work correctly.

Anonymous 0 Comments

All a CPU ever does is follow instructions. The main instructions are add, load, store, jump and jump if positive. The CPU goes down the list of instructions, adding 2 to the current number, then storing it in position 5 in cache. It then might jump to a next list of instructions to work on another thing. These instructions are stored in RAM alongside the data.

As for your examples, a power switch will interrupt the current workings on the CPU, and tell it to read from the sleep mode instructions. These will be repeating instructions that display the time, and check for presses. If you fully turn it off, it will run a shut down routine, then the battery control chips will stop current from flowing by using transistors.

Physical movements within a phone do not happen at larger scales than electrons when anything happens. The electrons move because of the electric field in the wires. However for taptic and the shutter on the camera, electromagnets will be used to rapidly move a heavy bit of metal in the device. Same with shutter.

The button effects what happens because when an input is given, it is placed into RAM, the CPU when it gets time to see what inputs have been given will see the input, then branch to the instructions relevant.

Anonymous 0 Comments

The main thing that transistors and other computer peripherals have in common is that they use electricity. When you provide an input to your computer of your phone, such as pushing the power button, an electrical impulse is sent into the transistors which are arranged in such a way that they’ll perform a set collection of actions. When those transistors need to tell another part of the device to do something, they send an electrical signal which is usually amplified by other electronics so that it produces an output (such as a noise or an image on a display).

Computer engineers have gotten very good over the decades at telling those transistors how to transform those electrical inputs into useful electrical outputs.

Anonymous 0 Comments

It’s not really the software affecting the hardware. It actually is just the hardware. The hardware has a lot of different switches, these are called memory. The processor then keeps switching these switches based on other switches. What running a program on a hardware comes down to is carefully setting up these switches so that when we let the processor do its automatic switch switching, it does what we intended.

Anonymous 0 Comments

> How is it that software, that runs on code, or some computer language, can affect the physical properties of the computer?

Software is also physical, it’s the pattern in which a ton of physical switches are set either on or off. It’s not an imaginary thing, even if it doesn’t seem as tangible than back when software was a [paper card with holes punched in it to make or break electrical connections](https://www.computerhistory.org/revolution/punched-cards/2)

Anonymous 0 Comments

Caveat, this is massively oversimplified.

So, the misunderstanding is that you’re assuming software doesn’t have a physical representation. It absolutely does. Software on your computer sits in your storage device (HDD or SSD). If it’s an HDD, each bit is stored as a tiny area that is either magnetized to demagnetized to store a 1 or 0. If it’s an SSD, there are little floating gate transistors that store the 0 or 1.

When that gets loaded into memory, like ram, the 0/1s are read from the physical properties on the disk and copied to the physical properties of memory, which can be made with capacitors. The charged/uncharged state of the capacitor can represent the 0 and 1.

When your processor accesses the memory, it can create a signal where one set of wires directs where to look in memory, and another set of wires have the resulting data copied onto them. We now have a bunch of physical wires that have a voltage on them representing the data that the CPU can use (~5v for 1, ~0v for 0).

Through the use of logic gates, the CPU can create electric signals on various wires to send electric signals to other parts of the hardware. These control signals are usually specific to the hardware in question, which is why there are usually drivers you install, or firmware on the device. A driver is basically a special program that gives the operating system a way to translate the conceptual thing it wants to do (“what data is at address 50?”) and turn that into a set of voltages on those wires (“put 00110010 on wires 1-8, because on this chip wires 1-8 are the memory address wires”).

So, to take it back to your question:

* You click your mouse

* That sends a signal to the motherboard, down the wire. Note that this could also be Bluetooth.

* Your operating system detects the new event, reads it and determines it’s a mouse click event. It’s now basically in “memory” / “software”. At this point, this is just changing 0/1s in memory.

* The operating system now sends that event to the software you’re running to handle.

* The software sees the click, and runs code in memory to see that the cursor (whose position is also in memory) was over a button.

* The software runs its response to being clicked. Your example talks about hardware, so in this case it finds the driver for your hardware and runs that code.

* The driver gets the signal, and determines that on your chipset, it needs to set a set of wires to certain values.

* Your motherboard directs that signal to the attached device, because the drivers/firmware know which ones to write to. It’s now back in hardware land.

* The device receives the electric signal. That signal can be fed to a device that does something from the digital signal. A PWM, for example, can use a digital signal (which is just a bunch of 0s and 1s in order) to control a motor.

It’s kind of crazy that it works as well as it does, and it’s no mystery how software acts cursed so often. Look at how stupidly complicated it is.

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.

Anonymous 0 Comments

There’s a big difference between consciousness and software. We don’t understand consciousness but we know that software exists empirically in the physical world as hundreds of millions of 1s and 0s stored in physical microscopic switches of some kind inside your computer’s circuitry.

(Think of the numbers you put into a safe door to unlock it. The number is physically represented in the mechanism, same with software.)

This pattern of 1s and 0s modifies the paths that electricity takes through your computer in a big network of wires. This network is extremely complex and it’s connected to things you as a person can interact with like your speakers, fans, keyboard, screen, etc. So the 1s and 0s that make up software are 100% as physical as a light switch. The difference between writing code and flipping a light switch is just the number of steps that happen in between and the number of switches involved.

Bottom line is that all of it was always physical, there was no jumping between worlds, it just seems like it because of the sheer complexity of modern computers.

Anonymous 0 Comments

There’s a big difference between consciousness and software. We don’t understand consciousness but we know that software exists empirically in the physical world as hundreds of millions of 1s and 0s stored in physical microscopic switches of some kind inside your computer’s circuitry.

(Think of the numbers you put into a safe door to unlock it. The number is physically represented in the mechanism, same with software.)

This pattern of 1s and 0s modifies the paths that electricity takes through your computer in a big network of wires. This network is extremely complex and it’s connected to things you as a person can interact with like your speakers, fans, keyboard, screen, etc. So the 1s and 0s that make up software are 100% as physical as a light switch. The difference between writing code and flipping a light switch is just the number of steps that happen in between and the number of switches involved.

Bottom line is that all of it was always physical, there was no jumping between worlds, it just seems like it because of the sheer complexity of modern computers.