嵌入式课程设计

时间:2024.3.15

 

嵌入式系统软件开发课程设计报告

题    目:基于嵌入式系统的传感器环境检测       

学    院:     物理与电子信息工程学院   

专  业:        计算机科学与技术      

班  级:       10计本                  

姓    名:       左凌轩                  

学    号:       10110013151             

指导老师:       徐玉                    

完成日期:       2013.3.30                

目录

摘  要... I

Abstract II

第一章       设计目的... 3

1.1 掌握STM32嵌入式系统各功能模块的使用方法。... 3

1.2 掌握SHT1x温湿度传感器、BMP085气压传感器、GL5528光敏电阻、雨量传感器的数据采集与处理方法。    3

1.3 掌握嵌入式系统上位机软件的实现方法。... 3

第二章 课程设计要求... 3

2.1        嵌入式系统要求... 3

2.2        上位机要求... 3

第三章 系统原理... 3

3.1硬件电路... 3

3.2 SHT1x温湿度传感器... 4

3.3 BMP085气压传感器... 4

3.4        GL5528光敏电阻... 4

3.5        雨量传感器... 5

第四章 系统开发步骤... 5

4.1开发板模块初始配置... 5

4.2传感器模块初始配置... 5

4.3 UI、传感器数据读取显示以及串口传输... 5

4.4上位机串口软件编写以及测试... 6

4.5 整体测试和调试... 8

第五章 总结... 11

第六章 附录... 12

6.1 Comopeator(主界面) 12

6.2 history(查看历史界面)... 22


摘  要

设计多传感器实现环境质量检测的多功能、实时数据保存以及查看,有利于各个领域在环境方面的检测和测试,方便在环境相应参数的调查和研究。本文采用Stm32开发版、BMP085、SHT1X、光强、雨量等灵敏度较高的先进传感器分别检测温度、气压、湿度、光强、雨量,并在上位机中用C++实现实时显示和数据库的保存。从设计中,各种检测和数据挖掘明显趋于简单。

关键词: 传感器 检测 数据

注:上位机关键代码见附录


Abstract

.

KeyWords:

 

                                                                                                                                


第一章 设计目的

1.1 掌握STM32嵌入式系统各功能模块的使用方法。

1.2 掌握SHT1x温湿度传感器、BMP085气压传感器、GL5528光敏电阻、雨量传感器的数据采集与处理方法。

1.3 掌握嵌入式系统上位机软件的实现方法。

 

第二章 课程设计要求

2.1嵌入式系统要求

2.1.1、SHT1x温湿度传感器的信息采集与处理

2.1.2、BMP085气压传感器的信息采集与处理

2.1.3、基于GL5528光敏电阻的亮度信息采集与处理

2.1.4、雨量传感器的数据采集与处理

2.1.5、传感器信息的LCD显示界面设计

2.1.6、串口通讯程序与相应通讯协议设计与实现

2.2上位机要求

2.2.1、   传感器信息的显示

2.2.2、   串口配置(串口号、波特率的选择)

2.2.3、   传感信息的数据库保存

2.2.4、   数据库信息的可视化显示

  第三章 系统原理

3.1硬件电路

本课程设计涉及的环境监测系统在STM32嵌入式实验教学系统的基础上实现,相关的硬件原理图如下图所示

      

                                          (图1)

3.2 SHT1x温湿度传感器

SHT1x温湿度传感器是应用非常广泛一类环境传感器,可以数字形式提供14位分辨率的温度信息与12位分辨率的相对湿度信息。该传感器提供专用的同步半双工串行接口向CPU传送采集的传感信息,其时钟信号连接STM32的PC14端口,数据信号连接STM32的PA9端口。STM32利用GPIO口模拟SHT1x专用的串口通讯协议以实现传感信息采集。

 

3.3 BMP085气压传感器

