How are everyday machines programmed? [closed] Ask Question

How are everyday machines programmed? [closed] Ask Question

How are everyday machines (not so much computers and mobile devices as appliances, digital watches, etc) programmed? What kind of code goes into the programming of a Coca-Cola vending machine? How does my coffee maker accept a pre-programmed time and begin brewing a pot of coffee hours later, when that time arrives?

Do these kinds of machines have operating systems inside of them, or is it something even more basic? Are they written in Assembly, C, or some other language?

And, I would really like to find some resource that lists these operating systems or underlying code systems, possibly even with source code if possible. If anyone knows of such a resource (searching yielded nothing for me), that would be fantastic.

ベストアンサー1

Most of what you're talking about are embedded systems where C is a luxury that may not be available. The software often isn't separate programs running under an OS like you'd have on a desktop or phone, especially if the chip the designers chose to use is described as a "microcontroller".

Most of the time the software is written in C or assembly. C requires a compiler to be written for that platform (and might produce bloated or inefficient asm if it doesn't optimize well), but a simple assembler only has to turn text into machine code one line at a time and is easy to write. (And if a vendor wants anyone to buy their microcontrollers, they'll make sure at least an assembler exists for it to make development attractive, often also a C compiler although sometimes non-optimizing.)

Your coffee pot and most simple systems like that don't carry an operating system. They simply load from a start address in memory and you put your code there. Often these systems have their "code" burned into EEPROMS that act as the hard drive of the system. Or depending on the type of EEPROM / flash, code may be able to run directly from flash without having to get loaded into RAM first. (The device may not be able to write to its own flash memory; that's done with external tools. The edit/compile/run cycle may include reprogramming the flash of actual hardware, if not testing in a simulator.)

Coca-cola machines, routers, etc. typically use a realtime OS like QNX, EMBOS, or sometimes RTlinux if you're lucky. Most of these are proprietary OS you license for lots of money, but they have C compilers, drivers to work with hardware, etc.

http://www.qnx.com/

http://www.segger.com/cms/embos.html

http://www.microsoft.com/windowsembedded/en-us/campaigns/compact7/default.aspx?WT.srch=1&WT.mc_ID=SEARCH

RTLinux

おすすめ記事