久久99精品久久久久久琪琪,久久人人爽人人爽人人片亞洲,熟妇人妻无码中文字幕,亚洲精品无码久久久久久久

嵌入式Linux系統下I2C設備驅動程序的開發(范文模版)

時間:2019-05-14 23:02:45下載本文作者:會員上傳
簡介:寫寫幫文庫小編為你整理了多篇相關的《嵌入式Linux系統下I2C設備驅動程序的開發(范文模版)》,但愿對你工作學習有幫助,當然你在寫寫幫文庫還可以找到更多《嵌入式Linux系統下I2C設備驅動程序的開發(范文模版)》。

第一篇:嵌入式Linux系統下I2C設備驅動程序的開發(范文模版)

嵌入式Linux系統下I2C設備驅動程序的開發

【摘 要】 I2C總線是一種很通用的總線,具有簡單、高效等特點,廣泛應用在各種消費類電子產品及音視頻設備上,在嵌入式系統的開發中也經常用到。本文分析了嵌入式 linux系統中I2C驅動程序的結構,并結合一個具體的I2C時鐘芯片DS1307,說明在嵌入式linux系統下開發I2C設備驅動程序的一般流程。【關鍵字】I2C總線 嵌入式linux 驅動開發

1、I2C總線簡介 I2C(Inter-Integrated Circuit)總線是一種由PHILIPS公司開發的兩線式串行總線,用于連接微控制器及其外圍設備。I2C總線最主要的優點就是簡單性和有效性。

1.1 I2C總線工作原理

I2C總線是由數據線SDA和時鐘SCL構成的串行總線,各種被控制器件均并聯在這條總線上,每個器件都有一個唯一的地址識別,可以作為總線上的一個發送器件或接收器件(具體由器件的功能決定)[1]。I2C總線的接口電路結構如圖1所示。

圖1 I2C總線接口電路[1] 1.2 I2C總線的幾種信號狀態[1]

1.空閑狀態:SDA和SCL都為高電平。2.開始條件(S):SCL為高電平時,SDA由高電平向低電平跳變,開始傳送數據。3.結束條件(P):SCL為低電平時,SDA 由低電平向高電平跳變,結束傳送數據。

4.數據有效:在SCL的高電平期間,SDA保持穩定,數據有效。SDA的改變只能發生在SCL的底電平期間。

5.ACK信號: 數據傳輸的過程中,接收器件每接收一個字節數據要產生一個ACK信號,向發送器件發出特定的低電平脈沖,表示已經收到數據。1.3 I2C總線基本操作

I2C總線必須由主器件(通常為微控制器)控制,主器件產生串行時鐘(SCL),同時控制總線的傳輸方向,并產生開始和停止條件。

數據傳輸中,首先主器件產生開始條件,隨后是器件的控制字節(前七位是從器件的地址,最后一位為讀寫位)。接下來是讀寫操作的數據,以及 ACK響應信號。數據傳輸結束時,主器件產生停止條件[1]。具體的過程如圖2所示。

圖2 完整的I2C數據傳輸過程[1] 2.Linux下I2C驅動程序的分析 2.1 Linux系統I2C驅動的層次結構

Linux系統對I2C設備具有很好的支持,Linux系統下的I2C驅動程序從邏輯上可以分為3個部分:

1.I2C總線的驅動 I2C core :實現對I2C總線、I2C adapter及I2C driver的管理。2.I2C控制器的驅動 I2C adapter :針對不同類型的I2C控制器,實現對I2C總線訪問的具體方法。

3.I2C設備的驅動 I2C driver :針對特定的I2C設備,實現具體的功能,包括read, write以及ioctl等對用戶層操作的接口。這三個部分的層次關系如圖3和圖4所示。

2.2 I2C 總線驅動 I2C core

I2C core是Linux內核用來維護和管理的I2C的核心部分,其中維護了兩個靜態的List,分別記錄系統中的I2C driver結構和I2C adapter結構。I2C core提供接口函數,允許一個I2C adatper,I2C driver和I2C client初始化時在I2C core中進行注冊,以及退出時進行注銷。同時還提供了I2C總線讀寫訪問的一般接口(具體的實現在與I2C控制器相關的I2C adapter中實現),主要應用在I2C設備驅動中。

2.3 I2C控制器的驅動 I2C adapter

I2C adapter是針對不同類型I2C控制器硬件,實現比較底層的對I2C總線訪問的具體方法。I2C adapter 構造一個對I2C core層接口的數據結構,并通過接口函數向I2C core注冊一個控制器。I2C adapter主要實現對I2C總線訪問的算法,iic_xfer()函數就是I2C adapter底層對I2C總線讀寫方法的實現。同時I2C adpter 中還實現了對I2C控制器中斷的處理函數。

2.4 I2C設備的驅動 I2C driver

I2C driver中提供了一個通用的I2C設備的驅動程序,實現了字符類型設備的訪問接口,對設備的具體訪問是通過I2C adapter來實現的。I2C driver構造一個對I2C core層接口的數據結構,通過接口函數向 I2C Core注冊一個I2C設備驅動。同時I2C driver 構造一個對用戶層接口的數據結構,并通過接口函數向內核注冊為一個主設備號為89的字符類型設備。

I2C driver實現用戶層對I2C設備的訪問,包括open,read,write,ioctl,release等常規文件操作,我們可以通過open函數 打開 I2C的設備文件,通過ioctl函數設定要訪問從設備的地址,然后就可以通過 read和write函數完成對I2C設備的讀寫操作。