BMP085是Bosch公司推出的一款绝对压力传感器,可以数字形式提供16-19位分辨率的绝对压力信息与16位分辨率的温度信息。STM32利用I2C1与该传感器通讯,PB6端口连接其时钟信号,PB7连接其数据信号。

 

3.4GL5528光敏电阻

光敏电阻的阻值随着亮度的提升而降低,基于此原理可利用上图所示电路中的电阻分压电路检测光敏电阻的阻值,进而根据阻值与亮度的关系计算环境中的光照强度。

3.5雨量传感器

雨量传感器由一系列互不连通的导线构成,当雨滴落到各导线上,由于水的导电作用雨量传感器的电阻会降低,阻值随着雨滴增多而降低,基于此原理可利用上图所示的电路中的分压电路检测雨量传感器的阻值,进而判断雨量大小。

  第四章 系统开发步骤

4.1开发板模块初始配置

void RCC_Configuration(void);

void SysTick_Configuration(void);//系统时钟初始化

void GPIO_Configuration(void);//管脚初始化

void EXTI_Configuration(void);//中断处理

void NVIC_Configuration(void);//优先级响应初始化

void ADC_Configuration(void); //数模转换以及模数转换

void DAC_Configuration(void);

void USART_Configuration(void);//串口模块初始化

void TIM_Configuration(void);//

void I2C_Configuration(void);//数据总线初始化

4.2传感器模块初始配置

void BMP085_BufferRead(u8 *pBuffer, u8 ReadAddr, u8 NumByteToRead);

void BMP085_ReadCalCoeff(void);

u16 BMP085_ReadTemp(void);//读取温度

u32 BMP085_ReadPressure(void);//读取气压

void SHT1x_DataOut(void);

void SHT1x__DataIn(void);

u8 SHT1x_WriteByte(u8 value);

u8 SHT1x_ReadByte(u8 ack);

void SHT1x_TransStart(void);

void SHT1x_ConnectionReset(void);//SHT1x初始化连接

u8 SHT1x_ReadReg(u8 *pvalue);

u8 SHT1x_Measure(u16 *pvalue, u8 mode);

u8 SHT1x_ReadTempHumi(float *ptemp,float *phumi);

float GL5528_ReadLight(void);//获取光强

u16 Rain_Read(void);//获取雨量数值

4.3 UI、传感器数据读取显示以及串口传输

4.3.1 UI设置

 Key1按下选择查看的项目,Key2按下确认进入查看的项目实时图形设置,Key3退出当前的页面(只在查看实时显示时有效)。

4.3.2数据读取

void getall();//读取所有数据

void settingdetail();//设置单个读取信息

void DiscribeLine();//UI画图函数

4.4上位机串口软件编写以及测试

本组采取的是C++ Builder IDE下的软件编写,在串口通讯方面使用了Victor串口通讯控件、EXCLE导出控件、以及自编注册表自动获取控件、Chart查看显性实时图像信息,以及数据库连接和数据库的存储(其中使用了SQLserver数据库及其触发器编程)。

4.4.1对应串口设置

固定波特率为:9600

自动搜索串口(从上位机注册表读取):ComX

4.4.2图像实时显示

4.4.3数据库保存

4.4.3历史数据查看以及到处生成EXCEL

4.4.5历史数据图像显示

4.5 整体测试和调试

第五章 总结

从上述设计中,本文顺利地解决了嵌入式系统的设计与编码,上位机的界面设计以及算法设计与编码,即可以简单快捷地使用此设计作为环境检测的标准。同时在设计的过程中遇到了许多困难和疑惑,但是在不懈努力与坚持下,本组组员都得以克服。最后让组员收获颇多。


第六章 附录

6.1 Comopeator(主界面)

//---------------------------------------------------------------------------

#ifndef ComOpeatorH

#define ComOpeatorH

//---------------------------------------------------------------------------

#include <Classes.hpp>

#include <Controls.hpp>

#include <StdCtrls.hpp>

#include <Forms.hpp>

#include "YbCommDevice.h"

