W
W
WorldEn2017-01-06 17:36:27
Electronics
WorldEn, 2017-01-06 17:36:27

How does the hardware "understand" the program?

Good day!
Let's say I wrote a C program with a graphical interface, where pressing the "on" button should make the LED light up. I am interested in the following: how is the current supplied to the LED? I understand that a microcontroller is needed for these purposes, but how does it "understand" the command that was written on the computer? Can you advise the literature, having read and studied which I can get fundamental knowledge about electronics programming. It is very interesting how they write software for household, medical, industrial equipment and I want to do it myself. Do you need a deep knowledge of electronics for this or is the school curriculum enough?

Answer the question

In order to leave comments, you need to log in

4 answer(s)
A
Alexander Gusev, 2017-01-06
@WorldEn

To do this, your program on the computer must communicate with the microcontroller (MC).
Let's say you send the string "LED 1 ON \n" through the virtual COM port via USB when you click on the graphical interface.
From USB, let's say through an adapter we convert it to UART and it goes to the MK.
Those. there will be a circuit PC -> USBtoUART -> MK
MK will have to read the UART (it will have to be programmed) and as soon as this line arrives, change the state of the leg (this also needs to be programmed on the MK) by turning on the LED.
You can look at the same mini-projects on arduino from an ampere to roughly understand how it is programmed inside, how diodes, buttons, etc. are connected to the MK.
wiki.amperka.ru
Here, by the way, almost your question

1
15432, 2017-01-06
@15432

The microcontroller does not understand, but stupidly executes instructions. It is your program that must correctly configure the hardware port of the microcontroller so that a logical unit appears at its output and the LED lights up.
The procedure differs depending on the microcontroller. Somewhere it is enough to write a bit to a certain memory address, somewhere special assembler commands are used to control ports, etc.
All this is usually programmed at the abstraction level, using ready-made libraries. Take a look at the same Arduino. Deep knowledge of electronics is required to design devices with these microcontrollers.

T
T_y_l_e_r, 2017-01-06
@T_y_l_e_r

The bottom line is this
The microcontroller already has firmware, this same firmware is written in C or assembler
The device has a COM port or some other interface
For firmware, another interface
In general, your program will be the maximum that will connect to the device port and send pre-programmed commands there
And in order to study everything and everything, you first need to solder the device and write the firmware of the microcontroller.
There are editors and compilers for this
. In fact, everything is initially done at the level of PCB development and firmware for it
. And it's not as easy as you think.
One lousy book. not enough

E
evgeniy_lm, 2017-01-06
@evgeniy_lm

How is the current supplied to the LED?
+ supply voltage is supplied to the anode of the LED, to the cathode -
MK does not understand the command written on the computer. In order for the MK to understand the program, you need to compile and get a set of commands understandable by the MK. Then, with the help of the programmer, the received set of commands must be written to the controller's memory.
? Start from here
There will be questions, write

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question