通過I2C driver提供的通用方法可以訪問任何一個I2C的設備,但是其中實現的read,write及ioctl等功能完全是基于一般設備的實現,所有的操作 數據都是基于字節流,沒有明確的格式和意義。為了更方便和有效地使用I2C設備,我們可以為一個具體的I2C設備開發特定的I2C設備驅動程序,在驅動中 完成對特定的數據格式的解釋以及實現一些專用的功能。3.一個具體的I2C設備驅動程序的開發

DS1307是一款小巧的I2C接口的實時時鐘芯片,具有低功耗,全BCD碼時鐘和日歷輸出,12 /24小時工作模式,時分秒、星期、年月日計時數據,潤年自動補償,有效期至2100年,外加56 Bytes的NV RAM(非易失性的RAM)等特點[3]。下面以DS1307為例,說明一個具體的I2C設備驅動程序的設計要點。3.1 I2C設備驅動程序的一般結構

一個具體的I2C設備驅動需要實現兩個方面的接口,一個是對I2C core層的接口,用以掛接I2C adapter層來實現對I2C總線及I2C設備具體的訪問方法,包括要實現attach_adapter,detach_client,command 等接口函數。另一個是對用戶應用層的接口,提供用戶程序訪問I2C設備的接口,包括實現open,release,read,write以及最重要的 ioctl等標準文件操作的接口函數。對I2C core層的接口函數的具體功能解釋如下: attach_adapter:I2C driver在調用I2C_add_driver()注冊時,對發現的每一個I2C adapter(對應一條I2C 總線)都要調用該函數,檢查該I2C adapter是否符合I2C driver的特定條件,如果符合條件則連接此I2C adapter,并通過I2C adapter來實現對I2C總線及I2C設備的訪問。

detach_client:I2C driver在刪除一個I2C device時調用該函數,清除描述這個I2C device的數據結構,這樣以后就不能訪問該設備了。

command:針對設備的特點,實現一系列的子功能,是用戶接口中的ioctl功能的底層實現。

3.2 DS1307驅動程序實現對I2C core層的接口

在驅動中必須實現一個struct i2c_driver 的數據結構,并在驅動模塊初始化時向I2C core注冊一個I2C驅動,并完成對I2C adapter的相關操作。struct i2c_driver ds1307_driver = { name: “DS1307”, id: I2C_DRIVERID_DS1307, flags: I2C_DF_NOTIFY, attach_adapter:ds1307_probe, detach_client:ds1307_detach, command: ds1307_command };數據結構ds1307_driver中的name:“DS1307”,Id:I2C_DRIVERID_DS1307用來標識DS1307驅動程序。flags: I2C_DF_NOTIFY表示在I2C總線發生變化時通知該驅動。

ds1307_probe對應i2c_driver數據結構中的attach_adapter,主要功能:調用 I2C core 層提供的i2c_probe函數查找一條I2C總線,看是否有DS1307的設備存在,如果存在DS1307,則將對應的I2C adapter 和DS1307設備掛接在一起,并通過該I2C adapter來實現對DS1307的訪問。同時使能DS1307, 并調用i2c_attach_client()向I2C core層注冊DS1307。

ds1307_detach對應i2c_driver數據結構中的detach_client,主要功能:調用i2c_detach_client()向I2C core層注銷DS1307,并不使能DS1307,這樣I2C驅動就不能訪問DS1307了。

ds1307_command對應i2c_driver 數據結構中的command,主要功能:針對DS1307時鐘芯片的特點,實現一系列的諸如DS1307_GETTIME,DS1307_SETTIME,DS1307_GETDATETIME,DS1307_MEM_READ,DS1307_MEM_WRITE等子功能,是用戶接口中的ioctl功能的底層實現。

以上3個接口函數使DS1307的驅動程序實現了對I2C 總線及I2C adpater的掛接,因此就可以通過I2C core的提供對I2C總線讀寫訪問的通用接口,來開發實現DS1037驅動程序對用戶應用層的接口函數。3.3 DS1307驅動程序實現對用戶應用層的接口

在驅動中必須實現一個struct file_operations 的數據結構,并向內核注冊為一個字符類型的設備(用單獨的主設備號來標識),或者注冊為一個miscdevice設備(所有miscdevice設備共同 一個主設備號,不同的次設備號,所有的miscdevice設備形成一個鏈表,對設備訪問時根據次設備號查找對應的miscdevice設備,然后調用其 struct file_operations中注冊的應用層接口進行操作)。

struct file_operations rtc_fops = { owner: THIS_MODULE, ioctl: ds1307_rtc_ioctl, read: ds1307_rtc_read, write: ds1307_rtc_read, open: ds1307_rtc_open, release: ds1307_rtc_release };數據結構rtc_fops 中的ds1307_rtc_open 和ds1307_rtc_release對應file_operations中的open和release,分別用來打開和關閉DS1307。ds1307_rtc_ioctl對應file_operations中的ioctl,對用戶提供的一系列控制時鐘芯片的具體命 令:RTC_GET_TIME: 以固定的數據格式讀取實時時鐘的時間。RTC_SET_TIME:以固定的數據格式設定實時時鐘的時間。RTC_SYNC_TIME:系統時鐘和實時時鐘 之間的時間同步。

ds1307_rtc_read 對應對應file_operations中的read,實現與ds1307_rtc_ioctl 的子功能RTC_GET_TIME相同的功能,以及從NV RAM讀取數據。

