Brief Analysis of Intelligent Lighting Control System Based on ARM

Publisher:科技律动Latest update time:2020-08-06 Source: elecfansKeywords:ARM Reading articles on mobile phones Scan QR code
Read articles on your mobile phone anytime, anywhere

After 3 months of continuous exploration, I finally completed the project practice content of the second phase of the 91arm Academy (the code in the video tutorial is not complete). I saved the relevant experience and code here for reference by myself and my classmates.


System Hardware:

Main control module: nanopi s2 (cortex-A9 quad-core s5p4418), 5v to 3.3v module, light sensor, sound sensor, 5v relay, breadboard and LED light, serial port to USB debugging interface, etc.


Wireless network module: tiny6410 (ARM11 Samsung S3C6410), infrared sensor, relay, breadboard and LED light


Let's look at the overall effect first. The main control program is znkg2018 and the network program is net_light

The main control and network end programs are as follows:

The web browser interface is as follows:

The main ideas of this project:

(1) The main control program znkg2018 (cross-compiled and ported to nanopi s2) contains four threads:

Thread 1: (used for inter-process communication) loops through shared memory and message queue data, and updates shared memory data to the main data structure memory in real time according to the message type of the message queue, or updates the main data structure memory to the shared memory;

Thread 2: (used to detect device online and offline) cyclically reads the data of the GPIO port of the development board connected to the 5V to 3.3V module. A high level indicates that the corresponding sensing device is connected to the system, and the level status of the GPIO port connected to the data line of the device can be read (the 5V to 3.3V module and the power line of the sensing device are connected together to achieve simultaneous plugging and unplugging, so that the plugging and unplugging of the corresponding sensing device can be detected through this thread);

Thread 3: (used to listen to the connection of network devices) This thread is the network server. First, it establishes a TCP data stream (socket~bind~listen ~ accetp) to loop and listen to the connection request of the network client. After receiving the request, it opens a new thread to communicate with the client, updates the network device status in the main data structure according to the client data, and sends corresponding commands to the network device according to the network device status in the main data structure. Network communication is based on the protocol, which is convenient for command classification and transmission verification.

Thread 4: (For lighting equipment switch control) This project has three small lights, two on the main control end and one on the network end. The switches are all controlled by relays, simulating 220V living room, study and office (remote) lights. Loop through the switch status of the lighting equipment in the main data structure, send write data commands to the corresponding relays to control the light switches. If the sensing device is bound to the lighting device, read the gpio port data of the sensing device and write the data to the gpio port of the relay. The network device only updates the network command status value, which is sent out by process three, and then processed by the network end program and controls its relay gpio, thereby controlling the corresponding light switch.

(2) The network client program net_light (cross-compiled and ported to tiny 6410) is just a main program:

The program connects to the network thread of the main control program on nanopi through the IP and port number, and updates the corresponding device status according to the network commands sent by the main control program.

(3) CGI program running on the boa server on nanopi:

After installing the boa server on nanopi, you can access the cgi program in nanopi through a browser. Put the index.html file in the www folder of boa, which is the welcome interface. The options in it are connected to different cgi programs. These programs open the shared memory and message queue managed by the main control program. By modifying the form and extracting the data in the form, updating the shared memory data, and notifying the main control device to update the shared memory or update the data in the shared memory to the main data structure memory through the message queue. After the main data structure memory is modified, the four threads of the main control device will take corresponding actions.

The editor uses the recommended source insight, which can automatically derive the declaration of variables and functions and their references to each other, making it easier to write and analyze programs (but the encoding format of the software I use is Ascill, not UTF-8, so it is garbled when compiled. It is OK to convert the encoding format with note pad ++)

Keywords:ARM Reference address:Brief Analysis of Intelligent Lighting Control System Based on ARM

Previous article:The most complete ARM instruction set in history
Next article:Answers to common questions for ARM embedded system beginners

Recommended ReadingLatest update time:2024-11-17 06:01

