What software engineers should be aware of when programming hardware
Learning hardware programming as a software engineer
First of all, it is important to understand pinout (arrangement) in order to understand hardware programming. Similar boards often have the same pinout, but the pinout itself may not contain the information needed for programming, for example, if some of the pins are restricted, and the actual board model number It is also important to check the board platform and firmware pin definitions from.
Once you know the pinouts, you need to figure out which pins play what role and what to use. The most basic pins are called digital pins and are responsible for transmitting on / off information such as whether a button is pressed.
However, if you need more control, you must use analog pins. The signal output from the analog pin isDACThe signal is converted from an analog signal to a digital signal using a converter called a digital signal, and the signal is read.resolutionIt depends on you. For exampleESP32Since has a resolution of 12 bits, it can only be represented by digital signals up to 4096 levels. Since analog signals are converted to digital signals, it is not possible to output a true and accurate signal, but it changes the time width of the ON statePWMThe analog signal can be expressed using the technique described above. Analog pins are used to get accurate data from the sensor or to dimm the LEDs.
In addition to digital and analog pins, there are communication pins that allow devices to communicate. The communication pin is for direct communicationUARTAnd for internal communication on the boardI2C, For device-to-device communicationSPIAnd1-WireThere are several interfaces, such as:
If you do not care whether it is a pin used by the device itself or a pin that controls the device, it may lead to unexpected operation. There is no problem if the built-in LED flashes by mistake, but the on-board flash memory may be broken. In the case of ESP32, there are also touch pins that can detect whether a person is touching, and DACs that can output analog signals by controlling the voltage.
With software, it is possible to easily replace a part of the program with a new one, but it is not always easy with hardware. It states that the entire device must be assembled from scratch, while at the same time checking for device compatibility and possible failures.EasyEDATools likebread boardWith it, you can investigate and test, ignoring compatibility and failure issues. Also, in the text editorVisual Studio CodeAndAtomProvided as an extension toPlatformIOAllows you to run tests on the local machine as well as the connected device and upload programs to the device.
A new generation ecosystem for embedded development
Software problems rarely start burning your PC, but hardware mistakes, such as using the wrong pins or switching relays at the wrong time, can cause serious damage. To prevent this damage, carefully design, fuse expensive or critical parts to prevent overvoltage failure, and prepare sockets for fragile parts to save soldering time. Vrampe says it's important to do that.