#include <ExtCtrls.hpp>

#include <Registry.hpp>

#include <DB.hpp>

#include <DBTables.hpp>

#include "Chart.hpp"

#include "Series.hpp"

#include "TeEngine.hpp"

#include "TeeProcs.hpp"

#include <ADODB.hpp>

#include <ComCtrls.hpp>

#include <DBGrids.hpp>

#include <Grids.hpp>

#include <ExtCtrls.hpp>

#include <sysvari.h>

#include <Provider.hpp>

#include <comobj.hpp>

#include <jpeg.hpp>

#include <Dialogs.hpp>

//---------------------------------------------------------------------------

class TComConnection : public TForm

{

__published:   // IDE-managed Components

       TYbCommDevice *YbCommDevice1;

       TMemo *Memo1;

       TButton *Button2;

       TComboBox *cbb_com;

       TButton *Button3;

       TButton *btClear;

       TLabeledEdit *LabeledEdit1;

       TLabeledEdit *LabeledEdit2;

       TLabeledEdit *LabeledEdit3;

       TLabeledEdit *LabeledEdit4;

       TLabeledEdit *LabeledEdit5;

       TLabeledEdit *LabeledEdit6;

       TChart *Chart1;

       TBarSeries *Series1;

       TButton *btshow;

       TButton *btdataopen;

       TADOConnection *ADOConnection1;

       TADOQuery *ADOQuery1;

       TDateTimePicker *DateTimePicker1;

       TButton *btdataclose;

       TTimer *Timer1;

       TPanel *Panel1;

       TDBGrid *DBGrid1;

       TDateTimePicker *DateTimePicker2;

       TDateTimePicker *DateTimePicker3;

       TADOQuery *ADOQuery2;

       TButton *Button1;

       TButton *Button4;

       TButton *Button5;

       TDataSource *DataSource1;

       TImage *Image1;

       TButton *Button6;

       void __fastcall Button2Click(TObject *Sender);

//     void __fastcall Button1Click(TObject *Sender);

       void __fastcall YbCommDevice1Package(TObject *Sender, int NotifyType);

       void __fastcall Button3Click(TObject *Sender);

       void __fastcall cbb_comSelect(TObject *Sender);

       void __fastcall btdatacloseClick(TObject *Sender);

       void __fastcall btClearClick(TObject *Sender);

       void __fastcall btshowClick(TObject *Sender);

       void __fastcall btdataopenClick(TObject *Sender);

       void __fastcall Timer1Timer(TObject *Sender);

       void __fastcall Button1Click(TObject *Sender);

       void __fastcall Button4Click(TObject *Sender);

       void __fastcall Button5Click(TObject *Sender);

       void __fastcall Button6Click(TObject *Sender);

private:   // User declarations

       bool comStatus;

       bool aotuCom;

       bool datain;

       bool dymcshow;

public:           // User declarations

       __fastcall TComConnection(TComponent* Owner);

       void FillInfo(int varity , UnicodeString s);

       void FillDatabase();

       bool DBGrid2Excel(TDataSet *dataset, String filename);

};

//---------------------------------------------------------------------------

extern PACKAGE TComConnection *ComConnection;

//---------------------------------------------------------------------------

#endif

//---------------------------------------------------------------------------

#include <vcl.h>

#pragma hdrstop

#include "ComOpeator.h"

#include "his.h"

//---------------------------------------------------------------------------

#pragma package(smart_init)

#pragma link "YbCommDevice"

#pragma link "Chart"

#pragma link "Series"

#pragma link "TeEngine"

#pragma link "TeeProcs"

#pragma resource "*.dfm"

TComConnection *ComConnection;

//---------------------------------------------------------------------------

__fastcall TComConnection::TComConnection(TComponent* Owner)

       : TForm(Owner)

{

       comStatus = false;

       aotuCom = false;

       datain = false;

       dymcshow = false;

       Memo1->Clear();

}

//---------------------------------------------------------------------------

