【Realtek RTL8722DM IoT Development Kit】Understanding Arduino Programming Paradigms
1) I would like to thank the Breadboard community for giving me this review opportunity! Thanks to REALTEK! I received the Ameba RTL8722DM MINI, which is compact and cute, and I really like it.
The name “Ameba” embodies the manufacturer’s hope for it to possess strong transformation and survival capabilities. The model number is a multiplication table 3721 transformed into 8722, hereafter referred to as “Ameba 87”.
First question: What is the relationship between the Ameba RTL8722DM MINI board and Arduino?
Answer: 1) The board hardware is not Arduino. The main reason is that Arduino is developed based on AVR microcontrollers, while Ameba 87 is based on ARM architecture.
This story is a bit long: it is not the Dutch lithography machine ASML, the names are somewhat similar. It was established in 1984 by the American ATMEL company. In 1997, Mr. A and Mr. V of ATMEL jointly developed a RISC 8-bit microcontroller, abbreviated AVR. Later, it expanded to 16-bit and 32-bit. There are three major series: low-end Tiny, mid-range AT90, and high-end ATmega, making a significant impact in the microcontroller world.
In 2005, students and teachers from an Italian university designed a control board using AVR. The Italian word “Arduino” means “powerful”, and it is said to be the name of an Italian king from 1000 years ago. The informal Italian language is definitely correct. Arduino fully utilized the capabilities of AVR chips, with a forward-thinking design philosophy, powerful functions, and affordable costs. Most importantly, the creators of Arduino decided to open source both hardware and software simultaneously, allowing people to produce Arduino clones without paying any fees or even obtaining permission from the Arduino team. The design hardware schematics and software program code became public goods for the first time, attracting many people to join, even large companies like Intel followed suit by releasing Arduino products.
Unfortunately, it is said that around 2008, Atmel experienced a global super shortage, just as STM32 rose to prominence. So, when everyone was doing new designs, AVR was generally not considered. And ATMEL was acquired by Microchip Technology in 2016, but that is another story.
STMicroelectronics is a merger of an Italian company and a French company, hence the name. ST specializes in discrete devices, mobile camera modules, and automotive integrated circuits, and is the world’s largest manufacturer of dedicated analog chips and power conversion chips. With a latecomer’s advantage, it launched STM8, STM32, and other microcontroller series, basic, enhanced, USB, complementary types, with prices that are simply outrageous! Especially in mainland China, STM32 is incredibly popular, especially the enhanced STM32F103 series, leading many to believe that there is only one microcontroller in the world, called STM32. After the rise of STM32, there has basically been no further developments for AVR. Although ATMEL later also launched ARM-based microcontrollers, their cost-performance ratio is not inferior to STM32, but it was already too late. Only in very low-end scenarios do some nostalgic people continue to use AVR, including Arduino.
Because Arduino has already reached the lowest limit of affordability, switching to STM32 is not worthwhile. Moreover, STM32 chip pins are not compatible and the ARM instruction set is also different; it would be a hassle to modify hardware and software for what? Therefore, the official version of Arduino has always adhered to the tradition of using the once-mainstream but now non-mainstream AVR chips.
Answer: 2) Ameba 87 can be developed based on Arduino IDE
The design programming language of the Arduino circuit board was developed by a student in just two days. The early Arduino core library was written in C, later a mix of C and C++ was adopted, namely AVR-Libc (the AVR support library based on GCC). Arduino re-packaged this core library, providing various language calling APIs. Arduino IDE is a development environment that allows writing program code in languages like Java and C, supporting uploading programs to Arduino circuit boards for execution. Although Ameba 87 is not Arduino, it can utilize this mechanism for code development. It’s like borrowing a highway for takeoff and landing of a jet, which can be considered a form of mimicry in biology.
After rambling on for so long, let’s get to the main topic (perhaps many meanings about the history of microcontrollers have not been fully expressed, if everyone likes this post more than 20 times, I will write a sequel).
2) Arduino IDE
The Arduino IDE needs to be used with Arduino hardware: the Arduino IDE is used to write programs and compile them into binary files, which are burned into Arduino hardware boards via USB cables. Then Arduino can control various sensors, Wi-Fi interfaces, Bluetooth interfaces, and perform various operations and controls according to these program instructions.
When I first saw the Arduino development interface, I had a feeling of true energy flowing backward:
1) Where is the main() function?
2) What are setup() and loop()?
3) Can my great design be expressed with such a trivial loop()?
Through searching and studying various materials, I finally understood: Arduino’s programming method is another programming paradigm. So it is possible for a student to complete the design language of Arduino in 3 days. If based on Von Neumann’s serial computer from scratch, it is absolutely impossible to complete in 3 days.
1) To illustrate this paradigm, let’s start with PLC (Programmable Logic Controller):
PLC appeared in 1969, even older than the IBM PC. And it was originally called PC (Programmable Controller), but later, due to the popularity of the PC, it had to add an L to distinguish itself, indicating it was slightly inferior, only performing logical programming control at the relay level. PLC also invented the famous ladder logic programming language, which is renowned in the industrial control field.
PLC is specifically designed for application in industrial environments, and its structure can be divided into: analog/digital input units, input memory, processing units, output memory, analog/digital output units.
The execution process is very simple: (1) Input unit samples into input memory (2) Processing unit executes user-defined programs, processes data from input memory, and outputs to output memory; (3) Output memory refreshes output to output units. (4) Repeatedly loops steps 1, 2, and 3, forever. That’s it. You did not misread, that’s it.
Impatient students may have noticed: the setup() process corresponds to the loop() process. The so-called loop() is the aforementioned step 2. And this repeated scheduling loop is hidden in the core library of Arduino.
This is a completely different operating method. It is, of course, a paradigm for specific occasions. Regardless, it works very well.
Currently, PLCs are a major industry, with over 200 PLC manufacturers worldwide and thousands of product models. It can be divided into three factions: American (AB, GE), European (Siemens, TE), and Japanese (Mitsubishi, Omron); there are also weak manufacturers from South Korea, Taiwan, etc.; domestic manufacturers can be ignored. In 2019, the global PLC market size reached about $9.5 billion. In 2020, the PLC market size in China was about 13 billion yuan. It’s not too big, not too small, but it is a key link in Industry 4.0.
2) If everyone understands the operating paradigm of PLC, let’s talk about the Processing language. Jumping from PLC hardware to a programming language. Although the leap is large, it follows the same paradigm: this Zhihu link is quite comprehensive https://zhuanlan.zhihu.com/p/20225132
Processing is designed for artistic and scientific purposes, aimed at artists. It is a fusion of mathematics, computer graphics, and visual programming. The website http://www.processing.org has many beautiful and incredible Processing examples. The author was so fascinated that he almost delayed this review. Processing simplifies the syntax based on the Java language, catering to the low-code level of media art designers. There are also dedicated communities and books, with the Chinese translated version named “Processing Programming Learning Guide”, published by the Machinery Industry Press. If anyone is interested, you can continue to study. Here we only talk about its design paradigm: look here: the demo framework of Processing:
It has the same setup(); here draw() is Arduino’s loop(). Do you see the trick?
Let me reiterate: the execution logic of the Processing language and PLC execution, in mathematical terms, is “isomorphic.” That is, they follow the same paradigm.
3) Based on Processing, there are many variants, such as Wiring (don’t worry, we are almost at Arduino).
There is relatively little information about Wiring; you can refer to this link: https://codingdict.com/os/software/89935
It is built on Processing and developed using Java, following GPLv2, and is an open-source electronic development platform, including software (Wiring IDE) and hardware (microcontrollers). Wiring allows writing cross-platform software to control devices connected to microcontrollers. Students, artists, designers, researchers, and enthusiasts learn, prototype, and produce.
4) Now we arrive at Arduino. Arduino is based on Wiring with some adjustments made for Arduino, allowing a student to complete it in 3 days.
This is the immense power of paradigms.