Answer the question
In order to leave comments, you need to log in
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
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
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.
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
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 questionAsk a Question
731 491 924 answers to any question