void __fastcall TComConnection::Button2Click(TObject *Sender)

{

       try{

       if(!comStatus){

              YbCommDevice1->Active = true; //打开串口

              YbCommDevice1->PackageType = cptFrameTimeout; //使用超时的方法识别每帧数据

              YbCommDevice1->UsePackage = true; //启动 Package

              Button2->Caption="关闭串口";

       }

       else

       {

              YbCommDevice1->Active = false;

              Button2->Caption="打开串口";

       }

       }

       catch(Exception &e){

              ShowMessage("打开串口失败,请先选择自动或检查串口是否正确接入。");

       }

       comStatus = !comStatus;

}

//---------------------------------------------------------------------------

/*

void __fastcall TComConnection::Button1Click(TObject *Sender)

{

  int nBytes = 0;

  char Buffer[1000];

  wchar_t *EndPtr;

  UnicodeString head="09 A1 ff ff ff ff ff ff ";

  UnicodeString code=head + Edit1->Text;

//  UnicodeString code= Edit1->Text;

  UnicodeString t,s = code.Trim(); //去掉两端的空格

  while(s.Length()>0)

   {

        int p = s.Pos(' '); //空格

        if(p>0)

         {

              t = s.SubString(1,p-1);

              s = s.SubString(p+1,s.Length()).Trim();

              Buffer[nBytes++] = wcstol(t.w_str(), &EndPtr, 16); //十六进制字符串转成字节

         }

        else //还剩下最后一个字节

         {

              t = s;

              s = "";

              Buffer[nBytes++] = wcstol(t.w_str(), &EndPtr, 16); //十六进制字符串转成字节

         }

   }

  YbCommDevice1->Write(Buffer,nBytes);

}

*/

//---------------------------------------------------------------------------

void __fastcall TComConnection::YbCommDevice1Package(TObject *Sender, int NotifyType)

{

       unsigned char Buf[1000]; //接收缓存

       int n = YbCommDevice1->ReadPackage(Buf,100);

       int varity = -1;

       if(n>0) //收到数据的字节数

        {

              UnicodeString s;

              for(int i=0; i<n; i++){

                     if(Buf[i] == 0xff){

                             Memo1->Lines->Add(s);

                             if(varity >=0)

                             FillInfo(varity,s);

                             s="";

                             continue;

                     }

                     else if(Buf[i] >=0xa0 && Buf[i]<=0xa5){

                            varity = Buf[i]-0xa0;

                            continue;

                     }

                     s += (char)(Buf[i]);

              }

         //  Memo1->Lines->Add(s); //在 Memo1 里显示出收到的数据, 将会是完整的一帧数据

        }

}

//---------------------------------------------------------------------------

void __fastcall TComConnection::Button3Click(TObject *Sender)

{

       try{

       TRegistry *reg = new TRegistry(KEY_READ);

       TStringList *strlist = new TStringList;

       reg->RootKey = HKEY_LOCAL_MACHINE;

/*

20##-1-26 未能将转义符转义,致使注册表打开失败,经过修改随即可行。

*/

       reg->OpenKeyReadOnly("HARDWARE\\DEVICEMAP\\SERIALCOMM");

       reg->GetValueNames(strlist);

       cbb_com->Clear();

       for( int i=0; i<strlist->Count;i++ )

       {

              strlist->Strings[i] = reg->ReadString(strlist->Strings[i]);

              cbb_com->Items->Add(strlist->Strings[i]);

       }

       cbb_com->ItemIndex = 0;

       delete reg,strlist;

       cbb_comSelect(this);

       aotuCom = true;

       }

       catch(Exception &e){

              ShowMessage("自动搜索串口失败,请检查串口是否正确接入。");

       }

}

//---------------------------------------------------------------------------

void __fastcall TComConnection::cbb_comSelect(TObject *Sender)

