How does a software code makes big machines move?



I’m in networking and still can’t wrap my head around this. How does changing some bits manages to physically move a hardware, be it small or big?

In: Technology

Servos and stepper motors which can detect and set their position based on the frequency or voltage of pulses sent to them. They have a high output driver that turns tiny 5-10volt signals in to larger voltages for the motors.

A computer sends those smaller signals which is ran by code. There are lots of protocols for communication between computers and driver boards.

A good place to look up the basics is programming Arduino Steppers, and CNC Steppers.

All of the larger machines, factories, and robots all use this same principal, just with more motors and moving parts.

So it depends on what exactly you’re powering, and what your digital signal is coming from, but usually it’s digital output -> transistor to amplify signal -> moving electrons generate magnetic field -> magnet or coil physically moves.

You might use a solenoid to actuate an air or hydraulic valve. You might control a stepper motor or servo motor. to more directly control the motion.

Your signal source could come from a microcontroller, maybe 3.3 or 5v, or maybe an industrial controller with stronger output drivers that can drive a solenoid directly.

It’s just a couple stages of amplification.

You can imagine a small digital signal turning on an LED yeah? Well take the same energy used to light an led and have that switch a bigger transistor that might control a 480V motor directly. The only real problem is making sure noise from the high power high voltage stuff doesn’t screw with your low voltage digital stuff.

Like the power doesn’t come from a processor directly. Power comes from high voltage power, pneumatics, or hydraulics. The software is just controlling where the energy goes.

Also some of the amplification might be mechanical. As a real world example you can have a 3.3V digital signal switch a 24V control signal that activates a 24V solenoid pneumatic pilot valve that activates a high flow pneumatic valve.

Or a 3.3V signal that drives a 24V, 2A low current relay that drives a 480V 50A contactor that runs a 20kW motor.

It is a -lot- more important that you don’t mess up your software or electronics though. There is a lot more magic smoke waiting to be released if you break something industrial.

the code you type is broken down by a compiler into machine code. machine code are ons and offs of switches that power on certain electrical devices in the computer the number of switches large so a lot of patterns for generating different electric signals can be made. those electric signals can be amplified to have more power like how a amp makes sounds louder but still the same notes.

as for physical movement it could be a number of mechanisms the most common I speculate is through electromagnetism essentially running current through a conductor makes a magnet with a given polarity run the current the other way and the polarity switches. magnets attract unlike poles and repel like poles. those pushes or pulls can be light and fast like a speaker or stronger and more constant like a motor.

Normally in low level programming, when you write a value to an address, you are just changing a value in RAM. However, hardware designers hardwire the computer to “intercept” certain addresses to let software control other things. They might make it so that whenever you write an integer to 0x123abc, a specific pin on your chip goes to almost 5V whenever you write a value other than 0 to it (and to almost 0V when you write 0). If you connect that pin to a relay controlling a motor (likely with the help of some basic amplifier circuit), you can then start and stop a motor as easily as setting a variable to 1 or 0.

They have to be wired up that way. The machine probably contains a microcontroller – or several – which is a small computer designed for this purpose. The microcontroller has a bunch of spare wires which the machine designer can use for any purpose, and the microcontroller’s software can tell it to turn them on or off.

So, “pin A3” may be connected to a circuit that makes the elevator go up. When the microcontroller gets to an instruction that says “turn on pin A3” then it does that and the elevator goes up.

Keyword: GPIO = General Purpose Input/Output