ds1307_rtc_write 對應file_operations中的write,實現與ds1307_rtc_ioctl的子功能 RTC_SET_TIME相同的功能,以及將數據寫入NV RAM。3.4 DS1307驅動程序的加載和測試

在DS1307驅動模塊的初始化函數ds1307_init()中,首先通過i2c_add_driver(&ds1307_driver)向I2C core層注冊一個I2C的設備驅動,然后再通過misc_register(&ds1307_rtc_miscdev)將DS1307注冊為一個miscdevice設備,這樣用戶程序就可以通過主設備號10 次設備號 135的設備節點/dev/rtc來訪問DS1307了。

將DS1307的驅動程序編譯成模塊的方式,通過insmod命令加載進內核,然后用測試代碼進行測試,DS1307驅動程序中實現的所有功能都達到了預期的效果。由于DS1307驅動程序在底層實現了對DS1307時鐘芯片數據的解釋和轉換,所以在用戶程序中得到的就是有固定格式和意義的數據,這樣就方便了用戶程序的訪問,提高了應用開發的效率。4.總結

I2C總線是一種結構小巧,協議簡單的總線,應用很廣泛,訪問起來簡單方便。linux系統下I2C的驅動程序具有清晰的層次結構,可以很容易地為一個特 定的I2C設備開發驅動。本文通過對linux系統下I2C驅動,以及一個具體的DS1307時鐘芯片驅動結構的分析,基本上可以很清楚看出一個I2C設 備驅動的開發過程。實現的關鍵分為兩個部分,1.對I2C core的接口,必須實現 struct i2c_drvier 數據結構中的幾個特定的功能函數。這些函數是I2C驅動與I2C總線物理層(I2C控制器)和I2C設備器件之間通信的基礎。2.對用戶應用層的接口,必須實現struct file_operation數據結構中的一些特定功能的函數,如 open,release , read ,write,lseek等函數。以上兩類接口中,對I2C core的接口是對I2C設備訪問的基礎,實現對I2C總線具體的訪問方法;對用戶應用層的接口則是方便應用程序開發,實現設備特定功能的必不可少的部 分。參考文獻:

[1] Philips Corporation,I2C bus specification version 2.1,2000 [2] Linux kernel,version 2.4.30 [3] Maxim Integrated Products , inc.USA.DS1307 Datasheet , 2004 [4] Aless and Robin著,魏永明等譯,《LINUX設備驅動程序(第二版)》,北京,中國電力出版社,2004年

第二篇:linux設備驅動程序開發總結

不管我們學習什么編程語言,和我們見面的第一個程序就是“hello world!” 相信各位道上的朋友都遇到過這種個程序!

學習驅動程序也不例外,我學的第一個驅動程序就是“hello world!” 具體的程序代碼如下:

#include

#include

MODULE_LICENSE(“Dual BSD/GPL”);

static int hello_init(void)

{

printk(KERN_ALERT“Hello, world!n”);

return 0;

}

static void hello_exit(void)

{

printk(KERN_ALERT“byby FriendyARM mini2440!n”);

}

module_init(hello_init);

module_exit(hello_exit);

將其復制到工作目錄下,并編寫一個簡單的Makefile文件:

由于每個人使用的Linux系統不一樣且每個人內核源代碼所存放的位置也不是一樣的。所以編寫Makefile文件的時候,參考別人的進行修改是一個很不錯的的學習Makefile文件的方法。當然你能把Linux內核的Makefile文件了解一下,對你了解Linux內核有很大的幫助的。

學習心得:

1、驅動模塊運行在內核空間,運行是不能依賴任何函數庫和模塊連接,所以在寫驅動程序的時候

所調用的函數只能是作為內核一部分的函數。

2、驅動模塊和應用程序的一個重要不同是:應用程序退出時可不管資源釋放或者其他的清除

工作,但模塊的退出啊哈念書必須仔細撤銷初始化函數所做的一切,否則,在系統想重新引導之前某些

東西就會殘留在系統中。

3、處理器的多種工作模式其實就是為了操作系統的用戶空間和內核空間設計的,在Unix類的操作系統

中只是用到了兩個級別:最高級別和最低級別。

4、要十分注意驅動程序的并發處理。在Linux驅動程序中必須解決的一個問題就是多個進程對共享資源的并發訪問.Linux對解決并發訪問可能導致的竟態問題提供了幾種機制:中斷屏蔽、原子操作、自旋鎖、信號量等機制。

5、內核API中具有下劃線(__)的函數,通常是接口的底層組件,應該慎用。

6、內核代碼不能實現浮點運算。內核中沒有提供一套進行浮點運算的完整的環境。

7、Makefile文件的分析:

obj-m := hello.o 代表了我們要構建的模塊名為hello.ko,make會子啊該目錄下自動找到hello.c文件進行編譯。如果hello.o文件是有其他的源文件生成(比如file.1和file1.c)的,則在下面加上:

hello-objs := file.o file1.o......(其中用紅色標志的是對應關系)$(MAKE)-C $(KERNELDIR)M=$(PWD)modules

其中-C $(KERNELDIR)指定了內核源代碼的位置,其中保存有內核的頂層makefile文件。

M=$(PWD)指定了模塊源代碼的位置

modules 目標指向obj-m變量中設定的模塊

8、insmod使用公共內核符號表來解析模塊中未定義的符號,公共內核符號表中包含了的、所有的全局內核項(即函數和變量的地址),這是實現模塊化驅動程序所必須的。

9、Linux使用模塊層疊技術,我們可以將模塊劃分為多個層次,通過簡化每個層可以縮短開發周期。如果一個模塊需要向其他模塊導出符號,則使用下面宏:

EXPORT_SYMBOL(name);

EXPORT_SYMBOL_GPL(name);

符號必須子啊模塊文件的全局變量部分導出,因為這兩個宏將被擴展為一個特殊變量的聲明,而該變量必須是全局的。

10、所有的模塊代碼都必須包含下面兩個頭文件:

#include

#include

11、所有模塊代碼都應指定所使用的許可證:

MODULE_LICENSE(“Dual BSD/GPL”);

12、初始化和關閉

初始化的實際定義通常是:

staticint _ _init initialization_function(void)

{

/*初始化代碼*/

}

module_init(initialization_function)

清除函數的實際定義是:

static int _ _exit cleanup_function(void)

{

/*清除代碼*/

}

module_exit(cleanup_function)

13、還有一些是可選的其他的描述型的定義:

MODULE_AUTHOR(“");

MODULE_DESCRIPTION(”“);

MODULE_VERSION(”“);

MODULE_ALIAS(”“);

MODULE_DEVICE_TABLE(”");

這些模塊的聲明習慣性的放在模塊程序的最后面。

14、Linux內核模塊的初始化出錯處理一般使用“goto”語句,通常情況下很少使用“goto”,但是出錯處理是(可能是唯一的情況),它卻非常的有用。

在大一學習C語言的時候,老師就建議不要使用“goto”語句,并說很少會用到,在這里遇到第一個建議使用“goto”語句的。在追求效率的代碼中使用goto語句一直是最好的錯誤恢復機制。下面是我截下來的一段關于使用goto語句實現錯誤處理的程序:

struct something*item1;

struct somethingelse*item2;

int stuff_ok;

void my_cleanup(void)

{

if(item1)

release_thing(item1);

if(item2)

release_thing2(item2);

if(stuff_ok)

unregister_stuff();

return;

}

int __init my_init(void)

{

int err=-ENOMEM;

item1= allocate_thing(arguments);item2= allocate_thing2(arguments2);if(!item2||!item2)

goto fail;

err= register_stuff(item1, item2);if(!err)

stuff_ok= 1;

else

goto fail;

return 0;/* success*/

fail:

my_cleanup();

return err;

}

第三篇:嵌入式開發實訓室設備維修制度

嵌入式開發實訓室設備維修制度

為做好分院實驗室儀器設備的維修管理工作,確保實驗室儀器設備的完好,特制定本制度。

一、儀器設備的使用管理人員應熟悉儀器設備,會正確操作使用,平時要做到精心維護,認真保養,加強檢查,及時排除隱患。

二、儀器設備維護保養要根據其性能進行,認真做好防銹、防火、防潮、防震工作,同時還應做好清潔潤滑、緊固、通電、更換易損零部件等工作。

三、儀器設備出現故障隱患苗頭時,應停止使用,及時檢查,并做好安全檢查記錄。

四、儀器設備的維修必須在認真做好故障診斷記錄的基礎上,由管理人員向分院提出維修申請報告,經批準后,方可進行修理。儀器設備的修理采取鼓勵校內修理,控制校外修理,盡可能減少異地修理。

五、儀器設備修理后,必須組織有關專業技術人員進行測試鑒定,并寫出鑒定結論,經確定為合格后方可投入正常使用。

六、儀器設備的維修記錄,應妥善保管,不得丟失。

七、實驗室各類技術人員都要認真學習修理技術,增強修理能力,做到儀器設備的一般故障,本室即可排除。

電子與信息工程分院2012年8月29日

第四篇:基于嵌入式ARM平臺的遠程IO數據采集系統的研究和開發.

Research and Development of the Remote I/O Data Acquisition System Based on Embedded ARM Platform

INTRODUCTION

With the wide use of the networked, intelligent and digital distributed control system, the data acquisition system based on the single-chip is not only limited in processing capacity, but also the problem of poor real-time and reliability.In recent years, with the rapid development of the field of industrial process control and the fast popularization of embedded ARM processor, it has been a trend that ARM processor can substitute the single-chip to realize data acquisition and control.Embedded ARM system can adapt to the strict requirements of the data acquisition system, such as the function, reliability, cost, size, power consumption, and so on.In this paper, a new kind of remote I/O data acquisition system based on ARM embedded platform has been researched and developed, which can measure all kinds of electrical and thermal parameters such as voltage, current, thermocouple, RTD, and so on.The measured data can be displayed on LCD of the system, and at the same time can be transmitted through RS485 or Ethernet network to remote DAS or DCS monitoring system by using Modbus/RTU or Modbus/TCP protocol.The system has the dual redundant network and long-distance communication function, which can ensure the disturb rejection capability and reliability of the communication network.The new

generation remote data acquisition and moni-toring system based on the high-performance embedded ARM microprocessor has important application significance.STRUCTRUE DESIGN OF THE WHOLE SYSTEM

The whole structure chart of the remote data acquisition and monitoring system based on embedded ARM platform is shown in Figure 1.In the scheme of the system, the remote I/O data acquisition modules are developed by embedded ARM processor, which can be widely used to diversified industries such as electric power, petroleum, chemical, metallurgy, steel, transportation and so on.This system is mainly used for the concentrative acquisition and digital conversion of a variety of electrical and thermal signals such as voltage, current, thermal resistance, thermo-couple in the production process.Then the converted data can be displayed on the LCD directly, and also can be sent to the embedded controller through RS485 or Ethernet network communication interface by using Modbus/RTU or Modbus/TCP protocol.The data in the embedded controller platform is transmitted to the work-stations of remote monitoring center by Ethernet after further analyzed and pro-cessed.At the same time, these data can be stored in the real time database of the database server in remote monitoring center.The system has the dual redun-dant network and long-distance communication

function, which can ensure the disturb rejection capability and reliability of the communication network.The hardware platform of the Remote I/O data acquisition system based on emb-edded ARM uses 32-bit ARM embedded microprocessor, and the software plat-form uses the real-time multi-task operating system uC/OS-II, which is open-source and can be grafted, cut out and solidified.The real time operating system(RTOS makes the design and expansion of the application becomes very easy, and without more changes when add new functions.Through the division of the appli-cation into several independent tasks, RTOS makes the design process of the application greatly simple.Figure 1 Structure of the whole system THE HARDWARE DESIGN OF THE SYSTEM

The remote I/O data acquisition system based on embedded ARM platform has high universality, each acquisition device equipped with 24-way acquisition I/O channels and isolated from each other.Each I/O channel can select a variety of voltage and current signals, as well as temperature signals such as thermal resis-tance, thermocouple and so on.The voltage signals in the range of 0-75 mV ,1-5V ,0-5V, and so on, the current signals in the range of 0-10mA and 4-20 mA, the thermal resistance measurement components including Cu50, Cu100, Pt50, Pt100, and the thermocouple measurement components including K, E, S, T, and so on.Figure2.Structure of the remote I/O data acquisition system based on ARM processor The structural design of the embedded remote I/O data acquisition system is shown in Figure 2.The system equipped with some peripherals such as power, keyboard, reset, LCD display, ADC, RS485, Ethernet, JTAG, I2C, E2PROM, and so on.The A/D interface circuit is independent with the embedded system, which is independent with the embedded system, which is system has setting buttons and 128*64 LCD, which makes the debugging and modification of the parameters easy.The collected data can be sent to the remote embedded controller or DAS, DCS system by using

Modbus/RTU or Modbus/TCP protocol through RS485 or Eth-ernet communication interface also, and then be used

for monitoring and control after farther disposal.The system of RS485 has a dual redundant network and long-distance communication function.As the embedded Ethernet interface makes the remote data exchange of the applications become very easy, the system can choose RS485 or Ethernet interface through jumper to communicate with host computer.Ethernet interface use independent ZNE-100TL intelligent embedded Ethernet to serial port conversion module in order to facilitate the system maintenance and upgrade.The ZNE-100TL module has an adaptive 10/100M Ethernet interface, which has a lot of working modes such as TCP Server, TCP Client, UDP, Real COM, and so on, and it can support four connections at most.Figure3.Diagram of the signal pretreatment circuit

Figure 3 shows the signal pretreatment circuit diagram.The signals of thermo-couple such as K,E,S,T etc and 0-500mV voltage signal can connect to the positive end INPx and the negative end INNx of the simulate multiplexers(MUX directly.The 4-20mA current signal and 1-5V voltage signal must be transformed by resis-tance before connecting to the positive end INPx and the negative end INNx of the MUX of certain channel.The RTD thermal resistance signals such as Cu50, Cu100, Pt50 and Pt100 should connect one 1mA constant current before connecting to the positive end INPx and the negative end INNx of the MUX of certain channel.Figure4.Diagram of ADC signal circuit Figure 4 shows the ADC signal circuit, which using the 16-bit ADC chip AD7715.The connection of the chip and the system is simple and only need

five lines which are CS(chip select, SCLK(system clock, DIN(data input, DOUT(data output and DRDY(data ready.As the ARM microprocessor has the characteristics of high speed, low power, low voltage and so on, which make its capacity of low-noise, the ripple of power, the transient response performance, the stability of clock source, the reliability of power control and many other aspects should be have higher request.The system reset circuit use special microprocessor power monitoring chip of MAX708S, in order to improve the reliability of the system.The system reset circuit is shown in Figure 5.Figure5.Diagram of system reset circuit

SOFTWARE DESIGN AND REALIZATION OF THE SYSTEM

The system software of the remote I/O data acquisition system based on embedded ARM platform use the real-time operating system(RTOS uC/OS-II, which is open-source and can be grafted,cut out and solidified.The key part of RTOS is the real-time multi-task core, whose basic functions including task management, resource management, system management, timer management, memory management, information management, queue management and so on.These functions are used though API service functions of the core.The system software platform use uC/OS-II real-time operating system core simplified the design of application system and made the whole structure of the system simple and the complex application hierarchical.The design of the whole system includes the tasks of the operating system and a series of user applications.The main function of the system is mainly to realize the initialization of the system hardware and the operating system.The initialization of hardware includes interr-upt、keyboard、LCD and so on.The initialization of operating system includes the control blocks and events control blocks, and before the start of multi-task schedu-ling, one task must be started at least.A start task has been created in this system, which is mainly responsible for the initialization and startup of clock, the start-up of interruption, the initialization of communication task module, as

well as the division of tasks and so on.The tasks must be divided in order to complete various functions of the real-time multi-task system.Figure6.Functional tasks of the system software Figure6 shows the functional tasks of the system software.According to importance of the tasks and the demands of real-time, the system applications are divided into six tasks with different priority, which including the tasks of A/D data acquisition, system monitoring, receive queue, data send, keyboard input, LCD display.The A/D data acquisition task demands the highest real-time requirements and the LCD display task is the lowest.Because each task has a different priority, the higher-priority task can access the ready one by calling the system hang up function or delay function.Figure7.Chart of AD7715 data transfer flow Figure 7 shows the data conversion flow of AD7715.The application A/D conversion is an important part of the data acquisition system.In the uC/OS-II real-time operating system core, the realization process of A/D driver depends mainly on the conversion time of A/D converter, the analog frequency of the conversion value, the number of input channels, the conversion frequency and so on.The typical A/D

conversion circuit is made up of analog multiplexer(MUX, amplifier and analog to digital converter(ADC.Figure8.Diagram of the application transfer driver Figure8 shows the application procedure transfer driver.The driver chooses the analog channel to read by MUX, then delay a few microseconds in order to make the signal pass through the MUX, and stabilize it.Then the ADC was triggered to start the conversion and the driver in the circle waiting for the ADC until its completion of the conversion.When waiting is in progress, the driver is detecting the ADC state signal.If the waiting time is longer than the set time, the cycle should be end.During waiting time of the cycle, if the conversion completed signal by ADC has been detected, the driver should read the results of the conversion and then return the result to the application.Figure9.Diagram of serial receive Figure9 shows the serial receive diagram with the buffer and signal quantity.Due to the existence of serial peripheral equipment does not match the speed of CPU, a buffer zone is needed, and when the data is sending to the serial, it need to be written to the buffer, and then be sent out through serial one by one.When the data is received from the serial port, it will not be processed until several bytes have been received, so the advance data can be stored in buffer.In practice, two buffer zones, the receiving buffer and the sending buffer, are needed to be opened from the memory.Here the buffer zone is defined as loop queue data structure.As the signal of uC/OS-II provides the overtime waiting mechanism, the serial also have the overtime reading and writing ability.If the initialization of the received data signal is 0, it expresses the loop buffer is empty.After the interrupt received, ISR read the received bytes from the UART receiving buffer, and put into receiving buffer region, at last wake the user task to execute read operation with the help of received signal.During the entire

process, the variable value of the current bytes in recording buffer can be inquired, which is able to shows whether the receive buffer is full.The size of the buffer zone should be set reasonable to reduce the possibility of data loss, and to avoid the waste of storage space.CONCLUSIONS

With the rapid development of the field of industrial process control and the wide range of applications of network, intelligence, digital distributed control System, it is necessary to make a higher demand of the data accuracy and reliability of the control system.Data acquisition system based on single-chip has been gradually eliminated because the problem of the poor real-time and reliability.With the fast popularization of embedded ARM processor, there has been a trend that ARM processor can alternate to single-chip to realize data acquisition and control.The embedded ARM system can adapt to the strict requirements of the data acquisition system, such as the function, reliability, cost, size, power consum-ption, and so on.In this paper, A kind of ARM-based embedded remote I/O data acquisition system has been researched and developed, whose hardware platform use 32-bit embedded ARM processor, and software platform use open-source RTOS uC/OS-II core.The system can be widely applied to electric power, petroleum, chemical, metallurgy, steel, transportation and so on.And it is mainly used in the collection and monitoring of all

kinds of electrical and thermal signals such as voltage, current, thermal resistance, thermocouple data of the production process.Then these data can be sent to the remote DAS, DCS monitoring system through RS485 or Ethernet interface.The system has the dual redundant network and long-distance communication function, which can ensure the disturb rejection capability and reliability of the communication network.基于嵌入式ARM平臺的遠程I / O數據采集系統的研究和開發

導言

隨著網絡化,智能化,數字化分布式控制系統的廣泛使用,基于單芯片的數據采集系統不僅在處理能力上受限制,并且在實時性和可靠性方面也出現了問題。近幾年來,隨著工業過程控制領域的迅速發展和嵌入式ARM處理器的迅速普及,ARM處理器代替單芯片實現數據的采集和控制成為了趨勢。嵌入式ARM系統能適應數據采集系統的嚴格要求,如功能性,可靠性,成本,體積,功耗等等。

在本文中提出一種新型的基于ARM嵌入式平臺的遠程I / O數據采集系統已被研制開發,它可以衡量各種電氣和熱參數,如電壓,電流,熱電偶,熱電阻等等。那個測量數據可以顯示在液晶顯示器的系統中,同時可通過使用Modbus / RTU或的Modbus / TCP協議從RS485或以太網網絡傳送到DAS或DCS遠程監控

系統。該系統具有雙冗余網絡和長途電通信功能,它可以確保通信網絡的干擾抑制能力和可靠性。基于高性能嵌入式ARM微處理器的新一代遠程數據采集和監控系統具有重要的應用意義。

整個系統的結構設計

基于嵌入式ARM的平臺的遠程數據采集和監控系統的整個結構圖在以下的圖1中展示。在這系統的計劃中,通過使用廣泛用于多種行業如電氣電力,石油,化工,冶金,鋼鐵,運輸等的嵌入式ARM處理器來開發遠程I / O數據采集模塊。該系統主要用于的集中采購和將各種電和熱信號如電壓,熱電阻,熱電偶在生產過程中進行數字轉換。轉換的數據可直接在液晶顯示器上顯示,也可以通過使用的Modbus / RTU或的Modbus / TCP協議的RS485總線或以太網網絡通信接口被發送到嵌入式控制器。嵌入控制器平臺的數據通過進一步以太網的分析和處理被傳送至遠程監控中心的工作站。與此同時,這些數據可以存儲在遠程監控中心數據庫服務器的實時數據庫中。該系統具有雙冗余網絡和遠程通訊功能,它可以確保通信網絡的干擾抑制能力和可靠性。

基于嵌入式ARM遠程I / O數據采集系統的硬件平臺使用32位ARM嵌入式微處理器和軟件平臺使用的是開源的并且可移植,削減和鞏固的實時多任務操作系統的第二代UC / OS核心。實時操作系統(RTOS)使設計和應用的擴大變得非常容

易,增加新的功能時也沒多大變化。通過幾個獨立的任務的應用,實時操作系統使得應用的設計過程極為簡單。

系統的硬件設計

基于嵌入式ARM平臺的遠程I / O數據采集系統具有很高的普遍性,每個購置設備配備24收購方式的I / O渠道且彼此孤立。每個I / O通道可以選擇不同的電壓和電流信號,以及溫度信號如熱電阻,熱電偶等。在05V的,010毫安和4100TL智能嵌入式以太網串口轉換模塊。該ZNE500mV的電壓信號可以直接接到模擬多路復用器(復用器)的INPx正極和INNx負極。45V的電壓信號必須用阻抗轉換。熱電阻的電阻信號如Cu50,Cu100,Pt50和Pt100應在接到某些頻道的復用器INPx正極和INNx負極前連接一1毫安的恒流源。

圖4顯示了使用16位ADC芯片AD7715的ADC信號電路。芯片與系統的連接非常簡單,只需要CS(芯片選擇),SLCK(系統時鐘),DIN(數據輸入),DOUT(數據輸出)和DRDY(數據準備)5根線。

由于ARM微處理器具有高速,低功耗,低電壓等優點,這使它在低噪音,紋波權力,瞬態響應性能,時鐘來源的穩定,功率控制和許多其他方面需要有更高的要求。為了改善系統的可靠性該系統復位電路中使用特殊的微處理器電源監測芯片MAX708S。圖5展示了該系統復位電路。

系統軟件的設計與實現

基于嵌入式ARM平臺的遠程I / O數據采集系統的軟件使用的是開源的并且可移植,削減和鞏固的實時多任務操作系統的第二代UC / OS核心。RTOS的關鍵部分是實時多任務的核心,其基本功能包括任務管理,資源管理,系統管理,計時器管理,內存管理,信息管理,隊列管理等。通過API服務職能核心使用這些功能。

該系統軟件平臺使用的是單一化的uC/ OS第二代實時簡化操作系統核心,使整個結構系統簡單和應用層次復雜。整個系統的設計包括操作系統的任務和一系列的用戶應用程序。系統的主要職能是實現系統硬件和操作系統的初始化。硬件初始化包括中斷,鍵盤,液晶顯示器等。操作系統初始化包括控制模塊和事件控制,在多任務調度前,至少有一個任務開始。一個開端任務已建立在這一系統,這系統主要負責初始化和啟動的時鐘,開辦中斷,通信任務模塊的初始化,以及任務分工等。為了完成實時多任務系統的多種職能那個任務必須被劃分。

圖6顯示系統軟件的功能任務。根據任務的重要性和實時要求,系統的應用曾劃分為六個不同優先級的任務,其中包括A / D數據采集任務,系統監控,接受隊列,數據傳送,鍵盤輸入,液晶顯示屏顯示。A / D數據采集任務要求最高的實時要求和液晶顯示器顯示任務是最低的。因為每個任務都有不同的優先事項,通過使用系統掛斷功能或延遲功能更高的優先任務可以開始已經準備好的任務。

圖7顯示的是AD7715的數據轉換流。A / D轉換器的應用是數據采集系統的一個重要組成部分。在uS/ OS的第二代實時操作系統的核心中,A / D驅動程序的實現過程主要取決于A / D轉換器的轉換時間,有轉換價值的模擬頻率,輸入通

道的數量,轉換頻率等等。典型的A / D轉換電路由模擬復用器(復用器),放大器和模擬到數字轉換器(ADC)組成。

圖8顯示了申請程序轉移的驅動程序。驅動程序可以在模擬通道讀取由復用器,那么幾微秒的延遲,以便使信號通過多路開關,并使其穩定。然后,當轉換開始時,ADC被觸發,并且驅動程序在一個周期內等待ADC的觸發,直到完成轉換。當等待的進展,該驅動程序檢測ADC的狀態信號。如果等待時間比規定的時間越長,周期應該結束。在等待的周期時間,如果轉換完成ADC的信號被檢測到,驅動程序應改為轉換的結果,然后將結果返回給應用程序。

圖9顯示了緩沖區和信號量的序列接收圖。由于外圍串行設備的存在CPU的運行速度匹配,一個緩沖區是必要的,當數據發送到序列,它必須被寫入緩沖區,然后通過串行逐一地被發送出去。當從串行端口收到數據,這些數據將不會被處理直到收到一些字節,因此先前的數據可以存儲在緩沖區中。在實踐中,兩個緩沖區,一個接收緩沖區和一個發送緩沖區,它們是需要從內存開放出來。在這里緩沖區像循環隊列數據結構一樣被定義。

由于uC/OS-II提供額外時間等待機制的信號,串口也具有額外的閱讀和寫作能力。如果收到的數據信號初值為0,它表示循環緩沖區是空的。在中斷收到后,ISR從UART接受緩沖區中讀到收到的數據,并投入接收緩沖區域,最后通過收到的數據開始用戶執行讀操作的的任務。在整個過程中,變量價值目前字節在存儲緩沖區中的字節的變量值是可以被詢問的,這能夠表明接收緩沖區是否已滿。為了降低數據丟失的可能性和避免浪費存儲空間應合理地設置緩沖區的大小。

結論

隨著工業過程控制領域的快速發展和網絡,智能,數字化分布式控制系統廣泛應用,有必要發展對數據準確性和控制可靠性要求更高的系統。由于較差的實時性和可靠性基于單片機數據采集系統已逐步被淘汰。隨著嵌入式ARM處理器的迅速普及,ARM處理器替代單芯片實現數據采集與控制成為了一種新的趨勢。嵌入式ARM系統能夠適應數據采集系統的嚴格要求,如功能,可靠性,成本,大小,耗電量等等。

在本文中一種基于ARM的嵌入式遠程I / O數據采集系統已被研究和開發,其硬件平臺采用32位嵌入式ARM處理器和軟件平臺的使用開源的RTOS uS/ OS-Ⅱ核心。該系統可廣泛應用于電力,石油,化工,冶金,鋼鐵,交通運輸等方面。這是主要用于收集和監測各種電氣和熱信號,如電壓,電流,熱電阻,生產過程中的熱電偶數據。然后通過RS485或以太網接口將這些數據發送到遠程的DAS,DCS控制系統的監測系統。該系統具有雙冗余網絡和長途通信功能,它可以確保干擾抑制和通信網絡的可靠性。

第五篇:采用服務器端嵌入式腳本語言PHP3進行Linux下的網站開發

中國搜課網 http://www.tmdps.cn

課件 教案 試題 論文 圖書 中考 高考 新課標

采用服務器端嵌入式腳本語言PHP3進行Linux下的網站開發 ux下安裝,不過如果用于商業用途需要付費.PostgreSQL也是Linux下的免費數據庫,RedHat5里面就帶了,不過我沒有用過,就不說了.mSQL與MySQL既然本來就是差不多的兩個東西,PHP中對它們的訪問語句也都差不多,例如msql_close與mysql_close就分別完成同樣的關閉動作.所以以下介紹時只對mysql介紹,msql的訪問語句只需換個前綴即可(特殊情況另行說明).注意:mSQL與MySQL訪問函數都需要有相應的權限才能運行.(1)mysql_connect(主機,用戶名,口令);返回一個連接號.注意:mysql各用戶的口令可以隨該用戶所在機器IP地址不同而改變.另外,mSQL沒有用戶名機制,所以msql_connect只需要一個主機參數.主機可以是IP地址或域名.(2)mysql_create_db(數據庫名);(3)mysql_select_db(數據庫名,連接號);連接一個數據庫.(4)mysql_query(SQL語句,連接號);如果SQL語句是select,則返回一個結果號.否則返回的值可以不理會.如果失敗,返回false.(5)mysql_fetch_array(結果號);取出下一行,返回一個數組.可以用數字下標訪問(第一個字段是下標 0),《采用服務器端嵌入式腳本語言PHP3進行Linux下的網站開發》一文由中國搜課網搜集整理,版權歸作者所有,轉載請注明出處!

中國搜課網 http://www.tmdps.cn 提供中小學全科課件、教案、論文、中高考試題、新課標資源、電子圖書搜索與下載服務。

下載嵌入式Linux系統下I2C設備驅動程序的開發(范文模版)word格式文檔
下載嵌入式Linux系統下I2C設備驅動程序的開發(范文模版).doc
將本文檔下載到自己電腦,方便修改和收藏,請勿使用迅雷等下載。
點此處下載文檔

文檔為doc格式


聲明:本文內容由互聯網用戶自發貢獻自行上傳,本網站不擁有所有權,未作人工編輯處理,也不承擔相關法律責任。如果您發現有涉嫌版權的內容,歡迎發送郵件至:645879355@qq.com 進行舉報,并提供相關證據,工作人員會在5個工作日內聯系你,一經查實,本站將立刻刪除涉嫌侵權內容。

相關范文推薦

主站蜘蛛池模板: 欧美性生交大片免费看app麻豆| 人妻无码| 午夜无码区在线观看| 久久综合狠狠综合久久综合88| 99久久99久久加热有精品| 亚洲精品入口一区二区乱麻豆精品| 丁香五香天堂网| 97超碰人人做人人爱欧美| 舌头伸进去添的我好爽高潮欧美| 2020亚洲欧美国产日韩| 国产精品51麻豆cm传媒| 伊在人天堂亚洲香蕉精品区| 午夜不卡无码中文字幕影院| 日本无遮挡吸乳呻吟视频| 四虎国产精品永久免费网址| 国产亚洲欧美日韩在线一区二区三区| 国产成人a无码短视频| 一本久道久久综合狠狠躁av| 国产亚洲av手机在线观看| 国产成人无码午夜视频在线观看| 亚洲国产午夜精华无码福利| 亚洲图片小说激情综合| 国产九九99久久99大香伊| 亚洲av日韩精品久久久久久| 欧美 亚洲 国产 另类| 精品国产一区二区三区久久影院| 亚洲国产精品久久久久秋霞| 午夜亚洲国产理论片_日本| 久久久久人妻精品一区| 色偷偷一区二区无码视频| 国产自在自线午夜精品| 国产精品香蕉成人网在线观看| 成熟丰满熟妇xxxxx丰满| 国产成人精品一区二三区| 无码国产精品一区二区免费i6| av小次郎收藏| 午夜福利理论片高清在线观看| 男人的天堂中文字幕熟女人妻| 国产 麻豆 日韩 欧美 久久| 男女无遮挡xx00动态图120秒| 日韩精品久久久久久久电影蜜臀|