{

        try

        {

              /*

              串口号的形式是COMC,

              其中C的取值不定,这里要将C提取出来,

              就是去掉前面三个字符,并且不要后面/r和/n

              那么它的长度就是length-3-2,而它的子串是从第四个开始的

              */

              YbCommDevice1->PortName = cbb_com->Items->Text;

              UnicodeString s=YbCommDevice1->PortName;

              s=s.SubString(4,YbCommDevice1->PortName.Length()-5);

              YbCommDevice1->PortNo = StrToInt(s);

        }

        catch(Exception &e){

              ShowMessage("自动搜索串口失败,请检查串口是否正确接入。");

       }

}

//---------------------------------------------------------------------------

void __fastcall TComConnection::btdatacloseClick(TObject *Sender)

{

       datain=false;

}

//------------------------------------------------------------------------------------------------------------------------------------

void __fastcall TComConnection::btClearClick(TObject *Sender)

{

       Memo1->Clear();

}

//---------------------------------------------------------------------------

void TComConnection::FillInfo(int varity,UnicodeString s){

       switch(varity){

              case 0:

              LabeledEdit1->Text=s;

                     break;

              case 1:

              LabeledEdit2->Text=s;

                     break;

              case 2:

              LabeledEdit3->Text=s;

                     break;

              case 3:

              LabeledEdit4->Text=s;

                     break;

              case 4:

              LabeledEdit5->Text=s;

                     break;

              case 5:

              LabeledEdit6->Text=s;

              FillDatabase();

                     break;

       }

}

void __fastcall TComConnection::btshowClick(TObject *Sender)

{

       this->dymcshow = true;

}

//---------------------------------------------------------------------------

void __fastcall TComConnection::btdataopenClick(TObject *Sender)

{

       datain=true;

}

//---------------------------------------------------------------------------

void TComConnection::FillDatabase(){

       if(datain){

              ADOQuery1->Connection = this->ADOConnection1;

              ADOQuery1->SQL->Clear();

              UnicodeString command = "insert into SensorData(bmptemp,bmppress,sht1xtemp,sht1xhr,light,rain,time) values(:bmptemp,:bmppress,:sht1xtemp,:sht1xhr,:light,:rain,:time)" ;

              this->ADOQuery1->SQL->Add(command);

              this->ADOQuery1->Parameters->ParamByName("bmptemp")->Value = this->LabeledEdit1->Text;

              this->ADOQuery1->Parameters->ParamByName("bmppress")->Value = this->LabeledEdit2->Text;

              this->ADOQuery1->Parameters->ParamByName("sht1xtemp")->Value = this->LabeledEdit3->Text;

              this->ADOQuery1->Parameters->ParamByName("sht1xhr")->Value = this->LabeledEdit4->Text;

              this->ADOQuery1->Parameters->ParamByName("light")->Value = this->LabeledEdit5->Text;

              this->ADOQuery1->Parameters->ParamByName("rain")->Value = this->LabeledEdit6->Text;

              this->ADOQuery1->Parameters->ParamByName("time")->Value = this->DateTimePicker1->DateTime.CurrentDateTime();

              this->ADOQuery1->ExecSQL();

       }

}

void __fastcall TComConnection::Timer1Timer(TObject *Sender)