VGA Display Technology Based on ARM Processor S3C2440
At present, many SOC manufacturers' microprocessor chips have integrated LCD controllers, such as Samsung's S3C2410. S3C2440, Intel's Xscale series, etc. Most embedded systems also use popular LCD display technology. However, in places where large-screen display is required and resolution is not high, such as workshops
[Microcontroller]
VGA Display Technology Based on ARM Processor S3C2440
22 common ARM concepts
1 Explanation of some common English abbreviations in ARM MSB: Most Significant Bit; LSB: Least Significant Bit; AHB: Advanced High-Performance Bus; VPB: VLSI Peripheral Bus that connects on-chip peripheral functions; EMC: External Memory Controller; MAM: Memory Acceleration Module; VIC: Vectored Interrupt Controller;
[Microcontroller]
Research on the Design of GPRS/CQT Test System Based on ARM Platform
     GPRS, as the bearer network for China Mobile's data services, supports a variety of data services involving different network elements. Any failure of a network element will directly affect the normal use of data services. It is very important to ensure end-to-end use for users.   GPRSDT/CQT test simulates the us
[Microcontroller]
Research on the Design of GPRS/CQT Test System Based on ARM Platform
ARM architecture CPU vulnerability
cve-2017-5753 Bounds Check Bypass Spectre CVE-2018-3693 Bounds Check Bypass cve-2017-5715 Branch Target Injection Spectre cve-2017-5754 Unauthorized Data Cache Load Meltdown CVE-2018-3640 Malicious system registry read CVE-2018-3639 Speculative Storage Bypass Meltdown vulnerability, low-privilege users can access th
[Microcontroller]
ARM architecture CPU vulnerability
Greenhouse intelligent monitoring system based on ARM+Zigbee
Platform Selection Instructions Design Notes
[Microcontroller]
Greenhouse intelligent monitoring system based on ARM+Zigbee
The difference between ARM and MCU
  1. Software   This is probably the biggest difference. The operating system was introduced. Why was the operating system introduced? What are the benefits?   1) Convenience. This is mainly reflected in the later development, that is, developing applications directly on the operating system. Unlike a single-chip mi
[Microcontroller]
ARM bare board debugging technology
What I mean by ARM bare board debugging is that after the ARM PCB board is made, the board that comes back with the patch has no program and is powered on for the first time. The reason why I wrote a blog is that I recently debugged an ARM board based on S3C6410, but we replaced the original M-DDR DRAM and Nandflash, a
[Microcontroller]
ARM and Allwinner Technology Sign Arm Total Access License Agreement, Entering a New Chapter of Technology Cooperation
Recently, ARM Technology (China) Co., Ltd. (hereinafter referred to as "ARM Technology") and Zhuhai Allwinner Technology Co., Ltd. (hereinafter referred to as "Allwinner Technology"), a leading domestic intelligent application processor SoC design manufacturer, jointly announced that the two parties have
[Embedded]
ARM and Allwinner Technology Sign Arm Total Access License Agreement, Entering a New Chapter of Technology Cooperation
Latest Microcontroller Articles
  • Download from the Internet--ARM Getting Started Notes
    A brief introduction: From today on, the ARM notebook of the rookie is open, and it can be regarded as a place to store these notes. Why publish it? Maybe you are interested in it. In fact, the reason for these notes is ...
  • Learn ARM development(22)
    Turning off and on interrupts Interrupts are an efficient dialogue mechanism, but sometimes you don't want to interrupt the program while it is running. For example, when you are printing something, the program suddenly interrupts and another ...
  • Learn ARM development(21)
    First, declare the task pointer, because it will be used later. Task pointer volatile TASK_TCB* volatile g_pCurrentTask = NULL;volatile TASK_TCB* vol ...
  • Learn ARM development(20)
    With the previous Tick interrupt, the basic task switching conditions are ready. However, this "easterly" is also difficult to understand. Only through continuous practice can we understand it. ...
  • Learn ARM development(19)
    After many days of hard work, I finally got the interrupt working. But in order to allow RTOS to use timer interrupts, what kind of interrupts can be implemented in S3C44B0? There are two methods in S3C44B0. ...
  • Learn ARM development(14)
  • Learn ARM development(15)
  • Learn ARM development(16)
  • Learn ARM development(17)
Change More Related Popular Components

EEWorld
subscription
account

EEWorld
service
account

Automotive
development
circle

About Us Customer Service Contact Information Datasheet Sitemap LatestNews


Room 1530, 15th Floor, Building B, No.18 Zhongguancun Street, Haidian District, Beijing, Postal Code: 100190 China Telephone: 008610 8235 0740

Copyright © 2005-2024 EEWORLD.com.cn, Inc. All rights reserved 京ICP证060456号 京ICP备10001474号-1 电信业务审批[2006]字第258号函 京公网安备 11010802033920号