The success of Linux on the desktop has made everyone see the brilliant application prospects of Linux in the field of embedded systems. Embedded Linux has the characteristics of open source code, low hardware requirements, modular software, freely configurable license-free, and portable, which meets the requirements of reliability, real-time and stability in the industrial control field. Qt is a cross-platform application development framework developed by Trolltech. It has an intuitive and powerful API interface and C++ class library. The Qt/Embedded Linux version released in 2000 can be used for Linux embedded devices, Qt/. Embedded Linux provides its own windowing system and can be used as a lightweight alternative to the X11. Semiconductor lasers have the advantages of small size, light weight, reliable operation, low power consumption, high efficiency, etc. As a novel laser source, they have been widely used in military, medical, communication, industrial and other fields, such as laser communication, laser radar, laser. Surgery, laser welding. The characteristics of the semiconductor laser are affected by the drive current and temperature. The threshold current increases with the increase of temperature. When the threshold current is reached, the output optical power changes linearly with the injection current. The output optical power of the same injection current at different temperatures is also Differently, the change in temperature also causes the drift of the center wavelength. Therefore, the control of the semiconductor laser includes control of the drive current and control of the operating temperature. There are various control methods for semiconductor laser drive power. The embedded graphical user interface developed by Qt/Embedded can easily realize real-time monitoring, control, data storage and other functions of the drive source system.
1 development environment constructionThe control core processor of the semiconductor laser driver power supply uses the Sitare series ARM processor AM3354, which can run up to 800 MHz, integrates ARM Cortex A8-based microprocessor unit (MPU), POWERVR SGXTM graphics accelerator, programmable real-time unit. And industrial communication subsystems to ensure high performance while operating at low power. The hardware structure is shown in Figure 1. It is externally connected with 256 MB SDRAM and 2 GB NANDFLASH. The power management chip TPS65217 is used for processor power management. It provides flexible power-on and power-down timing and has normal power output and button monitoring. Additional functions such as an external 7-inch LCD liquid crystal display touch screen, the LCD controller in the processor integrates the LCD interface display driver controller, and can directly connect the LCD module after the driving circuit; the AM3354 processor can support up to 6 UARTs, the system The data is transmitted through the serial port and the LD drive source.
Figure 1 LD drive source control hardware structure diagram
The development of embedded application software is cross-platform development. Since the target CPU and host CPU have different architectures, it is necessary to build a cross-compilation environment, so that the program developed on the host machine can be run on the target machine after cross-compilation. The computer used for development is called a host machine and generally runs the Linux operating system. Embedded devices belong to the target machine. The host used here is an X86 computer with Ubuntu operating system (Ubuntu is a Linux operating system based on desktop applications), the target machine is an embedded motherboard with AM3354 as the processor, and the operating system uses embedded Linux. Due to Qt /Embedded and Qt/X11 have the same API. When developing applications in the embedded environment, they can be developed on the host with Qt/X11 library.
The cross compiler version installed here is arm-linux-gcc-4.4.3, which supports hard floating point operations. Extract to a directory, set the cross compiler environment variable in the system startup file /etc/profile, and finally import the environment variable, #arm-linux-gcc-v command to check whether the compiler is added successfully. Install the embedded Qt application development library, extract the Qt/Embedded library to the appropriate directory and compile. When the application is running, set the environment variables correctly so that the program should correctly call the library files in the installation directory.
2 Qt/Embedded application software designThe Qt/Embedded software system eliminates the X lib library, abstracts external input devices into keyboard and mouse events, and uses frame buffers as the underlying graphics interface. Applications can write kernel frame buffers directly, avoiding the cumbersome X lib/Server mechanism.
There are two ways to design Qt/Embedded applications. One is to use the integrated development environment graphical programming, and the other is code programming. Either way, the meta-object system is involved. The meta-object system is a mechanism for extending C++. Qt uses this mechanism to create separate software components that provide two key technologies: signal-slot and introspection. Introspection is required to implement signals and slots, and allows application developers to get "meta information" about the QObject subclass at runtime, including a class name containing the object and a list of signals and slots it supports. . Signals and slots are at the heart of the Qt communication mechanism. When a special event occurs, a signal can be transmitted, and the slot is a function that is called after the signal is transmitted to respond to the signal. Usually one signal corresponds to one slot, and one signal can also be associated with multiple slots, multiple signals. It can also be associated to the same slot.
2.1 Serial Communication ImplementationThere is no specific serial port control class in Qt, and most of them use the qextserialport class written by a third party. This class contains two classes: the QextSeri-alBase class and the Posix_QextSerialPort class, which inherits the former, and the QextSerialBase class inherits from the QIODevice class that comes with the Qt software. In the QextSerialBase class, an enumeration variable QueryMode is involved, which has two values ​​Polling and EventDriven. Polling refers to the query mode read/write serial port, and EventDriven is event-driven. The event-driven mode is to use the event processing serial port to read. Once the data arrives, the readyRead() signal will be sent, and the signal can be correlated to read the serial port data.
In the event-driven mode, the read/write of the serial port is asynchronous, and the call read/write function returns immediately, and they do not freeze the calling thread. The polling read/write function of the query mode is executed synchronously. The signal operation does not work in this mode, but the overhead is small in this mode, and a timer can be established to read the serial port data and display the result. On Qt's graphical user interface. Here, the Polling query method is used to read/write the serial port. Set a 100 ms timer to correlate the timing overflow signal to the read serial port slot function through Qt's unique signal and slot mechanism to realize real-time data acquisition and display.
Program flow: First create a serial port class, set the properties of serial communication, the most common attribute settings include communication port, baud rate, data bit, parity, stop bit and control flow, and then read/write serial port.
Each device port has a corresponding file in the /dev directory. The files under Linux are described by file descriptors, which point to the file record table opened by each process in the kernel. The file path of the serial port resource is /dev/ttyO*, so the operation of the serial port is the same as the operation of the ordinary file. Some operating procedures are as follows:
Struct PortSetTIngs myComSetTIng = {BAUD9600, DATA_8, PAR_NONE, STOP_1, FLOW_OFF, 500};
QString portName = "/dev/ttyO2";
myCom=new Posix_QextSerialPort(portName, myComSetTIng, QextSerialBase::EventDriven);
myCom-"open(QIODevice::ReadWrite);
QByteArray temp=myCom-"readAl(l);
2.2 soft keyboard callThe soft keyboard designed in this paper includes the input of letters and numbers, the switching of uppercase and lowercase letters, and the functions of backspace and carriage return. In the Linux environment QtDesigner, create a new Widget, drag the PushButton button in the Buttons option into the soft keyboard area, and then modify the text attribute and name attribute on each button as needed.
The implementation of the soft keyboard is based on the signal and slot mechanism. Using Qt's multi-signal mapping mechanism, the QSignalMapper class is first used to bundle a series of parameterless signals sent by different keys and convert them into parameterized signals to implement a function that can respond to different button functions; then each needs to be built The relationship between the signal and the slot corresponding to the key value is connect(ui-"pushButton, SIGNAL(clicked()), and the code value signal calls the sendCharacter(QChar) slot to achieve the correct key value input. The interface design is shown in Figure 2. .
Vacuum UV Curing Machine,Vacuum Curing Machine,UV Machine
Shenzhen Jianjiantong Technology Co., Ltd. , https://www.jjthydrogelprotector.com