{

       if(!dymcshow)

              return ;

       try{

       Chart1->RemoveAllSeries(); // 清除Chart1上所有舊 Series

       Chart1->View3D=True; // 不要 3D 立體

       Chart1->Legend->Visible=false; // 不秀圖例說明

       Chart1->Title->Text->Clear();

       Chart1->Title->Text->Add("传感器指标");

       Series1->Clear();

       Series1->ParentChart=Chart1;

       Series1->Marks->Visible=true; // 設定要提示說明

/*

       int V; // value

       String L; //Label

       for (int i = 1; i <= 8; i++)

       {

       V=i; // Series 值

       L="V"+IntToStr(i); // 軸名稱

       Series1->Add( V , L , clTeeColor );

       }

*/

       double a[6] = {StrToFloat(LabeledEdit1->Text),

                                   StrToFloat(LabeledEdit2->Text)/10000,

                                   StrToFloat(LabeledEdit3->Text),

                                   StrToFloat(LabeledEdit4->Text),

                                   StrToFloat(LabeledEdit5->Text),

                                   StrToFloat(LabeledEdit6->Text)};

       UnicodeString b[]={LabeledEdit1->EditLabel->Caption,

                                          LabeledEdit2->EditLabel->Caption,

                                          LabeledEdit3->EditLabel->Caption,

                                          LabeledEdit4->EditLabel->Caption,

                                          LabeledEdit5->EditLabel->Caption,

                                          LabeledEdit6->EditLabel->Caption};

       for(int i=0;i<6;i++)

       Series1->AddXY(i*15,a[i],b[i],clTeeColor);

       }

       catch(Exception &e){

              dymcshow = false;

              ShowMessage("显示图形失败,请检查串口");

       }

}

//---------------------------------------------------------------------------

void __fastcall TComConnection::Button1Click(TObject *Sender)

{

        ADOQuery2->Connection = this->ADOConnection1;

        ADOQuery2->SQL->Clear();

        UnicodeString command = "select time as 时间 ,bmptemp as BMP温度,bmppress as BMP气压,sht1xtemp as SHT1温度,sht1xhr,light as 光强,rain as 雨量 from SensorData order by time desc";

        this->ADOQuery2->SQL->Add(command);

        this->ADOQuery2->Open();

        this->DBGrid1->DataSource = this->DataSource1;

}

//---------------------------------------------------------------------------

void __fastcall TComConnection::Button4Click(TObject *Sender)

{

        ADOQuery2->Connection = this->ADOConnection1;

        ADOQuery2->SQL->Clear();

        UnicodeString command = "select time as 时间 ,bmptemp as BMP温度,bmppress as BMP气压,sht1xtemp as SHT1温度,sht1xhr,light as 光强,rain as 雨量 from SensorData where time>=:stime and time <=:etime order by time desc";

        this->ADOQuery2->SQL->Add(command);

        this->ADOQuery2->Parameters->ParamByName("stime")->Value = this->DateTimePicker2->DateTime;

        this->ADOQuery2->Parameters->ParamByName("etime")->Value = this->DateTimePicker3->DateTime;

        this->ADOQuery2->Open();

        this->DBGrid1->DataSource = this->DataSource1;

}

//---------------------------------------------------------------------------

#define PG OlePropertyGet

#define PS OlePropertySet

#define FN OleFunction

#define PR OleProcedure

bool TComConnection::DBGrid2Excel(TDataSet *dataset, String filename)

{

    DeleteFile( filename );

       Variant excel = CreateOleObject("Excel.Application");

    try

       {

              Variant newxls = excel.PG("WorkBooks").FN("Add");

              int i;

              Variant v = "123";

        Variant vv = v.ChangeType(varOleStr);

              for ( i = 0; i < dataset->Fields->Count; i++ )

        {

             v = dataset->Fields->Fields[i]->FieldName;

             vv = v.ChangeType(varOleStr);

            (excel.PG("Cells", 1, i+1)).PS("Value", vv );

        }

        int row = 2;

        AnsiString pos;

        AnsiString tmp;

        Variant format = "@";

        while( !dataset->Eof )

        {

            for ( i = 0; i < dataset->Fields->Count; i++ )

            {

               (excel.PG("Cells", row, i+1)).PR("Select");

               (excel.PG("Selection")).PS("NumberFormat", format.ChangeType(varOleStr));

                v = dataset->Fields->Fields[i]->AsString;

                vv = v.ChangeType(varOleStr);

               (excel.PG("Cells", row, i+1)).PS("Value", vv );

            }

            row++;

                     dataset->Next();

        }

        Variant fn = filename;

        newxls.PR("SaveAs", fn.ChangeType(varOleStr) );

        excel.OleFunction("Quit");

    }

    catch(Exception& e)

    {

              excel.OleFunction("Quit");

        int xx = 0;

        xx = xx;

        throw e;

    }

       return true;

}

