个人做 网站2019,网站建设中长出现的问题,远程发布 wordpress,互动网站建设什么意思文章目录总结test1、动态显示一段正弦波信号的曲线#xff1a;test2、现提供随机信号函数#xff0c;随意设定两路不同幅度的随机信号#xff0c;动态显示出来。test3、用均值法将原始的传感器信号进行滤波处理test4、用滑动滤波法将原始的传感器信号进行滤波处理总结
1.为…
文章目录总结test1、动态显示一段正弦波信号的曲线test2、现提供随机信号函数随意设定两路不同幅度的随机信号动态显示出来。test3、用均值法将原始的传感器信号进行滤波处理test4、用滑动滤波法将原始的传感器信号进行滤波处理总结
1.为什么传感器要进行信号处理 仪器仪表上面的数据如果是跳来跳去的话就没法用比如说压力传感器一会显示1一会显示2那么这个数字就没多大意义所以需要进行信号处理。 2.这个仿真的代码中while(1)起到的是画点的作用 LCD_L0_DrawPixel(x, y)是画一个像素点可以用一个for循环改变这个点的xy坐标值画不同的连续的点很多个点动起来就成了一条线。 其中rand()%40意味着随机信号的幅度在40以内。 3.void draw_graphic(int y,int z,int color)这个函数起到了让点动起来的作用。
test1、动态显示一段正弦波信号的曲线
整个文件很大但是目前只需要处理MainTask.c文件的内容
以下是MainTask.c文件的内容
#include GUI.h
#include GUI_Protected.h#include stdio.h
#include string.h
#include math.h
#define pi 3.1415926
#define LVBOTIME 20
extern const GUI_BITMAP bmMicriumLogo;
extern const GUI_BITMAP bmMicriumLogo_1bpp;
void draw_graphic(int y,int z,int color);
int yy[2][320];
int LVBO[LVBOTIME];/*
*******************************************************************
*
* main()
*
*******************************************************************
*/
void MainTask(void) {int Cnt 0;int YPos,shidu0,wendu0;int x,y0,flag_x1,flag_y1;float z0,i0;int LCDXSize LCD_GET_XSIZE();int LCDYSize LCD_GET_YSIZE();const GUI_BITMAP *pBitmap;GUI_Init();GUI_SetColor(GUI_BLUE);GUI_SetBkColor(GUI_WHITE);GUI_Clear();GUI_DispStringHCenterAt(jym016, 280, 200);while(1){i;if(i360) i0;zsin(i/180*pi*4);draw_graphic(z*20120,1,GUI_RED);}
}void draw_graphic(int y,int z,int color)
{int x0;GUI_SetColor(GUI_WHITE);for(x0;x320;x){ LCD_L0_DrawPixel(x1, yy[z][x]);if(yy[z][x]yy[z][x1])GUI_DrawVLine(x1, yy[z][x], yy[z][x1]); elseGUI_DrawVLine(x1, yy[z][x1], yy[z][x]); }for(x0;x320;x){yy[z][x]yy[z][x1];}yy[z][319]y;GUI_SetColor(color);for(x0;x320;x){LCD_L0_DrawPixel(x1, yy[z][x]);if(yy[z][x]yy[z][x1])GUI_DrawVLine(x1, yy[z][x], yy[z][x1]); elseGUI_DrawVLine(x1, yy[z][x1], yy[z][x]); }GUI_Delay(50);
}实验结果
test2、现提供随机信号函数随意设定两路不同幅度的随机信号动态显示出来。
#include GUI.h
#include GUI_Protected.h#include stdio.h
#include string.h
#include math.h
#define pi 3.1415926
#define LVBOTIME 20
extern const GUI_BITMAP bmMicriumLogo;
extern const GUI_BITMAP bmMicriumLogo_1bpp;
void draw_graphic(int y,int z,int color);
int yy[2][320];
int LVBO[LVBOTIME];/*
*******************************************************************
*
* main()
*
*******************************************************************
*/
void MainTask(void) {int Cnt 0;int i,YPos,shidu0,wendu0;int x,y,flag_x1,flag_y1;float z0;int LCDXSize LCD_GET_XSIZE();int LCDYSize LCD_GET_YSIZE();const GUI_BITMAP *pBitmap;GUI_Init();GUI_SetColor(GUI_BLUE);GUI_SetBkColor(GUI_WHITE);GUI_Clear();GUI_DispStringHCenterAt(jym016, 280, 200);while(1){y rand()%40;draw_graphic(y50,0,GUI_RED);y rand()%10;draw_graphic(y150,1,GUI_BLUE);}
}void draw_graphic(int y,int z,int color)
{int x0;GUI_SetColor(GUI_WHITE);for(x0;x320;x){ LCD_L0_DrawPixel(x1, yy[z][x]);if(yy[z][x]yy[z][x1])GUI_DrawVLine(x1, yy[z][x], yy[z][x1]); elseGUI_DrawVLine(x1, yy[z][x1], yy[z][x]); }for(x0;x320;x){yy[z][x]yy[z][x1];}yy[z][319]y;GUI_SetColor(color);for(x0;x320;x){LCD_L0_DrawPixel(x1, yy[z][x]);if(yy[z][x]yy[z][x1])GUI_DrawVLine(x1, yy[z][x], yy[z][x1]); elseGUI_DrawVLine(x1, yy[z][x1], yy[z][x]); }GUI_Delay(50);
}实验结果
test3、用均值法将原始的传感器信号进行滤波处理
#include GUI.h
#include GUI_Protected.h#include stdio.h
#include string.h
#include math.h
#define pi 3.1415926
#define LVBOTIME 20
extern const GUI_BITMAP bmMicriumLogo;
extern const GUI_BITMAP bmMicriumLogo_1bpp;
void draw_graphic(int y,int z,int color);
int yy[2][320];
int LVBO[LVBOTIME];/*
*******************************************************************
*
* main()
*
*******************************************************************
*/
void MainTask(void) {int Cnt 0;int i,YPos,shidu0,wendu0;int x,y0,flag_x1,flag_y1;float z0;int LCDXSize LCD_GET_XSIZE();int LCDYSize LCD_GET_YSIZE();const GUI_BITMAP *pBitmap;GUI_Init();GUI_SetColor(GUI_BLUE);GUI_SetBkColor(GUI_WHITE);GUI_Clear();GUI_DispStringHCenterAt(jym016, 280, 200);while(1){draw_graphic(y50,0,GUI_RED);for(x0;xLVBOTIME;x){y rand()%40;zy;}z/LVBOTIME;draw_graphic(z150,1,GUI_GREEN);}
}void draw_graphic(int y,int z,int color)
{int x0;GUI_SetColor(GUI_WHITE);for(x0;x320;x){ LCD_L0_DrawPixel(x1, yy[z][x]);if(yy[z][x]yy[z][x1])GUI_DrawVLine(x1, yy[z][x], yy[z][x1]); elseGUI_DrawVLine(x1, yy[z][x1], yy[z][x]); }for(x0;x320;x){yy[z][x]yy[z][x1];}yy[z][319]y;GUI_SetColor(color);for(x0;x320;x){LCD_L0_DrawPixel(x1, yy[z][x]);if(yy[z][x]yy[z][x1])GUI_DrawVLine(x1, yy[z][x], yy[z][x1]); elseGUI_DrawVLine(x1, yy[z][x1], yy[z][x]); }GUI_Delay(50);
}实验结果
test4、用滑动滤波法将原始的传感器信号进行滤波处理
#include GUI.h
#include GUI_Protected.h#include stdio.h
#include string.h
#include math.h
#define pi 3.1415926
#define LVBOTIME 20
extern const GUI_BITMAP bmMicriumLogo;
extern const GUI_BITMAP bmMicriumLogo_1bpp;
void draw_graphic(int y,int z,int color);
int yy[2][320];
int LVBO[LVBOTIME];/*
*******************************************************************
*
* main()
*
*******************************************************************
*/
void MainTask(void) {int Cnt 0;int i,YPos,shidu0,wendu0;int x,y,flag_x1,flag_y1;float z0;int LCDXSize LCD_GET_XSIZE();int LCDYSize LCD_GET_YSIZE();const GUI_BITMAP *pBitmap;GUI_Init();GUI_SetColor(GUI_BLUE);GUI_SetBkColor(GUI_WHITE);GUI_Clear();GUI_DispStringHCenterAt(jym016, 280, 200);while(1){y rand()%40;draw_graphic(y50,0,GUI_RED);for(x0;xLVBOTIME;x)LVBO[x] LVBO[x1];LVBO[LVBOTIME-1] y;z0;for(x0;xLVBOTIME;x)z LVBO[x];z/LVBOTIME;draw_graphic(z140,1,GUI_GREEN);}
}void draw_graphic(int y,int z,int color)
{int x0;GUI_SetColor(GUI_WHITE);for(x0;x320;x){ LCD_L0_DrawPixel(x1, yy[z][x]);if(yy[z][x]yy[z][x1])GUI_DrawVLine(x1, yy[z][x], yy[z][x1]); elseGUI_DrawVLine(x1, yy[z][x1], yy[z][x]); }for(x0;x320;x){yy[z][x]yy[z][x1];}yy[z][319]y;GUI_SetColor(color);for(x0;x320;x){LCD_L0_DrawPixel(x1, yy[z][x]);if(yy[z][x]yy[z][x1])GUI_DrawVLine(x1, yy[z][x], yy[z][x1]); elseGUI_DrawVLine(x1, yy[z][x1], yy[z][x]); }GUI_Delay(50);
}实验结果 可以看出滑动滤波比均值滤波效果好得多