void __fastcall TComConnection::Button5Click(TObject *Sender)

{

         if(this->DBGrid2Excel(DataSource1->DataSet,"F:\\360data\\重要数据\\桌面\\传感器信息_")){

              ShowMessage("导出数据成功!");

         }

         else{

              ShowMessage("导出失败,请检查相应程序!");

         }

}

//---------------------------------------------------------------------------

void __fastcall TComConnection::Button6Click(TObject *Sender)

{

        hisc->Show();

}

//---------------------------------------------------------------------------

6.2 history(查看历史界面)

//---------------------------------------------------------------------------

#ifndef hisH

#define hisH

//---------------------------------------------------------------------------

#include <Classes.hpp>

#include <Controls.hpp>

#include <StdCtrls.hpp>

#include <Forms.hpp>

#include <ComCtrls.hpp>

#include "Chart.hpp"

#include "TeEngine.hpp"

#include "TeeProcs.hpp"

#include <ExtCtrls.hpp>

#include "Series.hpp"

#include <ADODB.hpp>

#include <DB.hpp>

#include <jpeg.hpp>

//---------------------------------------------------------------------------

class Thisc : public TForm

{

__published:   // IDE-managed Components

       TTabControl *TabControl1;

       TChart *Chart1;

       TLineSeries *Series1;

       TADOQuery *ADOQuery1;

       void __fastcall TabControl1Change(TObject *Sender);

private:   // User declarations

public:           // User declarations

       __fastcall Thisc(TComponent* Owner);

};

//---------------------------------------------------------------------------

extern PACKAGE Thisc *hisc;

//---------------------------------------------------------------------------

#endif

//---------------------------------------------------------------------------

#include <vcl.h>

#pragma hdrstop

#include "his.h"

#include "ComOpeator.h"

//---------------------------------------------------------------------------

#pragma package(smart_init)

#pragma link "Chart"

#pragma link "TeEngine"

#pragma link "TeeProcs"

#pragma link "Series"

#pragma resource "*.dfm"

Thisc *hisc;

UnicodeString sensorname[]={

"BMP温度",

"BMP气压",

"SHIT1x温度",

"SHIT1x湿度",

"光强",

"雨量"

};

UnicodeString fileindex[]={

"bmptemp","bmppress","sht1xtemp","sht1xhr","light","rain"

};

//---------------------------------------------------------------------------

__fastcall Thisc::Thisc(TComponent* Owner)

       : TForm(Owner)

{

}

//---------------------------------------------------------------------------

void __fastcall Thisc::TabControl1Change(TObject *Sender)

{

       int index = this->TabControl1->TabIndex;

       Chart1->RemoveAllSeries(); // 清除Chart1上所有舊 Series

       Chart1->View3D=True; // 要 3D 立體

       Chart1->Legend->Visible=true; //

       Chart1->Title->Text->Clear();

       Series1->Clear();

       Series1->ParentChart=Chart1;

       Series1->Marks->Visible=true; // 設定要提示說明

   ADOQuery1->SQL->Clear();

   UnicodeString command = "select top 20 "+fileindex[index]+" from SensorData order by time desc" ;

   this->ADOQuery1->SQL->Add(command);

//   this->ADOQuery1->Parameters->ParamByName("sfield")->Value = fileindex[index];

   this->ADOQuery1->Open();

   this->ADOQuery1->First();

   double count[100];

   int i=0;

   while(!(this->ADOQuery1->Eof)){

              count[i++] = StrToFloat(this->ADOQuery1->FieldByName(fileindex[index])->Text.Trim());

        //   Series1->AddY(tmp,"i",clTeeColor);

        //   Series1->add

              this->ADOQuery1->Next();

   }

   Series1->AddArray(count,i);

   Chart1->Title->Text->Add(sensorname[index]);

   this->ADOQuery1->Close();

}

//---------------------------------------------------------------------------

更多相关推荐:
嵌入式课程设计心得体会

本学期为期一周的嵌入式课程设计在不知不觉中结束了,虽说这次课程设计时间不是很长,但是感觉自己收获颇丰,不仅学习到了一些新知识,回顾了以前的一些快要遗忘的知识点,而且使自己的学习目标更加明确,学习方法更加完善,也…

嵌入式课程设计报告

福建工程学院嵌入式系统课程设计报告书题目基于S3C2440设备驱动及其界面设计班级姓名学号指导老师陈靖张平均李光炀2目录一设计课题4二设计目的4三设计任务及要求4四设计内容5五操作界面的生成7六操作界面调试9七...

嵌入式课程设计报告

信息技术学院嵌入式操作系统课程综合设计报告书姓名班级B0905学号XXXX题目嵌入式文件锁应用时间20xx年6月指导教师摘要随着PC时代的到来嵌入式系统技术已经成为了一个万众瞩目的焦点目前已广泛应用于信息家电数...

嵌入式课程设计报告

中南大学嵌入式课程设计基于ARM平台的打地鼠游戏姓名董嘉伟学号0909103303班级物联网1002时间20xx913目录课程设计内容课程设计实验环境课程设计原理分析课程设计开发计划课程设计系统设计图课程设计关...

嵌入式系统课程设计报告

嵌入式系统课程设计报告基于ARM的楼宇对讲系统设计摘要采用模块化设计方法设计出一款基于ARM微控制芯片和Linux操作系统的楼宇对讲系统,该对讲系统通过以太网与楼宇间的各室内机相连,实现了安装在楼道门口的终端机…

嵌入式课程设计报告

目录一前言211课题研究背景212课程研究目的和意义213ARM2440实验箱介绍31312440核心板规格31322440实验箱底板规格3133软件资源5二需求分析5三开发环境及系统结构631开发环境632系...

嵌入式课程设计报告

嵌入式控制器设计课程设计总结报告题目基于STM32F407的MP3学院计算机与信息科学学院软件学院专业自动化控制方向年级20xx级学号20xx3210420xx姓名陈萍指导教师赵亦欣黄伟成绩20xx年7月30日...

嵌入式课程设计报告

目录一前言111课题研究背景112课程研究目的和意义2二需求分析2三开发环境及系统结构331开发环境332系统结构3四详细设计441ARMLinux的建立4411建立交叉编译环境5412编译内核7413生成并配...

嵌入式PWM课程设计报告

嵌入式系统课程设计说明书基于S3C2410XPWM步进电机控制应用开发系部计算机与信息科学系组成员李传颂李佳文指导教师秦辉职称讲师专业计算机科学与技术班级完成时间20xx年12月12日目录1前言311课题研究背...

207李青艳嵌入式实验课程设计报告

ARM嵌入式课程设计华东交通大学理工学院课程设计报告书所属课程设计题目分院班级姓名学号指导教师实验地点20xx1226实验楼五楼嵌入式实验室5171ARM嵌入式课程设计华东交通大学理工学院课程设计任务书专业通信...

嵌入式交通灯课程设计

基于ARM的嵌入式交通灯课程设计课程名称嵌入式系统设计专业计算机科学与技术班级B0904学号0000000088姓名乔乔目录1摘要22绪论221课程设计目的222课程设计内容23最小系统设计及交通灯电路设计33...

QTOPIA的移植报告 嵌入式课程设计报告 QTOPIA的移植实验报告

课程设计报告课程名称嵌入式系统课题名称QTOPIA移植专业计算机科学与技术班级0902学号姓名指导教师郭鹏刘铁武李杰君20xx年9月3日湖南工程学院课程设计任务书课程名称嵌入式系统课题QTOPIA移植专业班级计...

嵌入式课程设计总结(39篇)